diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2024-03-15 16:14:32 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-15 16:14:32 -0400 |
| commit | 9b434e50f02f9ec02ce230de9042ce7448bae451 (patch) | |
| tree | 092aaecc785047a8005462764404f9c530e3a69c /source/slang/slang-ir.cpp | |
| parent | 9ee88a43f4e67d9c714c27bf968401b6bf7524af (diff) | |
Implement raytracing extension(s); resolves #3560 for GLSL & SPIR-V targets (#3675)
The following PR implements raytracing extensions (GLSL_EXT_ray_tracing, GLSL_EXT_ray_query, GLSL_NV_shader_invocation_reorder & GLSL_NV_ray_tracing_motion_blur); for GLSL & SPIR-V targets. Fully implements all functions, built-in variables, & syntax; resolves #3560 for GLSL & SPIR-V Targets.
notes of worth:
* __rayPayloadFromLocation, __rayAttributeFromLocation, and __rayCallableFromLocation, were added as SPIR-V Intrinsics to refer to location's of raytracing objects in SPIR-V for when using GLSL syntax.
Diffstat (limited to 'source/slang/slang-ir.cpp')
| -rw-r--r-- | source/slang/slang-ir.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index fdc10e774..104735c3e 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -74,8 +74,10 @@ namespace Slang case kIROp_TriangleInputPrimitiveTypeDecoration: case kIROp_UnsafeForceInlineEarlyDecoration: case kIROp_VulkanCallablePayloadDecoration: + case kIROp_VulkanCallablePayloadInDecoration: case kIROp_VulkanHitAttributesDecoration: case kIROp_VulkanRayPayloadDecoration: + case kIROp_VulkanRayPayloadInDecoration: case kIROp_VulkanHitObjectAttributesDecoration: { return true; @@ -5870,6 +5872,53 @@ namespace Slang return i; } + IRSPIRVAsmOperand* IRBuilder::createSPIRVAsmOperandInst(IRInst* inst) + { + SLANG_ASSERT(as<IRSPIRVAsm>(m_insertLoc.getParent())); + auto i = createInst<IRSPIRVAsmOperand>( + this, + kIROp_SPIRVAsmOperandInst, + inst->getFullType(), + inst + ); + return i; + } + IRSPIRVAsmOperand* IRBuilder::emitSPIRVAsmOperandRayPayloadFromLocation(IRInst* inst) + { + SLANG_ASSERT(as<IRSPIRVAsm>(m_insertLoc.getParent())); + auto i = createInst<IRSPIRVAsmOperand>( + this, + kIROp_SPIRVAsmOperandRayPayloadFromLocation, + inst->getFullType(), + inst + ); + addInst(i); + return i; + } + IRSPIRVAsmOperand* IRBuilder::emitSPIRVAsmOperandRayAttributeFromLocation(IRInst* inst) + { + SLANG_ASSERT(as<IRSPIRVAsm>(m_insertLoc.getParent())); + auto i = createInst<IRSPIRVAsmOperand>( + this, + kIROp_SPIRVAsmOperandRayAttributeFromLocation, + inst->getFullType(), + inst + ); + addInst(i); + return i; + } + IRSPIRVAsmOperand* IRBuilder::emitSPIRVAsmOperandRayCallableFromLocation(IRInst* inst) + { + SLANG_ASSERT(as<IRSPIRVAsm>(m_insertLoc.getParent())); + auto i = createInst<IRSPIRVAsmOperand>( + this, + kIROp_SPIRVAsmOperandRayCallableFromLocation, + inst->getFullType(), + inst + ); + addInst(i); + return i; + } IRSPIRVAsmOperand* IRBuilder::emitSPIRVAsmOperandId(IRInst* inst) { SLANG_ASSERT(as<IRSPIRVAsm>(m_insertLoc.getParent())); @@ -6892,6 +6941,21 @@ namespace Slang case kIROp_SPIRVAsmOperandInst: dumpInstExpr(context, inst->getOperand(0)); return; + case kIROp_SPIRVAsmOperandRayPayloadFromLocation: + dump(context, "__rayPayloadFromLocation("); + dumpInstExpr(context, inst->getOperand(0)); + dump(context, ")"); + return; + case kIROp_SPIRVAsmOperandRayAttributeFromLocation: + dump(context, "__rayAttributeFromLocation("); + dumpInstExpr(context, inst->getOperand(0)); + dump(context, ")"); + return; + case kIROp_SPIRVAsmOperandRayCallableFromLocation: + dump(context, "__rayCallableFromLocation("); + dumpInstExpr(context, inst->getOperand(0)); + dump(context, ")"); + return; case kIROp_SPIRVAsmOperandId: dump(context, "%"); dumpInstExpr(context, inst->getOperand(0)); |
