From b1a63d5418f80d3db33f009d14729286f1877ce6 Mon Sep 17 00:00:00 2001 From: Sviatoslav Peleshko Date: Thu, 7 Sep 2023 13:15:41 +0300 Subject: [PATCH] intel/fs: Check if the whole ubo load range is in the push const range Before this, we were checking only the beginning of the ubo range, so partially overlapping loads were trying to load undefined data. Fixes: b2da1238 ("i965: Use pushed UBO data in the scalar backend.") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9748 Signed-off-by: Sviatoslav Peleshko Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/compiler/brw_fs_nir.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp index 502f0105bad..6c257686c86 100644 --- a/src/intel/compiler/brw_fs_nir.cpp +++ b/src/intel/compiler/brw_fs_nir.cpp @@ -4955,6 +4955,8 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr const unsigned ubo_block = brw_nir_ubo_surface_index_get_push_block(instr->src[0]); const unsigned offset_256b = load_offset / 32; + const unsigned end_256b = + DIV_ROUND_UP(load_offset + type_size * instr->num_components, 32); /* See if we've selected this as a push constant candidate */ fs_reg push_reg; @@ -4962,7 +4964,7 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr const struct brw_ubo_range *range = &prog_data->ubo_ranges[i]; if (range->block == ubo_block && offset_256b >= range->start && - offset_256b < range->start + range->length) { + end_256b <= range->start + range->length) { push_reg = fs_reg(UNIFORM, UBO_START + i, dest.type); push_reg.offset = load_offset - 32 * range->start;