-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The basic bug there is that if you have a member of `struct` type in a `uniform` block and then pass a reference to that member directly to a call: ``` struct Foo { vec4 bar; }; uniform U { Foo foo; }; void main() { doSomething(foo); } ``` then glslang generates invalid SPIR-V which seems to cause an issue for some drivers. This change works around the problem by detecting cases where an argument to a function call is a reference to `uniform` block member (of `struct` type) and then rewrites the code to move that value to a temporary before the call.
- Loading branch information
1 parent
376e61a
commit 9d0b0e7
Showing
3 changed files
with
190 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#version 450 | ||
//TEST:COMPARE_GLSL: | ||
|
||
// Test workaround for glslang issue #988 | ||
// (https://github.com/KhronosGroup/glslang/issues/988) | ||
|
||
|
||
#if defined(__SLANG__) | ||
|
||
|
||
__import glslang_bug_988_workaround; | ||
|
||
uniform U | ||
{ | ||
Foo foo; | ||
}; | ||
|
||
vec4 doIt(Foo foo) | ||
{ | ||
return foo.bar; | ||
} | ||
|
||
layout(location = 0) | ||
out vec4 result; | ||
|
||
void main() | ||
{ | ||
result = doIt(foo); | ||
} | ||
|
||
#else | ||
|
||
struct Foo | ||
{ | ||
vec4 bar; | ||
}; | ||
|
||
layout(binding = 0) | ||
uniform U | ||
{ | ||
Foo foo; | ||
}; | ||
|
||
vec4 doIt(Foo foo) | ||
{ | ||
return foo.bar; | ||
} | ||
|
||
layout(location = 0) | ||
out vec4 result; | ||
|
||
void main() | ||
{ | ||
Foo SLANG_tmp_0 = foo; | ||
result = doIt(SLANG_tmp_0); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//TEST_IGNORE_FILE: | ||
|
||
struct Foo | ||
{ | ||
float4 bar; | ||
}; |