From 41d7debcfec191d1f6e933387d122ead1c4f8905 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 9 Jan 2026 14:28:51 -0800 Subject: [PATCH] brw: Use nir_imul_imm in per-vertex/per-primitive offset calculation This avoids generating some useless math that would need to be cleaned up later, without complicating things too much. Reviewed-by: Lionel Landwerlin Reviewed-by: Alyssa Rosenzweig Part-of: --- src/intel/compiler/brw/brw_nir.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/intel/compiler/brw/brw_nir.c b/src/intel/compiler/brw/brw_nir.c index 2b91932da52..772b50d6f2c 100644 --- a/src/intel/compiler/brw/brw_nir.c +++ b/src/intel/compiler/brw/brw_nir.c @@ -150,12 +150,12 @@ urb_offset(nir_builder *b, offset = nir_iadd(b, offset, nir_imul_imm(b, index->ssa, stride)); } else if (index) { - nir_def *stride = cb_data->dynamic_tes - ? intel_nir_tess_field(b, PER_VERTEX_SLOTS) - : nir_imm_int(b, cb_data->per_vertex_stride / - (cb_data->vec4_access ? 16 : 4)); + const unsigned unit = cb_data->vec4_access ? 16 : 4; + nir_def *index_offset = cb_data->dynamic_tes + ? nir_imul(b, index->ssa, intel_nir_tess_field(b, PER_VERTEX_SLOTS)) + : nir_imul_imm(b, index->ssa, cb_data->per_vertex_stride / unit); - offset = nir_iadd(b, offset, nir_imul(b, index->ssa, stride)); + offset = nir_iadd(b, offset, index_offset); /* In the Tessellation evaluation shader, reposition the offset of * builtins when using separate layout.