Commit 7e997e26 by John Kessenich

HLSL: Implicit bool conversions for conditional expressions and related.

Covers if(cond), while(cond), do-while(cond), for(;cond;), and (cond ? :). Fixes #778.
parent 8f9fdc98
...@@ -9,7 +9,7 @@ gl_FragCoord origin is upper left ...@@ -9,7 +9,7 @@ gl_FragCoord origin is upper left
0:11 Test condition and select ( temp void) 0:11 Test condition and select ( temp void)
0:11 Condition 0:11 Condition
0:11 Constant: 0:11 Constant:
0:11 0 (const int) 0:11 false (const bool)
0:11 true case is null 0:11 true case is null
0:2 Function Definition: PixelShaderFunction( ( temp void) 0:2 Function Definition: PixelShaderFunction( ( temp void)
0:2 Function Parameters: 0:2 Function Parameters:
...@@ -36,7 +36,7 @@ gl_FragCoord origin is upper left ...@@ -36,7 +36,7 @@ gl_FragCoord origin is upper left
0:11 Test condition and select ( temp void) 0:11 Test condition and select ( temp void)
0:11 Condition 0:11 Condition
0:11 Constant: 0:11 Constant:
0:11 0 (const int) 0:11 false (const bool)
0:11 true case is null 0:11 true case is null
0:2 Function Definition: PixelShaderFunction( ( temp void) 0:2 Function Definition: PixelShaderFunction( ( temp void)
0:2 Function Parameters: 0:2 Function Parameters:
...@@ -71,8 +71,8 @@ gl_FragCoord origin is upper left ...@@ -71,8 +71,8 @@ gl_FragCoord origin is upper left
7: TypeVector 6(float) 4 7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4) 8: TypePointer Function 7(fvec4)
9: TypeFunction 2 8(ptr) 9: TypeFunction 2 8(ptr)
13: TypeInt 32 1 13: TypeBool
14: 13(int) Constant 0 14: 13(bool) ConstantFalse
18: TypePointer Input 7(fvec4) 18: TypePointer Input 7(fvec4)
19(input): 18(ptr) Variable Input 19(input): 18(ptr) Variable Input
4(PixelShaderFunction): 2 Function None 3 4(PixelShaderFunction): 2 Function None 3
......
...@@ -25,6 +25,7 @@ gl_FragCoord origin is upper left ...@@ -25,6 +25,7 @@ gl_FragCoord origin is upper left
0:9 2 (const int) 0:9 2 (const int)
0:10 Test condition and select ( temp void) 0:10 Test condition and select ( temp void)
0:10 Condition 0:10 Condition
0:10 Convert float to bool ( temp bool)
0:10 direct index ( temp float) 0:10 direct index ( temp float)
0:10 'input' ( in 4-component vector of float) 0:10 'input' ( in 4-component vector of float)
0:10 Constant: 0:10 Constant:
...@@ -80,6 +81,7 @@ gl_FragCoord origin is upper left ...@@ -80,6 +81,7 @@ gl_FragCoord origin is upper left
0:9 2 (const int) 0:9 2 (const int)
0:10 Test condition and select ( temp void) 0:10 Test condition and select ( temp void)
0:10 Condition 0:10 Condition
0:10 Convert float to bool ( temp bool)
0:10 direct index ( temp float) 0:10 direct index ( temp float)
0:10 'input' ( in 4-component vector of float) 0:10 'input' ( in 4-component vector of float)
0:10 Constant: 0:10 Constant:
...@@ -107,12 +109,12 @@ gl_FragCoord origin is upper left ...@@ -107,12 +109,12 @@ gl_FragCoord origin is upper left
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 48 // Id's are bound by 50
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction" 43 EntryPoint Fragment 4 "PixelShaderFunction" 45
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Name 4 "PixelShaderFunction" Name 4 "PixelShaderFunction"
Name 10 "foo(f1;" Name 10 "foo(f1;"
...@@ -120,11 +122,11 @@ gl_FragCoord origin is upper left ...@@ -120,11 +122,11 @@ gl_FragCoord origin is upper left
Name 16 "@PixelShaderFunction(vf4;" Name 16 "@PixelShaderFunction(vf4;"
Name 15 "input" Name 15 "input"
Name 25 "param" Name 25 "param"
Name 37 "f" Name 39 "f"
Name 41 "input"
Name 43 "input" Name 43 "input"
Name 45 "param" Name 45 "input"
Decorate 43(input) Location 0 Name 47 "param"
Decorate 45(input) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
...@@ -138,17 +140,18 @@ gl_FragCoord origin is upper left ...@@ -138,17 +140,18 @@ gl_FragCoord origin is upper left
26: TypeInt 32 0 26: TypeInt 32 0
27: 26(int) Constant 2 27: 26(int) Constant 2
31: 26(int) Constant 0 31: 26(int) Constant 0
42: TypePointer Input 12(fvec4) 34: 6(float) Constant 0
43(input): 42(ptr) Variable Input 44: TypePointer Input 12(fvec4)
45(input): 44(ptr) Variable Input
4(PixelShaderFunction): 2 Function None 3 4(PixelShaderFunction): 2 Function None 3
5: Label 5: Label
41(input): 13(ptr) Variable Function 43(input): 13(ptr) Variable Function
45(param): 13(ptr) Variable Function 47(param): 13(ptr) Variable Function
44: 12(fvec4) Load 43(input) 46: 12(fvec4) Load 45(input)
Store 41(input) 44 Store 43(input) 46
46: 12(fvec4) Load 41(input) 48: 12(fvec4) Load 43(input)
Store 45(param) 46 Store 47(param) 48
47: 2 FunctionCall 16(@PixelShaderFunction(vf4;) 45(param) 49: 2 FunctionCall 16(@PixelShaderFunction(vf4;) 47(param)
Return Return
FunctionEnd FunctionEnd
10(foo(f1;): 2 Function None 8 10(foo(f1;): 2 Function None 8
...@@ -167,20 +170,21 @@ gl_FragCoord origin is upper left ...@@ -167,20 +170,21 @@ gl_FragCoord origin is upper left
15(input): 13(ptr) FunctionParameter 15(input): 13(ptr) FunctionParameter
17: Label 17: Label
25(param): 7(ptr) Variable Function 25(param): 7(ptr) Variable Function
37(f): 7(ptr) Variable Function 39(f): 7(ptr) Variable Function
28: 7(ptr) AccessChain 15(input) 27 28: 7(ptr) AccessChain 15(input) 27
29: 6(float) Load 28 29: 6(float) Load 28
Store 25(param) 29 Store 25(param) 29
30: 2 FunctionCall 10(foo(f1;) 25(param) 30: 2 FunctionCall 10(foo(f1;) 25(param)
32: 7(ptr) AccessChain 15(input) 31 32: 7(ptr) AccessChain 15(input) 31
33: 6(float) Load 32 33: 6(float) Load 32
SelectionMerge 35 None 35: 20(bool) FOrdNotEqual 33 34
BranchConditional 33 34 35 SelectionMerge 37 None
34: Label BranchConditional 35 36 37
36: Label
Kill Kill
35: Label 37: Label
38: 7(ptr) AccessChain 15(input) 31 40: 7(ptr) AccessChain 15(input) 31
39: 6(float) Load 38 41: 6(float) Load 40
Store 37(f) 39 Store 39(f) 41
Kill Kill
FunctionEnd FunctionEnd
...@@ -69,6 +69,7 @@ gl_FragCoord origin is upper left ...@@ -69,6 +69,7 @@ gl_FragCoord origin is upper left
0:26 'input' ( in 4-component vector of float) 0:26 'input' ( in 4-component vector of float)
0:30 Test condition and select ( temp void) 0:30 Test condition and select ( temp void)
0:30 Condition 0:30 Condition
0:30 Convert float to bool ( temp bool)
0:30 move second child to first child ( temp float) 0:30 move second child to first child ( temp float)
0:30 'ii' ( temp float) 0:30 'ii' ( temp float)
0:30 direct index ( temp float) 0:30 direct index ( temp float)
...@@ -178,6 +179,7 @@ gl_FragCoord origin is upper left ...@@ -178,6 +179,7 @@ gl_FragCoord origin is upper left
0:26 'input' ( in 4-component vector of float) 0:26 'input' ( in 4-component vector of float)
0:30 Test condition and select ( temp void) 0:30 Test condition and select ( temp void)
0:30 Condition 0:30 Condition
0:30 Convert float to bool ( temp bool)
0:30 move second child to first child ( temp float) 0:30 move second child to first child ( temp float)
0:30 'ii' ( temp float) 0:30 'ii' ( temp float)
0:30 direct index ( temp float) 0:30 direct index ( temp float)
...@@ -215,24 +217,24 @@ gl_FragCoord origin is upper left ...@@ -215,24 +217,24 @@ gl_FragCoord origin is upper left
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 101 // Id's are bound by 103
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction" 94 97 EntryPoint Fragment 4 "PixelShaderFunction" 96 99
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Name 4 "PixelShaderFunction" Name 4 "PixelShaderFunction"
Name 11 "@PixelShaderFunction(vf4;" Name 11 "@PixelShaderFunction(vf4;"
Name 10 "input" Name 10 "input"
Name 68 "ii" Name 68 "ii"
Name 80 "ii" Name 82 "ii"
Name 92 "input"
Name 94 "input" Name 94 "input"
Name 97 "@entryPointOutput" Name 96 "input"
Name 98 "param" Name 99 "@entryPointOutput"
Decorate 94(input) Location 0 Name 100 "param"
Decorate 97(@entryPointOutput) Location 0 Decorate 96(input) Location 0
Decorate 99(@entryPointOutput) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
...@@ -244,31 +246,32 @@ gl_FragCoord origin is upper left ...@@ -244,31 +246,32 @@ gl_FragCoord origin is upper left
67: TypePointer Function 6(float) 67: TypePointer Function 6(float)
69: TypeInt 32 0 69: TypeInt 32 0
70: 69(int) Constant 2 70: 69(int) Constant 2
76: 6(float) Constant 1065353216 73: 6(float) Constant 0
78: TypeInt 32 1 78: 6(float) Constant 1065353216
79: TypePointer Function 78(int) 80: TypeInt 32 1
82: 78(int) Constant 1 81: TypePointer Function 80(int)
93: TypePointer Input 7(fvec4) 84: 80(int) Constant 1
94(input): 93(ptr) Variable Input 95: TypePointer Input 7(fvec4)
96: TypePointer Output 7(fvec4) 96(input): 95(ptr) Variable Input
97(@entryPointOutput): 96(ptr) Variable Output 98: TypePointer Output 7(fvec4)
99(@entryPointOutput): 98(ptr) Variable Output
4(PixelShaderFunction): 2 Function None 3 4(PixelShaderFunction): 2 Function None 3
5: Label 5: Label
92(input): 8(ptr) Variable Function 94(input): 8(ptr) Variable Function
98(param): 8(ptr) Variable Function 100(param): 8(ptr) Variable Function
95: 7(fvec4) Load 94(input) 97: 7(fvec4) Load 96(input)
Store 92(input) 95 Store 94(input) 97
99: 7(fvec4) Load 92(input) 101: 7(fvec4) Load 94(input)
Store 98(param) 99 Store 100(param) 101
100: 7(fvec4) FunctionCall 11(@PixelShaderFunction(vf4;) 98(param) 102: 7(fvec4) FunctionCall 11(@PixelShaderFunction(vf4;) 100(param)
Store 97(@entryPointOutput) 100 Store 99(@entryPointOutput) 102
Return Return
FunctionEnd FunctionEnd
11(@PixelShaderFunction(vf4;): 7(fvec4) Function None 9 11(@PixelShaderFunction(vf4;): 7(fvec4) Function None 9
10(input): 8(ptr) FunctionParameter 10(input): 8(ptr) FunctionParameter
12: Label 12: Label
68(ii): 67(ptr) Variable Function 68(ii): 67(ptr) Variable Function
80(ii): 79(ptr) Variable Function 82(ii): 81(ptr) Variable Function
13: 7(fvec4) Load 10(input) 13: 7(fvec4) Load 10(input)
14: 7(fvec4) Load 10(input) 14: 7(fvec4) Load 10(input)
17: 16(bvec4) FOrdEqual 13 14 17: 16(bvec4) FOrdEqual 13 14
...@@ -338,28 +341,29 @@ gl_FragCoord origin is upper left ...@@ -338,28 +341,29 @@ gl_FragCoord origin is upper left
71: 67(ptr) AccessChain 10(input) 70 71: 67(ptr) AccessChain 10(input) 70
72: 6(float) Load 71 72: 6(float) Load 71
Store 68(ii) 72 Store 68(ii) 72
SelectionMerge 74 None 74: 15(bool) FOrdNotEqual 72 73
BranchConditional 72 73 74 SelectionMerge 76 None
73: Label BranchConditional 74 75 76
75: 6(float) Load 68(ii) 75: Label
77: 6(float) FAdd 75 76 77: 6(float) Load 68(ii)
Store 68(ii) 77 79: 6(float) FAdd 77 78
Branch 74 Store 68(ii) 79
74: Label Branch 76
81: 78(int) Load 80(ii) 76: Label
83: 78(int) IAdd 81 82 83: 80(int) Load 82(ii)
Store 80(ii) 83 85: 80(int) IAdd 83 84
84: 78(int) Load 80(ii) Store 82(ii) 85
85: 6(float) ConvertSToF 84 86: 80(int) Load 82(ii)
86: 15(bool) FOrdEqual 85 76 87: 6(float) ConvertSToF 86
SelectionMerge 88 None 88: 15(bool) FOrdEqual 87 78
BranchConditional 86 87 88 SelectionMerge 90 None
87: Label BranchConditional 88 89 90
89: 78(int) Load 80(ii) 89: Label
90: 78(int) IAdd 89 82 91: 80(int) Load 82(ii)
Store 80(ii) 90 92: 80(int) IAdd 91 84
Branch 88 Store 82(ii) 92
88: Label Branch 90
91: 7(fvec4) Undef 90: Label
ReturnValue 91 93: 7(fvec4) Undef
ReturnValue 93
FunctionEnd FunctionEnd
...@@ -31,6 +31,7 @@ gl_FragCoord origin is upper left ...@@ -31,6 +31,7 @@ gl_FragCoord origin is upper left
0:17 3 (const uint) 0:17 3 (const uint)
0:19 Test condition and select ( temp void) 0:19 Test condition and select ( temp void)
0:19 Condition 0:19 Condition
0:19 Convert int to bool ( temp bool)
0:19 ival: direct index for structure ( uniform int) 0:19 ival: direct index for structure ( uniform int)
0:19 'anon@0' (layout( row_major std140) uniform block{ uniform int ival, uniform 4-component vector of int ival4, uniform float fval, uniform 4-component vector of float fval4}) 0:19 'anon@0' (layout( row_major std140) uniform block{ uniform int ival, uniform 4-component vector of int ival4, uniform float fval, uniform 4-component vector of float fval4})
0:19 Constant: 0:19 Constant:
...@@ -38,6 +39,7 @@ gl_FragCoord origin is upper left ...@@ -38,6 +39,7 @@ gl_FragCoord origin is upper left
0:19 true case is null 0:19 true case is null
0:20 Test condition and select ( temp void) 0:20 Test condition and select ( temp void)
0:20 Condition 0:20 Condition
0:20 Convert float to bool ( temp bool)
0:20 fval: direct index for structure ( uniform float) 0:20 fval: direct index for structure ( uniform float)
0:20 'anon@0' (layout( row_major std140) uniform block{ uniform int ival, uniform 4-component vector of int ival4, uniform float fval, uniform 4-component vector of float fval4}) 0:20 'anon@0' (layout( row_major std140) uniform block{ uniform int ival, uniform 4-component vector of int ival4, uniform float fval, uniform 4-component vector of float fval4})
0:20 Constant: 0:20 Constant:
...@@ -123,6 +125,7 @@ gl_FragCoord origin is upper left ...@@ -123,6 +125,7 @@ gl_FragCoord origin is upper left
0:17 3 (const uint) 0:17 3 (const uint)
0:19 Test condition and select ( temp void) 0:19 Test condition and select ( temp void)
0:19 Condition 0:19 Condition
0:19 Convert int to bool ( temp bool)
0:19 ival: direct index for structure ( uniform int) 0:19 ival: direct index for structure ( uniform int)
0:19 'anon@0' (layout( row_major std140) uniform block{ uniform int ival, uniform 4-component vector of int ival4, uniform float fval, uniform 4-component vector of float fval4}) 0:19 'anon@0' (layout( row_major std140) uniform block{ uniform int ival, uniform 4-component vector of int ival4, uniform float fval, uniform 4-component vector of float fval4})
0:19 Constant: 0:19 Constant:
...@@ -130,6 +133,7 @@ gl_FragCoord origin is upper left ...@@ -130,6 +133,7 @@ gl_FragCoord origin is upper left
0:19 true case is null 0:19 true case is null
0:20 Test condition and select ( temp void) 0:20 Test condition and select ( temp void)
0:20 Condition 0:20 Condition
0:20 Convert float to bool ( temp bool)
0:20 fval: direct index for structure ( uniform float) 0:20 fval: direct index for structure ( uniform float)
0:20 'anon@0' (layout( row_major std140) uniform block{ uniform int ival, uniform 4-component vector of int ival4, uniform float fval, uniform 4-component vector of float fval4}) 0:20 'anon@0' (layout( row_major std140) uniform block{ uniform int ival, uniform 4-component vector of int ival4, uniform float fval, uniform 4-component vector of float fval4})
0:20 Constant: 0:20 Constant:
...@@ -181,12 +185,12 @@ gl_FragCoord origin is upper left ...@@ -181,12 +185,12 @@ gl_FragCoord origin is upper left
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 82 // Id's are bound by 84
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 79 EntryPoint Fragment 4 "main" 81
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Name 4 "main" Name 4 "main"
Name 8 "PS_OUTPUT" Name 8 "PS_OUTPUT"
...@@ -198,15 +202,15 @@ gl_FragCoord origin is upper left ...@@ -198,15 +202,15 @@ gl_FragCoord origin is upper left
MemberName 14($Global) 2 "fval" MemberName 14($Global) 2 "fval"
MemberName 14($Global) 3 "fval4" MemberName 14($Global) 3 "fval4"
Name 16 "" Name 16 ""
Name 70 "psout" Name 72 "psout"
Name 79 "Color" Name 81 "Color"
MemberDecorate 14($Global) 0 Offset 0 MemberDecorate 14($Global) 0 Offset 0
MemberDecorate 14($Global) 1 Offset 16 MemberDecorate 14($Global) 1 Offset 16
MemberDecorate 14($Global) 2 Offset 32 MemberDecorate 14($Global) 2 Offset 32
MemberDecorate 14($Global) 3 Offset 48 MemberDecorate 14($Global) 3 Offset 48
Decorate 14($Global) Block Decorate 14($Global) Block
Decorate 16 DescriptorSet 0 Decorate 16 DescriptorSet 0
Decorate 79(Color) Location 0 Decorate 81(Color) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
...@@ -234,22 +238,22 @@ gl_FragCoord origin is upper left ...@@ -234,22 +238,22 @@ gl_FragCoord origin is upper left
42: 12(int) Constant 3 42: 12(int) Constant 3
43: TypePointer Uniform 7(fvec4) 43: TypePointer Uniform 7(fvec4)
46: 7(fvec4) ConstantComposite 39 39 39 39 46: 7(fvec4) ConstantComposite 39 39 39 39
69: TypePointer Function 8(PS_OUTPUT) 71: TypePointer Function 8(PS_OUTPUT)
71: 6(float) Constant 1065353216 73: 6(float) Constant 1065353216
72: 7(fvec4) ConstantComposite 71 71 71 71 74: 7(fvec4) ConstantComposite 73 73 73 73
73: TypePointer Function 7(fvec4) 75: TypePointer Function 7(fvec4)
78: TypePointer Output 7(fvec4) 80: TypePointer Output 7(fvec4)
79(Color): 78(ptr) Variable Output 81(Color): 80(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
80:8(PS_OUTPUT) FunctionCall 10(@main() 82:8(PS_OUTPUT) FunctionCall 10(@main()
81: 7(fvec4) CompositeExtract 80 0 83: 7(fvec4) CompositeExtract 82 0
Store 79(Color) 81 Store 81(Color) 83
Return Return
FunctionEnd FunctionEnd
10(@main():8(PS_OUTPUT) Function None 9 10(@main():8(PS_OUTPUT) Function None 9
11: Label 11: Label
70(psout): 69(ptr) Variable Function 72(psout): 71(ptr) Variable Function
19: 18(ptr) AccessChain 16 17 19: 18(ptr) AccessChain 16 17
20: 12(int) Load 19 20: 12(int) Load 19
24: 21(bool) INotEqual 20 23 24: 21(bool) INotEqual 20 23
...@@ -268,38 +272,40 @@ gl_FragCoord origin is upper left ...@@ -268,38 +272,40 @@ gl_FragCoord origin is upper left
48: 30(bvec4) LogicalNot 47 48: 30(bvec4) LogicalNot 47
49: 18(ptr) AccessChain 16 17 49: 18(ptr) AccessChain 16 17
50: 12(int) Load 49 50: 12(int) Load 49
SelectionMerge 52 None 51: 21(bool) INotEqual 50 23
BranchConditional 50 51 52 SelectionMerge 53 None
51: Label BranchConditional 51 52 53
Branch 52
52: Label 52: Label
53: 36(ptr) AccessChain 16 35 Branch 53
54: 6(float) Load 53 53: Label
SelectionMerge 56 None 54: 36(ptr) AccessChain 16 35
BranchConditional 54 55 56 55: 6(float) Load 54
55: Label 56: 21(bool) FOrdNotEqual 55 39
Branch 56 SelectionMerge 58 None
56: Label BranchConditional 56 57 58
57: 18(ptr) AccessChain 16 17 57: Label
58: 12(int) Load 57 Branch 58
59: 21(bool) INotEqual 58 23 58: Label
60: 21(bool) LogicalNot 59 59: 18(ptr) AccessChain 16 17
SelectionMerge 62 None 60: 12(int) Load 59
BranchConditional 60 61 62 61: 21(bool) INotEqual 60 23
61: Label 62: 21(bool) LogicalNot 61
Branch 62 SelectionMerge 64 None
62: Label BranchConditional 62 63 64
63: 36(ptr) AccessChain 16 35 63: Label
64: 6(float) Load 63 Branch 64
65: 21(bool) FOrdNotEqual 64 39 64: Label
66: 21(bool) LogicalNot 65 65: 36(ptr) AccessChain 16 35
SelectionMerge 68 None 66: 6(float) Load 65
BranchConditional 66 67 68 67: 21(bool) FOrdNotEqual 66 39
67: Label 68: 21(bool) LogicalNot 67
Branch 68 SelectionMerge 70 None
68: Label BranchConditional 68 69 70
74: 73(ptr) AccessChain 70(psout) 17 69: Label
Store 74 72 Branch 70
75:8(PS_OUTPUT) Load 70(psout) 70: Label
ReturnValue 75 76: 75(ptr) AccessChain 72(psout) 17
Store 76 74
77:8(PS_OUTPUT) Load 72(psout)
ReturnValue 77
FunctionEnd FunctionEnd
float condf;
int condi;
float1 condf1;
int1 condi1;
float4 main() : SV_Target0
{
float4 a = float4(2.0, 2.0, 2.0, 2.0);
if (condi)
return a + 1.0;
if (condf)
return a + 2.0;
if (condf1)
return a + 3.0;
if (condi1)
return a + 4.0;
if (condi && condf || condf1)
return a + 5.0;
float f = condf;
while (f) { --f; }
int i = condi;
do { --i; } while (i);
for (; i; ) { --i; }
float g = condf ? 7.0 : 8.0;
a += g;
return a - 1.0;
}
\ No newline at end of file
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits. // For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run). // For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.1946" #define GLSLANG_REVISION "Overload400-PrecQual.1947"
#define GLSLANG_DATE "30-Mar-2017" #define GLSLANG_DATE "30-Mar-2017"
...@@ -127,6 +127,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -127,6 +127,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.hull.void.tesc", "main"}, {"hlsl.hull.void.tesc", "main"},
{"hlsl.identifier.sample.frag", "main"}, {"hlsl.identifier.sample.frag", "main"},
{"hlsl.if.frag", "PixelShaderFunction"}, {"hlsl.if.frag", "PixelShaderFunction"},
{"hlsl.implicitBool.frag", "main"},
{"hlsl.inoutquals.frag", "main"}, {"hlsl.inoutquals.frag", "main"},
{"hlsl.init.frag", "ShaderFunction"}, {"hlsl.init.frag", "ShaderFunction"},
{"hlsl.init2.frag", "main"}, {"hlsl.init2.frag", "main"},
......
...@@ -2527,6 +2527,10 @@ bool HlslGrammar::acceptConditionalExpression(TIntermTyped*& node) ...@@ -2527,6 +2527,10 @@ bool HlslGrammar::acceptConditionalExpression(TIntermTyped*& node)
if (! acceptTokenClass(EHTokQuestion)) if (! acceptTokenClass(EHTokQuestion))
return true; return true;
node = parseContext.convertConditionalExpression(token.loc, node);
if (node == nullptr)
return false;
TIntermTyped* trueNode = nullptr; TIntermTyped* trueNode = nullptr;
if (! acceptExpression(trueNode)) { if (! acceptExpression(trueNode)) {
expected("expression after ?"); expected("expression after ?");
...@@ -3197,6 +3201,9 @@ bool HlslGrammar::acceptSelectionStatement(TIntermNode*& statement) ...@@ -3197,6 +3201,9 @@ bool HlslGrammar::acceptSelectionStatement(TIntermNode*& statement)
TIntermTyped* condition; TIntermTyped* condition;
if (! acceptParenExpression(condition)) if (! acceptParenExpression(condition))
return false; return false;
condition = parseContext.convertConditionalExpression(loc, condition);
if (condition == nullptr)
return false;
// create the child statements // create the child statements
TIntermNodePair thenElse = { nullptr, nullptr }; TIntermNodePair thenElse = { nullptr, nullptr };
...@@ -3280,6 +3287,9 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement) ...@@ -3280,6 +3287,9 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement)
// LEFT_PAREN condition RIGHT_PAREN // LEFT_PAREN condition RIGHT_PAREN
if (! acceptParenExpression(condition)) if (! acceptParenExpression(condition))
return false; return false;
condition = parseContext.convertConditionalExpression(loc, condition);
if (condition == nullptr)
return false;
// statement // statement
if (! acceptScopedStatement(statement)) { if (! acceptScopedStatement(statement)) {
...@@ -3319,6 +3329,9 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement) ...@@ -3319,6 +3329,9 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement)
TIntermTyped* condition; TIntermTyped* condition;
if (! acceptParenExpression(condition)) if (! acceptParenExpression(condition))
return false; return false;
condition = parseContext.convertConditionalExpression(loc, condition);
if (condition == nullptr)
return false;
if (! acceptTokenClass(EHTokSemicolon)) if (! acceptTokenClass(EHTokSemicolon))
expected(";"); expected(";");
...@@ -3356,6 +3369,11 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement) ...@@ -3356,6 +3369,11 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement)
acceptExpression(condition); acceptExpression(condition);
if (! acceptTokenClass(EHTokSemicolon)) if (! acceptTokenClass(EHTokSemicolon))
expected(";"); expected(";");
if (condition != nullptr) {
condition = parseContext.convertConditionalExpression(loc, condition);
if (condition == nullptr)
return false;
}
// iterator SEMI_COLON // iterator SEMI_COLON
TIntermTyped* iterator = nullptr; TIntermTyped* iterator = nullptr;
......
...@@ -4285,6 +4285,18 @@ void HlslParseContext::handleRegister(const TSourceLoc& loc, TQualifier& qualifi ...@@ -4285,6 +4285,18 @@ void HlslParseContext::handleRegister(const TSourceLoc& loc, TQualifier& qualifi
} }
} }
// Convert to a scalar boolean, or if not allowed by HLSL semantics,
// report an error and return nullptr.
TIntermTyped* HlslParseContext::convertConditionalExpression(const TSourceLoc& loc, TIntermTyped* condition)
{
if (!condition->getType().isScalarOrVec1()) {
error(loc, "requires a scalar", "conditional expression", "");
return nullptr;
}
return intermediate.addConversion(EOpConstructBool, TType(EbtBool), condition);
}
// //
// Same error message for all places assignments don't work. // Same error message for all places assignments don't work.
// //
...@@ -4607,13 +4619,6 @@ bool HlslParseContext::voidErrorCheck(const TSourceLoc& loc, const TString& iden ...@@ -4607,13 +4619,6 @@ bool HlslParseContext::voidErrorCheck(const TSourceLoc& loc, const TString& iden
return false; return false;
} }
// Checks to see if the node (for the expression) contains a scalar boolean expression or not
void HlslParseContext::boolCheck(const TSourceLoc& loc, const TIntermTyped* type)
{
if (type->getBasicType() != EbtBool || type->isArray() || type->isMatrix() || type->isVector())
error(loc, "boolean expression expected", "", "");
}
// //
// Fix just a full qualifier (no variables or types yet, but qualifier is complete) at global level. // Fix just a full qualifier (no variables or types yet, but qualifier is complete) at global level.
// //
......
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
const glslang::TString* component); const glslang::TString* component);
void handleRegister(const TSourceLoc&, TQualifier&, const glslang::TString* profile, const glslang::TString& desc, void handleRegister(const TSourceLoc&, TQualifier&, const glslang::TString* profile, const glslang::TString& desc,
int subComponent, const glslang::TString*); int subComponent, const glslang::TString*);
TIntermTyped* convertConditionalExpression(const TSourceLoc&, TIntermTyped*);
TIntermAggregate* handleSamplerTextureCombine(const TSourceLoc& loc, TIntermTyped* argTex, TIntermTyped* argSampler); TIntermAggregate* handleSamplerTextureCombine(const TSourceLoc& loc, TIntermTyped* argTex, TIntermTyped* argSampler);
bool parseMatrixSwizzleSelector(const TSourceLoc&, const TString&, int cols, int rows, TSwizzleSelectors<TMatrixSelector>&); bool parseMatrixSwizzleSelector(const TSourceLoc&, const TString&, int cols, int rows, TSwizzleSelectors<TMatrixSelector>&);
...@@ -120,7 +120,6 @@ public: ...@@ -120,7 +120,6 @@ public:
void structArrayCheck(const TSourceLoc&, const TType& structure); void structArrayCheck(const TSourceLoc&, const TType& structure);
void arrayDimMerge(TType& type, const TArraySizes* sizes); void arrayDimMerge(TType& type, const TArraySizes* sizes);
bool voidErrorCheck(const TSourceLoc&, const TString&, TBasicType); bool voidErrorCheck(const TSourceLoc&, const TString&, TBasicType);
void boolCheck(const TSourceLoc&, const TIntermTyped*);
void globalQualifierFix(const TSourceLoc&, TQualifier&); void globalQualifierFix(const TSourceLoc&, TQualifier&);
bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType); bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType);
void mergeQualifiers(TQualifier& dst, const TQualifier& src); void mergeQualifiers(TQualifier& dst, const TQualifier& src);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment