From f030a5ab62235152055fe8a616dd6d0d7ba1c275 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 27 Jan 2025 18:17:16 -0800 Subject: Properly plumbing layout for global varyings. (#6198) * Properly plumbing layout for global varyings. * Fix test. --- source/slang/slang-parameter-binding.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source/slang/slang-parameter-binding.cpp') diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp index 825e0f4af..55c487e4e 100644 --- a/source/slang/slang-parameter-binding.cpp +++ b/source/slang/slang-parameter-binding.cpp @@ -712,6 +712,15 @@ RefPtr getTypeLayoutForGlobalShaderParameter( return createTypeLayoutWith(layoutContext, specializationConstantRule, type); } + if (varDecl->hasModifier()) + { + return createTypeLayoutWith(layoutContext, rules->getVaryingInputRules(), type); + } + else if (varDecl->hasModifier()) + { + return createTypeLayoutWith(layoutContext, rules->getVaryingOutputRules(), type); + } + // TODO(tfoley): there may be other cases that we need to handle here // An "ordinary" global variable is implicitly a uniform @@ -1120,6 +1129,25 @@ static void addExplicitParameterBindings_GLSL( return; } + if (auto foundVaryingInput = typeLayout->FindResourceInfo(LayoutResourceKind::VaryingInput)) + { + info[kResInfo].resInfo = foundVaryingInput; + + if (auto layoutAttr = varDecl.getDecl()->findModifier()) + info[kResInfo].semanticInfo.index = layoutAttr->value; + else + return; + } + if (auto foundVaryingOutput = typeLayout->FindResourceInfo(LayoutResourceKind::VaryingOutput)) + { + info[kResInfo].resInfo = foundVaryingOutput; + + if (auto layoutAttr = varDecl.getDecl()->findModifier()) + info[kResInfo].semanticInfo.index = layoutAttr->value; + else + return; + } + // For remaining cases, we only want to apply GLSL-style layout modifers // when compiling for Khronos and WGSL targets. // -- cgit v1.2.3