broadcom/vc4: Skip emitting redundant VC4_PACKET_GEM_HANDLES.
authorEric Anholt <eric@anholt.net>
Sat, 25 Nov 2017 06:15:28 +0000 (22:15 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 1 Dec 2017 23:37:28 +0000 (15:37 -0800)
Now that there's only one user of it, it's pretty obvious how to avoid
emitting redundant ones.  This should save a bunch of kernel validation
overhead.

No statistically sigificant difference on the minetest trace I was looking
at (n=169), but the maximum FPS is up by .3%

src/gallium/drivers/vc4/vc4_context.h
src/gallium/drivers/vc4/vc4_draw.c
src/gallium/drivers/vc4/vc4_job.c

index 4a1e4093f1a08e52532d8c36e53267693fa0a04e..cd404d42c3b0160320b9c9da1b918156d29c613e 100644 (file)
@@ -243,6 +243,9 @@ struct vc4_job {
          */
         uint32_t bo_space;
 
+        /* Last BO hindex referenced from VC4_PACKET_GEM_HANDLES. */
+        uint32_t last_gem_handle_hindex;
+
         /** @{ Surfaces to submit rendering for. */
         struct pipe_surface *color_read;
         struct pipe_surface *color_write;
index fd80f67b6a17f2d46acddde34b787b440c4ec439..fe9612c38e4e32c3aebef6737e2ea609aec7d364 100644 (file)
@@ -388,9 +388,13 @@ vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
                  * to perform the relocation in the IB packet (without
                  * emitting to the actual HW).
                  */
-                cl_u8(&bcl, VC4_PACKET_GEM_HANDLES);
-                cl_u32(&bcl, vc4_gem_hindex(job, rsc->bo));
-                cl_u32(&bcl, 0);
+                uint32_t hindex = vc4_gem_hindex(job, rsc->bo);
+                if (job->last_gem_handle_hindex != hindex) {
+                        cl_u8(&bcl, VC4_PACKET_GEM_HANDLES);
+                        cl_u32(&bcl, hindex);
+                        cl_u32(&bcl, 0);
+                        job->last_gem_handle_hindex = hindex;
+                }
 
                 cl_u8(&bcl, VC4_PACKET_GL_INDEXED_PRIMITIVE);
                 cl_u8(&bcl,
index 7fe20c16bad917637e5255c3a5e5bba7c740c4fb..5d18cb9bb8261ea72f103c109985b18b34c1050e 100644 (file)
@@ -90,6 +90,8 @@ vc4_job_create(struct vc4_context *vc4)
         job->draw_max_x = 0;
         job->draw_max_y = 0;
 
+        job->last_gem_handle_hindex = ~0;
+
         return job;
 }