Generate separate stores for partially swizzled memory stores

Full vector and fully specified vector swizzle stores are not affected by this change, only partial swizzles ie swizzles with fewer components than the vector being stored to.

Previously the vector being stored to loaded and any components not specified in the swizzle were used to create a full store to the vector.

While this change generates more SPIR-V instructions, it is necessary for correctness.

Fixes #2518.
This commit is contained in:
Jeremy Hayes
2021-07-16 15:07:16 -06:00
parent 9158061398
commit 6d5b40f051
50 changed files with 31343 additions and 26594 deletions

View File

@@ -1,33 +1,33 @@
spv.interpOps.frag
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 100
// Id's are bound by 120
Capability Shader
Capability InterpolationFunction
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 13 24 33 41 47 72 98
EntryPoint Fragment 4 "main" 13 24 36 49 55 86 118
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 9 "f4"
Name 13 "if1"
Name 24 "if2"
Name 33 "if3"
Name 41 "if4"
Name 47 "samp"
Name 72 "offset"
Name 98 "fragColor"
Name 36 "if3"
Name 49 "if4"
Name 55 "samp"
Name 86 "offset"
Name 118 "fragColor"
Decorate 13(if1) Location 0
Decorate 24(if2) Location 1
Decorate 33(if3) Location 2
Decorate 41(if4) Location 3
Decorate 47(samp) Flat
Decorate 47(samp) Location 4
Decorate 72(offset) Flat
Decorate 72(offset) Location 5
Decorate 98(fragColor) Location 0
Decorate 36(if3) Location 2
Decorate 49(if4) Location 3
Decorate 55(samp) Flat
Decorate 55(samp) Location 4
Decorate 86(offset) Flat
Decorate 86(offset) Location 5
Decorate 118(fragColor) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -43,17 +43,19 @@ spv.interpOps.frag
22: TypeVector 6(float) 2
23: TypePointer Input 22(fvec2)
24(if2): 23(ptr) Variable Input
31: TypeVector 6(float) 3
32: TypePointer Input 31(fvec3)
33(if3): 32(ptr) Variable Input
40: TypePointer Input 7(fvec4)
41(if4): 40(ptr) Variable Input
45: TypeInt 32 1
46: TypePointer Input 45(int)
47(samp): 46(ptr) Variable Input
72(offset): 23(ptr) Variable Input
97: TypePointer Output 7(fvec4)
98(fragColor): 97(ptr) Variable Output
31: 15(int) Constant 1
34: TypeVector 6(float) 3
35: TypePointer Input 34(fvec3)
36(if3): 35(ptr) Variable Input
45: 15(int) Constant 2
48: TypePointer Input 7(fvec4)
49(if4): 48(ptr) Variable Input
53: TypeInt 32 1
54: TypePointer Input 53(int)
55(samp): 54(ptr) Variable Input
86(offset): 23(ptr) Variable Input
117: TypePointer Output 7(fvec4)
118(fragColor): 117(ptr) Variable Output
4(main): 2 Function None 3
5: Label
9(f4): 8(ptr) Variable Function
@@ -68,77 +70,104 @@ spv.interpOps.frag
26: 7(fvec4) Load 9(f4)
27: 22(fvec2) VectorShuffle 26 26 0 1
28: 22(fvec2) FAdd 27 25
29: 7(fvec4) Load 9(f4)
30: 7(fvec4) VectorShuffle 29 28 4 5 2 3
Store 9(f4) 30
34: 31(fvec3) ExtInst 1(GLSL.std.450) 76(InterpolateAtCentroid) 33(if3)
35: 7(fvec4) Load 9(f4)
36: 31(fvec3) VectorShuffle 35 35 0 1 2
37: 31(fvec3) FAdd 36 34
29: 17(ptr) AccessChain 9(f4) 16
30: 6(float) CompositeExtract 28 0
Store 29 30
32: 17(ptr) AccessChain 9(f4) 31
33: 6(float) CompositeExtract 28 1
Store 32 33
37: 34(fvec3) ExtInst 1(GLSL.std.450) 76(InterpolateAtCentroid) 36(if3)
38: 7(fvec4) Load 9(f4)
39: 7(fvec4) VectorShuffle 38 37 4 5 6 3
Store 9(f4) 39
42: 7(fvec4) ExtInst 1(GLSL.std.450) 76(InterpolateAtCentroid) 41(if4)
43: 7(fvec4) Load 9(f4)
44: 7(fvec4) FAdd 43 42
Store 9(f4) 44
48: 45(int) Load 47(samp)
49: 6(float) ExtInst 1(GLSL.std.450) 77(InterpolateAtSample) 13(if1) 48
50: 17(ptr) AccessChain 9(f4) 16
51: 6(float) Load 50
52: 6(float) FAdd 51 49
53: 17(ptr) AccessChain 9(f4) 16
Store 53 52
54: 45(int) Load 47(samp)
55: 22(fvec2) ExtInst 1(GLSL.std.450) 77(InterpolateAtSample) 24(if2) 54
56: 7(fvec4) Load 9(f4)
57: 22(fvec2) VectorShuffle 56 56 0 1
58: 22(fvec2) FAdd 57 55
59: 7(fvec4) Load 9(f4)
60: 7(fvec4) VectorShuffle 59 58 4 5 2 3
Store 9(f4) 60
61: 45(int) Load 47(samp)
62: 31(fvec3) ExtInst 1(GLSL.std.450) 77(InterpolateAtSample) 33(if3) 61
63: 7(fvec4) Load 9(f4)
64: 31(fvec3) VectorShuffle 63 63 0 1 2
65: 31(fvec3) FAdd 64 62
66: 7(fvec4) Load 9(f4)
67: 7(fvec4) VectorShuffle 66 65 4 5 6 3
Store 9(f4) 67
68: 45(int) Load 47(samp)
69: 7(fvec4) ExtInst 1(GLSL.std.450) 77(InterpolateAtSample) 41(if4) 68
70: 7(fvec4) Load 9(f4)
71: 7(fvec4) FAdd 70 69
Store 9(f4) 71
73: 22(fvec2) Load 72(offset)
74: 6(float) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 13(if1) 73
75: 17(ptr) AccessChain 9(f4) 16
76: 6(float) Load 75
77: 6(float) FAdd 76 74
78: 17(ptr) AccessChain 9(f4) 16
Store 78 77
79: 22(fvec2) Load 72(offset)
80: 22(fvec2) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 24(if2) 79
81: 7(fvec4) Load 9(f4)
82: 22(fvec2) VectorShuffle 81 81 0 1
83: 22(fvec2) FAdd 82 80
39: 34(fvec3) VectorShuffle 38 38 0 1 2
40: 34(fvec3) FAdd 39 37
41: 17(ptr) AccessChain 9(f4) 16
42: 6(float) CompositeExtract 40 0
Store 41 42
43: 17(ptr) AccessChain 9(f4) 31
44: 6(float) CompositeExtract 40 1
Store 43 44
46: 17(ptr) AccessChain 9(f4) 45
47: 6(float) CompositeExtract 40 2
Store 46 47
50: 7(fvec4) ExtInst 1(GLSL.std.450) 76(InterpolateAtCentroid) 49(if4)
51: 7(fvec4) Load 9(f4)
52: 7(fvec4) FAdd 51 50
Store 9(f4) 52
56: 53(int) Load 55(samp)
57: 6(float) ExtInst 1(GLSL.std.450) 77(InterpolateAtSample) 13(if1) 56
58: 17(ptr) AccessChain 9(f4) 16
59: 6(float) Load 58
60: 6(float) FAdd 59 57
61: 17(ptr) AccessChain 9(f4) 16
Store 61 60
62: 53(int) Load 55(samp)
63: 22(fvec2) ExtInst 1(GLSL.std.450) 77(InterpolateAtSample) 24(if2) 62
64: 7(fvec4) Load 9(f4)
65: 22(fvec2) VectorShuffle 64 64 0 1
66: 22(fvec2) FAdd 65 63
67: 17(ptr) AccessChain 9(f4) 16
68: 6(float) CompositeExtract 66 0
Store 67 68
69: 17(ptr) AccessChain 9(f4) 31
70: 6(float) CompositeExtract 66 1
Store 69 70
71: 53(int) Load 55(samp)
72: 34(fvec3) ExtInst 1(GLSL.std.450) 77(InterpolateAtSample) 36(if3) 71
73: 7(fvec4) Load 9(f4)
74: 34(fvec3) VectorShuffle 73 73 0 1 2
75: 34(fvec3) FAdd 74 72
76: 17(ptr) AccessChain 9(f4) 16
77: 6(float) CompositeExtract 75 0
Store 76 77
78: 17(ptr) AccessChain 9(f4) 31
79: 6(float) CompositeExtract 75 1
Store 78 79
80: 17(ptr) AccessChain 9(f4) 45
81: 6(float) CompositeExtract 75 2
Store 80 81
82: 53(int) Load 55(samp)
83: 7(fvec4) ExtInst 1(GLSL.std.450) 77(InterpolateAtSample) 49(if4) 82
84: 7(fvec4) Load 9(f4)
85: 7(fvec4) VectorShuffle 84 83 4 5 2 3
85: 7(fvec4) FAdd 84 83
Store 9(f4) 85
86: 22(fvec2) Load 72(offset)
87: 31(fvec3) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 33(if3) 86
88: 7(fvec4) Load 9(f4)
89: 31(fvec3) VectorShuffle 88 88 0 1 2
90: 31(fvec3) FAdd 89 87
91: 7(fvec4) Load 9(f4)
92: 7(fvec4) VectorShuffle 91 90 4 5 6 3
Store 9(f4) 92
93: 22(fvec2) Load 72(offset)
94: 7(fvec4) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 41(if4) 93
87: 22(fvec2) Load 86(offset)
88: 6(float) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 13(if1) 87
89: 17(ptr) AccessChain 9(f4) 16
90: 6(float) Load 89
91: 6(float) FAdd 90 88
92: 17(ptr) AccessChain 9(f4) 16
Store 92 91
93: 22(fvec2) Load 86(offset)
94: 22(fvec2) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 24(if2) 93
95: 7(fvec4) Load 9(f4)
96: 7(fvec4) FAdd 95 94
Store 9(f4) 96
99: 7(fvec4) Load 9(f4)
Store 98(fragColor) 99
96: 22(fvec2) VectorShuffle 95 95 0 1
97: 22(fvec2) FAdd 96 94
98: 17(ptr) AccessChain 9(f4) 16
99: 6(float) CompositeExtract 97 0
Store 98 99
100: 17(ptr) AccessChain 9(f4) 31
101: 6(float) CompositeExtract 97 1
Store 100 101
102: 22(fvec2) Load 86(offset)
103: 34(fvec3) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 36(if3) 102
104: 7(fvec4) Load 9(f4)
105: 34(fvec3) VectorShuffle 104 104 0 1 2
106: 34(fvec3) FAdd 105 103
107: 17(ptr) AccessChain 9(f4) 16
108: 6(float) CompositeExtract 106 0
Store 107 108
109: 17(ptr) AccessChain 9(f4) 31
110: 6(float) CompositeExtract 106 1
Store 109 110
111: 17(ptr) AccessChain 9(f4) 45
112: 6(float) CompositeExtract 106 2
Store 111 112
113: 22(fvec2) Load 86(offset)
114: 7(fvec4) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 49(if4) 113
115: 7(fvec4) Load 9(f4)
116: 7(fvec4) FAdd 115 114
Store 9(f4) 116
119: 7(fvec4) Load 9(f4)
Store 118(fragColor) 119
Return
FunctionEnd