nir/spirv: Add support for add, subtract, and negate on matrices
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 8 Jan 2016 19:18:47 +0000 (11:18 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 8 Jan 2016 19:26:43 +0000 (11:26 -0800)
src/glsl/nir/spirv/vtn_alu.c

index a8c6e5cd89001f6f989eca09e01c0bc493a9415f..e8316d1f42e1185b33c4f0ab479f449888b2656a 100644 (file)
@@ -157,6 +157,32 @@ vtn_handle_matrix_alu(struct vtn_builder *b, SpvOp opcode,
                       struct vtn_ssa_value *src0, struct vtn_ssa_value *src1)
 {
    switch (opcode) {
+   case SpvOpFNegate: {
+      dest->ssa = vtn_create_ssa_value(b, src0->type);
+      unsigned cols = glsl_get_matrix_columns(src0->type);
+      for (unsigned i = 0; i < cols; i++)
+         dest->ssa->elems[i]->def = nir_fneg(&b->nb, src0->elems[i]->def);
+      break;
+   }
+
+   case SpvOpFAdd: {
+      dest->ssa = vtn_create_ssa_value(b, src0->type);
+      unsigned cols = glsl_get_matrix_columns(src0->type);
+      for (unsigned i = 0; i < cols; i++)
+         dest->ssa->elems[i]->def =
+            nir_fadd(&b->nb, src0->elems[i]->def, src1->elems[i]->def);
+      break;
+   }
+
+   case SpvOpFSub: {
+      dest->ssa = vtn_create_ssa_value(b, src0->type);
+      unsigned cols = glsl_get_matrix_columns(src0->type);
+      for (unsigned i = 0; i < cols; i++)
+         dest->ssa->elems[i]->def =
+            nir_fsub(&b->nb, src0->elems[i]->def, src1->elems[i]->def);
+      break;
+   }
+
    case SpvOpTranspose:
       dest->ssa = vtn_ssa_transpose(b, src0);
       break;