From 928cc86160644547decc49c72304549d9009a1af Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Sun, 9 Jul 2017 19:42:35 -0700 Subject: 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... --- source/slang/lower.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source/slang/lower.cpp') 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); -- cgit v1.2.3