diff options
author | Samuel Pitoiset <samuel.pitoiset@gmail.com> | 2023-03-02 10:24:37 +0100 |
---|---|---|
committer | Eric Engestrom <eric@engestrom.ch> | 2023-03-08 18:00:17 +0000 |
commit | 371926246b597f7d8541cb4b7426788992b8aa45 (patch) | |
tree | f7ce4df40bab8c621cc0e90d491e5a59ce43c750 | |
parent | 58f6de78bdbe9817068b284ddef0d95f1cf8fb85 (diff) | |
download | mesa-371926246b597f7d8541cb4b7426788992b8aa45.tar.gz |
radv: fix incorrect stride for primitives generated query with GDS
When the query pool uses GDS (for NGG), the stride is 40.
Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8412
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21650>
(cherry picked from commit c119b19f98dcaccb8802fb14f24b4f9b7574fceb)
-rw-r--r-- | .pick_status.json | 2 | ||||
-rw-r--r-- | src/amd/vulkan/radv_query.c | 17 |
2 files changed, 13 insertions, 6 deletions
diff --git a/.pick_status.json b/.pick_status.json index c9e81e5bdb6..48f58735e17 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1003,7 +1003,7 @@ "description": "radv: fix incorrect stride for primitives generated query with GDS", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/amd/vulkan/radv_query.c b/src/amd/vulkan/radv_query.c index 157f370ae82..d04675452e3 100644 --- a/src/amd/vulkan/radv_query.c +++ b/src/amd/vulkan/radv_query.c @@ -605,6 +605,9 @@ build_timestamp_query_shader(struct radv_device *device) return b.shader; } +#define RADV_PGQ_STRIDE 32 +#define RADV_PGQ_STRIDE_GDS (RADV_PGQ_STRIDE + 4 * 2) + static nir_shader * build_pg_query_shader(struct radv_device *device) { @@ -665,8 +668,12 @@ build_pg_query_shader(struct radv_device *device) /* Compute global ID. */ nir_ssa_def *global_id = get_global_ids(&b, 1); + /* Determine if the query pool uses GDS for NGG. */ + nir_ssa_def *uses_gds = + nir_i2b(&b, nir_load_push_constant(&b, 1, 32, nir_imm_int(&b, 16), .range = 20)); + /* Compute src/dst strides. */ - nir_ssa_def *input_stride = nir_imm_int(&b, 32); + nir_ssa_def *input_stride = nir_bcsel(&b, uses_gds, nir_imm_int(&b, RADV_PGQ_STRIDE_GDS), nir_imm_int(&b, RADV_PGQ_STRIDE)); nir_ssa_def *input_base = nir_imul(&b, input_stride, global_id); nir_ssa_def *output_stride = nir_load_push_constant(&b, 1, 32, nir_imm_int(&b, 4), .range = 16); nir_ssa_def *output_base = nir_imul(&b, output_stride, global_id); @@ -698,8 +705,7 @@ build_pg_query_shader(struct radv_device *device) nir_store_var(&b, result, primitive_storage_needed, 0x1); - nir_ssa_def *uses_gds = nir_load_push_constant(&b, 1, 32, nir_imm_int(&b, 16), .range = 20); - nir_push_if(&b, nir_i2b(&b, uses_gds)); + nir_push_if(&b, uses_gds); { nir_ssa_def *gds_start = nir_load_ssbo(&b, 1, 32, src_buf, nir_iadd(&b, input_base, nir_imm_int(&b, 32)), .align_mul = 4); @@ -1119,12 +1125,13 @@ radv_CreateQueryPool(VkDevice _device, const VkQueryPoolCreateInfo *pCreateInfo, pool->stride = 32; break; case VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT: - pool->stride = 32; if (pool->uses_gds && device->physical_device->rad_info.gfx_level < GFX11) { /* When the hardware can use both the legacy and the NGG paths in the same begin/end pair, * allocate 2x32-bit values for the GDS counters. */ - pool->stride += 4 * 2; + pool->stride = RADV_PGQ_STRIDE_GDS; + } else { + pool->stride = RADV_PGQ_STRIDE; } break; case VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR: { |