Skip to content

Commit 3d2391f

Browse files
committed
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.
1 parent 4f72970 commit 3d2391f

File tree

7 files changed

+462
-455
lines changed

7 files changed

+462
-455
lines changed

Test/baseResults/310AofA.vert.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ERROR: node is still EOpNull!
6161
0:49 Constant:
6262
0:49 0.000000
6363
0:50 Branch: Return with expression
64-
0:50 Construct float ( temp 4-element array of 7-element array of float)
64+
0:50 Construct float ( temp 4-element array of 7-element array of highp float)
6565
0:50 direct index ( temp 7-element array of highp float)
6666
0:50 'a' ( in 5-element array of 7-element array of highp float)
6767
0:50 Constant:
@@ -76,7 +76,7 @@ ERROR: node is still EOpNull!
7676
0:50 Constant:
7777
0:50 3 (const int)
7878
0:51 Branch: Return with expression
79-
0:51 Construct float ( temp 4-element array of 7-element array of float)
79+
0:51 Construct float ( temp 4-element array of 7-element array of highp float)
8080
0:51 direct index ( temp 7-element array of highp float)
8181
0:51 'a' ( in 5-element array of 7-element array of highp float)
8282
0:51 Constant:
@@ -91,7 +91,7 @@ ERROR: node is still EOpNull!
9191
0:51 Constant:
9292
0:51 3 (const int)
9393
0:52 Branch: Return with expression
94-
0:52 Construct float ( temp 4-element array of 7-element array of float)
94+
0:52 Construct float ( temp 4-element array of 7-element array of highp float)
9595
0:52 direct index ( temp 7-element array of highp float)
9696
0:52 'a' ( in 5-element array of 7-element array of highp float)
9797
0:52 Constant:

Test/baseResults/array100.frag.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ERROR: node is still EOpNull!
3131
0:9 'a' ( in 5-element array of mediump float)
3232
0:11 Sequence
3333
0:11 Branch: Return with expression
34-
0:11 Construct float ( temp 4-element array of float)
34+
0:11 Construct float ( temp 4-element array of mediump float)
3535
0:11 direct index ( temp mediump float)
3636
0:11 'a' ( in 5-element array of mediump float)
3737
0:11 Constant:
@@ -168,7 +168,7 @@ ERROR: node is still EOpNull!
168168
0:9 'a' ( in 5-element array of mediump float)
169169
0:11 Sequence
170170
0:11 Branch: Return with expression
171-
0:11 Construct float ( temp 4-element array of float)
171+
0:11 Construct float ( temp 4-element array of mediump float)
172172
0:11 direct index ( temp mediump float)
173173
0:11 'a' ( in 5-element array of mediump float)
174174
0:11 Constant:

Test/baseResults/spv.forwardFun.frag.out

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
spv.forwardFun.frag
22
// Module Version 10000
33
// Generated by (magic number): 8000a
4-
// Id's are bound by 64
4+
// Id's are bound by 60
55

66
Capability Shader
77
1: ExtInstImport "GLSL.std.450"
88
MemoryModel Logical GLSL450
9-
EntryPoint Fragment 4 "main" 20 30 36 63
9+
EntryPoint Fragment 4 "main" 20 30 36 59
1010
ExecutionMode 4 OriginUpperLeft
1111
Source GLSL 140
1212
Name 4 "main"
@@ -20,7 +20,7 @@ spv.forwardFun.frag
2020
Name 27 "f"
2121
Name 30 "gl_FragColor"
2222
Name 36 "d"
23-
Name 63 "bigColor"
23+
Name 59 "bigColor"
2424
Decorate 10(unreachableReturn() RelaxedPrecision
2525
Decorate 16(foo(vf4;) RelaxedPrecision
2626
Decorate 15(bar) RelaxedPrecision
@@ -41,15 +41,11 @@ spv.forwardFun.frag
4141
Decorate 36(d) RelaxedPrecision
4242
Decorate 36(d) Location 2
4343
Decorate 37 RelaxedPrecision
44-
Decorate 44 RelaxedPrecision
45-
Decorate 45 RelaxedPrecision
46-
Decorate 49 RelaxedPrecision
47-
Decorate 50 RelaxedPrecision
44+
Decorate 52 RelaxedPrecision
45+
Decorate 55 RelaxedPrecision
4846
Decorate 56 RelaxedPrecision
49-
Decorate 59 RelaxedPrecision
50-
Decorate 60 RelaxedPrecision
51-
Decorate 63(bigColor) RelaxedPrecision
52-
Decorate 63(bigColor) Location 0
47+
Decorate 59(bigColor) RelaxedPrecision
48+
Decorate 59(bigColor) Location 0
5349
2: TypeVoid
5450
3: TypeFunction 2
5551
8: TypeFloat 32
@@ -67,11 +63,11 @@ spv.forwardFun.frag
6763
38: 8(float) Constant 1082549862
6864
39: TypeBool
6965
43: 8(float) Constant 1067030938
70-
48: 8(float) Constant 1083179008
71-
53: TypeInt 32 0
72-
54: 53(int) Constant 0
73-
57: 53(int) Constant 1
74-
63(bigColor): 19(ptr) Variable Input
66+
46: 8(float) Constant 1083179008
67+
49: TypeInt 32 0
68+
50: 49(int) Constant 0
69+
53: 49(int) Constant 1
70+
59(bigColor): 19(ptr) Variable Input
7571
4(main): 2 Function None 3
7672
5: Label
7773
18(color): 13(ptr) Variable Function
@@ -97,31 +93,25 @@ spv.forwardFun.frag
9793
FunctionEnd
9894
10(unreachableReturn(): 8(float) Function None 9
9995
11: Label
100-
44: 26(ptr) Variable Function
101-
49: 26(ptr) Variable Function
10296
34: 2 FunctionCall 6(bar()
10397
37: 8(float) Load 36(d)
10498
40: 39(bool) FOrdLessThan 37 38
10599
SelectionMerge 42 None
106-
BranchConditional 40 41 47
100+
BranchConditional 40 41 45
107101
41: Label
108-
Store 44 43
109-
45: 8(float) Load 44
110-
ReturnValue 45
111-
47: Label
112-
Store 49 48
113-
50: 8(float) Load 49
114-
ReturnValue 50
102+
ReturnValue 43
103+
45: Label
104+
ReturnValue 46
115105
42: Label
116106
Unreachable
117107
FunctionEnd
118108
16(foo(vf4;): 8(float) Function None 14
119109
15(bar): 13(ptr) FunctionParameter
120110
17: Label
121-
55: 26(ptr) AccessChain 15(bar) 54
122-
56: 8(float) Load 55
123-
58: 26(ptr) AccessChain 15(bar) 57
124-
59: 8(float) Load 58
125-
60: 8(float) FAdd 56 59
126-
ReturnValue 60
111+
51: 26(ptr) AccessChain 15(bar) 50
112+
52: 8(float) Load 51
113+
54: 26(ptr) AccessChain 15(bar) 53
114+
55: 8(float) Load 54
115+
56: 8(float) FAdd 52 55
116+
ReturnValue 56
127117
FunctionEnd

0 commit comments

Comments
 (0)