spriv: don't set num_components for non-vectorised intrinsics
authorRob Clark <robdclark@chromium.org>
Tue, 9 Jun 2020 15:35:26 +0000 (08:35 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 16 Jun 2020 02:48:18 +0000 (02:48 +0000)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5371>

src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_subgroup.c

index 10c5de552164318204510eeae250c564533c5cab..b222e2b67a05c7fa1a0d906ca6516cfbb6ea8dce 100644 (file)
@@ -2962,17 +2962,16 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
       struct vtn_type *type = vtn_value(b, w[1], vtn_value_type_type)->type;
 
       unsigned dest_components = glsl_get_vector_elements(type->type);
-      intrin->num_components = nir_intrinsic_infos[op].dest_components;
-      if (intrin->num_components == 0)
+      if (nir_intrinsic_infos[op].dest_components == 0)
          intrin->num_components = dest_components;
 
       nir_ssa_dest_init(&intrin->instr, &intrin->dest,
-                        intrin->num_components, 32, NULL);
+                        nir_intrinsic_dest_components(intrin), 32, NULL);
 
       nir_builder_instr_insert(&b->nb, &intrin->instr);
 
       nir_ssa_def *result = &intrin->dest.ssa;
-      if (intrin->num_components != dest_components)
+      if (nir_intrinsic_dest_components(intrin) != dest_components)
          result = nir_channels(&b->nb, result, (1 << dest_components) - 1);
 
       struct vtn_value *val =
index eb255c4106cd2f47db02f54718f1fdc9d010a783..8d17845c1a0c420b83624b399c484c12dd2745f2 100644 (file)
@@ -252,7 +252,8 @@ vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode,
       }
       nir_intrinsic_instr *intrin =
          nir_intrinsic_instr_create(b->nb.shader, op);
-      intrin->num_components = src0->num_components;
+      if (nir_intrinsic_infos[op].src_components[0] == 0)
+         intrin->num_components = src0->num_components;
       intrin->src[0] = nir_src_for_ssa(src0);
       nir_ssa_dest_init_for_type(&intrin->instr, &intrin->dest,
                                  val->type->type, NULL);