summaryrefslogtreecommitdiffstats
path: root/source/slang/parameter-binding.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-17 19:37:24 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-18 12:58:47 -0700
commitf04bf3c51fef65cf6f1e29ad5f0d2f836bcc0d3c (patch)
tree707cdfcec2f1d023a2aa6fb6adae088fcdba79ac /source/slang/parameter-binding.cpp
parentac310e2d848f3174cfb88ca6166676afc2cbe3cd (diff)
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.
Diffstat (limited to 'source/slang/parameter-binding.cpp')
-rw-r--r--source/slang/parameter-binding.cpp31
1 files changed, 28 insertions, 3 deletions
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<VarLayout>,
+ RefPtr<VarLayout> 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
{