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@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13524>
This commit is contained in:
Kenneth Graunke
2021-10-02 01:31:35 -07:00
committed by Marge Bot
parent 80c2b27438
commit d832209a78

View File

@@ -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;