summaryrefslogtreecommitdiffstats
path: root/source/slang/emit.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-09-12 11:25:16 -0700
committerGitHub <noreply@github.com>2017-09-12 11:25:16 -0700
commit3763ca90479338f26b30a0147e8d41512c38e0cd (patch)
treea68fc0d963e434d554c67019b87adf81d899c1f9 /source/slang/emit.cpp
parentb0b076357f0869c0483fad6c456d6079e5a52610 (diff)
parent2e0f8f28a781c285e96670e515d8fab24c484ce8 (diff)
Merge pull request #181 from tfoleyNV/ir-lowering-work
Get IR working for `AdaptiveTessellationCS40/Render` test
Diffstat (limited to 'source/slang/emit.cpp')
-rw-r--r--source/slang/emit.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 40366c43c..209436da4 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -4416,6 +4416,16 @@ emitDeclImpl(decl, nullptr);
emit("]");
break;
+ case kIROp_Mul_Vector_Matrix:
+ case kIROp_Mul_Matrix_Vector:
+ case kIROp_Mul_Matrix_Matrix:
+ emit("mul(");
+ emitIROperand(context, inst->getArg(1));
+ emit(", ");
+ emitIROperand(context, inst->getArg(2));
+ emit(")");
+ break;
+
default:
emit("/* uhandled */");
break;
@@ -4575,6 +4585,34 @@ emitDeclImpl(decl, nullptr);
emit("};\n");
}
+ void emitIRVarModifiers(
+ EmitContext* context,
+ VarLayout* layout)
+ {
+ if (!layout)
+ return;
+
+ // We need to handle the case where the variable has
+ // a matrix type, and has been given a non-standard
+ // layout attribute (for HLSL, `row_major` is the
+ // non-standard layout).
+ //
+ if (auto matrixTypeLayout = layout->typeLayout.As<MatrixTypeLayout>())
+ {
+ switch (matrixTypeLayout->mode)
+ {
+ case kMatrixLayoutMode_ColumnMajor:
+ emit("column_major ");
+ break;
+
+ case kMatrixLayoutMode_RowMajor:
+ emit("row_major ");
+ break;
+ }
+
+ }
+ }
+
void emitIRParameterBlock(
EmitContext* context,
IRVar* varDecl,
@@ -4624,7 +4662,7 @@ emitDeclImpl(decl, nullptr);
auto fieldLayout = structTypeLayout->fields[fieldIndex++];
-
+ emitIRVarModifiers(context, fieldLayout);
auto fieldType = ff->getFieldType();
emitIRType(context, fieldType, getName(ff));
@@ -4662,6 +4700,11 @@ emitDeclImpl(decl, nullptr);
break;
}
+ // Need to emit appropriate modifiers here.
+
+ auto layout = getVarLayout(context, varDecl);
+
+ emitIRVarModifiers(context, layout);
emitIRType(context, varType, getName(varDecl));