summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-emit-spirv.cpp3
-rw-r--r--source/slang/slang-ir-util.cpp18
2 files changed, 18 insertions, 3 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index cb9eb0ae9..23eaa4435 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -6423,11 +6423,12 @@ struct SPIRVEmitContext
// If the component types are not the same, convert them to be so.
if (!isTypeEqual(getVectorElementType(toType), fromElementType))
{
+ SpvOp convertOp = isIntegralType(fromElementType) ? (isSignedType(fromElementType) ? SpvOpSConvert : SpvOpUConvert) : SpvOpFConvert;
auto newFromType = replaceVectorElementType(fromType, getVectorElementType(toType));
fromSpvInst = emitInstCustomOperandFunc(
parent,
nullptr,
- SpvOpFConvert,
+ convertOp,
[&]() {
emitOperand(newFromType);
emitOperand(kResultID),
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp
index 8294cd533..e030b6d24 100644
--- a/source/slang/slang-ir-util.cpp
+++ b/source/slang/slang-ir-util.cpp
@@ -1557,10 +1557,24 @@ void hoistInstOutOfASMBlocks(IRBlock* block)
IRType* getSPIRVSampledElementType(IRInst* sampledType)
{
auto sampledElementType = getVectorElementType((IRType*)sampledType);
- if (sampledElementType->getOp() == kIROp_HalfType)
+
+ IRBuilder builder(sampledType);
+ switch (sampledElementType->getOp())
{
- IRBuilder builder(sampledType);
+ case kIROp_HalfType:
sampledElementType = builder.getBasicType(BaseType::Float);
+ break;
+ case kIROp_UInt16Type:
+ case kIROp_UInt8Type:
+ case kIROp_CharType:
+ sampledElementType = builder.getBasicType(BaseType::UInt);
+ break;
+ case kIROp_Int8Type:
+ case kIROp_Int16Type:
+ sampledElementType = builder.getBasicType(BaseType::Int);
+ break;
+ default:
+ break;
}
return sampledElementType;
}