SPV: RelaxedPrecision: Generalize fix #2293 to cover more operations.

This simplifies and enforces use of precision in many more places,
to help avoid accidental loss of RelaxedPrecision through intermediate
operations. Known fixes are:
- ?:
- function return values with mis-matched precision
- precision of function return values when a copy was needed to fix types
This commit is contained in:
John Kessenich
2020-06-30 01:27:08 -06:00
parent 27e915ed4f
commit 435dd8028b
10 changed files with 835 additions and 670 deletions

View File

@@ -1,12 +1,12 @@
spv.forwardFun.frag
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 60
// Id's are bound by 64
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 20 30 36 59
EntryPoint Fragment 4 "main" 20 30 36 63
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 59 "bigColor"
Name 63 "bigColor"
Decorate 10(unreachableReturn() RelaxedPrecision
Decorate 16(foo(vf4;) RelaxedPrecision
Decorate 15(bar) RelaxedPrecision
@@ -39,10 +39,14 @@ spv.forwardFun.frag
Decorate 33 RelaxedPrecision
Decorate 36(d) RelaxedPrecision
Decorate 37 RelaxedPrecision
Decorate 52 RelaxedPrecision
Decorate 55 RelaxedPrecision
Decorate 44 RelaxedPrecision
Decorate 45 RelaxedPrecision
Decorate 49 RelaxedPrecision
Decorate 50 RelaxedPrecision
Decorate 56 RelaxedPrecision
Decorate 59(bigColor) RelaxedPrecision
Decorate 59 RelaxedPrecision
Decorate 60 RelaxedPrecision
Decorate 63(bigColor) RelaxedPrecision
2: TypeVoid
3: TypeFunction 2
8: TypeFloat 32
@@ -60,11 +64,11 @@ spv.forwardFun.frag
38: 8(float) Constant 1082549862
39: TypeBool
43: 8(float) Constant 1067030938
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
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
4(main): 2 Function None 3
5: Label
18(color): 13(ptr) Variable Function
@@ -90,25 +94,31 @@ 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 45
BranchConditional 40 41 47
41: Label
ReturnValue 43
45: Label
ReturnValue 46
Store 44 43
45: 8(float) Load 44
ReturnValue 45
47: Label
Store 49 48
50: 8(float) Load 49
ReturnValue 50
42: Label
Unreachable
FunctionEnd
16(foo(vf4;): 8(float) Function None 14
15(bar): 13(ptr) FunctionParameter
17: Label
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
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
FunctionEnd