From f04bf3c51fef65cf6f1e29ad5f0d2f836bcc0d3c Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 17 Jul 2017 19:37:24 -0700 Subject: Don't allow varying parameters to be merged in reflection data All varying input/output parameters need to be specified to the entry point that declared them. In the case of HLSL/Slang this happens for free, but in the case of GLSL we need to be careful not to merge global-scope `in` or `out` parameters in ways that don't make sense. --- source/slang/parameter-binding.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'source/slang/parameter-binding.cpp') diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp index fbafdd555..ca135f1ba 100644 --- a/source/slang/parameter-binding.cpp +++ b/source/slang/parameter-binding.cpp @@ -234,12 +234,37 @@ LayoutSemanticInfo ExtractLayoutSemanticInfo( return info; } +// This function is supposed to determine if two global shader +// parameter declarations represent the same logical parameter +// (so that they should get the exact same binding(s) allocated). +// static bool doesParameterMatch( ParameterBindingContext*, - RefPtr, + RefPtr varLayout, ParameterInfo*) { - // TODO: need to implement this eventually + // Any "varying" parameter should automatically be excluded + // + // Note that we use the `typeLayout` field rather than + // looking at resource information on the variable directly, + // because this may be called when binding hasn't been performed. + for (auto rr : varLayout->typeLayout->resourceInfos) + { + switch (rr.kind) + { + case LayoutResourceKind::VertexInput: + case LayoutResourceKind::FragmentOutput: + return false; + + default: + break; + } + } + + // TODO: this is where we should apply a more detailed + // matching process, to check that the existing + // declarations conform to the same basic layout. + return true; } @@ -470,7 +495,7 @@ static void collectGlobalScopeParameter( { parameterInfo = new ParameterInfo(); context->shared->parameters.Add(parameterInfo); - context->mapNameToParameterInfo.Add(parameterName, parameterInfo); + context->mapNameToParameterInfo.AddIfNotExists(parameterName, parameterInfo); } else { -- cgit v1.2.3