glslang -> SPV: fix degenerate switch topologies (bug 14118).

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31485 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2015-06-12 22:34:37 +00:00
parent 93930d6f9a
commit 8d64d44c3f
3 changed files with 29 additions and 2 deletions

View File

@ -1109,7 +1109,8 @@ bool TGlslangToSpvTraverser::visitSwitch(glslang::TVisit /* visit */, glslang::T
// handle the case where the last code segment is missing, due to no code
// statements between the last case and the end of the switch statement
if ((int)codeSegments.size() == valueIndexToSegment[caseValues.size() - 1])
if ((caseValues.size() && (int)codeSegments.size() == valueIndexToSegment[caseValues.size() - 1]) ||
(int)codeSegments.size() == defaultSegment)
codeSegments.push_back(nullptr);
// make the switch statement

View File

@ -1,5 +1,7 @@
spv.switch.frag
WARNING: 0:121: 'switch' : last case/default label not followed by statements
WARNING: 0:134: 'switch' : last case/default label not followed by statements
WARNING: 0:139: 'switch' : last case/default label not followed by statements
@ -9,7 +11,7 @@ Linked fragment stage:
// Module Version 99
// Generated by (magic number): 51a00bb
// Id's are bound by 249
// Id's are bound by 261
Source ESSL 300
1: ExtInstImport "GLSL.std.450"
@ -322,6 +324,21 @@ Linked fragment stage:
247: 7(float) Load 222(color)
248: 7(float) FAdd 247 246
Store 222(color) 248
249: 10(int) Load 61(c)
SelectionMerge 252 None
Switch 249 251
case 0: 250
250: Label
Branch 252
251: Label
Branch 252
252: Label
256: 10(int) Load 61(c)
SelectionMerge 258 None
Switch 256 257
257: Label
Branch 258
258: Label
Branch 6
6: Label
Return

View File

@ -130,4 +130,13 @@ void main()
color += foo1(v,v,c).y;
color += foo2(v,v,c).z;
switch (c) {
case 0: break;
default:
}
switch (c) {
default:
}
}