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

@ -69,12 +69,13 @@ gl_FragCoord origin is upper left
0:26 'input' ( in 4-component vector of float)
0:30 Test condition and select ( temp void)
0:30 Condition
0:30 move second child to first child ( temp float)
0:30 'ii' ( temp float)
0:30 direct index ( temp float)
0:30 'input' ( in 4-component vector of float)
0:30 Constant:
0:30 2 (const int)
0:30 Convert float to bool ( temp bool)
0:30 move second child to first child ( temp float)
0:30 'ii' ( temp float)
0:30 direct index ( temp float)
0:30 'input' ( in 4-component vector of float)
0:30 Constant:
0:30 2 (const int)
0:30 true case
0:31 Pre-Increment ( temp float)
0:31 'ii' ( temp float)
@ -178,12 +179,13 @@ gl_FragCoord origin is upper left
0:26 'input' ( in 4-component vector of float)
0:30 Test condition and select ( temp void)
0:30 Condition
0:30 move second child to first child ( temp float)
0:30 'ii' ( temp float)
0:30 direct index ( temp float)
0:30 'input' ( in 4-component vector of float)
0:30 Constant:
0:30 2 (const int)
0:30 Convert float to bool ( temp bool)
0:30 move second child to first child ( temp float)
0:30 'ii' ( temp float)
0:30 direct index ( temp float)
0:30 'input' ( in 4-component vector of float)
0:30 Constant:
0:30 2 (const int)
0:30 true case
0:31 Pre-Increment ( temp float)
0:31 'ii' ( temp float)
@ -215,24 +217,24 @@ gl_FragCoord origin is upper left
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 101
// Id's are bound by 103
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction" 94 97
EntryPoint Fragment 4 "PixelShaderFunction" 96 99
ExecutionMode 4 OriginUpperLeft
Name 4 "PixelShaderFunction"
Name 11 "@PixelShaderFunction(vf4;"
Name 10 "input"
Name 68 "ii"
Name 80 "ii"
Name 92 "input"
Name 82 "ii"
Name 94 "input"
Name 97 "@entryPointOutput"
Name 98 "param"
Decorate 94(input) Location 0
Decorate 97(@entryPointOutput) Location 0
Name 96 "input"
Name 99 "@entryPointOutput"
Name 100 "param"
Decorate 96(input) Location 0
Decorate 99(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -244,31 +246,32 @@ gl_FragCoord origin is upper left
67: TypePointer Function 6(float)
69: TypeInt 32 0
70: 69(int) Constant 2
76: 6(float) Constant 1065353216
78: TypeInt 32 1
79: TypePointer Function 78(int)
82: 78(int) Constant 1
93: TypePointer Input 7(fvec4)
94(input): 93(ptr) Variable Input
96: TypePointer Output 7(fvec4)
97(@entryPointOutput): 96(ptr) Variable Output
73: 6(float) Constant 0
78: 6(float) Constant 1065353216
80: TypeInt 32 1
81: TypePointer Function 80(int)
84: 80(int) Constant 1
95: TypePointer Input 7(fvec4)
96(input): 95(ptr) Variable Input
98: TypePointer Output 7(fvec4)
99(@entryPointOutput): 98(ptr) Variable Output
4(PixelShaderFunction): 2 Function None 3
5: Label
92(input): 8(ptr) Variable Function
98(param): 8(ptr) Variable Function
95: 7(fvec4) Load 94(input)
Store 92(input) 95
99: 7(fvec4) Load 92(input)
Store 98(param) 99
100: 7(fvec4) FunctionCall 11(@PixelShaderFunction(vf4;) 98(param)
Store 97(@entryPointOutput) 100
94(input): 8(ptr) Variable Function
100(param): 8(ptr) Variable Function
97: 7(fvec4) Load 96(input)
Store 94(input) 97
101: 7(fvec4) Load 94(input)
Store 100(param) 101
102: 7(fvec4) FunctionCall 11(@PixelShaderFunction(vf4;) 100(param)
Store 99(@entryPointOutput) 102
Return
FunctionEnd
11(@PixelShaderFunction(vf4;): 7(fvec4) Function None 9
10(input): 8(ptr) FunctionParameter
12: Label
68(ii): 67(ptr) Variable Function
80(ii): 79(ptr) Variable Function
82(ii): 81(ptr) Variable Function
13: 7(fvec4) Load 10(input)
14: 7(fvec4) Load 10(input)
17: 16(bvec4) FOrdEqual 13 14
@ -338,28 +341,29 @@ gl_FragCoord origin is upper left
71: 67(ptr) AccessChain 10(input) 70
72: 6(float) Load 71
Store 68(ii) 72
SelectionMerge 74 None
BranchConditional 72 73 74
73: Label
75: 6(float) Load 68(ii)
77: 6(float) FAdd 75 76
Store 68(ii) 77
Branch 74
74: Label
81: 78(int) Load 80(ii)
83: 78(int) IAdd 81 82
Store 80(ii) 83
84: 78(int) Load 80(ii)
85: 6(float) ConvertSToF 84
86: 15(bool) FOrdEqual 85 76
SelectionMerge 88 None
BranchConditional 86 87 88
87: Label
89: 78(int) Load 80(ii)
90: 78(int) IAdd 89 82
Store 80(ii) 90
Branch 88
88: Label
91: 7(fvec4) Undef
ReturnValue 91
74: 15(bool) FOrdNotEqual 72 73
SelectionMerge 76 None
BranchConditional 74 75 76
75: Label
77: 6(float) Load 68(ii)
79: 6(float) FAdd 77 78
Store 68(ii) 79
Branch 76
76: Label
83: 80(int) Load 82(ii)
85: 80(int) IAdd 83 84
Store 82(ii) 85
86: 80(int) Load 82(ii)
87: 6(float) ConvertSToF 86
88: 15(bool) FOrdEqual 87 78
SelectionMerge 90 None
BranchConditional 88 89 90
89: Label
91: 80(int) Load 82(ii)
92: 80(int) IAdd 91 84
Store 82(ii) 92
Branch 90
90: Label
93: 7(fvec4) Undef
ReturnValue 93
FunctionEnd