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,7 +1,7 @@
spv.precisionArgs.frag
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 42
// Id's are bound by 83
Capability Shader
1: ExtInstImport "GLSL.std.450"
@@ -16,66 +16,109 @@ spv.precisionArgs.frag
Name 16 "foo(f1;f1;"
Name 14 "f"
Name 15 "g"
Name 18 "aM"
Name 20 "bM"
Name 22 "arg"
Name 25 "aH"
Name 27 "bH"
Name 29 "arg"
Name 32 "param"
Name 34 "param"
Name 37 "param"
Name 39 "param"
Name 20 "retM(f1;"
Name 19 "x"
Name 23 "retH(f1;"
Name 22 "x"
Name 26 "retHM(f1;"
Name 25 "x"
Name 29 "retMH(f1;"
Name 28 "x"
Name 47 "aM"
Name 49 "bM"
Name 51 "arg"
Name 54 "aH"
Name 56 "bH"
Name 58 "arg"
Name 61 "param"
Name 63 "param"
Name 66 "param"
Name 68 "param"
Name 71 "param"
Name 74 "param"
Name 77 "param"
Name 80 "param"
Decorate 8(f) RelaxedPrecision
Decorate 14(f) RelaxedPrecision
Decorate 18(aM) RelaxedPrecision
Decorate 19 RelaxedPrecision
Decorate 20(bM) RelaxedPrecision
Decorate 21 RelaxedPrecision
Decorate 29(arg) RelaxedPrecision
Decorate 30 RelaxedPrecision
Decorate 32(param) RelaxedPrecision
Decorate 33 RelaxedPrecision
Decorate 35 RelaxedPrecision
Decorate 37(param) RelaxedPrecision
Decorate 20(retM(f1;) RelaxedPrecision
Decorate 19(x) RelaxedPrecision
Decorate 26(retHM(f1;) RelaxedPrecision
Decorate 28(x) RelaxedPrecision
Decorate 31 RelaxedPrecision
Decorate 38 RelaxedPrecision
Decorate 39 RelaxedPrecision
Decorate 42 RelaxedPrecision
Decorate 47(aM) RelaxedPrecision
Decorate 48 RelaxedPrecision
Decorate 49(bM) RelaxedPrecision
Decorate 50 RelaxedPrecision
Decorate 58(arg) RelaxedPrecision
Decorate 59 RelaxedPrecision
Decorate 61(param) RelaxedPrecision
Decorate 62 RelaxedPrecision
Decorate 64 RelaxedPrecision
Decorate 66(param) RelaxedPrecision
Decorate 71(param) RelaxedPrecision
Decorate 72 RelaxedPrecision
Decorate 73 RelaxedPrecision
Decorate 79 RelaxedPrecision
Decorate 80(param) RelaxedPrecision
Decorate 81 RelaxedPrecision
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeFunction 2 6(float) 6(float)
12: TypePointer Function 6(float)
13: TypeFunction 2 12(ptr) 12(ptr)
18: TypeFunction 6(float) 12(ptr)
4(main): 2 Function None 3
5: Label
18(aM): 12(ptr) Variable Function
20(bM): 12(ptr) Variable Function
22(arg): 12(ptr) Variable Function
25(aH): 12(ptr) Variable Function
27(bH): 12(ptr) Variable Function
29(arg): 12(ptr) Variable Function
32(param): 12(ptr) Variable Function
34(param): 12(ptr) Variable Function
37(param): 12(ptr) Variable Function
39(param): 12(ptr) Variable Function
19: 6(float) Load 18(aM)
21: 6(float) Load 20(bM)
Store 22(arg) 21
23: 6(float) Load 22(arg)
24: 2 FunctionCall 10(fooConst(f1;f1;) 19 23
26: 6(float) Load 25(aH)
28: 6(float) Load 27(bH)
Store 29(arg) 26
30: 6(float) Load 29(arg)
31: 2 FunctionCall 10(fooConst(f1;f1;) 30 28
33: 6(float) Load 18(aM)
Store 32(param) 33
35: 6(float) Load 20(bM)
Store 34(param) 35
36: 2 FunctionCall 16(foo(f1;f1;) 32(param) 34(param)
38: 6(float) Load 25(aH)
Store 37(param) 38
40: 6(float) Load 27(bH)
Store 39(param) 40
41: 2 FunctionCall 16(foo(f1;f1;) 37(param) 39(param)
47(aM): 12(ptr) Variable Function
49(bM): 12(ptr) Variable Function
51(arg): 12(ptr) Variable Function
54(aH): 12(ptr) Variable Function
56(bH): 12(ptr) Variable Function
58(arg): 12(ptr) Variable Function
61(param): 12(ptr) Variable Function
63(param): 12(ptr) Variable Function
66(param): 12(ptr) Variable Function
68(param): 12(ptr) Variable Function
71(param): 12(ptr) Variable Function
74(param): 12(ptr) Variable Function
77(param): 12(ptr) Variable Function
80(param): 12(ptr) Variable Function
48: 6(float) Load 47(aM)
50: 6(float) Load 49(bM)
Store 51(arg) 50
52: 6(float) Load 51(arg)
53: 2 FunctionCall 10(fooConst(f1;f1;) 48 52
55: 6(float) Load 54(aH)
57: 6(float) Load 56(bH)
Store 58(arg) 55
59: 6(float) Load 58(arg)
60: 2 FunctionCall 10(fooConst(f1;f1;) 59 57
62: 6(float) Load 47(aM)
Store 61(param) 62
64: 6(float) Load 49(bM)
Store 63(param) 64
65: 2 FunctionCall 16(foo(f1;f1;) 61(param) 63(param)
67: 6(float) Load 54(aH)
Store 66(param) 67
69: 6(float) Load 56(bH)
Store 68(param) 69
70: 2 FunctionCall 16(foo(f1;f1;) 66(param) 68(param)
72: 6(float) Load 47(aM)
Store 71(param) 72
73: 6(float) FunctionCall 20(retM(f1;) 71(param)
75: 6(float) Load 54(aH)
Store 74(param) 75
76: 6(float) FunctionCall 23(retH(f1;) 74(param)
78: 6(float) Load 54(aH)
Store 77(param) 78
79: 6(float) FunctionCall 26(retHM(f1;) 77(param)
81: 6(float) Load 47(aM)
Store 80(param) 81
82: 6(float) FunctionCall 29(retMH(f1;) 80(param)
Return
FunctionEnd
10(fooConst(f1;f1;): 2 Function None 7
@@ -90,3 +133,33 @@ spv.precisionArgs.frag
17: Label
Return
FunctionEnd
20(retM(f1;): 6(float) Function None 18
19(x): 12(ptr) FunctionParameter
21: Label
31: 6(float) Load 19(x)
ReturnValue 31
FunctionEnd
23(retH(f1;): 6(float) Function None 18
22(x): 12(ptr) FunctionParameter
24: Label
34: 6(float) Load 22(x)
ReturnValue 34
FunctionEnd
26(retHM(f1;): 6(float) Function None 18
25(x): 12(ptr) FunctionParameter
27: Label
38: 12(ptr) Variable Function
37: 6(float) Load 25(x)
Store 38 37
39: 6(float) Load 38
ReturnValue 39
FunctionEnd
29(retMH(f1;): 6(float) Function None 18
28(x): 12(ptr) FunctionParameter
30: Label
43: 12(ptr) Variable Function
42: 6(float) Load 28(x)
Store 43 42
44: 6(float) Load 43
ReturnValue 44
FunctionEnd