From 26a1adce5bd2f0e44900f21e58ea09fea9f6690f Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 3 Apr 2020 12:38:32 -0500 Subject: [PATCH] anv: Fix UBO range detection in anv_nir_compute_push_layout This fixes two bugs: First, if the same block index showed up twice, we only pick the first one. Second, we weren't multiplying by 32. This didn't show up in tests because RBA testing is garbage. Found while looking at shaders from the UE4 Shooter demo. Fixes: e03f9652 "anv: Bounds-check pushed UBOs when..." Reviewed-by: Caio Marcelo de Oliveira Filho Part-of: --- src/intel/vulkan/anv_nir_compute_push_layout.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/intel/vulkan/anv_nir_compute_push_layout.c b/src/intel/vulkan/anv_nir_compute_push_layout.c index 3f9572644df..960fb1ca4a3 100644 --- a/src/intel/vulkan/anv_nir_compute_push_layout.c +++ b/src/intel/vulkan/anv_nir_compute_push_layout.c @@ -208,8 +208,11 @@ anv_nir_compute_push_layout(const struct anv_physical_device *pdevice, int ubo_range_idx = -1; for (unsigned i = 0; i < 4; i++) { - if (prog_data->ubo_ranges[i].length > 0 && - prog_data->ubo_ranges[i].block == index) { + const struct brw_ubo_range *range = + &prog_data->ubo_ranges[i]; + if (range->block == index && + offset + size > range->start * 32 && + offset < (range->start + range->length) * 32) { ubo_range_idx = i; break; } @@ -218,14 +221,6 @@ anv_nir_compute_push_layout(const struct anv_physical_device *pdevice, if (ubo_range_idx < 0) break; - const struct brw_ubo_range *range = - &prog_data->ubo_ranges[ubo_range_idx]; - const uint32_t range_end = - (range->start + range->length) * 32; - - if (range_end < offset || offset + size <= range->start) - break; - b.cursor = nir_after_instr(&intrin->instr); assert(push_range_idx_map[ubo_range_idx] >= 0); -- 2.30.2