[Mesa-dev] [PATCH 2/3] broadcom/vc4: Add support for extended CL submission

Boris Brezillon boris.brezillon at free-electrons.com
Thu Dec 7 15:52:06 UTC 2017


Recent versions of the VC4 driver support CL extensions, which allows one
to pass extra attributes to the CL submission.
In order to make this feature backward compatible with the existing
SUBMIT_CL ioctl, we had to add a new flag and re-use the optional
bin_cl fields. Binner CL are now passed as an extra chunk.

Signed-off-by: Boris Brezillon <boris.brezillon at free-electrons.com>
---
 src/gallium/drivers/vc4/vc4_job.c    | 23 +++++++++++++++++++++--
 src/gallium/drivers/vc4/vc4_screen.c |  2 ++
 src/gallium/drivers/vc4/vc4_screen.h |  1 +
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_job.c b/src/gallium/drivers/vc4/vc4_job.c
index 7fe20c16bad9..fb0c5bbc78cf 100644
--- a/src/gallium/drivers/vc4/vc4_job.c
+++ b/src/gallium/drivers/vc4/vc4_job.c
@@ -362,12 +362,18 @@ vc4_submit_setup_rcl_msaa_surface(struct vc4_job *job,
         rsc->writes++;
 }
 
+#define MAX_CHUNKS		1
+
 /**
  * Submits the job to the kernel and then reinitializes it.
  */
 void
 vc4_job_submit(struct vc4_context *vc4, struct vc4_job *job)
 {
+        struct vc4_screen *screen = vc4_screen(vc4->base.screen);
+        union drm_vc4_submit_cl_chunk chunks[MAX_CHUNKS] = { };
+        uint32_t nchunks = 0;
+
         if (!job->needs_flush)
                 goto done;
 
@@ -446,14 +452,27 @@ vc4_job_submit(struct vc4_context *vc4, struct vc4_job *job)
 
         submit.bo_handles = (uintptr_t)job->bo_handles.base;
         submit.bo_handle_count = cl_offset(&job->bo_handles) / 4;
-        submit.bin_cl = (uintptr_t)job->bcl.base;
-        submit.bin_cl_size = cl_offset(&job->bcl);
+        if (!screen->has_extended_cl) {
+                submit.bin_cl = (uintptr_t)job->bcl.base;
+                submit.bin_cl_size = cl_offset(&job->bcl);
+        } else if (cl_offset(&job->bcl)) {
+                chunks[nchunks].bin.type = VC4_BIN_CL_CHUNK;
+                chunks[nchunks].bin.size = cl_offset(&job->bcl);
+                chunks[nchunks].bin.ptr = (uintptr_t)job->bcl.base;
+                nchunks++;
+        }
         submit.shader_rec = (uintptr_t)job->shader_rec.base;
         submit.shader_rec_size = cl_offset(&job->shader_rec);
         submit.shader_rec_count = job->shader_rec_count;
         submit.uniforms = (uintptr_t)job->uniforms.base;
         submit.uniforms_size = cl_offset(&job->uniforms);
 
+        if (nchunks) {
+                submit.flags |= VC4_SUBMIT_CL_EXTENDED;
+                submit.cl_chunks = (uintptr_t)chunks;
+                submit.num_cl_chunks = nchunks;
+        }
+
         assert(job->draw_min_x != ~0 && job->draw_min_y != ~0);
         submit.min_x_tile = job->draw_min_x / job->tile_width;
         submit.min_y_tile = job->draw_min_y / job->tile_height;
diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
index a42ba675c130..4b63e940822d 100644
--- a/src/gallium/drivers/vc4/vc4_screen.c
+++ b/src/gallium/drivers/vc4/vc4_screen.c
@@ -696,6 +696,8 @@ vc4_screen_create(int fd, struct renderonly *ro)
                 vc4_has_feature(screen, DRM_VC4_PARAM_SUPPORTS_THREADED_FS);
         screen->has_madvise =
                 vc4_has_feature(screen, DRM_VC4_PARAM_SUPPORTS_MADVISE);
+        screen->has_extended_cl =
+                vc4_has_feature(screen, DRM_VC4_PARAM_SUPPORTS_EXTENDED_CL);
 
         if (!vc4_get_chip_info(screen))
                 goto fail;
diff --git a/src/gallium/drivers/vc4/vc4_screen.h b/src/gallium/drivers/vc4/vc4_screen.h
index 09d1c342ed19..83719d88baf0 100644
--- a/src/gallium/drivers/vc4/vc4_screen.h
+++ b/src/gallium/drivers/vc4/vc4_screen.h
@@ -97,6 +97,7 @@ struct vc4_screen {
         bool has_threaded_fs;
         bool has_madvise;
         bool has_tiling_ioctl;
+        bool has_extended_cl;
 
         struct vc4_simulator_file *sim_file;
 };
-- 
2.11.0



More information about the mesa-dev mailing list