From af61737e7ba107e9e92164bf39ce6ab34e05ce82 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 28 Sep 2023 18:08:06 -0700 Subject: [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 --- source/slang/slang-emit-c-like.cpp | 53 +++----------------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) (limited to 'source/slang/slang-emit-c-like.cpp') 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* 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 -- cgit v1.2.3