Commit 6b86d496 by Rex Xu

Add new test case for image functions and fix issues caught by this test

parent bba5c809
...@@ -1757,11 +1757,10 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate& ...@@ -1757,11 +1757,10 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate&
break; break;
} }
if (lvalue) { if (lvalue)
arguments.push_back(builder.accessChainGetLValue()); arguments.push_back(builder.accessChainGetLValue());
} else { else
arguments.push_back(builder.accessChainLoad(convertGlslangToSpvType(glslangArguments[i]->getAsTyped()->getType()))); arguments.push_back(builder.accessChainLoad(convertGlslangToSpvType(glslangArguments[i]->getAsTyped()->getType())));
}
} }
} }
...@@ -1820,16 +1819,37 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -1820,16 +1819,37 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
// Check for image functions other than queries // Check for image functions other than queries
if (node->isImage()) { if (node->isImage()) {
if (node->getOp() == glslang::EOpImageLoad) { // Process image load/store
return builder.createOp(spv::OpImageRead, convertGlslangToSpvType(node->getType()), arguments); if (node->getOp() == glslang::EOpImageLoad ||
} node->getOp() == glslang::EOpImageStore) {
else if (node->getOp() == glslang::EOpImageStore) { std::vector<spv::Id> operands;
builder.createNoResultOp(spv::OpImageWrite, arguments); auto opIt = arguments.begin();
return spv::NoResult; operands.push_back(*(opIt++));
} operands.push_back(*(opIt++));
else { if (sampler.ms) {
// Process image atomic operations. GLSL "IMAGE_PARAMS" will involve in constructing an image texel // For MS, image operand mask has to be added to indicate the presence of "sample" operand.
// pointer and this pointer, as the first source operand, is required by SPIR-V atomic operations. spv::Id sample = *(opIt++);
for (; opIt != arguments.end(); ++opIt)
operands.push_back(*opIt);
operands.push_back(spv::ImageOperandsSampleMask);
operands.push_back(sample);
} else {
for (; opIt != arguments.end(); ++opIt)
operands.push_back(*opIt);
}
if (node->getOp() == glslang::EOpImageLoad)
return builder.createOp(spv::OpImageRead, convertGlslangToSpvType(node->getType()), operands);
else {
builder.createNoResultOp(spv::OpImageWrite, operands);
return spv::NoResult;
}
} else {
// Process image atomic operations
// GLSL "IMAGE_PARAMS" will involve in constructing an image texel pointer and this pointer,
// as the first source operand, is required by SPIR-V atomic operations.
std::vector<spv::Id> imageParams; std::vector<spv::Id> imageParams;
auto opIt = arguments.begin(); auto opIt = arguments.begin();
imageParams.push_back(*(opIt++)); imageParams.push_back(*(opIt++));
...@@ -1885,8 +1905,8 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -1885,8 +1905,8 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
if (cracked.lod) { if (cracked.lod) {
params.lod = arguments[2]; params.lod = arguments[2];
++extraArgs; ++extraArgs;
} else if (cracked.sample) { } else if (sampler.ms) {
params.sample = arguments[2]; // For MS, sample should be specified params.sample = arguments[2]; // For MS, "sample" should be specified
++extraArgs; ++extraArgs;
} }
if (cracked.grad) { if (cracked.grad) {
......
...@@ -159,8 +159,9 @@ public: ...@@ -159,8 +159,9 @@ public:
} }
Id getImageType(Id resultId) const Id getImageType(Id resultId) const
{ {
assert(isSampledImageType(getTypeId(resultId))); Id typeId = getTypeId(resultId);
return module.getInstruction(getTypeId(resultId))->getIdOperand(0); assert(isImageType(typeId) || isSampledImageType(typeId));
return isSampledImageType(typeId) ? module.getInstruction(typeId)->getIdOperand(0) : typeId;
} }
bool isArrayedImageType(Id typeId) const bool isArrayedImageType(Id typeId) const
{ {
......
...@@ -1635,10 +1635,12 @@ void Parameterize() ...@@ -1635,10 +1635,12 @@ void Parameterize()
InstructionDesc[OpImageRead].operands.push(OperandId, "'Image'"); InstructionDesc[OpImageRead].operands.push(OperandId, "'Image'");
InstructionDesc[OpImageRead].operands.push(OperandId, "'Coordinate'"); InstructionDesc[OpImageRead].operands.push(OperandId, "'Coordinate'");
InstructionDesc[OpImageRead].operands.push(OperandOptionalImage, "");
InstructionDesc[OpImageWrite].operands.push(OperandId, "'Image'"); InstructionDesc[OpImageWrite].operands.push(OperandId, "'Image'");
InstructionDesc[OpImageWrite].operands.push(OperandId, "'Coordinate'"); InstructionDesc[OpImageWrite].operands.push(OperandId, "'Coordinate'");
InstructionDesc[OpImageWrite].operands.push(OperandId, "'Texel'"); InstructionDesc[OpImageWrite].operands.push(OperandId, "'Texel'");
InstructionDesc[OpImageWrite].operands.push(OperandOptionalImage, "");
InstructionDesc[OpImageSampleImplicitLod].operands.push(OperandId, "'Sampled Image'"); InstructionDesc[OpImageSampleImplicitLod].operands.push(OperandId, "'Sampled Image'");
InstructionDesc[OpImageSampleImplicitLod].operands.push(OperandId, "'Coordinate'"); InstructionDesc[OpImageSampleImplicitLod].operands.push(OperandId, "'Coordinate'");
......
...@@ -25,11 +25,11 @@ Linked vertex stage: ...@@ -25,11 +25,11 @@ Linked vertex stage:
6: TypeInt 32 1 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: 6(int) Constant 0 9: 6(int) Constant 0
14: TypeBool 13: TypeBool
15: 14(bool) ConstantTrue 15: 13(bool) ConstantTrue
19: 6(int) Constant 10 19: 6(int) Constant 10
23: 6(int) Constant 1 23: 6(int) Constant 1
25: 14(bool) ConstantFalse 25: 13(bool) ConstantFalse
26: TypePointer Input 6(int) 26: TypePointer Input 6(int)
27(gl_VertexID): 26(ptr) Variable Input 27(gl_VertexID): 26(ptr) Variable Input
28(gl_InstanceID): 26(ptr) Variable Input 28(gl_InstanceID): 26(ptr) Variable Input
...@@ -39,15 +39,15 @@ Linked vertex stage: ...@@ -39,15 +39,15 @@ Linked vertex stage:
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
13: 14(bool) Phi 15 5 25 12 14: 13(bool) Phi 15 5 25 12
LoopMerge 11 None LoopMerge 11 None
Branch 16 Branch 16
16: Label 16: Label
SelectionMerge 12 None SelectionMerge 12 None
BranchConditional 13 12 17 BranchConditional 14 12 17
17: Label 17: Label
18: 6(int) Load 8(i) 18: 6(int) Load 8(i)
20: 14(bool) SLessThan 18 19 20: 13(bool) SLessThan 18 19
SelectionMerge 21 None SelectionMerge 21 None
BranchConditional 20 21 11 BranchConditional 20 21 11
21: Label 21: Label
......
...@@ -32,12 +32,12 @@ Linked vertex stage: ...@@ -32,12 +32,12 @@ Linked vertex stage:
6: TypeInt 32 1 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: 6(int) Constant 0 9: 6(int) Constant 0
14: TypeBool 13: TypeBool
15: 14(bool) ConstantTrue 15: 13(bool) ConstantTrue
19: 6(int) Constant 1 19: 6(int) Constant 1
21: 6(int) Constant 19 21: 6(int) Constant 19
26: 6(int) Constant 2 26: 6(int) Constant 2
31: 14(bool) ConstantFalse 31: 13(bool) ConstantFalse
35: 6(int) Constant 5 35: 6(int) Constant 5
40: 6(int) Constant 3 40: 6(int) Constant 3
43: 6(int) Constant 42 43: 6(int) Constant 42
...@@ -59,17 +59,17 @@ Linked vertex stage: ...@@ -59,17 +59,17 @@ Linked vertex stage:
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
13: 14(bool) Phi 15 5 31 28 31 38 14: 13(bool) Phi 15 5 31 28 31 38
LoopMerge 11 None LoopMerge 11 None
Branch 16 Branch 16
16: Label 16: Label
SelectionMerge 12 None SelectionMerge 12 None
BranchConditional 13 12 17 BranchConditional 14 12 17
17: Label 17: Label
18: 6(int) Load 8(i) 18: 6(int) Load 8(i)
20: 6(int) IAdd 18 19 20: 6(int) IAdd 18 19
Store 8(i) 20 Store 8(i) 20
22: 14(bool) SLessThan 20 21 22: 13(bool) SLessThan 20 21
SelectionMerge 23 None SelectionMerge 23 None
BranchConditional 22 23 11 BranchConditional 22 23 11
23: Label 23: Label
...@@ -77,7 +77,7 @@ Linked vertex stage: ...@@ -77,7 +77,7 @@ Linked vertex stage:
12: Label 12: Label
Store 24(A) 9 Store 24(A) 9
25: 6(int) Load 8(i) 25: 6(int) Load 8(i)
27: 14(bool) IEqual 25 26 27: 13(bool) IEqual 25 26
SelectionMerge 29 None SelectionMerge 29 None
BranchConditional 27 28 29 BranchConditional 27 28 29
28: Label 28: Label
...@@ -88,7 +88,7 @@ Linked vertex stage: ...@@ -88,7 +88,7 @@ Linked vertex stage:
Branch 29 Branch 29
29: Label 29: Label
34: 6(int) Load 8(i) 34: 6(int) Load 8(i)
36: 14(bool) IEqual 34 35 36: 13(bool) IEqual 34 35
SelectionMerge 38 None SelectionMerge 38 None
BranchConditional 36 37 38 BranchConditional 36 37 38
37: Label 37: Label
......
...@@ -28,13 +28,13 @@ Linked fragment stage: ...@@ -28,13 +28,13 @@ Linked fragment stage:
8: TypePointer Function 7(fvec4) 8: TypePointer Function 7(fvec4)
10: TypePointer Input 7(fvec4) 10: TypePointer Input 7(fvec4)
11(BaseColor): 10(ptr) Variable Input 11(BaseColor): 10(ptr) Variable Input
17: TypeBool 16: TypeBool
18: 17(bool) ConstantTrue 18: 16(bool) ConstantTrue
23: TypePointer UniformConstant 6(float) 23: TypePointer UniformConstant 6(float)
24(d): 23(ptr) Variable UniformConstant 24(d): 23(ptr) Variable UniformConstant
28: TypePointer UniformConstant 7(fvec4) 28: TypePointer UniformConstant 7(fvec4)
29(bigColor): 28(ptr) Variable UniformConstant 29(bigColor): 28(ptr) Variable UniformConstant
33: 17(bool) ConstantFalse 33: 16(bool) ConstantFalse
34: TypePointer Output 7(fvec4) 34: TypePointer Output 7(fvec4)
35(gl_FragColor): 34(ptr) Variable Output 35(gl_FragColor): 34(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
...@@ -44,17 +44,17 @@ Linked fragment stage: ...@@ -44,17 +44,17 @@ Linked fragment stage:
Store 9(color) 12 Store 9(color) 12
Branch 13 Branch 13
13: Label 13: Label
16: 17(bool) Phi 18 5 33 15 17: 16(bool) Phi 18 5 33 15
LoopMerge 14 None LoopMerge 14 None
Branch 19 Branch 19
19: Label 19: Label
SelectionMerge 15 None SelectionMerge 15 None
BranchConditional 16 15 20 BranchConditional 17 15 20
20: Label 20: Label
21: 7(fvec4) Load 9(color) 21: 7(fvec4) Load 9(color)
22: 6(float) CompositeExtract 21 0 22: 6(float) CompositeExtract 21 0
25: 6(float) Load 24(d) 25: 6(float) Load 24(d)
26: 17(bool) FOrdLessThan 22 25 26: 16(bool) FOrdLessThan 22 25
SelectionMerge 27 None SelectionMerge 27 None
BranchConditional 26 27 14 BranchConditional 26 27 14
27: Label 27: Label
......
...@@ -117,15 +117,15 @@ Linked fragment stage: ...@@ -117,15 +117,15 @@ Linked fragment stage:
8: TypePointer Function 7(fvec4) 8: TypePointer Function 7(fvec4)
10: TypePointer Input 7(fvec4) 10: TypePointer Input 7(fvec4)
11(BaseColor): 10(ptr) Variable Input 11(BaseColor): 10(ptr) Variable Input
17: TypeBool 16: TypeBool
18: 17(bool) ConstantTrue 18: 16(bool) ConstantTrue
23: TypePointer UniformConstant 6(float) 23: TypePointer UniformConstant 6(float)
24(d4): 23(ptr) Variable UniformConstant 24(d4): 23(ptr) Variable UniformConstant
28: TypePointer UniformConstant 7(fvec4) 28: TypePointer UniformConstant 7(fvec4)
29(bigColor4): 28(ptr) Variable UniformConstant 29(bigColor4): 28(ptr) Variable UniformConstant
39: 6(float) Constant 1073741824 39: 6(float) Constant 1073741824
53: 6(float) Constant 1065353216 53: 6(float) Constant 1065353216
57: 17(bool) ConstantFalse 57: 16(bool) ConstantFalse
83(d13): 23(ptr) Variable UniformConstant 83(d13): 23(ptr) Variable UniformConstant
147: TypePointer Output 7(fvec4) 147: TypePointer Output 7(fvec4)
148(gl_FragColor): 147(ptr) Variable Output 148(gl_FragColor): 147(ptr) Variable Output
...@@ -181,17 +181,17 @@ Linked fragment stage: ...@@ -181,17 +181,17 @@ Linked fragment stage:
Store 9(color) 12 Store 9(color) 12
Branch 13 Branch 13
13: Label 13: Label
16: 17(bool) Phi 18 5 57 49 57 64 17: 16(bool) Phi 18 5 57 49 57 64
LoopMerge 14 None LoopMerge 14 None
Branch 19 Branch 19
19: Label 19: Label
SelectionMerge 15 None SelectionMerge 15 None
BranchConditional 16 15 20 BranchConditional 17 15 20
20: Label 20: Label
21: 7(fvec4) Load 9(color) 21: 7(fvec4) Load 9(color)
22: 6(float) CompositeExtract 21 2 22: 6(float) CompositeExtract 21 2
25: 6(float) Load 24(d4) 25: 6(float) Load 24(d4)
26: 17(bool) FOrdLessThan 22 25 26: 16(bool) FOrdLessThan 22 25
SelectionMerge 27 None SelectionMerge 27 None
BranchConditional 26 27 14 BranchConditional 26 27 14
27: Label 27: Label
...@@ -204,7 +204,7 @@ Linked fragment stage: ...@@ -204,7 +204,7 @@ Linked fragment stage:
33: 7(fvec4) Load 9(color) 33: 7(fvec4) Load 9(color)
34: 6(float) CompositeExtract 33 0 34: 6(float) CompositeExtract 33 0
35: 6(float) Load 24(d4) 35: 6(float) Load 24(d4)
36: 17(bool) FOrdLessThan 34 35 36: 16(bool) FOrdLessThan 34 35
SelectionMerge 38 None SelectionMerge 38 None
BranchConditional 36 37 38 BranchConditional 36 37 38
37: Label 37: Label
...@@ -217,7 +217,7 @@ Linked fragment stage: ...@@ -217,7 +217,7 @@ Linked fragment stage:
45: 7(fvec4) Load 9(color) 45: 7(fvec4) Load 9(color)
46: 6(float) CompositeExtract 45 2 46: 6(float) CompositeExtract 45 2
47: 6(float) Load 24(d4) 47: 6(float) Load 24(d4)
48: 17(bool) FOrdLessThan 46 47 48: 16(bool) FOrdLessThan 46 47
SelectionMerge 50 None SelectionMerge 50 None
BranchConditional 48 49 50 BranchConditional 48 49 50
49: Label 49: Label
...@@ -234,7 +234,7 @@ Linked fragment stage: ...@@ -234,7 +234,7 @@ Linked fragment stage:
59: 7(fvec4) Load 9(color) 59: 7(fvec4) Load 9(color)
60: 6(float) CompositeExtract 59 1 60: 6(float) CompositeExtract 59 1
61: 6(float) Load 24(d4) 61: 6(float) Load 24(d4)
62: 17(bool) FOrdLessThan 60 61 62: 16(bool) FOrdLessThan 60 61
SelectionMerge 64 None SelectionMerge 64 None
BranchConditional 62 63 71 BranchConditional 62 63 71
63: Label 63: Label
...@@ -263,14 +263,14 @@ Linked fragment stage: ...@@ -263,14 +263,14 @@ Linked fragment stage:
81: 7(fvec4) Load 9(color) 81: 7(fvec4) Load 9(color)
82: 6(float) CompositeExtract 81 3 82: 6(float) CompositeExtract 81 3
84: 6(float) Load 83(d13) 84: 6(float) Load 83(d13)
85: 17(bool) FOrdLessThan 82 84 85: 16(bool) FOrdLessThan 82 84
LoopMerge 79 None LoopMerge 79 None
BranchConditional 85 80 79 BranchConditional 85 80 79
80: Label 80: Label
86: 7(fvec4) Load 9(color) 86: 7(fvec4) Load 9(color)
87: 6(float) CompositeExtract 86 2 87: 6(float) CompositeExtract 86 2
88: 6(float) Load 83(d13) 88: 6(float) Load 83(d13)
89: 17(bool) FOrdLessThan 87 88 89: 16(bool) FOrdLessThan 87 88
SelectionMerge 91 None SelectionMerge 91 None
BranchConditional 89 90 95 BranchConditional 89 90 95
90: Label 90: Label
...@@ -293,7 +293,7 @@ Linked fragment stage: ...@@ -293,7 +293,7 @@ Linked fragment stage:
102: 7(fvec4) Load 9(color) 102: 7(fvec4) Load 9(color)
103: 6(float) CompositeExtract 102 0 103: 6(float) CompositeExtract 102 0
104: 6(float) Load 24(d4) 104: 6(float) Load 24(d4)
105: 17(bool) FOrdLessThan 103 104 105: 16(bool) FOrdLessThan 103 104
SelectionMerge 107 None SelectionMerge 107 None
BranchConditional 105 106 107 BranchConditional 105 106 107
106: Label 106: Label
...@@ -306,7 +306,7 @@ Linked fragment stage: ...@@ -306,7 +306,7 @@ Linked fragment stage:
113: 7(fvec4) Load 9(color) 113: 7(fvec4) Load 9(color)
114: 6(float) CompositeExtract 113 2 114: 6(float) CompositeExtract 113 2
115: 6(float) Load 24(d4) 115: 6(float) Load 24(d4)
116: 17(bool) FOrdLessThan 114 115 116: 16(bool) FOrdLessThan 114 115
SelectionMerge 118 None SelectionMerge 118 None
BranchConditional 116 117 118 BranchConditional 116 117 118
117: Label 117: Label
...@@ -323,7 +323,7 @@ Linked fragment stage: ...@@ -323,7 +323,7 @@ Linked fragment stage:
125: 7(fvec4) Load 9(color) 125: 7(fvec4) Load 9(color)
126: 6(float) CompositeExtract 125 1 126: 6(float) CompositeExtract 125 1
127: 6(float) Load 24(d4) 127: 6(float) Load 24(d4)
128: 17(bool) FOrdLessThan 126 127 128: 16(bool) FOrdLessThan 126 127
SelectionMerge 130 None SelectionMerge 130 None
BranchConditional 128 129 137 BranchConditional 128 129 137
129: Label 129: Label
......
...@@ -196,13 +196,13 @@ Linked fragment stage: ...@@ -196,13 +196,13 @@ Linked fragment stage:
64: 21 Load 23(s3D) 64: 21 Load 23(s3D)
68: 65(ivec3) Load 67(ic3D) 68: 65(ivec3) Load 67(ic3D)
71: 50(int) Load 70(ic1D) 71: 50(int) Load 70(ic1D)
72: 7(fvec4) ImageFetch 64 68 72: 7(fvec4) ImageFetch 64 68 71
73: 7(fvec4) Load 9(v) 73: 7(fvec4) Load 9(v)
74: 7(fvec4) FAdd 73 72 74: 7(fvec4) FAdd 73 72
Store 9(v) 74 Store 9(v) 74
75: 11 Load 13(s2D) 75: 11 Load 13(s2D)
78: 51(ivec2) Load 77(ic2D) 78: 51(ivec2) Load 77(ic2D)
80: 7(fvec4) ImageFetch 75 78 79 80: 7(fvec4) ImageFetch 75 78 79 53
81: 7(fvec4) Load 9(v) 81: 7(fvec4) Load 9(v)
82: 7(fvec4) FAdd 81 80 82: 7(fvec4) FAdd 81 80
Store 9(v) 82 Store 9(v) 82
...@@ -321,7 +321,7 @@ Linked fragment stage: ...@@ -321,7 +321,7 @@ Linked fragment stage:
205: 202 Load 204(is2DArray) 205: 202 Load 204(is2DArray)
206: 65(ivec3) Load 67(ic3D) 206: 65(ivec3) Load 67(ic3D)
207: 50(int) Load 70(ic1D) 207: 50(int) Load 70(ic1D)
208: 139(ivec4) ImageFetch 205 206 208: 139(ivec4) ImageFetch 205 206 207
Store 141(iv) 208 Store 141(iv) 208
209: 139(ivec4) Load 141(iv) 209: 139(ivec4) Load 141(iv)
210: 7(fvec4) ConvertSToF 209 210: 7(fvec4) ConvertSToF 209
......
...@@ -310,7 +310,7 @@ Linked fragment stage: ...@@ -310,7 +310,7 @@ Linked fragment stage:
214: 70 Load 72(texSampler2D) 214: 70 Load 72(texSampler2D)
215: 205(ivec2) Load 207(iCoords2D) 215: 205(ivec2) Load 207(iCoords2D)
216: 204(int) Load 212(iLod) 216: 204(int) Load 212(iLod)
217: 22(fvec4) ImageFetch 214 215 217: 22(fvec4) ImageFetch 214 215 216
218: 22(fvec4) Load 26(color) 218: 22(fvec4) Load 26(color)
219: 22(fvec4) FAdd 218 217 219: 22(fvec4) FAdd 218 217
Store 26(color) 219 Store 26(color) 219
......
#version 450
layout(rgba32f, binding = 0) uniform image1D i1D;
layout(rgba32f, binding = 1) uniform image2D i2D;
layout(rgba32f, binding = 2) uniform image3D i3D;
layout(rgba32f, binding = 3) uniform imageCube iCube;
layout(rgba32f, binding = 4) uniform imageCubeArray iCubeArray;
layout(rgba32f, binding = 5) uniform image2DRect i2DRect;
layout(rgba32f, binding = 6) uniform image1DArray i1DArray;
layout(rgba32f, binding = 7) uniform image2DArray i2DArray;
layout(rgba32f, binding = 8) uniform imageBuffer iBuffer;
layout(rgba32f, binding = 9) uniform image2DMS i2DMS;
layout(rgba32f, binding = 10) uniform image2DMSArray i2DMSArray;
layout(r32i, binding = 11) uniform iimage1D ii1D;
layout(r32ui, binding = 12) uniform uimage2D ui2D;
uniform int ic1D;
uniform ivec2 ic2D;
uniform ivec3 ic3D;
uniform ivec4 ic4D;
uniform uint value;
out vec4 fragData;
void main()
{
ivec3 iv = ivec3(0);
iv.x += imageSize(i1D);
iv.xy += imageSize(i2D);
iv.xyz += imageSize(i3D);
iv.xy += imageSize(iCube);
iv.xyz += imageSize(iCubeArray);
iv.xy += imageSize(i2DRect);
iv.xy += imageSize(i1DArray);
iv.xyz += imageSize(i2DArray);
iv.x += imageSize(iBuffer);
iv.xy += imageSize(i2DMS);
iv.xyz += imageSize(i2DMSArray);
iv.x += imageSamples(i2DMS);
iv.x += imageSamples(i2DMSArray);
vec4 v = vec4(0.0);
v += imageLoad(i1D, ic1D);
imageStore(i1D, ic1D, v);
v += imageLoad(i2D, ic2D);
imageStore(i2D, ic2D, v);
v += imageLoad(i3D, ic3D);
imageStore(i3D, ic3D, v);
v += imageLoad(iCube, ic3D);
imageStore(iCube, ic3D, v);
v += imageLoad(iCubeArray, ic4D);
imageStore(iCubeArray, ic4D, v);
v += imageLoad(i2DRect, ic2D);
imageStore(i2DRect, ic2D, v);
v += imageLoad(i1DArray, ic2D);
imageStore(i1DArray, ic2D, v);
v += imageLoad(i2DArray, ic3D);
imageStore(i2DArray, ic3D, v);
v += imageLoad(iBuffer, ic1D);
imageStore(iBuffer, ic1D, v);
v += imageLoad(i2DMS, ic2D, 1);
imageStore(i2DMS, ic2D, 2, v);
v += imageLoad(i2DMSArray, ic3D, 3);
imageStore(i2DMSArray, ic3D, 4, v);
uint ui = 0;
iv.x += imageAtomicAdd(ii1D, ic1D, 10);
ui += imageAtomicAdd(ui2D, ic2D, value);
iv.x += imageAtomicMin(ii1D, ic1D, 11);
ui += imageAtomicMin(ui2D, ic2D, value);
iv.x += imageAtomicMax(ii1D, ic1D, 12);
ui += imageAtomicMax(ui2D, ic2D, value);
iv.x += imageAtomicAnd(ii1D, ic1D, 13);
ui += imageAtomicAnd(ui2D, ic2D, value);
iv.x += imageAtomicOr(ii1D, ic1D, 14);
ui += imageAtomicOr(ui2D, ic2D, value);
iv.x += imageAtomicXor(ii1D, ic1D, 15);
ui += imageAtomicXor(ui2D, ic2D, value);
iv.x += imageAtomicExchange(ii1D, ic1D, 16);
ui += imageAtomicExchange(ui2D, ic2D, value);
iv.x += imageAtomicCompSwap(ii1D, ic1D, 18, 17);
ui += imageAtomicCompSwap(ui2D, ic2D, 19u, value);
fragData = ui != iv.y ? v : vec4(0.0);
}
...@@ -70,6 +70,7 @@ spv.test.frag ...@@ -70,6 +70,7 @@ spv.test.frag
spv.test.vert spv.test.vert
spv.texture.frag spv.texture.frag
spv.texture.vert spv.texture.vert
spv.image.frag
spv.types.frag spv.types.frag
spv.uint.frag spv.uint.frag
spv.uniformArray.frag spv.uniformArray.frag
......
...@@ -617,7 +617,6 @@ struct TCrackedTextureOp { ...@@ -617,7 +617,6 @@ struct TCrackedTextureOp {
bool query; bool query;
bool proj; bool proj;
bool lod; bool lod;
bool sample;
bool fetch; bool fetch;
bool offset; bool offset;
bool offsets; bool offsets;
...@@ -645,7 +644,6 @@ public: ...@@ -645,7 +644,6 @@ public:
cracked.query = false; cracked.query = false;
cracked.proj = false; cracked.proj = false;
cracked.lod = false; cracked.lod = false;
cracked.sample = false;
cracked.fetch = false; cracked.fetch = false;
cracked.offset = false; cracked.offset = false;
cracked.offsets = false; cracked.offsets = false;
...@@ -653,6 +651,8 @@ public: ...@@ -653,6 +651,8 @@ public:
cracked.grad = false; cracked.grad = false;
switch (op) { switch (op) {
case EOpImageQuerySize:
case EOpImageQuerySamples:
case EOpTextureQuerySize: case EOpTextureQuerySize:
case EOpTextureQueryLod: case EOpTextureQueryLod:
case EOpTextureQueryLevels: case EOpTextureQueryLevels:
...@@ -672,22 +672,14 @@ public: ...@@ -672,22 +672,14 @@ public:
break; break;
case EOpTextureFetch: case EOpTextureFetch:
cracked.fetch = true; cracked.fetch = true;
if (sampler.dim == Esd1D || sampler.dim == Esd2D || sampler.dim == Esd3D) { if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D)
if (sampler.ms) cracked.lod = true;
cracked.sample = true;
else
cracked.lod = true;
}
break; break;
case EOpTextureFetchOffset: case EOpTextureFetchOffset:
cracked.fetch = true; cracked.fetch = true;
cracked.offset = true; cracked.offset = true;
if (sampler.dim == Esd1D || sampler.dim == Esd2D || sampler.dim == Esd3D) { if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D)
if (sampler.ms) cracked.lod = true;
cracked.sample = true;
else
cracked.lod = true;
}
break; break;
case EOpTextureProjOffset: case EOpTextureProjOffset:
cracked.offset = true; cracked.offset = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment