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>2024-01-18 09:29:10 +0800
commit41658975b2b9684ce14ff891be07476fbcd0a044 (patch)
treeb738f255045ca3da87fd4ba77972ffa45f479f1b
parentcfe87edfb0f97d02432bc14f3fd9008f35a01ca3 (diff)
downloadmesa-41658975b2b9684ce14ff891be07476fbcd0a044.tar.gz
mesa-41658975b2b9684ce14ff891be07476fbcd0a044.tar.bz2
mesa-41658975b2b9684ce14ff891be07476fbcd0a044.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 1dc4bd017fe..1fa7295b326 100644
--- a/src/gallium/drivers/v3d/v3d_context.c
+++ b/src/gallium/drivers/v3d/v3d_context.c
@@ -380,6 +380,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 948abe686d7..bb602914437 100644
--- a/src/gallium/drivers/v3d/v3d_context.h
+++ b/src/gallium/drivers/v3d/v3d_context.h
@@ -627,6 +627,9 @@ struct v3d_context {
bool cond_cond;
enum pipe_render_cond_flag cond_mode;
/** @} */
+
+ int in_fence_fd;
+ uint32_t in_syncobj;
};
struct v3d_rasterizer_state {
@@ -807,6 +810,9 @@ void v3d_get_tile_buffer_size(const struct v3d_device_info *devinfo,
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);
bool v3d_render_condition_check(struct v3d_context *v3d);
diff --git a/src/gallium/drivers/v3d/v3d_fence.c b/src/gallium/drivers/v3d/v3d_fence.c
index ca0a145f3d1..ed7381be186 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"
@@ -142,6 +143,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)
{
@@ -150,6 +179,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 577890a06c3..af80399a04b 100644
--- a/src/gallium/drivers/v3d/v3d_job.c
+++ b/src/gallium/drivers/v3d/v3d_job.c
@@ -519,7 +519,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;