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.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index 79f324988..afb1b3a63 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -2956,6 +2956,7 @@ struct SPIRVEmitContext
// We will continue to use the Slang terminology here, since
// this code path is a catch-all for stuff that only needs to
// be emitted if the owning instruction gets emitted.
+ bool isRayTracingObject = false;
switch( decoration->getOp() )
{
@@ -3225,13 +3226,25 @@ struct SPIRVEmitContext
}
break;
+ case kIROp_VulkanHitAttributesDecoration:
case kIROp_VulkanCallablePayloadDecoration:
+ case kIROp_VulkanCallablePayloadInDecoration:
+ ensureExtensionDeclaration(UnownedStringSlice("SPV_KHR_ray_tracing"));
+ requireSPIRVCapability(SpvCapabilityRayTracingKHR);
+ isRayTracingObject = true;
+ break;
case kIROp_VulkanHitObjectAttributesDecoration:
+ // needed since GLSL will not set optypes accordingly, but will keep the decoration
+ ensureExtensionDeclaration(UnownedStringSlice("SPV_NV_shader_invocation_reorder"));
+ requireSPIRVCapability(SpvCapabilityShaderInvocationReorderNV);
+ isRayTracingObject = true;
+ break;
case kIROp_VulkanRayPayloadDecoration:
- emitOpDecorateLocation(getSection(SpvLogicalSectionID::Annotations),
- decoration,
- dstID,
- SpvLiteralInteger::from32(int32_t(getIntVal(decoration->getOperand(0)))));
+ case kIROp_VulkanRayPayloadInDecoration:
+ // needed since GLSL will not set optypes accordingly, but will keep the decoration
+ ensureExtensionDeclaration(UnownedStringSlice("SPV_KHR_ray_query"));
+ requireSPIRVCapability(SpvCapabilityRayQueryKHR);
+ isRayTracingObject = true;
break;
case kIROp_GloballyCoherentDecoration:
emitOpDecorate(getSection(SpvLogicalSectionID::Annotations),
@@ -3242,6 +3255,17 @@ struct SPIRVEmitContext
// ...
}
+ if(isRayTracingObject)
+ {
+ if (decoration->getOperandCount() > 0) {
+ //if not greater than 0, this is not a layout decoration (no val)
+ emitOpDecorateLocation(getSection(SpvLogicalSectionID::Annotations),
+ decoration,
+ dstID,
+ SpvLiteralInteger::from32(int32_t(getIntVal(decoration->getOperand(0)))));
+ }
+ }
+
if (shouldEmitSPIRVReflectionInfo())
{
switch (decoration->getOp())
@@ -5823,7 +5847,7 @@ SlangResult emitSPIRVFromIR(
SPIRVEmitContext context(irModule, codeGenContext->getTargetProgram(), sink);
legalizeIRForSPIRV(&context, irModule, irEntryPoints, codeGenContext);
-
+
#if 0
{
DiagnosticSinkWriter writer(codeGenContext->getSink());