summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-spirv.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
-rw-r--r--source/slang/slang-emit-spirv.cpp42
1 files changed, 36 insertions, 6 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index 6bd781e62..104fab339 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -1378,6 +1378,11 @@ struct SPIRVEmitContext
requireSPIRVCapability(SpvCapabilityRayQueryKHR);
return emitOpTypeRayQuery(inst);
+ case kIROp_HitObjectType:
+ ensureExtensionDeclaration(UnownedStringSlice("SPV_NV_shader_invocation_reorder"));
+ requireSPIRVCapability(SpvCapabilityShaderInvocationReorderNV);
+ return emitOpTypeHitObject(inst);
+
case kIROp_FuncType:
// > OpTypeFunction
//
@@ -2263,6 +2268,12 @@ struct SPIRVEmitContext
case kIROp_Rsh:
case kIROp_Lsh:
return emitArithmetic(parent, inst);
+ case kIROp_GlobalValueRef:
+ {
+ auto inner = ensureInst(inst->getOperand(0));
+ registerInst(inst, inner);
+ return inner;
+ }
case kIROp_Return:
if (as<IRReturn>(inst)->getVal()->getOp() == kIROp_VoidLit)
return emitOpReturn(parent, inst);
@@ -3938,14 +3949,33 @@ struct SPIRVEmitContext
SLANG_ASSERT(!as<IRVectorType>(fromTypeV) == !as<IRVectorType>(toTypeV));
const auto fromType = dropVector(fromTypeV);
const auto toType = dropVector(toTypeV);
- SLANG_ASSERT(isIntegralType(fromType));
SLANG_ASSERT(isFloatingType(toType));
- const auto fromInfo = getIntTypeInfo(fromType);
+ if (isIntegralType(fromType))
+ {
+ const auto fromInfo = getIntTypeInfo(fromType);
- return fromInfo.isSigned
- ? emitOpConvertSToF(parent, inst, toTypeV, inst->getOperand(0))
- : emitOpConvertUToF(parent, inst, toTypeV, inst->getOperand(0));
+ return fromInfo.isSigned
+ ? emitOpConvertSToF(parent, inst, toTypeV, inst->getOperand(0))
+ : emitOpConvertUToF(parent, inst, toTypeV, inst->getOperand(0));
+ }
+ else if (as<IRBoolType>(fromType))
+ {
+ IRBuilder builder(inst);
+ builder.setInsertBefore(inst);
+ auto one = builder.getFloatValue(toType, 1.0f);
+ auto zero = builder.getFloatValue(toType, 0.0f);
+ if (as<IRVectorType>(toTypeV))
+ {
+ one = builder.emitMakeVectorFromScalar(toTypeV, one);
+ zero = builder.emitMakeVectorFromScalar(toTypeV, zero);
+ }
+ return emitInst(parent, inst, SpvOpSelect, inst->getFullType(), kResultID, inst->getOperand(0), one, zero);
+ }
+ else
+ {
+ SLANG_UNREACHABLE("unknown from type");
+ }
}
SpvInst* emitFloatToIntCast(SpvInstParent* parent, IRCastFloatToInt* inst)
@@ -4206,7 +4236,7 @@ struct SPIRVEmitContext
opCode = isFloatingPoint ? SpvOpFOrdEqual : isBool ? SpvOpLogicalEqual : SpvOpIEqual;
break;
case kIROp_Neq:
- opCode = isFloatingPoint ? SpvOpFOrdNotEqual
+ opCode = isFloatingPoint ? SpvOpFUnordNotEqual
: isBool ? SpvOpLogicalNotEqual : SpvOpINotEqual;
break;
case kIROp_Geq: