diff options
Diffstat (limited to 'source/slang/emit.cpp')
| -rw-r--r-- | source/slang/emit.cpp | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 5c39dd50c..644725fa8 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -148,6 +148,7 @@ struct SharedEmitContext DiagnosticSink* getSink() { return &entryPoint->compileRequest->mSink; } Dictionary<IRInst*, UInt> mapIRValueToRayPayloadLocation; + Dictionary<IRInst*, UInt> mapIRValueToCallablePayloadLocation; }; struct EmitContext @@ -3315,7 +3316,7 @@ struct EmitVisitor case 'P': { // The `$XP` case handles looking up - // the assocaited `location` for a variable + // the associated `location` for a variable // used as the argument ray payload at a // trace call site. @@ -3329,6 +3330,23 @@ struct EmitVisitor } break; + case 'C': + { + // The `$XC` case handles looking up + // the associated `location` for a variable + // used as the argument callable payload at a + // call site. + + UInt argIndex = 0; + SLANG_RELEASE_ASSERT(argCount > argIndex); + auto arg = args[argIndex].get(); + auto argLoad = as<IRLoad>(arg); + SLANG_RELEASE_ASSERT(argLoad); + auto argVar = argLoad->getOperand(0); + Emit(getCallablePayloadLocation(ctx, argVar)); + } + break; + case 'T': { // The `$XT` case handles selecting between @@ -5347,6 +5365,20 @@ struct EmitVisitor return value; } + UInt getCallablePayloadLocation( + EmitContext* ctx, + IRInst* inst) + { + auto& map = ctx->shared->mapIRValueToCallablePayloadLocation; + UInt value = 0; + if(map.TryGetValue(inst, value)) + return value; + + value = map.Count(); + map.Add(inst, value); + return value; + } + void emitIRVarModifiers( EmitContext* ctx, VarLayout* layout, @@ -5365,6 +5397,13 @@ struct EmitVisitor emit(")\n"); emit("rayPayloadNV\n"); } + if(varDecl->findDecoration<IRVulkanCallablePayloadDecoration>()) + { + emit("layout(location = "); + Emit(getCallablePayloadLocation(ctx, varDecl)); + emit(")\n"); + emit("callableDataNV\n"); + } if(varDecl->findDecoration<IRVulkanHitAttributesDecoration>()) { emit("hitAttributeNV\n"); @@ -5520,6 +5559,12 @@ struct EmitVisitor } break; + case LayoutResourceKind::CallablePayload: + { + emit("callableDataInNV "); + } + break; + case LayoutResourceKind::HitAttributes: { emit("hitAttributeNV "); |
