summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoonbum Ko <joonbum.ko@samsung.com>2020-06-02 13:47:22 +0900
committerxuelian.bai <xuelian.bai@samsung.com>2021-03-19 23:03:24 +0800
commit48761c711d9b7435ab26be69e2bd93b57d07aef5 (patch)
tree58580742accc0c461a2319bd86a68d2785d3b8a6
parent2f9fefad15ef50f3fc4f198b638b7043fe7ef4f1 (diff)
downloadmesa-48761c711d9b7435ab26be69e2bd93b57d07aef5.tar.gz
mesa-48761c711d9b7435ab26be69e2bd93b57d07aef5.tar.bz2
mesa-48761c711d9b7435ab26be69e2bd93b57d07aef5.zip
v3d: Implemented some functions to support eglWaitsync.
This is a test phase and can be fixed later. Change-Id: I9670fc27b331b7ac4ccbcb9f659d82f4ab78f058 Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
-rw-r--r--src/gallium/drivers/v3d/v3d_context.c3
-rw-r--r--src/gallium/drivers/v3d/v3d_context.h6
-rw-r--r--src/gallium/drivers/v3d/v3d_fence.c47
-rw-r--r--src/gallium/drivers/v3d/v3d_job.c14
4 files changed, 69 insertions, 1 deletions
diff --git a/src/gallium/drivers/v3d/v3d_context.c b/src/gallium/drivers/v3d/v3d_context.c
index 0a5f67d7b2b..5badebf50a4 100644
--- a/src/gallium/drivers/v3d/v3d_context.c
+++ b/src/gallium/drivers/v3d/v3d_context.c
@@ -372,6 +372,9 @@ v3d_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
v3d->fd = screen->fd;
+ if(v3d_fence_context_init(v3d))
+ goto fail;
+
slab_create_child(&v3d->transfer_pool, &screen->transfer_pool);
v3d->uploader = u_upload_create_default(&v3d->base);
diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h
index 89b70fcc0e1..cf85e12c7b1 100644
--- a/src/gallium/drivers/v3d/v3d_context.h
+++ b/src/gallium/drivers/v3d/v3d_context.h
@@ -551,6 +551,9 @@ struct v3d_context {
uint32_t prim_counts_offset;
struct pipe_debug_callback debug;
/** @} */
+
+ int in_fence_fd;
+ uint32_t in_syncobj;
};
struct v3d_rasterizer_state {
@@ -728,6 +731,9 @@ void v3d_get_tile_buffer_size(bool is_msaa,
uint32_t *tile_width,
uint32_t *tile_height,
uint32_t *max_bpp);
+int v3d_fence_context_init(struct v3d_context *v3d);
+
+void v3d_tf_update_counters(struct v3d_context *v3d);
#ifdef v3dX
# include "v3dx_context.h"
diff --git a/src/gallium/drivers/v3d/v3d_fence.c b/src/gallium/drivers/v3d/v3d_fence.c
index e969a207541..6958c4e65fd 100644
--- a/src/gallium/drivers/v3d/v3d_fence.c
+++ b/src/gallium/drivers/v3d/v3d_fence.c
@@ -34,6 +34,7 @@
* fired off as our fence marker.
*/
+#include <libsync.h>
#include <fcntl.h>
#include "util/u_inlines.h"
@@ -122,6 +123,34 @@ v3d_fence_create(struct v3d_context *v3d)
return f;
}
+static void
+v3d_fence_create_fd(struct pipe_context *pctx, struct pipe_fence_handle **pf,
+ int fd, enum pipe_fd_type type)
+{
+ struct v3d_fence **fence = (struct v3d_fence **)pf;
+ struct v3d_fence *f = calloc(1, sizeof(*f));
+
+ assert(type == PIPE_FD_TYPE_NATIVE_SYNC);
+
+ if (f) {
+ pipe_reference_init(&f->reference, 1);
+ f->fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
+ }
+
+ *fence = f;
+}
+
+static void
+v3d_fence_server_sync(struct pipe_context *pctx,
+ struct pipe_fence_handle *pfence)
+{
+ struct v3d_context *v3d = (struct v3d_context *)pctx;
+ struct v3d_fence *fence = (struct v3d_fence *)pfence;
+
+ if (fence->fd >= 0)
+ sync_accumulate("v3d", &v3d->in_fence_fd, fence->fd);
+}
+
static int
v3d_fence_get_fd(struct pipe_screen *screen, struct pipe_fence_handle *pfence)
{
@@ -130,6 +159,24 @@ v3d_fence_get_fd(struct pipe_screen *screen, struct pipe_fence_handle *pfence)
return fcntl(fence->fd, F_DUPFD_CLOEXEC, 3);
}
+int
+v3d_fence_context_init(struct v3d_context *v3d)
+{
+ v3d->base.create_fence_fd = v3d_fence_create_fd;
+ v3d->base.fence_server_sync = v3d_fence_server_sync;
+ v3d->in_fence_fd = -1;
+
+ /* Since we initialize the in_fence_fd to -1 (no wait necessary),
+ * we also need to initialize our in_syncobj as signaled.
+ */
+ if (v3d->screen->has_syncobj) {
+ return drmSyncobjCreate(v3d->fd, DRM_SYNCOBJ_CREATE_SIGNALED,
+ &v3d->in_syncobj);
+ } else {
+ return 0;
+ }
+}
+
void
v3d_fence_init(struct v3d_screen *screen)
{
diff --git a/src/gallium/drivers/v3d/v3d_job.c b/src/gallium/drivers/v3d/v3d_job.c
index e8e1188b826..470d9e17a2b 100644
--- a/src/gallium/drivers/v3d/v3d_job.c
+++ b/src/gallium/drivers/v3d/v3d_job.c
@@ -494,7 +494,19 @@ v3d_job_submit(struct v3d_context *v3d, struct v3d_job *job)
* finished, we also need to block on any previous TFU job we may have
* dispatched.
*/
- job->submit.in_sync_rcl = v3d->out_sync;
+
+ if (screen->has_syncobj) {
+ if (v3d->in_fence_fd >= 0) {
+ /* This replaces the fence in the syncobj. */
+ drmSyncobjImportSyncFile(v3d->fd, v3d->in_syncobj,
+ v3d->in_fence_fd);
+ job->submit.in_sync_rcl = v3d->in_syncobj;
+ close(v3d->in_fence_fd);
+ v3d->in_fence_fd = -1;
+ }
+ } else {
+ job->submit.in_sync_rcl = v3d->out_sync;
+ }
/* Update the sync object for the last rendering by our context. */
job->submit.out_sync = v3d->out_sync;