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,7 +1,7 @@
spv.400.frag
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 1118
// Id's are bound by 1122
Capability Shader
Capability Geometry
@ -11,7 +11,7 @@ spv.400.frag
Capability SampledRect
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 13 1027 1033 1038 1050 1076 1097 1099 1105 1107 1116
EntryPoint Fragment 4 "main" 13 1027 1033 1038 1054 1080 1101 1103 1109 1111 1120
ExecutionMode 4 OriginUpperLeft
Source GLSL 400
SourceExtension "GL_ARB_separate_shader_objects"
@ -42,16 +42,16 @@ spv.400.frag
Name 1027 "i"
Name 1033 "c2D"
Name 1038 "gl_ClipDistance"
Name 1050 "uoutp"
Name 1054 "samp2dr"
Name 1076 "ioutp"
Name 1080 "isamp2DA"
Name 1097 "gl_FragCoord"
Name 1099 "vl2"
Name 1105 "uo"
Name 1107 "u"
Name 1115 "id"
Name 1116 "gl_PrimitiveID"
Name 1054 "uoutp"
Name 1058 "samp2dr"
Name 1080 "ioutp"
Name 1084 "isamp2DA"
Name 1101 "gl_FragCoord"
Name 1103 "vl2"
Name 1109 "uo"
Name 1111 "u"
Name 1119 "id"
Name 1120 "gl_PrimitiveID"
Decorate 13(outp) Location 1
Decorate 17(u2drs) DescriptorSet 0
Decorate 17(u2drs) Binding 3
@ -61,19 +61,19 @@ spv.400.frag
Decorate 1027(i) Location 1
Decorate 1033(c2D) Location 0
Decorate 1038(gl_ClipDistance) BuiltIn ClipDistance
Decorate 1050(uoutp) Location 3
Decorate 1054(samp2dr) DescriptorSet 0
Decorate 1054(samp2dr) Binding 1
Decorate 1076(ioutp) Location 2
Decorate 1080(isamp2DA) DescriptorSet 0
Decorate 1080(isamp2DA) Binding 2
Decorate 1097(gl_FragCoord) BuiltIn FragCoord
Decorate 1099(vl2) Location 6
Decorate 1105(uo) Location 0
Decorate 1107(u) Flat
Decorate 1107(u) Location 2
Decorate 1116(gl_PrimitiveID) Flat
Decorate 1116(gl_PrimitiveID) BuiltIn PrimitiveId
Decorate 1054(uoutp) Location 3
Decorate 1058(samp2dr) DescriptorSet 0
Decorate 1058(samp2dr) Binding 1
Decorate 1080(ioutp) Location 2
Decorate 1084(isamp2DA) DescriptorSet 0
Decorate 1084(isamp2DA) Binding 2
Decorate 1101(gl_FragCoord) BuiltIn FragCoord
Decorate 1103(vl2) Location 6
Decorate 1109(uo) Location 0
Decorate 1111(u) Flat
Decorate 1111(u) Location 2
Decorate 1120(gl_PrimitiveID) Flat
Decorate 1120(gl_PrimitiveID) BuiltIn PrimitiveId
2: TypeVoid
3: TypeFunction 2
10: TypeFloat 32
@ -161,46 +161,46 @@ spv.400.frag
1038(gl_ClipDistance): 1037(ptr) Variable Input
1039: TypePointer Input 10(float)
1043: TypeVector 10(float) 3
1048: TypeVector 32(int) 4
1049: TypePointer Output 1048(ivec4)
1050(uoutp): 1049(ptr) Variable Output
1051: TypeImage 32(int) Rect sampled format:Unknown
1052: TypeSampledImage 1051
1053: TypePointer UniformConstant 1052
1054(samp2dr): 1053(ptr) Variable UniformConstant
1057: 32(int) Constant 4
1058: TypeArray 24(ivec2) 1057
1059: 24(ivec2) ConstantComposite 966 970
1060: 23(int) Constant 15
1061: 23(int) Constant 16
1062: 24(ivec2) ConstantComposite 1060 1061
1063: 23(int) Constant 4294967294
1064: 23(int) Constant 0
1065: 24(ivec2) ConstantComposite 1063 1064
1066: 1058 ConstantComposite 1059 27 1062 1065
1074: TypeVector 23(int) 4
1075: TypePointer Output 1074(ivec4)
1076(ioutp): 1075(ptr) Variable Output
1077: TypeImage 23(int) 2D array sampled format:Unknown
1078: TypeSampledImage 1077
1079: TypePointer UniformConstant 1078
1080(isamp2DA): 1079(ptr) Variable UniformConstant
1082: 10(float) Constant 1036831949
1083: 1043(fvec3) ConstantComposite 1082 1082 1082
1084: 24(ivec2) ConstantComposite 966 966
1096: TypePointer Input 11(fvec4)
1097(gl_FragCoord): 1096(ptr) Variable Input
1099(vl2): 1096(ptr) Variable Input
1104: TypePointer Output 32(int)
1105(uo): 1104(ptr) Variable Output
1106: TypePointer Input 32(int)
1107(u): 1106(ptr) Variable Input
1114: TypePointer Function 23(int)
1116(gl_PrimitiveID): 1026(ptr) Variable Input
1052: TypeVector 32(int) 4
1053: TypePointer Output 1052(ivec4)
1054(uoutp): 1053(ptr) Variable Output
1055: TypeImage 32(int) Rect sampled format:Unknown
1056: TypeSampledImage 1055
1057: TypePointer UniformConstant 1056
1058(samp2dr): 1057(ptr) Variable UniformConstant
1061: 32(int) Constant 4
1062: TypeArray 24(ivec2) 1061
1063: 24(ivec2) ConstantComposite 966 970
1064: 23(int) Constant 15
1065: 23(int) Constant 16
1066: 24(ivec2) ConstantComposite 1064 1065
1067: 23(int) Constant 4294967294
1068: 23(int) Constant 0
1069: 24(ivec2) ConstantComposite 1067 1068
1070: 1062 ConstantComposite 1063 27 1066 1069
1078: TypeVector 23(int) 4
1079: TypePointer Output 1078(ivec4)
1080(ioutp): 1079(ptr) Variable Output
1081: TypeImage 23(int) 2D array sampled format:Unknown
1082: TypeSampledImage 1081
1083: TypePointer UniformConstant 1082
1084(isamp2DA): 1083(ptr) Variable UniformConstant
1086: 10(float) Constant 1036831949
1087: 1043(fvec3) ConstantComposite 1086 1086 1086
1088: 24(ivec2) ConstantComposite 966 966
1100: TypePointer Input 11(fvec4)
1101(gl_FragCoord): 1100(ptr) Variable Input
1103(vl2): 1100(ptr) Variable Input
1108: TypePointer Output 32(int)
1109(uo): 1108(ptr) Variable Output
1110: TypePointer Input 32(int)
1111(u): 1110(ptr) Variable Input
1118: TypePointer Function 23(int)
1120(gl_PrimitiveID): 1026(ptr) Variable Input
4(main): 2 Function None 3
5: Label
1019(v): 1018(ptr) Variable Function
1115(id): 1114(ptr) Variable Function
1119(id): 1118(ptr) Variable Function
1028: 23(int) Load 1027(i)
1030: 1029(ptr) AccessChain 1025(arrayedSampler) 1028
1031: 1021 Load 1030
@ -213,50 +213,56 @@ spv.400.frag
Store 1042 1041
1044: 11(fvec4) Load 1019(v)
1045: 1043(fvec3) VectorShuffle 1044 1044 1 2 3
1046: 11(fvec4) Load 13(outp)
1047: 11(fvec4) VectorShuffle 1046 1045 0 4 5 6
Store 13(outp) 1047
1055: 1052 Load 1054(samp2dr)
1056: 20(fvec2) Load 1033(c2D)
1067: 1048(ivec4) ImageGather 1055 1056 970 ConstOffsets 1066
Store 1050(uoutp) 1067
1068: 1029(ptr) AccessChain 1025(arrayedSampler) 1064
1069: 1021 Load 1068
1070: 20(fvec2) Load 1033(c2D)
1071: 11(fvec4) ImageGather 1069 1070 1064
1072: 11(fvec4) Load 13(outp)
1073: 11(fvec4) FAdd 1072 1071
Store 13(outp) 1073
1081: 1078 Load 1080(isamp2DA)
1085: 1074(ivec4) ImageGather 1081 1083 25 ConstOffset 1084
Store 1076(ioutp) 1085
1086: 1078 Load 1080(isamp2DA)
1087: 1074(ivec4) ImageGather 1086 1083 25 ConstOffset 1084
1088: 1074(ivec4) Load 1076(ioutp)
1089: 1074(ivec4) IAdd 1088 1087
Store 1076(ioutp) 1089
1090: 1078 Load 1080(isamp2DA)
1091: 23(int) Load 1027(i)
1092: 24(ivec2) CompositeConstruct 1091 1091
1093: 1074(ivec4) ImageGather 1090 1083 1064 Offset 1092
1094: 1074(ivec4) Load 1076(ioutp)
1095: 1074(ivec4) IAdd 1094 1093
Store 1076(ioutp) 1095
1098: 11(fvec4) Load 1097(gl_FragCoord)
1100: 11(fvec4) Load 1099(vl2)
1101: 11(fvec4) FAdd 1098 1100
1102: 11(fvec4) Load 13(outp)
1103: 11(fvec4) FAdd 1102 1101
Store 13(outp) 1103
1108: 32(int) Load 1107(u)
1109: 23(int) Load 1027(i)
1110: 32(int) Bitcast 1109
1111: 32(int) UMod 1108 1110
Store 1105(uo) 1111
1112: 2 FunctionCall 6(foo23()
1113: 2 FunctionCall 8(doubles()
1117: 23(int) Load 1116(gl_PrimitiveID)
Store 1115(id) 1117
1046: 34(ptr) AccessChain 13(outp) 954
1047: 10(float) CompositeExtract 1045 0
Store 1046 1047
1048: 34(ptr) AccessChain 13(outp) 958
1049: 10(float) CompositeExtract 1045 1
Store 1048 1049
1050: 34(ptr) AccessChain 13(outp) 962
1051: 10(float) CompositeExtract 1045 2
Store 1050 1051
1059: 1056 Load 1058(samp2dr)
1060: 20(fvec2) Load 1033(c2D)
1071: 1052(ivec4) ImageGather 1059 1060 970 ConstOffsets 1070
Store 1054(uoutp) 1071
1072: 1029(ptr) AccessChain 1025(arrayedSampler) 1068
1073: 1021 Load 1072
1074: 20(fvec2) Load 1033(c2D)
1075: 11(fvec4) ImageGather 1073 1074 1068
1076: 11(fvec4) Load 13(outp)
1077: 11(fvec4) FAdd 1076 1075
Store 13(outp) 1077
1085: 1082 Load 1084(isamp2DA)
1089: 1078(ivec4) ImageGather 1085 1087 25 ConstOffset 1088
Store 1080(ioutp) 1089
1090: 1082 Load 1084(isamp2DA)
1091: 1078(ivec4) ImageGather 1090 1087 25 ConstOffset 1088
1092: 1078(ivec4) Load 1080(ioutp)
1093: 1078(ivec4) IAdd 1092 1091
Store 1080(ioutp) 1093
1094: 1082 Load 1084(isamp2DA)
1095: 23(int) Load 1027(i)
1096: 24(ivec2) CompositeConstruct 1095 1095
1097: 1078(ivec4) ImageGather 1094 1087 1068 Offset 1096
1098: 1078(ivec4) Load 1080(ioutp)
1099: 1078(ivec4) IAdd 1098 1097
Store 1080(ioutp) 1099
1102: 11(fvec4) Load 1101(gl_FragCoord)
1104: 11(fvec4) Load 1103(vl2)
1105: 11(fvec4) FAdd 1102 1104
1106: 11(fvec4) Load 13(outp)
1107: 11(fvec4) FAdd 1106 1105
Store 13(outp) 1107
1112: 32(int) Load 1111(u)
1113: 23(int) Load 1027(i)
1114: 32(int) Bitcast 1113
1115: 32(int) UMod 1112 1114
Store 1109(uo) 1115
1116: 2 FunctionCall 6(foo23()
1117: 2 FunctionCall 8(doubles()
1121: 23(int) Load 1120(gl_PrimitiveID)
Store 1119(id) 1121
Return
FunctionEnd
6(foo23(): 2 Function None 3