From e49419b0637a357d2e713a0435f0c5ad0c102487 Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Fri, 28 Jun 2024 04:07:12 -0400 Subject: Implement HLSL resource bindings and default type `float4` to `SubpassInput` (#4462) * Add case to `emitVectorReshape` for `vector<>` type, `scalar` value 1. Add new case 2. Add test * fix warning * fix warning * Implement HLSL resource bindings and default type `float4` to `SubpassInput` fixes: #4440 1. Removed GLSLInputAttachmentIndexLayout modifier and the somewhat 'hacky' binding model 'Input Attachment' previously relied upon. This was changed to work with the slang-type-layout rules system. This change allows Slang automatic bindings, HLSL bindings, GLSL bindings, and translation of GLSL to and from HLSL bindings to work. 2. Added default argument `float4` to SubpassInput. 3. Merged glsl.meta and hlsl.meta SubpassInput logic. * fix InputAttachment attribute checks fix InputAttachment attribute checks for HLSL and GLSL syntax * remove unused var * validate attribute correctly Attributes do not have type information. We must check the type expression to validate attribute usage. * remove hacky validation type based validation before types are fully resolved is quite hacky and unstable to changes and wrapped types * fix warning * remove redundant `!= nullptr` * remove extra `!= nullptr` * fix some warnings/errors * subpass capability to limit to dxc & remove default values in some functions * revert logic to previous logic revert logic to return if we have a binding regardless of if a VarDecl is given the binding --- source/slang/slang-emit-c-like.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 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 6062875b3..66ee12ca6 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -3160,9 +3160,14 @@ void CLikeSourceEmitter::emitSemantics(IRInst* inst, bool allowOffsetLayout) emitSemanticsImpl(inst, allowOffsetLayout); } +void CLikeSourceEmitter::emitDecorationLayoutSemantics(IRInst* inst, char const* uniformSemanticSpelling) +{ + emitLayoutSemanticsImpl(inst, uniformSemanticSpelling, EmitLayoutSemanticOption::kPreType); +} + void CLikeSourceEmitter::emitLayoutSemantics(IRInst* inst, char const* uniformSemanticSpelling) { - emitLayoutSemanticsImpl(inst, uniformSemanticSpelling); + emitLayoutSemanticsImpl(inst, uniformSemanticSpelling, EmitLayoutSemanticOption::kPostType); } void CLikeSourceEmitter::emitRegion(Region* inRegion) @@ -3959,7 +3964,7 @@ void CLikeSourceEmitter::emitVar(IRVar* varDecl) emitType(varType, getName(varDecl)); emitSemantics(varDecl); - emitLayoutSemantics(varDecl); + emitLayoutSemantics(varDecl, "register"); emitPostDeclarationAttributesForType(varType); // TODO: ideally this logic should scan ahead to see if it can find a `store` @@ -4092,7 +4097,7 @@ void CLikeSourceEmitter::emitGlobalVar(IRGlobalVar* varDecl) // global variables. // emitSemantics(varDecl); - emitLayoutSemantics(varDecl); + emitLayoutSemantics(varDecl, "register"); if (varDecl->getFirstBlock()) { @@ -4155,13 +4160,15 @@ void CLikeSourceEmitter::emitGlobalParam(IRGlobalParam* varDecl) SLANG_ASSERT(layout); emitVarModifiers(layout, varDecl, varType); + + emitDecorationLayoutSemantics(varDecl, "register"); emitRateQualifiersAndAddressSpace(varDecl); emitType(varType, getName(varDecl)); emitSemantics(varDecl); - emitLayoutSemantics(varDecl); + emitLayoutSemantics(varDecl, "register"); // A shader parameter cannot have an initializer, // so we do need to consider emitting one here. -- cgit v1.2.3