GLSL/SPV: Propagaet precision qualifier from function to return value.

When a return value's type has no precision qualification (e.g., the return
expression is formed from a constructor), and the formal function return type
has a precision qualification, back propagate that from the return type to the
type of the return value's expression.
This commit is contained in:
John Kessenich 2020-07-15 23:38:47 -06:00
parent 4f72970ed3
commit 3d2391fb25
7 changed files with 462 additions and 455 deletions

View File

@ -61,7 +61,7 @@ ERROR: node is still EOpNull!
0:49 Constant: 0:49 Constant:
0:49 0.000000 0:49 0.000000
0:50 Branch: Return with expression 0:50 Branch: Return with expression
0:50 Construct float ( temp 4-element array of 7-element array of float) 0:50 Construct float ( temp 4-element array of 7-element array of highp float)
0:50 direct index ( temp 7-element array of highp float) 0:50 direct index ( temp 7-element array of highp float)
0:50 'a' ( in 5-element array of 7-element array of highp float) 0:50 'a' ( in 5-element array of 7-element array of highp float)
0:50 Constant: 0:50 Constant:
@ -76,7 +76,7 @@ ERROR: node is still EOpNull!
0:50 Constant: 0:50 Constant:
0:50 3 (const int) 0:50 3 (const int)
0:51 Branch: Return with expression 0:51 Branch: Return with expression
0:51 Construct float ( temp 4-element array of 7-element array of float) 0:51 Construct float ( temp 4-element array of 7-element array of highp float)
0:51 direct index ( temp 7-element array of highp float) 0:51 direct index ( temp 7-element array of highp float)
0:51 'a' ( in 5-element array of 7-element array of highp float) 0:51 'a' ( in 5-element array of 7-element array of highp float)
0:51 Constant: 0:51 Constant:
@ -91,7 +91,7 @@ ERROR: node is still EOpNull!
0:51 Constant: 0:51 Constant:
0:51 3 (const int) 0:51 3 (const int)
0:52 Branch: Return with expression 0:52 Branch: Return with expression
0:52 Construct float ( temp 4-element array of 7-element array of float) 0:52 Construct float ( temp 4-element array of 7-element array of highp float)
0:52 direct index ( temp 7-element array of highp float) 0:52 direct index ( temp 7-element array of highp float)
0:52 'a' ( in 5-element array of 7-element array of highp float) 0:52 'a' ( in 5-element array of 7-element array of highp float)
0:52 Constant: 0:52 Constant:

View File

@ -31,7 +31,7 @@ ERROR: node is still EOpNull!
0:9 'a' ( in 5-element array of mediump float) 0:9 'a' ( in 5-element array of mediump float)
0:11 Sequence 0:11 Sequence
0:11 Branch: Return with expression 0:11 Branch: Return with expression
0:11 Construct float ( temp 4-element array of float) 0:11 Construct float ( temp 4-element array of mediump float)
0:11 direct index ( temp mediump float) 0:11 direct index ( temp mediump float)
0:11 'a' ( in 5-element array of mediump float) 0:11 'a' ( in 5-element array of mediump float)
0:11 Constant: 0:11 Constant:
@ -168,7 +168,7 @@ ERROR: node is still EOpNull!
0:9 'a' ( in 5-element array of mediump float) 0:9 'a' ( in 5-element array of mediump float)
0:11 Sequence 0:11 Sequence
0:11 Branch: Return with expression 0:11 Branch: Return with expression
0:11 Construct float ( temp 4-element array of float) 0:11 Construct float ( temp 4-element array of mediump float)
0:11 direct index ( temp mediump float) 0:11 direct index ( temp mediump float)
0:11 'a' ( in 5-element array of mediump float) 0:11 'a' ( in 5-element array of mediump float)
0:11 Constant: 0:11 Constant:

View File

@ -1,12 +1,12 @@
spv.forwardFun.frag spv.forwardFun.frag
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 8000a // Generated by (magic number): 8000a
// Id's are bound by 64 // Id's are bound by 60
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 20 30 36 63 EntryPoint Fragment 4 "main" 20 30 36 59
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source GLSL 140 Source GLSL 140
Name 4 "main" Name 4 "main"
@ -20,7 +20,7 @@ spv.forwardFun.frag
Name 27 "f" Name 27 "f"
Name 30 "gl_FragColor" Name 30 "gl_FragColor"
Name 36 "d" Name 36 "d"
Name 63 "bigColor" Name 59 "bigColor"
Decorate 10(unreachableReturn() RelaxedPrecision Decorate 10(unreachableReturn() RelaxedPrecision
Decorate 16(foo(vf4;) RelaxedPrecision Decorate 16(foo(vf4;) RelaxedPrecision
Decorate 15(bar) RelaxedPrecision Decorate 15(bar) RelaxedPrecision
@ -41,15 +41,11 @@ spv.forwardFun.frag
Decorate 36(d) RelaxedPrecision Decorate 36(d) RelaxedPrecision
Decorate 36(d) Location 2 Decorate 36(d) Location 2
Decorate 37 RelaxedPrecision Decorate 37 RelaxedPrecision
Decorate 44 RelaxedPrecision Decorate 52 RelaxedPrecision
Decorate 45 RelaxedPrecision Decorate 55 RelaxedPrecision
Decorate 49 RelaxedPrecision
Decorate 50 RelaxedPrecision
Decorate 56 RelaxedPrecision Decorate 56 RelaxedPrecision
Decorate 59 RelaxedPrecision Decorate 59(bigColor) RelaxedPrecision
Decorate 60 RelaxedPrecision Decorate 59(bigColor) Location 0
Decorate 63(bigColor) RelaxedPrecision
Decorate 63(bigColor) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
8: TypeFloat 32 8: TypeFloat 32
@ -67,11 +63,11 @@ spv.forwardFun.frag
38: 8(float) Constant 1082549862 38: 8(float) Constant 1082549862
39: TypeBool 39: TypeBool
43: 8(float) Constant 1067030938 43: 8(float) Constant 1067030938
48: 8(float) Constant 1083179008 46: 8(float) Constant 1083179008
53: TypeInt 32 0 49: TypeInt 32 0
54: 53(int) Constant 0 50: 49(int) Constant 0
57: 53(int) Constant 1 53: 49(int) Constant 1
63(bigColor): 19(ptr) Variable Input 59(bigColor): 19(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
18(color): 13(ptr) Variable Function 18(color): 13(ptr) Variable Function
@ -97,31 +93,25 @@ spv.forwardFun.frag
FunctionEnd FunctionEnd
10(unreachableReturn(): 8(float) Function None 9 10(unreachableReturn(): 8(float) Function None 9
11: Label 11: Label
44: 26(ptr) Variable Function
49: 26(ptr) Variable Function
34: 2 FunctionCall 6(bar() 34: 2 FunctionCall 6(bar()
37: 8(float) Load 36(d) 37: 8(float) Load 36(d)
40: 39(bool) FOrdLessThan 37 38 40: 39(bool) FOrdLessThan 37 38
SelectionMerge 42 None SelectionMerge 42 None
BranchConditional 40 41 47 BranchConditional 40 41 45
41: Label 41: Label
Store 44 43 ReturnValue 43
45: 8(float) Load 44 45: Label
ReturnValue 45 ReturnValue 46
47: Label
Store 49 48
50: 8(float) Load 49
ReturnValue 50
42: Label 42: Label
Unreachable Unreachable
FunctionEnd FunctionEnd
16(foo(vf4;): 8(float) Function None 14 16(foo(vf4;): 8(float) Function None 14
15(bar): 13(ptr) FunctionParameter 15(bar): 13(ptr) FunctionParameter
17: Label 17: Label
55: 26(ptr) AccessChain 15(bar) 54 51: 26(ptr) AccessChain 15(bar) 50
56: 8(float) Load 55 52: 8(float) Load 51
58: 26(ptr) AccessChain 15(bar) 57 54: 26(ptr) AccessChain 15(bar) 53
59: 8(float) Load 58 55: 8(float) Load 54
60: 8(float) FAdd 56 59 56: 8(float) FAdd 52 55
ReturnValue 60 ReturnValue 56
FunctionEnd FunctionEnd

View File

@ -5,12 +5,12 @@ WARNING: 0:139: 'switch' : last case/default label not followed by statements
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 8000a // Generated by (magic number): 8000a
// Id's are bound by 275 // Id's are bound by 269
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 68 81 135 233 239 EntryPoint Fragment 4 "main" 62 75 129 227 233
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source ESSL 310 Source ESSL 310
Name 4 "main" Name 4 "main"
@ -22,21 +22,21 @@ WARNING: 0:139: 'switch' : last case/default label not followed by statements
Name 17 "v1" Name 17 "v1"
Name 18 "v2" Name 18 "v2"
Name 19 "i1" Name 19 "i1"
Name 66 "local" Name 60 "local"
Name 68 "c" Name 62 "c"
Name 79 "f" Name 73 "f"
Name 81 "x" Name 75 "x"
Name 135 "d" Name 129 "d"
Name 161 "i" Name 155 "i"
Name 181 "j" Name 175 "j"
Name 233 "color" Name 227 "color"
Name 239 "v" Name 233 "v"
Name 240 "param" Name 234 "param"
Name 242 "param" Name 236 "param"
Name 244 "param" Name 238 "param"
Name 252 "param" Name 246 "param"
Name 254 "param" Name 248 "param"
Name 256 "param" Name 250 "param"
Decorate 15(foo1(vf4;vf4;i1;) RelaxedPrecision Decorate 15(foo1(vf4;vf4;i1;) RelaxedPrecision
Decorate 12(v1) RelaxedPrecision Decorate 12(v1) RelaxedPrecision
Decorate 13(v2) RelaxedPrecision Decorate 13(v2) RelaxedPrecision
@ -51,142 +51,136 @@ WARNING: 0:139: 'switch' : last case/default label not followed by statements
Decorate 31 RelaxedPrecision Decorate 31 RelaxedPrecision
Decorate 32 RelaxedPrecision Decorate 32 RelaxedPrecision
Decorate 33 RelaxedPrecision Decorate 33 RelaxedPrecision
Decorate 38 RelaxedPrecision Decorate 40 RelaxedPrecision
Decorate 39 RelaxedPrecision Decorate 46 RelaxedPrecision
Decorate 42 RelaxedPrecision Decorate 51 RelaxedPrecision
Decorate 48 RelaxedPrecision
Decorate 52 RelaxedPrecision
Decorate 53 RelaxedPrecision Decorate 53 RelaxedPrecision
Decorate 54 RelaxedPrecision
Decorate 55 RelaxedPrecision Decorate 55 RelaxedPrecision
Decorate 57 RelaxedPrecision Decorate 60(local) RelaxedPrecision
Decorate 58 RelaxedPrecision Decorate 62(c) RelaxedPrecision
Decorate 59 RelaxedPrecision Decorate 62(c) Flat
Decorate 62 RelaxedPrecision Decorate 62(c) Location 0
Decorate 63 RelaxedPrecision Decorate 63 RelaxedPrecision
Decorate 66(local) RelaxedPrecision Decorate 64 RelaxedPrecision
Decorate 68(c) RelaxedPrecision Decorate 66 RelaxedPrecision
Decorate 68(c) Flat Decorate 67 RelaxedPrecision
Decorate 68(c) Location 0 Decorate 73(f) RelaxedPrecision
Decorate 69 RelaxedPrecision Decorate 75(x) RelaxedPrecision
Decorate 70 RelaxedPrecision Decorate 75(x) Location 2
Decorate 72 RelaxedPrecision Decorate 76 RelaxedPrecision
Decorate 73 RelaxedPrecision Decorate 77 RelaxedPrecision
Decorate 79(f) RelaxedPrecision Decorate 79 RelaxedPrecision
Decorate 81(x) RelaxedPrecision Decorate 80 RelaxedPrecision
Decorate 81(x) Location 2
Decorate 82 RelaxedPrecision Decorate 82 RelaxedPrecision
Decorate 83 RelaxedPrecision Decorate 83 RelaxedPrecision
Decorate 85 RelaxedPrecision Decorate 85 RelaxedPrecision
Decorate 86 RelaxedPrecision Decorate 90 RelaxedPrecision
Decorate 88 RelaxedPrecision
Decorate 89 RelaxedPrecision
Decorate 91 RelaxedPrecision Decorate 91 RelaxedPrecision
Decorate 92 RelaxedPrecision
Decorate 93 RelaxedPrecision
Decorate 94 RelaxedPrecision
Decorate 95 RelaxedPrecision
Decorate 96 RelaxedPrecision Decorate 96 RelaxedPrecision
Decorate 97 RelaxedPrecision Decorate 97 RelaxedPrecision
Decorate 98 RelaxedPrecision
Decorate 99 RelaxedPrecision Decorate 99 RelaxedPrecision
Decorate 100 RelaxedPrecision Decorate 100 RelaxedPrecision
Decorate 101 RelaxedPrecision Decorate 101 RelaxedPrecision
Decorate 102 RelaxedPrecision Decorate 102 RelaxedPrecision
Decorate 103 RelaxedPrecision Decorate 104 RelaxedPrecision
Decorate 105 RelaxedPrecision
Decorate 106 RelaxedPrecision
Decorate 107 RelaxedPrecision
Decorate 108 RelaxedPrecision Decorate 108 RelaxedPrecision
Decorate 109 RelaxedPrecision
Decorate 110 RelaxedPrecision Decorate 110 RelaxedPrecision
Decorate 111 RelaxedPrecision
Decorate 113 RelaxedPrecision
Decorate 114 RelaxedPrecision Decorate 114 RelaxedPrecision
Decorate 115 RelaxedPrecision Decorate 115 RelaxedPrecision
Decorate 116 RelaxedPrecision Decorate 116 RelaxedPrecision
Decorate 117 RelaxedPrecision
Decorate 119 RelaxedPrecision Decorate 119 RelaxedPrecision
Decorate 120 RelaxedPrecision Decorate 124 RelaxedPrecision
Decorate 121 RelaxedPrecision
Decorate 122 RelaxedPrecision
Decorate 125 RelaxedPrecision Decorate 125 RelaxedPrecision
Decorate 126 RelaxedPrecision
Decorate 127 RelaxedPrecision
Decorate 129(d) RelaxedPrecision
Decorate 129(d) Flat
Decorate 129(d) Location 1
Decorate 130 RelaxedPrecision Decorate 130 RelaxedPrecision
Decorate 131 RelaxedPrecision Decorate 134 RelaxedPrecision
Decorate 132 RelaxedPrecision Decorate 135 RelaxedPrecision
Decorate 133 RelaxedPrecision
Decorate 135(d) RelaxedPrecision
Decorate 135(d) Flat
Decorate 135(d) Location 1
Decorate 136 RelaxedPrecision Decorate 136 RelaxedPrecision
Decorate 137 RelaxedPrecision
Decorate 138 RelaxedPrecision
Decorate 139 RelaxedPrecision
Decorate 140 RelaxedPrecision Decorate 140 RelaxedPrecision
Decorate 141 RelaxedPrecision
Decorate 142 RelaxedPrecision Decorate 142 RelaxedPrecision
Decorate 143 RelaxedPrecision Decorate 143 RelaxedPrecision
Decorate 144 RelaxedPrecision Decorate 144 RelaxedPrecision
Decorate 145 RelaxedPrecision Decorate 145 RelaxedPrecision
Decorate 146 RelaxedPrecision Decorate 146 RelaxedPrecision
Decorate 148 RelaxedPrecision
Decorate 149 RelaxedPrecision
Decorate 150 RelaxedPrecision Decorate 150 RelaxedPrecision
Decorate 151 RelaxedPrecision Decorate 151 RelaxedPrecision
Decorate 152 RelaxedPrecision Decorate 152 RelaxedPrecision
Decorate 156 RelaxedPrecision Decorate 153 RelaxedPrecision
Decorate 157 RelaxedPrecision Decorate 155(i) RelaxedPrecision
Decorate 158 RelaxedPrecision Decorate 162 RelaxedPrecision
Decorate 159 RelaxedPrecision Decorate 166 RelaxedPrecision
Decorate 161(i) RelaxedPrecision Decorate 171 RelaxedPrecision
Decorate 168 RelaxedPrecision
Decorate 172 RelaxedPrecision Decorate 172 RelaxedPrecision
Decorate 177 RelaxedPrecision Decorate 173 RelaxedPrecision
Decorate 178 RelaxedPrecision Decorate 174 RelaxedPrecision
Decorate 179 RelaxedPrecision Decorate 175(j) RelaxedPrecision
Decorate 180 RelaxedPrecision Decorate 182 RelaxedPrecision
Decorate 181(j) RelaxedPrecision Decorate 185 RelaxedPrecision
Decorate 188 RelaxedPrecision Decorate 186 RelaxedPrecision
Decorate 191 RelaxedPrecision Decorate 187 RelaxedPrecision
Decorate 192 RelaxedPrecision
Decorate 193 RelaxedPrecision Decorate 193 RelaxedPrecision
Decorate 194 RelaxedPrecision
Decorate 196 RelaxedPrecision
Decorate 197 RelaxedPrecision
Decorate 198 RelaxedPrecision
Decorate 199 RelaxedPrecision Decorate 199 RelaxedPrecision
Decorate 200 RelaxedPrecision
Decorate 202 RelaxedPrecision Decorate 202 RelaxedPrecision
Decorate 203 RelaxedPrecision Decorate 203 RelaxedPrecision
Decorate 204 RelaxedPrecision Decorate 204 RelaxedPrecision
Decorate 205 RelaxedPrecision Decorate 205 RelaxedPrecision
Decorate 208 RelaxedPrecision Decorate 207 RelaxedPrecision
Decorate 209 RelaxedPrecision
Decorate 210 RelaxedPrecision
Decorate 211 RelaxedPrecision
Decorate 213 RelaxedPrecision Decorate 213 RelaxedPrecision
Decorate 214 RelaxedPrecision
Decorate 215 RelaxedPrecision
Decorate 219 RelaxedPrecision Decorate 219 RelaxedPrecision
Decorate 220 RelaxedPrecision Decorate 220 RelaxedPrecision
Decorate 221 RelaxedPrecision Decorate 221 RelaxedPrecision
Decorate 225 RelaxedPrecision Decorate 222 RelaxedPrecision
Decorate 226 RelaxedPrecision Decorate 227(color) RelaxedPrecision
Decorate 227 RelaxedPrecision Decorate 227(color) Location 0
Decorate 228 RelaxedPrecision Decorate 228 RelaxedPrecision
Decorate 233(color) RelaxedPrecision Decorate 229 RelaxedPrecision
Decorate 233(color) Location 0 Decorate 230 RelaxedPrecision
Decorate 234 RelaxedPrecision Decorate 231 RelaxedPrecision
Decorate 233(v) RelaxedPrecision
Decorate 233(v) Location 3
Decorate 234(param) RelaxedPrecision
Decorate 235 RelaxedPrecision Decorate 235 RelaxedPrecision
Decorate 236 RelaxedPrecision Decorate 236(param) RelaxedPrecision
Decorate 237 RelaxedPrecision Decorate 237 RelaxedPrecision
Decorate 239(v) RelaxedPrecision Decorate 238(param) RelaxedPrecision
Decorate 239(v) Location 3 Decorate 239 RelaxedPrecision
Decorate 240(param) RelaxedPrecision Decorate 240 RelaxedPrecision
Decorate 241 RelaxedPrecision
Decorate 242(param) RelaxedPrecision
Decorate 243 RelaxedPrecision Decorate 243 RelaxedPrecision
Decorate 244(param) RelaxedPrecision Decorate 244 RelaxedPrecision
Decorate 245 RelaxedPrecision Decorate 245 RelaxedPrecision
Decorate 246 RelaxedPrecision Decorate 246(param) RelaxedPrecision
Decorate 247 RelaxedPrecision
Decorate 248(param) RelaxedPrecision
Decorate 249 RelaxedPrecision Decorate 249 RelaxedPrecision
Decorate 250 RelaxedPrecision Decorate 250(param) RelaxedPrecision
Decorate 251 RelaxedPrecision Decorate 251 RelaxedPrecision
Decorate 252(param) RelaxedPrecision Decorate 252 RelaxedPrecision
Decorate 253 RelaxedPrecision Decorate 254 RelaxedPrecision
Decorate 254(param) RelaxedPrecision
Decorate 255 RelaxedPrecision Decorate 255 RelaxedPrecision
Decorate 256(param) RelaxedPrecision Decorate 256 RelaxedPrecision
Decorate 257 RelaxedPrecision Decorate 257 RelaxedPrecision
Decorate 258 RelaxedPrecision Decorate 264 RelaxedPrecision
Decorate 260 RelaxedPrecision
Decorate 261 RelaxedPrecision
Decorate 262 RelaxedPrecision
Decorate 263 RelaxedPrecision
Decorate 270 RelaxedPrecision
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
@ -197,295 +191,295 @@ WARNING: 0:139: 'switch' : last case/default label not followed by statements
11: TypeFunction 7(fvec4) 8(ptr) 8(ptr) 10(ptr) 11: TypeFunction 7(fvec4) 8(ptr) 8(ptr) 10(ptr)
36: 6(float) Constant 0 36: 6(float) Constant 0
37: 7(fvec4) ConstantComposite 36 36 36 36 37: 7(fvec4) ConstantComposite 36 36 36 36
50: 6(float) Constant 1065353216 48: 6(float) Constant 1065353216
51: 7(fvec4) ConstantComposite 50 50 50 50 49: 7(fvec4) ConstantComposite 48 48 48 48
67: TypePointer Input 9(int) 61: TypePointer Input 9(int)
68(c): 67(ptr) Variable Input 62(c): 61(ptr) Variable Input
71: 9(int) Constant 1 65: 9(int) Constant 1
78: TypePointer Function 6(float) 72: TypePointer Function 6(float)
80: TypePointer Input 6(float) 74: TypePointer Input 6(float)
81(x): 80(ptr) Variable Input 75(x): 74(ptr) Variable Input
135(d): 67(ptr) Variable Input 129(d): 61(ptr) Variable Input
162: 9(int) Constant 0 156: 9(int) Constant 0
169: 9(int) Constant 10 163: 9(int) Constant 10
170: TypeBool 164: TypeBool
182: 9(int) Constant 20 176: 9(int) Constant 20
189: 9(int) Constant 30 183: 9(int) Constant 30
194: 6(float) Constant 1120429670 188: 6(float) Constant 1120429670
214: 6(float) Constant 1079739679 208: 6(float) Constant 1079739679
232: TypePointer Output 6(float) 226: TypePointer Output 6(float)
233(color): 232(ptr) Variable Output 227(color): 226(ptr) Variable Output
238: TypePointer Input 7(fvec4) 232: TypePointer Input 7(fvec4)
239(v): 238(ptr) Variable Input 233(v): 232(ptr) Variable Input
247: TypeInt 32 0 241: TypeInt 32 0
248: 247(int) Constant 1 242: 241(int) Constant 1
259: 247(int) Constant 2 253: 241(int) Constant 2
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
66(local): 10(ptr) Variable Function 60(local): 10(ptr) Variable Function
79(f): 78(ptr) Variable Function 73(f): 72(ptr) Variable Function
161(i): 10(ptr) Variable Function 155(i): 10(ptr) Variable Function
181(j): 10(ptr) Variable Function 175(j): 10(ptr) Variable Function
240(param): 8(ptr) Variable Function 234(param): 8(ptr) Variable Function
242(param): 8(ptr) Variable Function 236(param): 8(ptr) Variable Function
244(param): 10(ptr) Variable Function 238(param): 10(ptr) Variable Function
252(param): 8(ptr) Variable Function 246(param): 8(ptr) Variable Function
254(param): 8(ptr) Variable Function 248(param): 8(ptr) Variable Function
256(param): 10(ptr) Variable Function 250(param): 10(ptr) Variable Function
69: 9(int) Load 68(c) 63: 9(int) Load 62(c)
Store 66(local) 69 Store 60(local) 63
70: 9(int) Load 66(local) 64: 9(int) Load 60(local)
72: 9(int) IAdd 70 71 66: 9(int) IAdd 64 65
Store 66(local) 72 Store 60(local) 66
73: 9(int) Load 68(c) 67: 9(int) Load 62(c)
SelectionMerge 77 None SelectionMerge 71 None
Switch 73 76 Switch 67 70
case 1: 74 case 1: 68
case 2: 75 case 2: 69
76: Label 70: Label
88: 6(float) Load 81(x) 82: 6(float) Load 75(x)
89: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 88 83: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 82
Store 79(f) 89 Store 73(f) 83
Branch 77 Branch 71
74: Label 68: Label
82: 6(float) Load 81(x) 76: 6(float) Load 75(x)
83: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 82 77: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 76
Store 79(f) 83 Store 73(f) 77
Branch 77 Branch 71
75: Label 69: Label
85: 6(float) Load 81(x) 79: 6(float) Load 75(x)
86: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 85 80: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 79
Store 79(f) 86 Store 73(f) 80
Branch 77 Branch 71
77: Label 71: Label
91: 9(int) Load 68(c) 85: 9(int) Load 62(c)
SelectionMerge 95 None SelectionMerge 89 None
Switch 91 94 Switch 85 88
case 1: 92 case 1: 86
case 2: 93 case 2: 87
94: Label 88: Label
105: 6(float) Load 81(x) 99: 6(float) Load 75(x)
106: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 105 100: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 99
107: 6(float) Load 79(f) 101: 6(float) Load 73(f)
108: 6(float) FAdd 107 106 102: 6(float) FAdd 101 100
Store 79(f) 108 Store 73(f) 102
Branch 95 Branch 89
92: Label 86: Label
96: 6(float) Load 81(x) 90: 6(float) Load 75(x)
97: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 96 91: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 90
98: 6(float) Load 79(f) 92: 6(float) Load 73(f)
99: 6(float) FAdd 98 97 93: 6(float) FAdd 92 91
Store 79(f) 99 Store 73(f) 93
Branch 93 Branch 87
93: Label 87: Label
100: 6(float) Load 81(x) 94: 6(float) Load 75(x)
101: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 100 95: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 94
102: 6(float) Load 79(f) 96: 6(float) Load 73(f)
103: 6(float) FAdd 102 101 97: 6(float) FAdd 96 95
Store 79(f) 103 Store 73(f) 97
Branch 95 Branch 89
95: Label 89: Label
110: 9(int) Load 68(c) 104: 9(int) Load 62(c)
SelectionMerge 113 None SelectionMerge 107 None
Switch 110 113 Switch 104 107
case 1: 111 case 1: 105
case 2: 112 case 2: 106
111: Label 105: Label
114: 6(float) Load 81(x) 108: 6(float) Load 75(x)
115: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 114 109: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 108
116: 6(float) Load 79(f) 110: 6(float) Load 73(f)
117: 6(float) FAdd 116 115 111: 6(float) FAdd 110 109
Store 79(f) 117 Store 73(f) 111
Branch 113 Branch 107
112: Label 106: Label
119: 6(float) Load 81(x) 113: 6(float) Load 75(x)
120: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 119 114: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 113
121: 6(float) Load 79(f) 115: 6(float) Load 73(f)
122: 6(float) FAdd 121 120 116: 6(float) FAdd 115 114
Store 79(f) 122 Store 73(f) 116
Branch 113 Branch 107
113: Label 107: Label
125: 9(int) Load 68(c) 119: 9(int) Load 62(c)
SelectionMerge 129 None SelectionMerge 123 None
Switch 125 128 Switch 119 122
case 1: 126 case 1: 120
case 2: 127 case 2: 121
128: Label 122: Label
156: 6(float) Load 81(x) 150: 6(float) Load 75(x)
157: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 156 151: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 150
158: 6(float) Load 79(f) 152: 6(float) Load 73(f)
159: 6(float) FAdd 158 157 153: 6(float) FAdd 152 151
Store 79(f) 159 Store 73(f) 153
Branch 129 Branch 123
126: Label 120: Label
130: 6(float) Load 81(x) 124: 6(float) Load 75(x)
131: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 130 125: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 124
132: 6(float) Load 79(f) 126: 6(float) Load 73(f)
133: 6(float) FAdd 132 131 127: 6(float) FAdd 126 125
Store 79(f) 133 Store 73(f) 127
Branch 129 Branch 123
127: Label 121: Label
136: 9(int) Load 135(d) 130: 9(int) Load 129(d)
SelectionMerge 139 None SelectionMerge 133 None
Switch 136 139 Switch 130 133
case 1: 137 case 1: 131
case 2: 138 case 2: 132
137: Label 131: Label
140: 6(float) Load 81(x) 134: 6(float) Load 75(x)
141: 6(float) Load 81(x) 135: 6(float) Load 75(x)
142: 6(float) FMul 140 141 136: 6(float) FMul 134 135
143: 6(float) Load 81(x) 137: 6(float) Load 75(x)
138: 6(float) FMul 136 137
139: 6(float) Load 73(f)
140: 6(float) FAdd 139 138
Store 73(f) 140
Branch 133
132: Label
142: 6(float) Load 75(x)
143: 6(float) Load 75(x)
144: 6(float) FMul 142 143 144: 6(float) FMul 142 143
145: 6(float) Load 79(f) 145: 6(float) Load 73(f)
146: 6(float) FAdd 145 144 146: 6(float) FAdd 145 144
Store 79(f) 146 Store 73(f) 146
Branch 139 Branch 133
138: Label 133: Label
148: 6(float) Load 81(x) Branch 123
149: 6(float) Load 81(x) 123: Label
150: 6(float) FMul 148 149 Store 155(i) 156
151: 6(float) Load 79(f) Branch 157
152: 6(float) FAdd 151 150 157: Label
Store 79(f) 152 LoopMerge 159 160 None
Branch 139 Branch 161
139: Label 161: Label
Branch 129 162: 9(int) Load 155(i)
129: Label 165: 164(bool) SLessThan 162 163
Store 161(i) 162 BranchConditional 165 158 159
Branch 163 158: Label
163: Label 166: 9(int) Load 62(c)
LoopMerge 165 166 None SelectionMerge 170 None
Branch 167 Switch 166 169
167: Label case 1: 167
168: 9(int) Load 161(i) case 2: 168
171: 170(bool) SLessThan 168 169 169: Label
BranchConditional 171 164 165 202: 6(float) Load 75(x)
164: Label 203: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 202
172: 9(int) Load 68(c) 204: 6(float) Load 73(f)
SelectionMerge 176 None
Switch 172 175
case 1: 173
case 2: 174
175: Label
208: 6(float) Load 81(x)
209: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 208
210: 6(float) Load 79(f)
211: 6(float) FAdd 210 209
Store 79(f) 211
Branch 176
173: Label
177: 6(float) Load 81(x)
178: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 177
179: 6(float) Load 79(f)
180: 6(float) FAdd 179 178
Store 79(f) 180
Store 181(j) 182
Branch 183
183: Label
LoopMerge 185 186 None
Branch 187
187: Label
188: 9(int) Load 181(j)
190: 170(bool) SLessThan 188 189
BranchConditional 190 184 185
184: Label
191: 6(float) Load 79(f)
192: 6(float) FAdd 191 50
Store 79(f) 192
193: 6(float) Load 79(f)
195: 170(bool) FOrdLessThan 193 194
SelectionMerge 197 None
BranchConditional 195 196 197
196: Label
Branch 185
197: Label
Branch 186
186: Label
199: 9(int) Load 181(j)
200: 9(int) IAdd 199 71
Store 181(j) 200
Branch 183
185: Label
Branch 176
174: Label
202: 6(float) Load 81(x)
203: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 202
204: 6(float) Load 79(f)
205: 6(float) FAdd 204 203 205: 6(float) FAdd 204 203
Store 79(f) 205 Store 73(f) 205
Branch 176 Branch 170
176: Label 167: Label
213: 6(float) Load 79(f) 171: 6(float) Load 75(x)
215: 170(bool) FOrdLessThan 213 214 172: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 171
SelectionMerge 217 None 173: 6(float) Load 73(f)
BranchConditional 215 216 217 174: 6(float) FAdd 173 172
Store 73(f) 174
Store 175(j) 176
Branch 177
177: Label
LoopMerge 179 180 None
Branch 181
181: Label
182: 9(int) Load 175(j)
184: 164(bool) SLessThan 182 183
BranchConditional 184 178 179
178: Label
185: 6(float) Load 73(f)
186: 6(float) FAdd 185 48
Store 73(f) 186
187: 6(float) Load 73(f)
189: 164(bool) FOrdLessThan 187 188
SelectionMerge 191 None
BranchConditional 189 190 191
190: Label
Branch 179
191: Label
Branch 180
180: Label
193: 9(int) Load 175(j)
194: 9(int) IAdd 193 65
Store 175(j) 194
Branch 177
179: Label
Branch 170
168: Label
196: 6(float) Load 75(x)
197: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 196
198: 6(float) Load 73(f)
199: 6(float) FAdd 198 197
Store 73(f) 199
Branch 170
170: Label
207: 6(float) Load 73(f)
209: 164(bool) FOrdLessThan 207 208
SelectionMerge 211 None
BranchConditional 209 210 211
210: Label
Branch 159
211: Label
Branch 160
160: Label
213: 9(int) Load 155(i)
214: 9(int) IAdd 213 65
Store 155(i) 214
Branch 157
159: Label
215: 9(int) Load 62(c)
SelectionMerge 218 None
Switch 215 218
case 1: 216
case 2: 217
216: Label 216: Label
Branch 165 219: 6(float) Load 75(x)
220: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 219
221: 6(float) Load 73(f)
222: 6(float) FAdd 221 220
Store 73(f) 222
Branch 218
217: Label 217: Label
Branch 166 Branch 218
166: Label 218: Label
219: 9(int) Load 161(i) 228: 6(float) Load 73(f)
220: 9(int) IAdd 219 71 229: 9(int) Load 60(local)
Store 161(i) 220 230: 6(float) ConvertSToF 229
Branch 163 231: 6(float) FAdd 228 230
165: Label Store 227(color) 231
221: 9(int) Load 68(c) 235: 7(fvec4) Load 233(v)
SelectionMerge 224 None Store 234(param) 235
Switch 221 224 237: 7(fvec4) Load 233(v)
case 1: 222 Store 236(param) 237
case 2: 223 239: 9(int) Load 62(c)
222: Label Store 238(param) 239
225: 6(float) Load 81(x) 240: 7(fvec4) FunctionCall 15(foo1(vf4;vf4;i1;) 234(param) 236(param) 238(param)
226: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 225 243: 6(float) CompositeExtract 240 1
227: 6(float) Load 79(f) 244: 6(float) Load 227(color)
228: 6(float) FAdd 227 226 245: 6(float) FAdd 244 243
Store 79(f) 228 Store 227(color) 245
Branch 224 247: 7(fvec4) Load 233(v)
223: Label Store 246(param) 247
Branch 224 249: 7(fvec4) Load 233(v)
224: Label Store 248(param) 249
234: 6(float) Load 79(f) 251: 9(int) Load 62(c)
235: 9(int) Load 66(local) Store 250(param) 251
236: 6(float) ConvertSToF 235 252: 7(fvec4) FunctionCall 20(foo2(vf4;vf4;i1;) 246(param) 248(param) 250(param)
237: 6(float) FAdd 234 236 254: 6(float) CompositeExtract 252 2
Store 233(color) 237 255: 6(float) Load 227(color)
241: 7(fvec4) Load 239(v) 256: 6(float) FAdd 255 254
Store 240(param) 241 Store 227(color) 256
243: 7(fvec4) Load 239(v) 257: 9(int) Load 62(c)
Store 242(param) 243 SelectionMerge 260 None
245: 9(int) Load 68(c) Switch 257 259
Store 244(param) 245 case 0: 258
246: 7(fvec4) FunctionCall 15(foo1(vf4;vf4;i1;) 240(param) 242(param) 244(param) 259: Label
249: 6(float) CompositeExtract 246 1 Branch 260
250: 6(float) Load 233(color) 258: Label
251: 6(float) FAdd 250 249 Branch 260
Store 233(color) 251 260: Label
253: 7(fvec4) Load 239(v) 264: 9(int) Load 62(c)
Store 252(param) 253
255: 7(fvec4) Load 239(v)
Store 254(param) 255
257: 9(int) Load 68(c)
Store 256(param) 257
258: 7(fvec4) FunctionCall 20(foo2(vf4;vf4;i1;) 252(param) 254(param) 256(param)
260: 6(float) CompositeExtract 258 2
261: 6(float) Load 233(color)
262: 6(float) FAdd 261 260
Store 233(color) 262
263: 9(int) Load 68(c)
SelectionMerge 266 None SelectionMerge 266 None
Switch 263 265 Switch 264 265
case 0: 264
265: Label 265: Label
Branch 266 Branch 266
264: Label
Branch 266
266: Label 266: Label
270: 9(int) Load 68(c)
SelectionMerge 272 None
Switch 270 271
271: Label
Branch 272
272: Label
Return Return
FunctionEnd FunctionEnd
15(foo1(vf4;vf4;i1;): 7(fvec4) Function None 11 15(foo1(vf4;vf4;i1;): 7(fvec4) Function None 11
@ -493,7 +487,6 @@ WARNING: 0:139: 'switch' : last case/default label not followed by statements
13(v2): 8(ptr) FunctionParameter 13(v2): 8(ptr) FunctionParameter
14(i1): 10(ptr) FunctionParameter 14(i1): 10(ptr) FunctionParameter
16: Label 16: Label
38: 8(ptr) Variable Function
22: 9(int) Load 14(i1) 22: 9(int) Load 14(i1)
SelectionMerge 26 None SelectionMerge 26 None
Switch 22 26 Switch 22 26
@ -513,41 +506,33 @@ WARNING: 0:139: 'switch' : last case/default label not followed by statements
33: 7(fvec4) FMul 31 32 33: 7(fvec4) FMul 31 32
ReturnValue 33 ReturnValue 33
26: Label 26: Label
Store 38 37 ReturnValue 37
39: 7(fvec4) Load 38
ReturnValue 39
FunctionEnd FunctionEnd
20(foo2(vf4;vf4;i1;): 7(fvec4) Function None 11 20(foo2(vf4;vf4;i1;): 7(fvec4) Function None 11
17(v1): 8(ptr) FunctionParameter 17(v1): 8(ptr) FunctionParameter
18(v2): 8(ptr) FunctionParameter 18(v2): 8(ptr) FunctionParameter
19(i1): 10(ptr) FunctionParameter 19(i1): 10(ptr) FunctionParameter
21: Label 21: Label
52: 8(ptr) Variable Function 40: 9(int) Load 19(i1)
62: 8(ptr) Variable Function SelectionMerge 45 None
42: 9(int) Load 19(i1) Switch 40 45
SelectionMerge 47 None case 0: 41
Switch 42 47 case 2: 42
case 0: 43 case 1: 43
case 2: 44 case 3: 44
case 1: 45 41: Label
case 3: 46 46: 7(fvec4) Load 17(v1)
ReturnValue 46
42: Label
ReturnValue 49
43: Label 43: Label
48: 7(fvec4) Load 17(v1) 51: 7(fvec4) Load 18(v2)
ReturnValue 48 ReturnValue 51
44: Label 44: Label
Store 52 51 53: 7(fvec4) Load 17(v1)
53: 7(fvec4) Load 52 54: 7(fvec4) Load 18(v2)
ReturnValue 53 55: 7(fvec4) FMul 53 54
45: Label
55: 7(fvec4) Load 18(v2)
ReturnValue 55 ReturnValue 55
46: Label 45: Label
57: 7(fvec4) Load 17(v1) ReturnValue 37
58: 7(fvec4) Load 18(v2)
59: 7(fvec4) FMul 57 58
ReturnValue 59
47: Label
Store 62 37
63: 7(fvec4) Load 62
ReturnValue 63
FunctionEnd FunctionEnd

View File

@ -1231,6 +1231,7 @@ public:
TOperator getFlowOp() const { return flowOp; } TOperator getFlowOp() const { return flowOp; }
TIntermTyped* getExpression() const { return expression; } TIntermTyped* getExpression() const { return expression; }
void setExpression(TIntermTyped* pExpression) { expression = pExpression; } void setExpression(TIntermTyped* pExpression) { expression = pExpression; }
void updatePrecision(TPrecisionQualifier parentPrecision);
protected: protected:
TOperator flowOp; TOperator flowOp;
TIntermTyped* expression; TIntermTyped* expression;

View File

@ -2777,6 +2777,22 @@ TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TIntermTyped* expres
return node; return node;
} }
// Propagate precision from formal function return type to actual return type,
// and on to its subtree.
void TIntermBranch::updatePrecision(TPrecisionQualifier parentPrecision)
{
TIntermTyped* exp = getExpression();
if (exp == nullptr)
return;
if (exp->getBasicType() == EbtInt || exp->getBasicType() == EbtUint ||
exp->getBasicType() == EbtFloat || exp->getBasicType() == EbtFloat16) {
if (parentPrecision != EpqNone && exp->getQualifier().precision == EpqNone) {
exp->propagatePrecision(parentPrecision);
}
}
}
// //
// This is to be executed after the final root is put on top by the parsing // This is to be executed after the final root is put on top by the parsing
// process. // process.
@ -3284,9 +3300,11 @@ bool TIntermediate::promoteUnary(TIntermUnary& node)
return true; return true;
} }
// Propagate precision qualifiers *up* from children to parent.
void TIntermUnary::updatePrecision() void TIntermUnary::updatePrecision()
{ {
if (getBasicType() == EbtInt || getBasicType() == EbtUint || getBasicType() == EbtFloat || getBasicType() == EbtFloat16) { if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
if (operand->getQualifier().precision > getQualifier().precision) if (operand->getQualifier().precision > getQualifier().precision)
getQualifier().precision = operand->getQualifier().precision; getQualifier().precision = operand->getQualifier().precision;
} }
@ -3782,9 +3800,12 @@ bool TIntermediate::promoteAggregate(TIntermAggregate& node)
return false; return false;
} }
// Propagate precision qualifiers *up* from children to parent, and then
// back *down* again to the children's subtrees.
void TIntermBinary::updatePrecision() void TIntermBinary::updatePrecision()
{ {
if (getBasicType() == EbtInt || getBasicType() == EbtUint || getBasicType() == EbtFloat || getBasicType() == EbtFloat16) { if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
getQualifier().precision = std::max(right->getQualifier().precision, left->getQualifier().precision); getQualifier().precision = std::max(right->getQualifier().precision, left->getQualifier().precision);
if (getQualifier().precision != EpqNone) { if (getQualifier().precision != EpqNone) {
left->propagatePrecision(getQualifier().precision); left->propagatePrecision(getQualifier().precision);
@ -3793,9 +3814,14 @@ void TIntermBinary::updatePrecision()
} }
} }
// Recursively propagate precision qualifiers *down* the subtree of the current node,
// until reaching a node that already has a precision qualifier or otherwise does
// not participate in precision propagation.
void TIntermTyped::propagatePrecision(TPrecisionQualifier newPrecision) void TIntermTyped::propagatePrecision(TPrecisionQualifier newPrecision)
{ {
if (getQualifier().precision != EpqNone || (getBasicType() != EbtInt && getBasicType() != EbtUint && getBasicType() != EbtFloat && getBasicType() != EbtFloat16)) if (getQualifier().precision != EpqNone ||
(getBasicType() != EbtInt && getBasicType() != EbtUint &&
getBasicType() != EbtFloat && getBasicType() != EbtFloat16))
return; return;
getQualifier().precision = newPrecision; getQualifier().precision = newPrecision;

View File

@ -1415,23 +1415,28 @@ TIntermNode* TParseContext::handleReturnValue(const TSourceLoc& loc, TIntermType
#endif #endif
functionReturnsValue = true; functionReturnsValue = true;
TIntermBranch* branch = nullptr;
if (currentFunctionType->getBasicType() == EbtVoid) { if (currentFunctionType->getBasicType() == EbtVoid) {
error(loc, "void function cannot return a value", "return", ""); error(loc, "void function cannot return a value", "return", "");
return intermediate.addBranch(EOpReturn, loc); branch = intermediate.addBranch(EOpReturn, loc);
} else if (*currentFunctionType != value->getType()) { } else if (*currentFunctionType != value->getType()) {
TIntermTyped* converted = intermediate.addConversion(EOpReturn, *currentFunctionType, value); TIntermTyped* converted = intermediate.addConversion(EOpReturn, *currentFunctionType, value);
if (converted) { if (converted) {
if (*currentFunctionType != converted->getType()) if (*currentFunctionType != converted->getType())
error(loc, "cannot convert return value to function return type", "return", ""); error(loc, "cannot convert return value to function return type", "return", "");
if (version < 420) if (version < 420)
warn(loc, "type conversion on return values was not explicitly allowed until version 420", "return", ""); warn(loc, "type conversion on return values was not explicitly allowed until version 420",
return intermediate.addBranch(EOpReturn, converted, loc); "return", "");
branch = intermediate.addBranch(EOpReturn, converted, loc);
} else { } else {
error(loc, "type does not match, or is not convertible to, the function's return type", "return", ""); error(loc, "type does not match, or is not convertible to, the function's return type", "return", "");
return intermediate.addBranch(EOpReturn, value, loc); branch = intermediate.addBranch(EOpReturn, value, loc);
} }
} else } else
return intermediate.addBranch(EOpReturn, value, loc); branch = intermediate.addBranch(EOpReturn, value, loc);
branch->updatePrecision(currentFunctionType->getQualifier().precision);
return branch;
} }
// See if the operation is being done in an illegal location. // See if the operation is being done in an illegal location.