HLSL: Implicit bool conversions for conditional expressions and related.

Covers if(cond), while(cond), do-while(cond), for(;cond;), and (cond ? :).
Fixes #778.
This commit is contained in:
John Kessenich
2017-03-30 22:09:30 -06:00
parent 8f9fdc986a
commit 7e997e2612
12 changed files with 887 additions and 263 deletions

View File

@@ -55,7 +55,8 @@ gl_FragCoord origin is upper left
0:12 'a' ( temp int)
0:12 Test condition and select ( temp int)
0:12 Condition
0:12 'b' ( temp int)
0:12 Convert int to bool ( temp bool)
0:12 'b' ( temp int)
0:12 true case
0:12 move second child to first child ( temp int)
0:12 'c' ( temp int)
@@ -67,7 +68,8 @@ gl_FragCoord origin is upper left
0:12 'b' ( temp int)
0:12 Test condition and select ( temp int)
0:12 Condition
0:12 'a' ( temp int)
0:12 Convert int to bool ( temp bool)
0:12 'a' ( temp int)
0:12 true case
0:12 move second child to first child ( temp int)
0:12 'd' ( temp int)
@@ -179,7 +181,8 @@ gl_FragCoord origin is upper left
0:12 'a' ( temp int)
0:12 Test condition and select ( temp int)
0:12 Condition
0:12 'b' ( temp int)
0:12 Convert int to bool ( temp bool)
0:12 'b' ( temp int)
0:12 true case
0:12 move second child to first child ( temp int)
0:12 'c' ( temp int)
@@ -191,7 +194,8 @@ gl_FragCoord origin is upper left
0:12 'b' ( temp int)
0:12 Test condition and select ( temp int)
0:12 Condition
0:12 'a' ( temp int)
0:12 Convert int to bool ( temp bool)
0:12 'a' ( temp int)
0:12 true case
0:12 move second child to first child ( temp int)
0:12 'd' ( temp int)
@@ -245,12 +249,12 @@ gl_FragCoord origin is upper left
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 100
// Id's are bound by 102
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction" 93 96
EntryPoint Fragment 4 "PixelShaderFunction" 95 98
ExecutionMode 4 OriginUpperLeft
Name 4 "PixelShaderFunction"
Name 11 "@PixelShaderFunction(vf4;"
@@ -261,13 +265,13 @@ gl_FragCoord origin is upper left
Name 21 "d"
Name 22 "ret"
Name 42 "e"
Name 59 "f"
Name 91 "input"
Name 64 "f"
Name 93 "input"
Name 96 "@entryPointOutput"
Name 97 "param"
Decorate 93(input) Location 0
Decorate 96(@entryPointOutput) Location 0
Name 95 "input"
Name 98 "@entryPointOutput"
Name 99 "param"
Decorate 95(input) Location 0
Decorate 98(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -279,27 +283,27 @@ gl_FragCoord origin is upper left
16: 13(int) Constant 5
18: 13(int) Constant 6
20: 13(int) Constant 7
49: 13(int) Constant 10
57: 13(int) Constant 11
61: TypeInt 32 0
62: 61(int) Constant 0
63: TypePointer Function 6(float)
66: 61(int) Constant 1
69: TypeBool
92: TypePointer Input 7(fvec4)
93(input): 92(ptr) Variable Input
95: TypePointer Output 7(fvec4)
96(@entryPointOutput): 95(ptr) Variable Output
45: TypeBool
46: TypeInt 32 0
47: 46(int) Constant 0
53: 13(int) Constant 10
62: 13(int) Constant 11
66: TypePointer Function 6(float)
69: 46(int) Constant 1
94: TypePointer Input 7(fvec4)
95(input): 94(ptr) Variable Input
97: TypePointer Output 7(fvec4)
98(@entryPointOutput): 97(ptr) Variable Output
4(PixelShaderFunction): 2 Function None 3
5: Label
91(input): 8(ptr) Variable Function
97(param): 8(ptr) Variable Function
94: 7(fvec4) Load 93(input)
Store 91(input) 94
98: 7(fvec4) Load 91(input)
Store 97(param) 98
99: 7(fvec4) FunctionCall 11(@PixelShaderFunction(vf4;) 97(param)
Store 96(@entryPointOutput) 99
93(input): 8(ptr) Variable Function
99(param): 8(ptr) Variable Function
96: 7(fvec4) Load 95(input)
Store 93(input) 96
100: 7(fvec4) Load 93(input)
Store 99(param) 100
101: 7(fvec4) FunctionCall 11(@PixelShaderFunction(vf4;) 99(param)
Store 98(@entryPointOutput) 101
Return
FunctionEnd
11(@PixelShaderFunction(vf4;): 7(fvec4) Function None 9
@@ -312,9 +316,9 @@ gl_FragCoord origin is upper left
22(ret): 8(ptr) Variable Function
42(e): 14(ptr) Variable Function
43: 14(ptr) Variable Function
51: 14(ptr) Variable Function
59(f): 8(ptr) Variable Function
60: 8(ptr) Variable Function
55: 14(ptr) Variable Function
64(f): 8(ptr) Variable Function
65: 8(ptr) Variable Function
Store 15(a) 16
Store 17(b) 18
Store 19(c) 20
@@ -340,63 +344,65 @@ gl_FragCoord origin is upper left
41: 7(fvec4) FAdd 36 40
Store 22(ret) 41
44: 13(int) Load 17(b)
SelectionMerge 46 None
BranchConditional 44 45 48
45: Label
47: 13(int) Load 21(d)
Store 19(c) 47
Store 43 47
Branch 46
48: Label
Store 43 49
Branch 46
46: Label
50: 13(int) Load 43
Store 15(a) 50
Store 42(e) 50
52: 13(int) Load 15(a)
SelectionMerge 54 None
BranchConditional 52 53 56
53: Label
55: 13(int) Load 19(c)
Store 21(d) 55
Store 51 55
Branch 54
56: Label
Store 51 57
Branch 54
54: Label
58: 13(int) Load 51
Store 17(b) 58
64: 63(ptr) AccessChain 22(ret) 62
65: 6(float) Load 64
67: 63(ptr) AccessChain 10(input) 66
48: 45(bool) INotEqual 44 47
SelectionMerge 50 None
BranchConditional 48 49 52
49: Label
51: 13(int) Load 21(d)
Store 19(c) 51
Store 43 51
Branch 50
52: Label
Store 43 53
Branch 50
50: Label
54: 13(int) Load 43
Store 15(a) 54
Store 42(e) 54
56: 13(int) Load 15(a)
57: 45(bool) INotEqual 56 47
SelectionMerge 59 None
BranchConditional 57 58 61
58: Label
60: 13(int) Load 19(c)
Store 21(d) 60
Store 55 60
Branch 59
61: Label
Store 55 62
Branch 59
59: Label
63: 13(int) Load 55
Store 17(b) 63
67: 66(ptr) AccessChain 22(ret) 47
68: 6(float) Load 67
70: 69(bool) FOrdLessThan 65 68
SelectionMerge 72 None
BranchConditional 70 71 77
71: Label
73: 13(int) Load 19(c)
74: 6(float) ConvertSToF 73
75: 7(fvec4) Load 10(input)
76: 7(fvec4) VectorTimesScalar 75 74
Store 60 76
Branch 72
77: Label
78: 13(int) Load 21(d)
79: 6(float) ConvertSToF 78
80: 7(fvec4) Load 10(input)
81: 7(fvec4) VectorTimesScalar 80 79
Store 60 81
Branch 72
72: Label
82: 7(fvec4) Load 60
Store 59(f) 82
83: 13(int) Load 42(e)
84: 6(float) ConvertSToF 83
85: 7(fvec4) Load 22(ret)
86: 7(fvec4) VectorTimesScalar 85 84
87: 7(fvec4) Load 59(f)
88: 7(fvec4) FAdd 86 87
ReturnValue 88
70: 66(ptr) AccessChain 10(input) 69
71: 6(float) Load 70
72: 45(bool) FOrdLessThan 68 71
SelectionMerge 74 None
BranchConditional 72 73 79
73: Label
75: 13(int) Load 19(c)
76: 6(float) ConvertSToF 75
77: 7(fvec4) Load 10(input)
78: 7(fvec4) VectorTimesScalar 77 76
Store 65 78
Branch 74
79: Label
80: 13(int) Load 21(d)
81: 6(float) ConvertSToF 80
82: 7(fvec4) Load 10(input)
83: 7(fvec4) VectorTimesScalar 82 81
Store 65 83
Branch 74
74: Label
84: 7(fvec4) Load 65
Store 64(f) 84
85: 13(int) Load 42(e)
86: 6(float) ConvertSToF 85
87: 7(fvec4) Load 22(ret)
88: 7(fvec4) VectorTimesScalar 87 86
89: 7(fvec4) Load 64(f)
90: 7(fvec4) FAdd 88 89
ReturnValue 90
FunctionEnd