summaryrefslogtreecommitdiffstats
path: root/source/slang/lower.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-09 19:42:35 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-09 19:42:35 -0700
commit928cc86160644547decc49c72304549d9009a1af (patch)
tree6d8f21290cd1745bd19dcfe991dbd564a4f4527c /source/slang/lower.cpp
parent8aa0dcff397a6dbb1c262588e45110a6f673f6f9 (diff)
Ensure that lowered globals for `inout` shader parameters have unique names
If the user had a shader entry point with an `inout` parameter, we would end up lowering it to two GLSL global variables with the same name. This change adds a `SLANG_in_` or `SLANG_out_` prefix to the two declarations. Note: I haven't dealt with the issue that we end up printing two different `layout` qualifiers on such a variable...
Diffstat (limited to 'source/slang/lower.cpp')
-rw-r--r--source/slang/lower.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp
index 60f86ad17..6c54d18b6 100644
--- a/source/slang/lower.cpp
+++ b/source/slang/lower.cpp
@@ -1684,6 +1684,18 @@ struct LoweringVisitor
info.name = name;
info.direction = direction;
+ // Ensure that we don't get name collisions on `inout` variables
+ switch (direction)
+ {
+ case VaryingParameterDirection::Input:
+ info.name = "SLANG_in_" + name;
+ break;
+
+ case VaryingParameterDirection::Output:
+ info.name = "SLANG_out_" + name;
+ break;
+ }
+
lowerShaderParameterToGLSLGLobalsRec(
info,
localVarDecl->getType(),
@@ -1774,7 +1786,7 @@ struct LoweringVisitor
{
resultVarDecl = new Variable();
resultVarDecl->Position = loweredEntryPointFunc->Position;
- resultVarDecl->Name.Content = "_main_result";
+ resultVarDecl->Name.Content = "main_result";
resultVarDecl->Type = TypeExp(loweredEntryPointFunc->ReturnType);
ensureDeclHasAValidName(resultVarDecl);