Commit 33661450 by John Kessenich

SPV: Implement OpImage functionality (emit before query).

parent 45457bcd
......@@ -1855,6 +1855,9 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
// Check for queries
if (cracked.query) {
// a sampled image needs to have the image extracted first
if (builder.isSampledImage(params.sampler))
params.sampler = builder.createUnaryOp(spv::OpImage, builder.getImageType(params.sampler), params.sampler);
switch (node->getOp()) {
case glslang::EOpImageQuerySize:
case glslang::EOpTextureQuerySize:
......
......@@ -122,23 +122,24 @@ public:
Id getContainedTypeId(Id typeId, int) const;
StorageClass getTypeStorageClass(Id typeId) const { return module.getStorageClass(typeId); }
bool isPointer(Id resultId) const { return isPointerType(getTypeId(resultId)); }
bool isScalar(Id resultId) const { return isScalarType(getTypeId(resultId)); }
bool isVector(Id resultId) const { return isVectorType(getTypeId(resultId)); }
bool isMatrix(Id resultId) const { return isMatrixType(getTypeId(resultId)); }
bool isAggregate(Id resultId) const { return isAggregateType(getTypeId(resultId)); }
bool isBoolType(Id typeId) const { return groupedTypes[OpTypeBool].size() > 0 && typeId == groupedTypes[OpTypeBool].back()->getResultId(); }
bool isPointerType(Id typeId) const { return getTypeClass(typeId) == OpTypePointer; }
bool isScalarType(Id typeId) const { return getTypeClass(typeId) == OpTypeFloat || getTypeClass(typeId) == OpTypeInt || getTypeClass(typeId) == OpTypeBool; }
bool isVectorType(Id typeId) const { return getTypeClass(typeId) == OpTypeVector; }
bool isMatrixType(Id typeId) const { return getTypeClass(typeId) == OpTypeMatrix; }
bool isStructType(Id typeId) const { return getTypeClass(typeId) == OpTypeStruct; }
bool isArrayType(Id typeId) const { return getTypeClass(typeId) == OpTypeArray; }
bool isAggregateType(Id typeId) const { return isArrayType(typeId) || isStructType(typeId); }
bool isImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeImage; }
bool isSamplerType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampler; }
bool isSampledImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampledImage; }
bool isPointer(Id resultId) const { return isPointerType(getTypeId(resultId)); }
bool isScalar(Id resultId) const { return isScalarType(getTypeId(resultId)); }
bool isVector(Id resultId) const { return isVectorType(getTypeId(resultId)); }
bool isMatrix(Id resultId) const { return isMatrixType(getTypeId(resultId)); }
bool isAggregate(Id resultId) const { return isAggregateType(getTypeId(resultId)); }
bool isSampledImage(Id resultId) const { return isSampledImageType(getTypeId(resultId)); }
bool isBoolType(Id typeId) const { return groupedTypes[OpTypeBool].size() > 0 && typeId == groupedTypes[OpTypeBool].back()->getResultId(); }
bool isPointerType(Id typeId) const { return getTypeClass(typeId) == OpTypePointer; }
bool isScalarType(Id typeId) const { return getTypeClass(typeId) == OpTypeFloat || getTypeClass(typeId) == OpTypeInt || getTypeClass(typeId) == OpTypeBool; }
bool isVectorType(Id typeId) const { return getTypeClass(typeId) == OpTypeVector; }
bool isMatrixType(Id typeId) const { return getTypeClass(typeId) == OpTypeMatrix; }
bool isStructType(Id typeId) const { return getTypeClass(typeId) == OpTypeStruct; }
bool isArrayType(Id typeId) const { return getTypeClass(typeId) == OpTypeArray; }
bool isAggregateType(Id typeId) const { return isArrayType(typeId) || isStructType(typeId); }
bool isImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeImage; }
bool isSamplerType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampler; }
bool isSampledImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampledImage; }
bool isConstantOpCode(Op opcode) const;
bool isConstant(Id resultId) const { return isConstantOpCode(getOpCode(resultId)); }
......
......@@ -5,7 +5,7 @@ Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 97
// Id's are bound by 99
Capability Shader
1: ExtInstImport "GLSL.std.450"
......@@ -22,41 +22,41 @@ Linked fragment stage:
Name 33 "gl_ClipDistance"
Name 43 "k"
Name 55 "sampR"
Name 62 "sampB"
Name 84 "samp2Da"
Name 88 "bn"
MemberName 88(bn) 0 "matra"
MemberName 88(bn) 1 "matca"
MemberName 88(bn) 2 "matr"
MemberName 88(bn) 3 "matc"
MemberName 88(bn) 4 "matrdef"
Name 90 ""
Name 93 "bi"
MemberName 93(bi) 0 "v"
Name 96 "bname"
Name 63 "sampB"
Name 86 "samp2Da"
Name 90 "bn"
MemberName 90(bn) 0 "matra"
MemberName 90(bn) 1 "matca"
MemberName 90(bn) 2 "matr"
MemberName 90(bn) 3 "matc"
MemberName 90(bn) 4 "matrdef"
Name 92 ""
Name 95 "bi"
MemberName 95(bi) 0 "v"
Name 98 "bname"
Decorate 16(gl_FrontFacing) BuiltIn FrontFacing
Decorate 33(gl_ClipDistance) BuiltIn ClipDistance
Decorate 87 ArrayStride 64
Decorate 87 ArrayStride 64
MemberDecorate 88(bn) 0 RowMajor
MemberDecorate 88(bn) 0 Offset 0
MemberDecorate 88(bn) 0 MatrixStride 16
MemberDecorate 88(bn) 1 ColMajor
MemberDecorate 88(bn) 1 Offset 256
MemberDecorate 88(bn) 1 MatrixStride 16
MemberDecorate 88(bn) 2 RowMajor
MemberDecorate 88(bn) 2 Offset 512
MemberDecorate 88(bn) 2 MatrixStride 16
MemberDecorate 88(bn) 3 ColMajor
MemberDecorate 88(bn) 3 Offset 576
MemberDecorate 88(bn) 3 MatrixStride 16
MemberDecorate 88(bn) 4 RowMajor
MemberDecorate 88(bn) 4 Offset 640
MemberDecorate 88(bn) 4 MatrixStride 16
Decorate 88(bn) Block
Decorate 92 ArrayStride 16
MemberDecorate 93(bi) 0 Offset 0
Decorate 93(bi) Block
Decorate 89 ArrayStride 64
Decorate 89 ArrayStride 64
MemberDecorate 90(bn) 0 RowMajor
MemberDecorate 90(bn) 0 Offset 0
MemberDecorate 90(bn) 0 MatrixStride 16
MemberDecorate 90(bn) 1 ColMajor
MemberDecorate 90(bn) 1 Offset 256
MemberDecorate 90(bn) 1 MatrixStride 16
MemberDecorate 90(bn) 2 RowMajor
MemberDecorate 90(bn) 2 Offset 512
MemberDecorate 90(bn) 2 MatrixStride 16
MemberDecorate 90(bn) 3 ColMajor
MemberDecorate 90(bn) 3 Offset 576
MemberDecorate 90(bn) 3 MatrixStride 16
MemberDecorate 90(bn) 4 RowMajor
MemberDecorate 90(bn) 4 Offset 640
MemberDecorate 90(bn) 4 MatrixStride 16
Decorate 90(bn) Block
Decorate 94 ArrayStride 16
MemberDecorate 95(bi) 0 Offset 0
Decorate 95(bi) Block
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
......@@ -92,31 +92,31 @@ Linked fragment stage:
53: TypeSampledImage 52
54: TypePointer UniformConstant 53
55(sampR): 54(ptr) Variable UniformConstant
57: TypeVector 34(int) 2
59: TypeImage 34(int) Buffer sampled format:Unknown
60: TypeSampledImage 59
61: TypePointer UniformConstant 60
62(sampB): 61(ptr) Variable UniformConstant
67: TypeVector 6(float) 2
70: 6(float) Constant 1120403456
72: 29(int) Constant 3
80: TypeImage 6(float) 2D sampled format:Unknown
81: TypeSampledImage 80
82: TypeArray 81 72
83: TypePointer UniformConstant 82
84(samp2Da): 83(ptr) Variable UniformConstant
85: TypeMatrix 26(fvec4) 4
86: 29(int) Constant 4
87: TypeArray 85 86
88(bn): TypeStruct 87 87 85 85 85
89: TypePointer Uniform 88(bn)
90: 89(ptr) Variable Uniform
91: TypeVector 6(float) 3
92: TypeArray 91(fvec3) 50
93(bi): TypeStruct 92
94: TypeArray 93(bi) 86
95: TypePointer Uniform 94
96(bname): 95(ptr) Variable Uniform
58: TypeVector 34(int) 2
60: TypeImage 34(int) Buffer sampled format:Unknown
61: TypeSampledImage 60
62: TypePointer UniformConstant 61
63(sampB): 62(ptr) Variable UniformConstant
69: TypeVector 6(float) 2
72: 6(float) Constant 1120403456
74: 29(int) Constant 3
82: TypeImage 6(float) 2D sampled format:Unknown
83: TypeSampledImage 82
84: TypeArray 83 74
85: TypePointer UniformConstant 84
86(samp2Da): 85(ptr) Variable UniformConstant
87: TypeMatrix 26(fvec4) 4
88: 29(int) Constant 4
89: TypeArray 87 88
90(bn): TypeStruct 89 89 87 87 87
91: TypePointer Uniform 90(bn)
92: 91(ptr) Variable Uniform
93: TypeVector 6(float) 3
94: TypeArray 93(fvec3) 50
95(bi): TypeStruct 94
96: TypeArray 95(bi) 88
97: TypePointer Uniform 96
98(bname): 97(ptr) Variable Uniform
4(main): 2 Function None 3
5: Label
13: 12(ptr) Variable Function
......@@ -145,25 +145,27 @@ Linked fragment stage:
51: 40(ptr) AccessChain 28(o) 50
Store 51 49
56: 53 Load 55(sampR)
58: 57(ivec2) ImageQuerySize 56
63: 60 Load 62(sampB)
64: 34(int) ImageQuerySize 63
65: 57(ivec2) CompositeConstruct 64 64
66: 57(ivec2) IAdd 58 65
68: 67(fvec2) ConvertSToF 66
69: 6(float) CompositeExtract 68 0
71: 6(float) FDiv 69 70
73: 40(ptr) AccessChain 28(o) 72
Store 73 71
74: 6(float) FunctionCall 8(foo()
75: 40(ptr) AccessChain 28(o) 50
Store 75 74
57: 52 Image 56
59: 58(ivec2) ImageQuerySize 57
64: 61 Load 63(sampB)
65: 60 Image 64
66: 34(int) ImageQuerySize 65
67: 58(ivec2) CompositeConstruct 66 66
68: 58(ivec2) IAdd 59 67
70: 69(fvec2) ConvertSToF 68
71: 6(float) CompositeExtract 70 0
73: 6(float) FDiv 71 72
75: 40(ptr) AccessChain 28(o) 74
Store 75 73
76: 6(float) FunctionCall 8(foo()
77: 40(ptr) AccessChain 28(o) 50
Store 77 76
Return
FunctionEnd
8(foo(): 6(float) Function None 7
9: Label
76: 6(float) Load 11(i1)
77: 6(float) Load 24(i2)
78: 6(float) FAdd 76 77
ReturnValue 78
78: 6(float) Load 11(i1)
79: 6(float) Load 24(i2)
80: 6(float) FAdd 78 79
ReturnValue 80
FunctionEnd
......@@ -7,12 +7,12 @@ Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 277
// Id's are bound by 278
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 29 17 55 26 84 91 81 276 246
EntryPoint Fragment 4 "main" 29 17 55 26 84 91 81 277 247
ExecutionMode 4 OriginLowerLeft
Source GLSL 430
Name 4 "main"
......@@ -39,17 +39,17 @@ Linked fragment stage:
Name 227 "is2DArray"
Name 237 "iv2"
Name 241 "sCubeShadow"
Name 246 "FragData"
Name 258 "is2Dms"
Name 262 "us2D"
Name 266 "us3D"
Name 270 "usCube"
Name 274 "us2DArray"
Name 276 "ic4D"
Name 247 "FragData"
Name 259 "is2Dms"
Name 263 "us2D"
Name 267 "us3D"
Name 271 "usCube"
Name 275 "us2DArray"
Name 277 "ic4D"
Decorate 81(ic3D) Flat
Decorate 84(ic1D) Flat
Decorate 91(ic2D) Flat
Decorate 276(ic4D) Flat
Decorate 277(ic4D) Flat
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
......@@ -140,31 +140,31 @@ Linked fragment stage:
240: TypePointer UniformConstant 239
241(sCubeShadow): 240(ptr) Variable UniformConstant
243: 67(int) Constant 2
245: TypePointer Output 7(fvec4)
246(FragData): 245(ptr) Variable Output
250: 6(float) Constant 0
255: TypeImage 67(int) 2D multi-sampled sampled format:Unknown
256: TypeSampledImage 255
257: TypePointer UniformConstant 256
258(is2Dms): 257(ptr) Variable UniformConstant
259: TypeImage 32(int) 2D sampled format:Unknown
260: TypeSampledImage 259
261: TypePointer UniformConstant 260
262(us2D): 261(ptr) Variable UniformConstant
263: TypeImage 32(int) 3D sampled format:Unknown
264: TypeSampledImage 263
265: TypePointer UniformConstant 264
266(us3D): 265(ptr) Variable UniformConstant
267: TypeImage 32(int) Cube sampled format:Unknown
268: TypeSampledImage 267
269: TypePointer UniformConstant 268
270(usCube): 269(ptr) Variable UniformConstant
271: TypeImage 32(int) 2D array sampled format:Unknown
272: TypeSampledImage 271
273: TypePointer UniformConstant 272
274(us2DArray): 273(ptr) Variable UniformConstant
275: TypePointer Input 162(ivec4)
276(ic4D): 275(ptr) Variable Input
246: TypePointer Output 7(fvec4)
247(FragData): 246(ptr) Variable Output
251: 6(float) Constant 0
256: TypeImage 67(int) 2D multi-sampled sampled format:Unknown
257: TypeSampledImage 256
258: TypePointer UniformConstant 257
259(is2Dms): 258(ptr) Variable UniformConstant
260: TypeImage 32(int) 2D sampled format:Unknown
261: TypeSampledImage 260
262: TypePointer UniformConstant 261
263(us2D): 262(ptr) Variable UniformConstant
264: TypeImage 32(int) 3D sampled format:Unknown
265: TypeSampledImage 264
266: TypePointer UniformConstant 265
267(us3D): 266(ptr) Variable UniformConstant
268: TypeImage 32(int) Cube sampled format:Unknown
269: TypeSampledImage 268
270: TypePointer UniformConstant 269
271(usCube): 270(ptr) Variable UniformConstant
272: TypeImage 32(int) 2D array sampled format:Unknown
273: TypeSampledImage 272
274: TypePointer UniformConstant 273
275(us2DArray): 274(ptr) Variable UniformConstant
276: TypePointer Input 162(ivec4)
277(ic4D): 276(ptr) Variable Input
4(main): 2 Function None 3
5: Label
9(v): 8(ptr) Variable Function
......@@ -345,15 +345,16 @@ Linked fragment stage:
235: 7(fvec4) FAdd 234 233
Store 9(v) 235
242: 239 Load 241(sCubeShadow)
244: 68(ivec2) ImageQuerySizeLod 242 243
Store 237(iv2) 244
247: 7(fvec4) Load 9(v)
248: 68(ivec2) Load 237(iv2)
249: 15(fvec2) ConvertSToF 248
251: 6(float) CompositeExtract 249 0
252: 6(float) CompositeExtract 249 1
253: 7(fvec4) CompositeConstruct 251 252 250 250
254: 7(fvec4) FAdd 247 253
Store 246(FragData) 254
244: 238 Image 242
245: 68(ivec2) ImageQuerySizeLod 244 243
Store 237(iv2) 245
248: 7(fvec4) Load 9(v)
249: 68(ivec2) Load 237(iv2)
250: 15(fvec2) ConvertSToF 249
252: 6(float) CompositeExtract 250 0
253: 6(float) CompositeExtract 250 1
254: 7(fvec4) CompositeConstruct 252 253 251 251
255: 7(fvec4) FAdd 248 254
Store 247(FragData) 255
Return
FunctionEnd
......@@ -2,5 +2,5 @@
// 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).
#define GLSLANG_REVISION "SPIRV99.824"
#define GLSLANG_DATE "06-Dec-2015"
#define GLSLANG_REVISION "SPIRV99.830"
#define GLSLANG_DATE "08-Dec-2015"
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