Skip to content

Commit

Permalink
Merge pull request #143 from tfoleyNV/fixup-for-glslang-bug-fixup
Browse files Browse the repository at this point in the history
Fixup for the glslang bug workaround
  • Loading branch information
Tim Foley authored Jul 24, 2017
2 parents 1d4633f + e7241a9 commit 29fb1d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 9 additions & 1 deletion source/slang/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3006,8 +3006,16 @@ return loweredExpr;
}

RefPtr<VarDeclBase> loweredDecl = loweredDeclClass.createInstance();

// Note: we lower the declaration (including its initialization expression, if any)
// *before* we add the declaration to the current context (e.g., a statement being
// built), so that any operations inside the initialization expression that
// might need to inject statements/temporaries/whatever happen *before*
// the declaration of this variable.
auto result = lowerSimpleVarDeclCommon(loweredDecl, decl, loweredType);
addDecl(loweredDecl);
return lowerSimpleVarDeclCommon(loweredDecl, decl, loweredType);

return result;
}

RefPtr<VarDeclBase> lowerVarDeclCommon(
Expand Down
6 changes: 4 additions & 2 deletions tests/rewriter/glslang-bug-988-workaround.frag
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ out vec4 result;

void main()
{
result = doIt(foo);
vec4 r = doIt(foo);
result = r;
}

#else
Expand All @@ -52,7 +53,8 @@ out vec4 result;
void main()
{
Foo SLANG_tmp_0 = foo;
result = doIt(SLANG_tmp_0);
vec4 r = doIt(SLANG_tmp_0);
result = r;
}

#endif

0 comments on commit 29fb1d7

Please sign in to comment.