From d832209a781f7d3e04b23ddd7e5bfd0ee1a0533a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 2 Oct 2021 01:31:35 -0700 Subject: [PATCH] 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 Part-of: --- 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 881b46d..c8fabb0 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; -- 2.7.4