diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-11-12 09:57:46 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-12 09:57:46 -0800 |
| commit | 039c233d9e4617ba9edd702a8275df0837ca8365 (patch) | |
| tree | 75d22b74eb2e163bf5d57dc1a202b1b90aba10bd /source/slang/type-layout.cpp | |
| parent | c07f60af241b1b0f7b7eba62c65d9fe750f8f3b7 (diff) | |
Add callable shader support for Vulkan ray tracing (#718)
* Add callable shader support for Vulkan ray tracing
This change extends the previous work to update Vulkan ray tracing support for the finished `GL_NV_ray_tracing` spec.
One of the features missing in the experimental extension that was added to the final spec is "callable shaders," which allow ray tracing shaders to call other shaders as general-purpose subroutines.
Most of the implementation work here mirrors what was done for the `TraceRay()` function to map it to `traceNV()`.
We map the generic `CallShader<P>` function to the non-generic `executeCallableNV`, with a payload identifier that indicates a specific global variable of type `P` (the global variable being generated from a `static` local in `CallShader`). A new modifier is added to identify the payload structure, and the parameter binding/layout logic introduces a new resource kind for callable-shader payload data (where previously the logic had assumed ray and callable payloads should use the same resource kind).
Two test shaders are included: one for the callable shader (`callable.slang`) and one for a ray generation shader that calls it (`callable-caller.slang`). Just for kicks, the payload data type is defined in a shared file so that we can be sure the two agree (trying to emulate what might be good practice, and ensure that ray tracing support works together with other Slang mechanisms).
* Typo fix: assocaited->associated
One instance was found in review, but I went ahead and fixed a bunch since I seem to make this typo a lot.
* Typo fix: defintiion->definition
Diffstat (limited to 'source/slang/type-layout.cpp')
| -rw-r--r-- | source/slang/type-layout.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/source/slang/type-layout.cpp b/source/slang/type-layout.cpp index 6915def2c..e3b89a831 100644 --- a/source/slang/type-layout.cpp +++ b/source/slang/type-layout.cpp @@ -401,12 +401,14 @@ GLSLVaryingLayoutRulesImpl kGLSLVaryingInputLayoutRulesImpl(LayoutResourceKind:: GLSLVaryingLayoutRulesImpl kGLSLVaryingOutputLayoutRulesImpl(LayoutResourceKind::FragmentOutput); GLSLRayTracingLayoutRulesImpl kGLSLRayPayloadParameterLayoutRulesImpl(LayoutResourceKind::RayPayload); +GLSLRayTracingLayoutRulesImpl kGLSLCallablePayloadParameterLayoutRulesImpl(LayoutResourceKind::CallablePayload); GLSLRayTracingLayoutRulesImpl kGLSLHitAttributesParameterLayoutRulesImpl(LayoutResourceKind::HitAttributes); HLSLVaryingLayoutRulesImpl kHLSLVaryingInputLayoutRulesImpl(LayoutResourceKind::VertexInput); HLSLVaryingLayoutRulesImpl kHLSLVaryingOutputLayoutRulesImpl(LayoutResourceKind::FragmentOutput); HLSLRayTracingLayoutRulesImpl kHLSLRayPayloadParameterLayoutRulesImpl(LayoutResourceKind::RayPayload); +HLSLRayTracingLayoutRulesImpl kHLSLCallablePayloadParameterLayoutRulesImpl(LayoutResourceKind::CallablePayload); HLSLRayTracingLayoutRulesImpl kHLSLHitAttributesParameterLayoutRulesImpl(LayoutResourceKind::HitAttributes); // @@ -423,7 +425,8 @@ struct GLSLLayoutRulesFamilyImpl : LayoutRulesFamilyImpl virtual LayoutRulesImpl* getParameterBlockRules() override; LayoutRulesImpl* getRayPayloadParameterRules() override; - LayoutRulesImpl* getHitAttributesParameterRules() override; + LayoutRulesImpl* getCallablePayloadParameterRules() override; + LayoutRulesImpl* getHitAttributesParameterRules() override; }; struct HLSLLayoutRulesFamilyImpl : LayoutRulesFamilyImpl @@ -438,7 +441,8 @@ struct HLSLLayoutRulesFamilyImpl : LayoutRulesFamilyImpl virtual LayoutRulesImpl* getParameterBlockRules() override; LayoutRulesImpl* getRayPayloadParameterRules() override; - LayoutRulesImpl* getHitAttributesParameterRules() override; + LayoutRulesImpl* getCallablePayloadParameterRules() override; + LayoutRulesImpl* getHitAttributesParameterRules() override; }; GLSLLayoutRulesFamilyImpl kGLSLLayoutRulesFamilyImpl; @@ -475,6 +479,10 @@ LayoutRulesImpl kGLSLRayPayloadParameterLayoutRulesImpl_ = { &kGLSLLayoutRulesFamilyImpl, &kGLSLRayPayloadParameterLayoutRulesImpl, &kGLSLObjectLayoutRulesImpl, }; +LayoutRulesImpl kGLSLCallablePayloadParameterLayoutRulesImpl_ = { + &kGLSLLayoutRulesFamilyImpl, &kGLSLCallablePayloadParameterLayoutRulesImpl, &kGLSLObjectLayoutRulesImpl, +}; + LayoutRulesImpl kGLSLHitAttributesParameterLayoutRulesImpl_ = { &kGLSLLayoutRulesFamilyImpl, &kGLSLHitAttributesParameterLayoutRulesImpl, &kGLSLObjectLayoutRulesImpl, }; @@ -501,6 +509,10 @@ LayoutRulesImpl kHLSLRayPayloadParameterLayoutRulesImpl_ = { &kHLSLLayoutRulesFamilyImpl, &kHLSLRayPayloadParameterLayoutRulesImpl, &kHLSLObjectLayoutRulesImpl, }; +LayoutRulesImpl kHLSLCallablePayloadParameterLayoutRulesImpl_ = { + &kHLSLLayoutRulesFamilyImpl, &kHLSLCallablePayloadParameterLayoutRulesImpl, &kHLSLObjectLayoutRulesImpl, +}; + LayoutRulesImpl kHLSLHitAttributesParameterLayoutRulesImpl_ = { &kHLSLLayoutRulesFamilyImpl, &kHLSLHitAttributesParameterLayoutRulesImpl, &kHLSLObjectLayoutRulesImpl, }; @@ -553,6 +565,11 @@ LayoutRulesImpl* GLSLLayoutRulesFamilyImpl::getRayPayloadParameterRules() return &kGLSLRayPayloadParameterLayoutRulesImpl_; } +LayoutRulesImpl* GLSLLayoutRulesFamilyImpl::getCallablePayloadParameterRules() +{ + return &kGLSLCallablePayloadParameterLayoutRulesImpl_; +} + LayoutRulesImpl* GLSLLayoutRulesFamilyImpl::getHitAttributesParameterRules() { return &kGLSLHitAttributesParameterLayoutRulesImpl_; @@ -607,6 +624,11 @@ LayoutRulesImpl* HLSLLayoutRulesFamilyImpl::getRayPayloadParameterRules() return &kHLSLRayPayloadParameterLayoutRulesImpl_; } +LayoutRulesImpl* HLSLLayoutRulesFamilyImpl::getCallablePayloadParameterRules() +{ + return &kHLSLCallablePayloadParameterLayoutRulesImpl_; +} + LayoutRulesImpl* HLSLLayoutRulesFamilyImpl::getHitAttributesParameterRules() { return &kHLSLHitAttributesParameterLayoutRulesImpl_; |
