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

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