nir: Add range_base to atomic_counter and an option to use it
Some drivers may encode constant offsets in the instruction, so make it possible for the drivers to request lowering the atomic uniform offset into the range_base variable of the intrinsic. v2: drop patch to use build-in array offset evaluation, it makes problems with zink, and update the code accordingly v3: always initialize range base Signed-off-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19980>
This commit is contained in:
@@ -111,7 +111,14 @@ lower_deref_instr(nir_builder *b, nir_intrinsic_instr *instr,
|
||||
|
||||
b->cursor = nir_before_instr(&instr->instr);
|
||||
|
||||
nir_ssa_def *offset = nir_imm_int(b, var->data.offset);
|
||||
int offset_value = 0;
|
||||
int range_base = 0;
|
||||
if (!b->shader->options->lower_atomic_offset_to_range_base)
|
||||
offset_value = var->data.offset;
|
||||
else
|
||||
range_base = var->data.offset;
|
||||
|
||||
nir_ssa_def *offset = nir_imm_int(b, offset_value);
|
||||
for (nir_deref_instr *d = deref; d->deref_type != nir_deref_type_var;
|
||||
d = nir_deref_instr_parent(d)) {
|
||||
assert(d->deref_type == nir_deref_type_array);
|
||||
@@ -130,6 +137,8 @@ lower_deref_instr(nir_builder *b, nir_intrinsic_instr *instr,
|
||||
* opcode.
|
||||
*/
|
||||
instr->intrinsic = op;
|
||||
nir_intrinsic_set_range_base(instr, range_base);
|
||||
|
||||
nir_instr_rewrite_src(&instr->instr, &instr->src[0],
|
||||
nir_src_for_ssa(offset));
|
||||
nir_intrinsic_set_base(instr, idx);
|
||||
|
Reference in New Issue
Block a user