Mesa (master): nir/spirv: Use the type from the deref for atomics

Jason Ekstrand jekstrand at kemper.freedesktop.org
Wed Jul 5 22:27:09 UTC 2017


Module: Mesa
Branch: master
Commit: a10d887ad1eba7baca74b8fbd9c9ec171dbcf3a7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a10d887ad1eba7baca74b8fbd9c9ec171dbcf3a7

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Thu Jun 29 10:33:24 2017 -0700

nir/spirv: Use the type from the deref for atomics

Previously, we were using the type of the variable which is incorrect.

Cc: "17.1" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>

---

 src/compiler/spirv/spirv_to_nir.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 0a5eb0eb6b..78ccd65903 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -2112,19 +2112,19 @@ vtn_handle_ssbo_or_shared_atomic(struct vtn_builder *b, SpvOp opcode,
    */
 
    if (chain->var->mode == vtn_variable_mode_workgroup) {
-      struct vtn_type *type = chain->var->type;
       nir_deref_var *deref = vtn_access_chain_to_deref(b, chain);
+      const struct glsl_type *deref_type = nir_deref_tail(&deref->deref)->type;
       nir_intrinsic_op op = get_shared_nir_atomic_op(opcode);
       atomic = nir_intrinsic_instr_create(b->nb.shader, op);
       atomic->variables[0] = nir_deref_var_clone(deref, atomic);
 
       switch (opcode) {
       case SpvOpAtomicLoad:
-         atomic->num_components = glsl_get_vector_elements(type->type);
+         atomic->num_components = glsl_get_vector_elements(deref_type);
          break;
 
       case SpvOpAtomicStore:
-         atomic->num_components = glsl_get_vector_elements(type->type);
+         atomic->num_components = glsl_get_vector_elements(deref_type);
          nir_intrinsic_set_write_mask(atomic, (1 << atomic->num_components) - 1);
          atomic->src[0] = nir_src_for_ssa(vtn_ssa_value(b, w[4])->def);
          break;




More information about the mesa-commit mailing list