SPV: Minor corrections to previous big merge for images and atomics.

This commit is contained in:
John Kessenich 2015-09-16 10:54:31 -06:00
parent f6890c3798
commit 56bab0483a
8 changed files with 54 additions and 76 deletions

View File

@ -844,9 +844,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
builder.setAccessChainRValue(result); builder.setAccessChainRValue(result);
return false; return false;
} } else if (node->getOp() == glslang::EOpImageStore) {
else if (node->getOp() == glslang::EOpImageStore)
{
// "imageStore" is a special case, which has no result // "imageStore" is a special case, which has no result
return false; return false;
} }
@ -1819,45 +1817,27 @@ 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()) {
// Process image load/store
if (node->getOp() == glslang::EOpImageLoad ||
node->getOp() == glslang::EOpImageStore) {
std::vector<spv::Id> operands; std::vector<spv::Id> operands;
auto opIt = arguments.begin(); auto opIt = arguments.begin();
operands.push_back(*(opIt++)); operands.push_back(*(opIt++));
operands.push_back(*(opIt++)); operands.push_back(*(opIt++));
if (sampler.ms) { if (node->getOp() == glslang::EOpImageStore)
// For MS, image operand mask has to be added to indicate the presence of "sample" operand. operands.push_back(*(opIt++));
spv::Id sample = *(opIt++); // TODO: add 'sample' operand
for (; opIt != arguments.end(); ++opIt) if (node->getOp() == glslang::EOpImageLoad) {
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); return builder.createOp(spv::OpImageRead, convertGlslangToSpvType(node->getType()), operands);
else { } else if (node->getOp() == glslang::EOpImageStore) {
builder.createNoResultOp(spv::OpImageWrite, operands); builder.createNoResultOp(spv::OpImageWrite, operands);
return spv::NoResult; return spv::NoResult;
}
} else { } else {
// Process image atomic operations // Process image atomic operations
// GLSL "IMAGE_PARAMS" will involve in constructing an image texel pointer and this pointer, // 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. // as the first source operand, is required by SPIR-V atomic operations.
std::vector<spv::Id> imageParams; operands.push_back(sampler.ms ? *(opIt++) : 0); // For non-MS, the value should be 0
auto opIt = arguments.begin();
imageParams.push_back(*(opIt++));
imageParams.push_back(*(opIt++));
imageParams.push_back(sampler.ms ? *(opIt++) : 0); // For non-MS, the value should be 0
spv::Id resultTypeId = builder.makePointer(spv::StorageClassImage, convertGlslangToSpvType(node->getType())); spv::Id resultTypeId = builder.makePointer(spv::StorageClassImage, convertGlslangToSpvType(node->getType()));
spv::Id pointer = builder.createOp(spv::OpImageTexelPointer, resultTypeId, imageParams); spv::Id pointer = builder.createOp(spv::OpImageTexelPointer, resultTypeId, operands);
std::vector<spv::Id> operands; std::vector<spv::Id> operands;
operands.push_back(pointer); operands.push_back(pointer);

View File

@ -1635,12 +1635,10 @@ 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'");

View File

@ -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
13: TypeBool 14: TypeBool
15: 13(bool) ConstantTrue 15: 14(bool) ConstantTrue
19: 6(int) Constant 10 19: 6(int) Constant 10
23: 6(int) Constant 1 23: 6(int) Constant 1
25: 13(bool) ConstantFalse 25: 14(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:
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
14: 13(bool) Phi 15 5 25 12 13: 14(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 14 12 17 BranchConditional 13 12 17
17: Label 17: Label
18: 6(int) Load 8(i) 18: 6(int) Load 8(i)
20: 13(bool) SLessThan 18 19 20: 14(bool) SLessThan 18 19
SelectionMerge 21 None SelectionMerge 21 None
BranchConditional 20 21 11 BranchConditional 20 21 11
21: Label 21: Label

View File

@ -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
13: TypeBool 14: TypeBool
15: 13(bool) ConstantTrue 15: 14(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: 13(bool) ConstantFalse 31: 14(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:
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
14: 13(bool) Phi 15 5 31 28 31 38 13: 14(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 14 12 17 BranchConditional 13 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: 13(bool) SLessThan 20 21 22: 14(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:
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: 13(bool) IEqual 25 26 27: 14(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:
Branch 29 Branch 29
29: Label 29: Label
34: 6(int) Load 8(i) 34: 6(int) Load 8(i)
36: 13(bool) IEqual 34 35 36: 14(bool) IEqual 34 35
SelectionMerge 38 None SelectionMerge 38 None
BranchConditional 36 37 38 BranchConditional 36 37 38
37: Label 37: Label

View File

@ -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
16: TypeBool 17: TypeBool
18: 16(bool) ConstantTrue 18: 17(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: 16(bool) ConstantFalse 33: 17(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:
Store 9(color) 12 Store 9(color) 12
Branch 13 Branch 13
13: Label 13: Label
17: 16(bool) Phi 18 5 33 15 16: 17(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 17 15 20 BranchConditional 16 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: 16(bool) FOrdLessThan 22 25 26: 17(bool) FOrdLessThan 22 25
SelectionMerge 27 None SelectionMerge 27 None
BranchConditional 26 27 14 BranchConditional 26 27 14
27: Label 27: Label

View File

@ -329,24 +329,24 @@ Linked fragment stage:
ImageWrite 209 210 211 ImageWrite 209 210 211
212: 95 Load 97(i2DMS) 212: 95 Load 97(i2DMS)
213: 27(ivec2) Load 143(ic2D) 213: 27(ivec2) Load 143(ic2D)
215: 126(fvec4) ImageRead 212 213 214 215: 126(fvec4) ImageRead 212 213
216: 126(fvec4) Load 128(v) 216: 126(fvec4) Load 128(v)
217: 126(fvec4) FAdd 216 215 217: 126(fvec4) FAdd 216 215
Store 128(v) 217 Store 128(v) 217
218: 95 Load 97(i2DMS) 218: 95 Load 97(i2DMS)
219: 27(ivec2) Load 143(ic2D) 219: 27(ivec2) Load 143(ic2D)
221: 126(fvec4) Load 128(v) 221: 126(fvec4) Load 128(v)
ImageWrite 218 219 221 220 ImageWrite 218 219 220
222: 105 Load 107(i2DMSArray) 222: 105 Load 107(i2DMSArray)
223: 7(ivec3) Load 153(ic3D) 223: 7(ivec3) Load 153(ic3D)
225: 126(fvec4) ImageRead 222 223 224 225: 126(fvec4) ImageRead 222 223
226: 126(fvec4) Load 128(v) 226: 126(fvec4) Load 128(v)
227: 126(fvec4) FAdd 226 225 227: 126(fvec4) FAdd 226 225
Store 128(v) 227 Store 128(v) 227
228: 105 Load 107(i2DMSArray) 228: 105 Load 107(i2DMSArray)
229: 7(ivec3) Load 153(ic3D) 229: 7(ivec3) Load 153(ic3D)
231: 126(fvec4) Load 128(v) 231: 126(fvec4) Load 128(v)
ImageWrite 228 229 231 230 ImageWrite 228 229 230
Store 234(ui) 235 Store 234(ui) 235
239: 6(int) Load 133(ic1D) 239: 6(int) Load 133(ic1D)
242: 241(ptr) ImageTexelPointer 238(ii1D) 239 0 242: 241(ptr) ImageTexelPointer 238(ii1D) 239 0

View File

@ -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
16: TypeBool 17: TypeBool
18: 16(bool) ConstantTrue 18: 17(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: 16(bool) ConstantFalse 57: 17(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:
Store 9(color) 12 Store 9(color) 12
Branch 13 Branch 13
13: Label 13: Label
17: 16(bool) Phi 18 5 57 49 57 64 16: 17(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 17 15 20 BranchConditional 16 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: 16(bool) FOrdLessThan 22 25 26: 17(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:
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: 16(bool) FOrdLessThan 34 35 36: 17(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:
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: 16(bool) FOrdLessThan 46 47 48: 17(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:
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: 16(bool) FOrdLessThan 60 61 62: 17(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:
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: 16(bool) FOrdLessThan 82 84 85: 17(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: 16(bool) FOrdLessThan 87 88 89: 17(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:
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: 16(bool) FOrdLessThan 103 104 105: 17(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:
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: 16(bool) FOrdLessThan 114 115 116: 17(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:
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: 16(bool) FOrdLessThan 126 127 128: 17(bool) FOrdLessThan 126 127
SelectionMerge 130 None SelectionMerge 130 None
BranchConditional 128 129 137 BranchConditional 128 129 137
129: Label 129: Label

View File

@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits. // For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run). // For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "3.0.756" #define GLSLANG_REVISION "3.0.769"
#define GLSLANG_DATE "15-Sep-2015" #define GLSLANG_DATE "16-Sep-2015"