nir/lower_io: Use the variable mode for load_scratch_base_ptr checks
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6379>
diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index 1dc2a2d..ed4daaa 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -1185,12 +1185,16 @@
assert(deref->dest.is_ssa);
switch (deref->deref_type) {
case nir_deref_type_var:
- assert(deref->mode & (nir_var_uniform | nir_var_mem_shared |
- nir_var_shader_temp | nir_var_function_temp));
+ assert(deref->var->data.mode & (nir_var_uniform |
+ nir_var_mem_shared |
+ nir_var_shader_temp |
+ nir_var_function_temp));
if (addr_format_is_global(addr_format)) {
- assert(nir_var_shader_temp | nir_var_function_temp);
+ assert(deref->var->data.mode == nir_var_shader_temp ||
+ deref->var->data.mode == nir_var_function_temp);
+ bool is_function = deref->var->data.mode == nir_var_function_temp;
base_addr =
- nir_load_scratch_base_ptr(b, !(deref->mode & nir_var_shader_temp),
+ nir_load_scratch_base_ptr(b, is_function,
nir_address_format_num_components(addr_format),
nir_address_format_bit_size(addr_format));
return build_addr_iadd_imm(b, base_addr, addr_format,