From 5ffd3048df2d7faf30ca8192c117d73e908212cd Mon Sep 17 00:00:00 2001 From: Alexey Panteleev Date: Wed, 13 Apr 2022 14:24:58 -0700 Subject: Callable shader fix and explicit payload locations for GLSL (#2185) * Fixed the callable shader payload type for GLSL. * Added location parameters to the __vulkanRayPayload and __vulkanCallablePayload attributes. The default value is -1 which means use the old auto-assignment logic. * Fixed the vkray/callable-caller test. --- source/slang/slang-emit-c-like.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (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 562a532cd..2d30c2109 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -2945,6 +2945,14 @@ void CLikeSourceEmitter::emitInterpolationModifiers(IRInst* varInst, IRType* val UInt CLikeSourceEmitter::getRayPayloadLocation(IRInst* inst) { + if (auto rayPayloadDecoration = inst->findDecoration()) + { + int explicitLocation = int(getIntVal(rayPayloadDecoration->getOperand(0))); + + if (explicitLocation >= 0) + return UInt(explicitLocation); + } + auto& map = m_mapIRValueToRayPayloadLocation; UInt value = 0; if(map.TryGetValue(inst, value)) @@ -2957,6 +2965,14 @@ UInt CLikeSourceEmitter::getRayPayloadLocation(IRInst* inst) UInt CLikeSourceEmitter::getCallablePayloadLocation(IRInst* inst) { + if (auto callablePayloadDecoration = inst->findDecoration()) + { + int explicitLocation = int(getIntVal(callablePayloadDecoration->getOperand(0))); + + if (explicitLocation >= 0) + return UInt(explicitLocation); + } + auto& map = m_mapIRValueToCallablePayloadLocation; UInt value = 0; if(map.TryGetValue(inst, value)) -- cgit v1.2.3