spirv: Only copy needed components for OpSpecConstantOp
authorJason Ekstrand <jason@jlekstrand.net>
Thu, 6 Jun 2019 15:20:48 +0000 (10:20 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Wed, 19 Jun 2019 21:05:54 +0000 (21:05 +0000)
Reviewed-by: Karol Herbst <kherbst@redhat.com>
src/compiler/spirv/spirv_to_nir.c

index aa3ab303ac42dee9a6931e3aecc916b1bc6cb6ad..1e23654e897425f025c0327453cd810d7e420d85 100644 (file)
@@ -1940,8 +1940,13 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
             if (!nir_alu_type_get_type_size(nir_op_infos[op].input_types[i]))
                bit_size = glsl_get_bit_size(src_val->type->type);
 
+            unsigned src_comps = nir_op_infos[op].input_sizes[i] ?
+                                 nir_op_infos[op].input_sizes[i] :
+                                 num_components;
+
             unsigned j = swap ? 1 - i : i;
-            memcpy(src[j], src_val->constant->values[0], sizeof(src[j]));
+            for (unsigned c = 0; c < src_comps; c++)
+               src[j][c] = src_val->constant->values[0][c];
          }
 
          /* fix up fixed size sources */