summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-emit-spirv.cpp35
-rw-r--r--source/slang/slang-ir-util.cpp7
-rw-r--r--source/slang/slang-ir-util.h3
3 files changed, 41 insertions, 4 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index 1a4d80ae1..f7d807190 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -2403,7 +2403,7 @@ struct SPIRVEmitContext
// For now we aren't handling function declarations;
// we expect to deal only with fully linked modules.
//
- SLANG_UNUSED(irFunc);
+ m_sink->diagnose(irFunc, Diagnostics::internalCompilerError);
SLANG_UNEXPECTED("function declaration in SPIR-V emit");
UNREACHABLE_RETURN(nullptr);
}
@@ -5194,9 +5194,36 @@ struct SPIRVEmitContext
{
const auto fromTypeV = inst->getOperand(0)->getDataType();
const auto toTypeV = inst->getDataType();
- SLANG_ASSERT(!as<IRVectorType>(fromTypeV) == !as<IRVectorType>(toTypeV));
- const auto fromType = getVectorElementType(fromTypeV);
- const auto toType = getVectorElementType(toTypeV);
+
+ IRType* fromType = nullptr;
+ IRType* toType = nullptr;
+
+ if (as<IRVectorType>(fromTypeV) || as<IRVectorType>(toTypeV))
+ {
+ fromType = getVectorElementType(fromTypeV);
+ toType = getVectorElementType(toTypeV);
+ }
+ else if (as<IRMatrixType>(fromTypeV) || as<IRMatrixType>(toTypeV))
+ {
+ fromType = getMatrixElementType(fromTypeV);
+ toType = getMatrixElementType(toTypeV);
+ }
+ else
+ {
+ fromType = fromTypeV;
+ toType = toTypeV;
+ }
+
+ // We'd better give some diagnostics to at least point out which line in the shader is wrong, so
+ // it can help the user or developers to locate the issue easier.
+ if (!isFloatingType(fromType)) {
+ m_sink->diagnose(inst, Diagnostics::internalCompilerError);
+ }
+
+ if (!isFloatingType(toType)) {
+ m_sink->diagnose(inst, Diagnostics::internalCompilerError);
+ }
+
SLANG_ASSERT(isFloatingType(fromType));
SLANG_ASSERT(isFloatingType(toType));
SLANG_ASSERT(!isTypeEqual(fromType, toType));
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp
index 10c7bfea6..8294cd533 100644
--- a/source/slang/slang-ir-util.cpp
+++ b/source/slang/slang-ir-util.cpp
@@ -23,6 +23,13 @@ IRType* getVectorElementType(IRType* type)
return type;
}
+IRType* getMatrixElementType(IRType* type)
+{
+ if (auto matrixType = as<IRMatrixType>(type))
+ return matrixType->getElementType();
+ return type;
+}
+
Dictionary<IRInst*, IRInst*> buildInterfaceRequirementDict(IRInterfaceType* interfaceType)
{
Dictionary<IRInst*, IRInst*> result;
diff --git a/source/slang/slang-ir-util.h b/source/slang/slang-ir-util.h
index 855046c04..c7d6a1544 100644
--- a/source/slang/slang-ir-util.h
+++ b/source/slang/slang-ir-util.h
@@ -77,6 +77,9 @@ bool isComInterfaceType(IRType* type);
// If `type` is a vector, returns its element type. Otherwise, return `type`.
IRType* getVectorElementType(IRType* type);
+// If `type` is a matrix, returns its element type. Otherwise, return `type`.
+IRType* getMatrixElementType(IRType* type);
+
// True if type is a resource backing memory
bool isResourceType(IRType* type);