ir3: Pass through access flags when lowering global accesses

This will let us do optimizations such as moving loads to a preamble.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34483>
This commit is contained in:
Connor Abbott 2025-04-10 17:14:40 -04:00 committed by Marge Bot
parent b7ff9dddd4
commit ec780eb0e7

View file

@ -262,14 +262,25 @@ lower_64b_global(nir_builder *b, nir_instr *instr, void *unused)
.atomic_op = nir_intrinsic_atomic_op(intr));
}
enum gl_access_qualifier access = nir_intrinsic_access(intr);
if (load) {
unsigned num_comp = nir_intrinsic_dest_components(intr);
nir_def *components[num_comp];
/* load_global_constant is redundant and should be removed, because we can
* express the same thing with extra access flags, but for now translate
* it to load_global_ir3 with those extra flags.
*/
if (intr->intrinsic == nir_intrinsic_load_global_constant)
access |= ACCESS_NON_WRITEABLE | ACCESS_CAN_REORDER;
for (unsigned off = 0; off < num_comp;) {
unsigned c = MIN2(num_comp - off, 4);
nir_def *val = nir_load_global_ir3(
b, c, intr->def.bit_size,
addr, nir_imm_int(b, off));
addr, nir_imm_int(b, off),
.access = access);
for (unsigned i = 0; i < c; i++) {
components[off++] = nir_channel(b, val, i);
}