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

@ -238,12 +238,12 @@ Shader version: 500
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 90
// Id's are bound by 93
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 83 86
EntryPoint Vertex 4 "main" 86 89
Source HLSL 500
Name 4 "main"
Name 11 "@main(vf4;"
@ -257,15 +257,15 @@ Shader version: 500
Name 24 "packed"
Name 27 "tex"
Name 47 "i"
Name 69 "packed2"
Name 81 "pos"
Name 83 "pos"
Name 86 "@entryPointOutput"
Name 87 "param"
Name 72 "packed2"
Name 84 "pos"
Name 86 "pos"
Name 89 "@entryPointOutput"
Name 90 "param"
Decorate 27(tex) DescriptorSet 0
Decorate 27(tex) Binding 0
Decorate 83(pos) Location 0
Decorate 86(@entryPointOutput) BuiltIn Position
Decorate 86(pos) Location 0
Decorate 89(@entryPointOutput) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -300,20 +300,22 @@ Shader version: 500
44: 21(int) Constant 4
45: TypePointer Function 21(int)
54: TypeBool
82: TypePointer Input 7(fvec4)
83(pos): 82(ptr) Variable Input
85: TypePointer Output 7(fvec4)
86(@entryPointOutput): 85(ptr) Variable Output
64: 15(int) Constant 0
67: 15(int) Constant 1
85: TypePointer Input 7(fvec4)
86(pos): 85(ptr) Variable Input
88: TypePointer Output 7(fvec4)
89(@entryPointOutput): 88(ptr) Variable Output
4(main): 2 Function None 3
5: Label
81(pos): 8(ptr) Variable Function
87(param): 8(ptr) Variable Function
84: 7(fvec4) Load 83(pos)
Store 81(pos) 84
88: 7(fvec4) Load 81(pos)
Store 87(param) 88
89: 7(fvec4) FunctionCall 11(@main(vf4;) 87(param)
Store 86(@entryPointOutput) 89
84(pos): 8(ptr) Variable Function
90(param): 8(ptr) Variable Function
87: 7(fvec4) Load 86(pos)
Store 84(pos) 87
91: 7(fvec4) Load 84(pos)
Store 90(param) 91
92: 7(fvec4) FunctionCall 11(@main(vf4;) 90(param)
Store 89(@entryPointOutput) 92
Return
FunctionEnd
11(@main(vf4;): 7(fvec4) Function None 9
@ -321,7 +323,7 @@ Shader version: 500
12: Label
24(packed): 23(ptr) Variable Function
47(i): 45(ptr) Variable Function
69(packed2): 23(ptr) Variable Function
72(packed2): 23(ptr) Variable Function
28: 13 Load 27(tex)
30: 29(ptr) AccessChain 24(packed) 25
Store 30 28
@ -351,26 +353,28 @@ Shader version: 500
61: 14(fvec3) Load 60
62: 18(fvec2) VectorShuffle 61 61 0 1
63: 18(fvec2) FAdd 62 59
64: 34(ptr) AccessChain 24(packed) 31 56
65: 14(fvec3) Load 64
66: 14(fvec3) VectorShuffle 65 63 3 4 2
Store 64 66
65: 42(ptr) AccessChain 24(packed) 31 56 64
66: 6(float) CompositeExtract 63 0
Store 65 66
68: 42(ptr) AccessChain 24(packed) 31 56 67
69: 6(float) CompositeExtract 63 1
Store 68 69
Branch 51
51: Label
67: 21(int) Load 47(i)
68: 21(int) IAdd 67 31
Store 47(i) 68
70: 21(int) Load 47(i)
71: 21(int) IAdd 70 31
Store 47(i) 71
Branch 48
50: Label
70: 22(Packed) Load 24(packed)
Store 69(packed2) 70
71: 7(fvec4) Load 10(pos)
72: 34(ptr) AccessChain 69(packed2) 31 25
73: 14(fvec3) Load 72
74: 6(float) CompositeExtract 73 0
75: 6(float) CompositeExtract 73 1
76: 6(float) CompositeExtract 73 2
77: 7(fvec4) CompositeConstruct 74 75 76 32
78: 7(fvec4) FAdd 71 77
ReturnValue 78
73: 22(Packed) Load 24(packed)
Store 72(packed2) 73
74: 7(fvec4) Load 10(pos)
75: 34(ptr) AccessChain 72(packed2) 31 25
76: 14(fvec3) Load 75
77: 6(float) CompositeExtract 76 0
78: 6(float) CompositeExtract 76 1
79: 6(float) CompositeExtract 76 2
80: 7(fvec4) CompositeConstruct 77 78 79 32
81: 7(fvec4) FAdd 74 80
ReturnValue 81
FunctionEnd