Commit 33661450 by John Kessenich

SPV: Implement OpImage functionality (emit before query).

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