spirv: Give atomic counters their own variable mode
authorJason Ekstrand <jason@jlekstrand.net>
Fri, 29 May 2020 23:39:30 +0000 (18:39 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Fri, 24 Jul 2020 03:43:21 +0000 (22:43 -0500)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5278>

src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_private.h
src/compiler/spirv/vtn_variables.c

index e24508ea812314fce640d1993913e476111fa7ad..7f595c2be367879299b0060653f2c463d051ba1b 100644 (file)
@@ -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);
index 7a1140a38915ae8d09d8ad9d13a1f684f95ee995..3ff28a7d1c9e42e3448db0d5bb3b2f96f50d4aa4 100644 (file)
@@ -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,
index 60a1672d5dd01698305cf920d04914f9c4bbe27b..05535bce83fb087f61276e127d12ef1d38442e36 100644 (file)
@@ -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.