diff options
| author | Yong He <yonghe@outlook.com> | 2023-09-28 18:08:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-28 18:08:06 -0700 |
| commit | af61737e7ba107e9e92164bf39ce6ab34e05ce82 (patch) | |
| tree | 37747b26fb951548256669124adb83c0246a8f32 /source/slang/slang-emit-c-like.cpp | |
| parent | b7d318f48db2cb83a41d665f1727ae93fc555124 (diff) | |
[Direct SPIRV]: ray tracing pipeline intrinsics. (#3244)
* Use a dedicated inst opcode to retrieve ray payload locations.
* [Direct SPIRV]: ray tracing pipeline intrinsics.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 53 |
1 files changed, 3 insertions, 50 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index 2559269d4..fb216ae01 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -41,56 +41,6 @@ struct CLikeSourceEmitter::ComputeEmitActionsContext List<EmitAction>* actions; }; -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!! LocationTracker !!!!!!!!!!!!!!!!!!!!!!!!!! */ - -/* static */LocationTracker::Kind LocationTracker::getKindFromDecoration(IRDecoration* decoration) -{ - switch (decoration->getOp()) - { - case kIROp_VulkanRayPayloadDecoration: return Kind::RayPayload; - case kIROp_VulkanCallablePayloadDecoration: return Kind::CallablePayload; - case kIROp_VulkanHitObjectAttributesDecoration: return Kind::HitObjectAttribute; - default: break; - } - return Kind::Invalid; -} - -Index LocationTracker::getValue(IRInst* inst, IRDecoration* decoration) -{ - const Kind kind = getKindFromDecoration(decoration); - SLANG_RELEASE_ASSERT(kind != Kind::Invalid); - if (kind == Kind::Invalid) - { - return -1; - } - - return getValue(kind, inst, decoration); -} - -Index LocationTracker::getValue(Kind kind, IRInst* inst, IRDecoration* decoration) -{ - if (decoration->getOperandCount() > 0) - { - // TODO(JS): - // There could be a clash with the auto generated location, and the user set value/ - // Perhaps the implication in practice is that either all are marked or none. - const int explicitLocation = int(getIntVal(decoration->getOperand(0))); - if (explicitLocation >= 0) - return UInt(explicitLocation); - } - - auto& nextValue = m_nextValueForKind[Index(kind)]; - - const Location defaultLocation{kind, nextValue}; - const Location foundLocation = m_mapIRToLocations.getOrAddValue(inst, defaultLocation); - - // Increase if it was the default - nextValue += Index(defaultLocation == foundLocation); - - // Has to match the kind - return (foundLocation.kind == kind) ? foundLocation.value : -1; -} - /* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CLikeSourceEmitter !!!!!!!!!!!!!!!!!!!!!!!!!! */ /* static */SourceLanguage CLikeSourceEmitter::getSourceLanguage(CodeGenTarget target) @@ -1242,6 +1192,9 @@ bool CLikeSourceEmitter::shouldFoldInstIntoUseSites(IRInst* inst) case kIROp_LookupWitness: case kIROp_GetValueFromBoundInterface: return true; + + case kIROp_GetVulkanRayTracingPayloadLocation: + return true; } // Layouts and attributes are only present to annotate other |
