-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1410 from KhronosGroup/fix-1406
GLSL: Support switch more properly in legacy ESSL
- Loading branch information
Showing
8 changed files
with
334 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#version 100 | ||
precision mediump float; | ||
precision highp int; | ||
|
||
varying highp float vIndexF; | ||
|
||
void main() | ||
{ | ||
int _13 = int(vIndexF); | ||
highp vec4 _65; | ||
highp vec4 _66; | ||
highp vec4 _68; | ||
for (int SPIRV_Cross_Dummy = 0; SPIRV_Cross_Dummy < 1; SPIRV_Cross_Dummy++) | ||
{ | ||
if (_13 == 2) | ||
{ | ||
_68 = vec4(0.0, 2.0, 3.0, 4.0); | ||
break; | ||
} | ||
else if ((_13 == 4) || (_13 == 5)) | ||
{ | ||
_68 = vec4(1.0, 2.0, 3.0, 4.0); | ||
break; | ||
} | ||
else if ((_13 == 8) || (_13 == 9)) | ||
{ | ||
_68 = vec4(40.0, 20.0, 30.0, 40.0); | ||
break; | ||
} | ||
else if (_13 == 10) | ||
{ | ||
_65 = vec4(10.0); | ||
highp vec4 _45 = _65 + vec4(1.0); | ||
_66 = _45; | ||
highp vec4 _48 = _66 + vec4(2.0); | ||
_68 = _48; | ||
break; | ||
} | ||
else if (_13 == 11) | ||
{ | ||
_65 = vec4(0.0); | ||
highp vec4 _45 = _65 + vec4(1.0); | ||
_66 = _45; | ||
highp vec4 _48 = _66 + vec4(2.0); | ||
_68 = _48; | ||
break; | ||
} | ||
else if (_13 == 12) | ||
{ | ||
_66 = vec4(0.0); | ||
highp vec4 _48 = _66 + vec4(2.0); | ||
_68 = _48; | ||
break; | ||
} | ||
else | ||
{ | ||
_68 = vec4(10.0, 20.0, 30.0, 40.0); | ||
break; | ||
} | ||
} | ||
highp vec4 _70; | ||
for (int SPIRV_Cross_Dummy = 0; SPIRV_Cross_Dummy < 1; SPIRV_Cross_Dummy++) | ||
{ | ||
if ((_13 == 10) || (_13 == 20)) | ||
{ | ||
_70 = vec4(40.0); | ||
break; | ||
} | ||
else | ||
{ | ||
_70 = vec4(20.0); | ||
break; | ||
} | ||
} | ||
gl_FragData[0] = _68 + _70; | ||
} | ||
|
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
24 changes: 24 additions & 0 deletions
24
reference/shaders-no-opt/legacy/frag/switch-single-case-multiple-exit-cfg.legacy.asm.frag
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,24 @@ | ||
#version 100 | ||
precision mediump float; | ||
precision highp int; | ||
|
||
vec2 _19; | ||
|
||
void main() | ||
{ | ||
highp vec2 _30; | ||
for (int SPIRV_Cross_Dummy = 0; SPIRV_Cross_Dummy < 1; SPIRV_Cross_Dummy++) | ||
{ | ||
if (gl_FragCoord.x != gl_FragCoord.x) | ||
{ | ||
_30 = _19; | ||
break; | ||
} | ||
highp vec2 _29 = _19; | ||
_29.y = _19.y; | ||
_30 = _29; | ||
break; | ||
} | ||
gl_FragData[0] = vec4(_30, 1.0, 1.0); | ||
} | ||
|
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,78 @@ | ||
#version 100 | ||
precision mediump float; | ||
precision highp int; | ||
|
||
varying highp float vIndexF; | ||
|
||
void main() | ||
{ | ||
int vIndex = int(vIndexF); | ||
highp vec4 v = vec4(0.0); | ||
for (int SPIRV_Cross_Dummy = 0; SPIRV_Cross_Dummy < 1; SPIRV_Cross_Dummy++) | ||
{ | ||
if (vIndex == 2) | ||
{ | ||
v = vec4(0.0, 2.0, 3.0, 4.0); | ||
break; | ||
} | ||
else if ((vIndex == 4) || (vIndex == 5)) | ||
{ | ||
v = vec4(1.0, 2.0, 3.0, 4.0); | ||
break; | ||
} | ||
else if ((vIndex == 8) || (vIndex == 9)) | ||
{ | ||
v = vec4(40.0, 20.0, 30.0, 40.0); | ||
break; | ||
} | ||
else if (vIndex == 10) | ||
{ | ||
v = vec4(10.0); | ||
highp vec4 _43 = v; | ||
highp vec4 _44 = vec4(1.0); | ||
highp vec4 _45 = _43 + _44; | ||
v = _45; | ||
highp vec4 _46 = v; | ||
highp vec4 _47 = vec4(2.0); | ||
highp vec4 _48 = _46 + _47; | ||
v = _48; | ||
break; | ||
} | ||
else if (vIndex == 11) | ||
{ | ||
highp vec4 _43 = v; | ||
highp vec4 _44 = vec4(1.0); | ||
highp vec4 _45 = _43 + _44; | ||
v = _45; | ||
highp vec4 _46 = v; | ||
highp vec4 _47 = vec4(2.0); | ||
highp vec4 _48 = _46 + _47; | ||
v = _48; | ||
break; | ||
} | ||
else if (vIndex == 12) | ||
{ | ||
highp vec4 _46 = v; | ||
highp vec4 _47 = vec4(2.0); | ||
highp vec4 _48 = _46 + _47; | ||
v = _48; | ||
break; | ||
} | ||
else | ||
{ | ||
v = vec4(10.0, 20.0, 30.0, 40.0); | ||
break; | ||
} | ||
} | ||
highp vec4 w = vec4(20.0); | ||
for (int SPIRV_Cross_Dummy = 0; SPIRV_Cross_Dummy < 1; SPIRV_Cross_Dummy++) | ||
{ | ||
if ((vIndex == 10) || (vIndex == 20)) | ||
{ | ||
w = vec4(40.0); | ||
break; | ||
} | ||
} | ||
gl_FragData[0] = v + w; | ||
} | ||
|
57 changes: 57 additions & 0 deletions
57
shaders-no-opt/legacy/frag/switch-single-case-multiple-exit-cfg.legacy.asm.frag
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,57 @@ | ||
; SPIR-V | ||
; Version: 1.0 | ||
; Generator: Khronos Glslang Reference Front End; 7 | ||
; Bound: 54 | ||
; Schema: 0 | ||
OpCapability Shader | ||
%1 = OpExtInstImport "GLSL.std.450" | ||
OpMemoryModel Logical GLSL450 | ||
OpEntryPoint Fragment %main "main" %gl_FragCoord %_GLF_color | ||
OpExecutionMode %main OriginUpperLeft | ||
OpSource ESSL 310 | ||
OpName %main "main" | ||
OpName %gl_FragCoord "gl_FragCoord" | ||
OpName %_GLF_color "_GLF_color" | ||
OpDecorate %gl_FragCoord BuiltIn FragCoord | ||
OpDecorate %_GLF_color Location 0 | ||
%void = OpTypeVoid | ||
%3 = OpTypeFunction %void | ||
%int = OpTypeInt 32 1 | ||
%int_0 = OpConstant %int 0 | ||
%float = OpTypeFloat 32 | ||
%v4float = OpTypeVector %float 4 | ||
%_ptr_Input_v4float = OpTypePointer Input %v4float | ||
%gl_FragCoord = OpVariable %_ptr_Input_v4float Input | ||
%uint = OpTypeInt 32 0 | ||
%uint_0 = OpConstant %uint 0 | ||
%_ptr_Input_float = OpTypePointer Input %float | ||
%bool = OpTypeBool | ||
%v2float = OpTypeVector %float 2 | ||
%_ptr_Output_v4float = OpTypePointer Output %v4float | ||
%_GLF_color = OpVariable %_ptr_Output_v4float Output | ||
%float_1 = OpConstant %float 1 | ||
%52 = OpUndef %v2float | ||
%main = OpFunction %void None %3 | ||
%5 = OpLabel | ||
OpSelectionMerge %9 None | ||
OpSwitch %int_0 %8 | ||
%8 = OpLabel | ||
%17 = OpAccessChain %_ptr_Input_float %gl_FragCoord %uint_0 | ||
%18 = OpLoad %float %17 | ||
%22 = OpFOrdNotEqual %bool %18 %18 | ||
OpSelectionMerge %24 None | ||
OpBranchConditional %22 %23 %24 | ||
%23 = OpLabel | ||
OpBranch %9 | ||
%24 = OpLabel | ||
%33 = OpCompositeExtract %float %52 1 | ||
%51 = OpCompositeInsert %v2float %33 %52 1 | ||
OpBranch %9 | ||
%9 = OpLabel | ||
%53 = OpPhi %v2float %52 %23 %51 %24 | ||
%42 = OpCompositeExtract %float %53 0 | ||
%43 = OpCompositeExtract %float %53 1 | ||
%48 = OpCompositeConstruct %v4float %42 %43 %float_1 %float_1 | ||
OpStore %_GLF_color %48 | ||
OpReturn | ||
OpFunctionEnd |
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,43 @@ | ||
#version 450 | ||
|
||
layout(location = 0) out vec4 FragColor; | ||
layout(location = 0) in float vIndexF; | ||
|
||
void main() | ||
{ | ||
int vIndex = int(vIndexF); | ||
vec4 v = vec4(0.0); | ||
switch (vIndex) | ||
{ | ||
case 2: | ||
v = vec4(0, 2, 3, 4); | ||
break; | ||
case 4: | ||
case 5: | ||
v = vec4(1, 2, 3, 4); | ||
break; | ||
case 8: | ||
case 9: | ||
v = vec4(40, 20, 30, 40); | ||
break; | ||
case 10: | ||
v = vec4(10.0); | ||
case 11: | ||
v += 1.0; | ||
case 12: | ||
v += 2.0; | ||
break; | ||
default: | ||
v = vec4(10, 20, 30, 40); | ||
break; | ||
} | ||
|
||
vec4 w = vec4(20.0); | ||
switch (vIndex) | ||
{ | ||
case 10: | ||
case 20: | ||
w = vec4(40.0); | ||
} | ||
FragColor = v + w; | ||
} |
Oops, something went wrong.