Mesa (main): blorp: Fix compute-blits for rectangles not aligned to the workgroup

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 30 12:47:56 UTC 2021


Module: Mesa
Branch: main
Commit: d832209a781f7d3e04b23ddd7e5bfd0ee1a0533a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d832209a781f7d3e04b23ddd7e5bfd0ee1a0533a

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Sat Oct  2 01:31:35 2021 -0700

blorp: Fix compute-blits for rectangles not aligned to the workgroup

When dispatching compute shaders to do a blit, our destination rectangle
may not line up perfectly with the workgroup size.  For example, we may
round the left x0 coordinate down to a multiple of the workgroup width,
and the right x1 coordinate up to the next multiple of the workgroup
width.  Similarly for y0/y1 and workgroup height.  This means that we
may dispatch additional invocations which should not actually do any
blitting.  We need to set key->uses_kill to bounds check and drop those.

Caught by Piglit's arb_copy_image-simple when forcing iris to perform
resource_copy_region via BLOCS and running with INTEL_DEBUG=norbc on
Icelake.

Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13524>

---

 src/intel/blorp/blorp_blit.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c
index 881b46de51a..c8fabb01a08 100644
--- a/src/intel/blorp/blorp_blit.c
+++ b/src/intel/blorp/blorp_blit.c
@@ -2198,9 +2198,24 @@ try_blorp_blit(struct blorp_batch *batch,
 
    const bool compute =
       key->base.shader_pipeline == BLORP_SHADER_PIPELINE_COMPUTE;
-   if (compute)
+   if (compute) {
       key->local_y = blorp_get_cs_local_y(params);
 
+      unsigned workgroup_width = 16 / key->local_y;
+      unsigned workgroup_height = key->local_y;
+
+      /* If the rectangle being drawn isn't an exact multiple of the
+       * workgroup size, we'll get extra invocations that should not
+       * perform blits.  We need to set use_kill to bounds check and
+       * prevent those invocations from blitting.
+       */
+      if ((params->x0 % workgroup_width) != 0 ||
+          (params->x1 % workgroup_width) != 0 ||
+          (params->y0 % workgroup_height) != 0 ||
+          (params->y1 % workgroup_height) != 0)
+         key->use_kill = true;
+   }
+
    if (compute) {
       if (!brw_blorp_get_blit_kernel_cs(batch, params, key))
          return 0;



More information about the mesa-commit mailing list