From: Jason Ekstrand Date: Fri, 29 May 2020 23:39:30 +0000 (-0500) Subject: spirv: Give atomic counters their own variable mode X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=051f8d3d1cf1d6eba5775622fddb280ce810daf1;p=mesa.git spirv: Give atomic counters their own variable mode Reviewed-by: Caio Marcelo de Oliveira Filho Part-of: --- diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index e24508ea812..7f595c2be36 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -3161,7 +3161,7 @@ vtn_handle_atomics(struct vtn_builder *b, SpvOp opcode, } /* uniform as "atomic counter uniform" */ - if (ptr->mode == vtn_variable_mode_uniform) { + if (ptr->mode == vtn_variable_mode_atomic_counter) { nir_deref_instr *deref = vtn_pointer_to_deref(b, ptr); nir_intrinsic_op op = get_uniform_nir_atomic_op(b, opcode); atomic = nir_intrinsic_instr_create(b->nb.shader, op); diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index 7a1140a3891..3ff28a7d1c9 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -467,6 +467,7 @@ enum vtn_variable_mode { vtn_variable_mode_function, vtn_variable_mode_private, vtn_variable_mode_uniform, + vtn_variable_mode_atomic_counter, vtn_variable_mode_ubo, vtn_variable_mode_ssbo, vtn_variable_mode_phys_ssbo, diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 60a1672d5dd..05535bce83f 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1845,7 +1845,7 @@ vtn_storage_class_to_mode(struct vtn_builder *b, nir_mode = nir_var_mem_shared; break; case SpvStorageClassAtomicCounter: - mode = vtn_variable_mode_uniform; + mode = vtn_variable_mode_atomic_counter; nir_mode = nir_var_uniform; break; case SpvStorageClassCrossWorkgroup: @@ -1897,6 +1897,7 @@ vtn_mode_to_address_format(struct vtn_builder *b, enum vtn_variable_mode mode) case vtn_variable_mode_private: case vtn_variable_mode_uniform: + case vtn_variable_mode_atomic_counter: case vtn_variable_mode_input: case vtn_variable_mode_output: case vtn_variable_mode_image: @@ -2190,11 +2191,12 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, case vtn_variable_mode_function: case vtn_variable_mode_private: case vtn_variable_mode_uniform: + case vtn_variable_mode_atomic_counter: /* For these, we create the variable normally */ var->var = rzalloc(b->shader, nir_variable); var->var->name = ralloc_strdup(var->var, val->name); - if (storage_class == SpvStorageClassAtomicCounter) { + if (var->mode == vtn_variable_mode_atomic_counter) { /* Need to tweak the nir type here as at vtn_handle_type we don't * have the access to storage_class, that is the one that points us * that is an atomic uint.