SPV: Support the new OpCode - OpImageSparseRead
This commit is contained in:
parent
5047c6f7a7
commit
5eafa472d3
@ -2087,7 +2087,7 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate&
|
|||||||
|
|
||||||
glslang::TSampler sampler = {};
|
glslang::TSampler sampler = {};
|
||||||
bool cubeCompare = false;
|
bool cubeCompare = false;
|
||||||
if (node.isTexture()) {
|
if (node.isTexture() || node.isImage()) {
|
||||||
sampler = glslangArguments[0]->getAsTyped()->getType().getSampler();
|
sampler = glslangArguments[0]->getAsTyped()->getType().getSampler();
|
||||||
cubeCompare = sampler.dim == glslang::EsdCube && sampler.arrayed && sampler.shadow;
|
cubeCompare = sampler.dim == glslang::EsdCube && sampler.arrayed && sampler.shadow;
|
||||||
}
|
}
|
||||||
@ -2110,6 +2110,10 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate&
|
|||||||
if (i == 0)
|
if (i == 0)
|
||||||
lvalue = true;
|
lvalue = true;
|
||||||
break;
|
break;
|
||||||
|
case glslang::EOpSparseImageLoad:
|
||||||
|
if ((sampler.ms && i == 3) || (! sampler.ms && i == 2))
|
||||||
|
lvalue = true;
|
||||||
|
break;
|
||||||
case glslang::EOpSparseTexture:
|
case glslang::EOpSparseTexture:
|
||||||
if ((cubeCompare && i == 3) || (! cubeCompare && i == 2))
|
if ((cubeCompare && i == 3) || (! cubeCompare && i == 2))
|
||||||
lvalue = true;
|
lvalue = true;
|
||||||
@ -2253,9 +2257,9 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
|||||||
operands.push_back(spv::ImageOperandsSampleMask);
|
operands.push_back(spv::ImageOperandsSampleMask);
|
||||||
operands.push_back(*opIt);
|
operands.push_back(*opIt);
|
||||||
}
|
}
|
||||||
return builder.createOp(spv::OpImageRead, convertGlslangToSpvType(node->getType()), operands);
|
|
||||||
if (builder.getImageTypeFormat(builder.getImageType(operands.front())) == spv::ImageFormatUnknown)
|
if (builder.getImageTypeFormat(builder.getImageType(operands.front())) == spv::ImageFormatUnknown)
|
||||||
builder.addCapability(spv::CapabilityStorageImageReadWithoutFormat);
|
builder.addCapability(spv::CapabilityStorageImageReadWithoutFormat);
|
||||||
|
return builder.createOp(spv::OpImageRead, convertGlslangToSpvType(node->getType()), operands);
|
||||||
} else if (node->getOp() == glslang::EOpImageStore) {
|
} else if (node->getOp() == glslang::EOpImageStore) {
|
||||||
if (sampler.ms) {
|
if (sampler.ms) {
|
||||||
operands.push_back(*(opIt + 1));
|
operands.push_back(*(opIt + 1));
|
||||||
@ -2267,9 +2271,27 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
|||||||
if (builder.getImageTypeFormat(builder.getImageType(operands.front())) == spv::ImageFormatUnknown)
|
if (builder.getImageTypeFormat(builder.getImageType(operands.front())) == spv::ImageFormatUnknown)
|
||||||
builder.addCapability(spv::CapabilityStorageImageWriteWithoutFormat);
|
builder.addCapability(spv::CapabilityStorageImageWriteWithoutFormat);
|
||||||
return spv::NoResult;
|
return spv::NoResult;
|
||||||
} else if (node->isSparseImage()) {
|
} else if (node->getOp() == glslang::EOpSparseImageLoad) {
|
||||||
spv::MissingFunctionality("sparse image functions");
|
builder.addCapability(spv::CapabilitySparseResidency);
|
||||||
return spv::NoResult;
|
if (builder.getImageTypeFormat(builder.getImageType(operands.front())) == spv::ImageFormatUnknown)
|
||||||
|
builder.addCapability(spv::CapabilityStorageImageReadWithoutFormat);
|
||||||
|
|
||||||
|
if (sampler.ms) {
|
||||||
|
operands.push_back(spv::ImageOperandsSampleMask);
|
||||||
|
operands.push_back(*opIt++);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the return type that was a special structure
|
||||||
|
spv::Id texelOut = *opIt;
|
||||||
|
spv::Id typeId0 = convertGlslangToSpvType(node->getType());
|
||||||
|
spv::Id typeId1 = builder.getDerefTypeId(texelOut);
|
||||||
|
spv::Id resultTypeId = builder.makeStructResultType(typeId0, typeId1);
|
||||||
|
|
||||||
|
spv::Id resultId = builder.createOp(spv::OpImageSparseRead, resultTypeId, operands);
|
||||||
|
|
||||||
|
// Decode the return type
|
||||||
|
builder.createStore(builder.createCompositeExtract(resultId, typeId1, 1), texelOut);
|
||||||
|
return builder.createCompositeExtract(resultId, typeId0, 0);
|
||||||
} else {
|
} else {
|
||||||
// Process image atomic operations
|
// Process image atomic operations
|
||||||
|
|
||||||
|
@ -7,7 +7,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 399
|
// Id's are bound by 433
|
||||||
|
|
||||||
Capability Shader
|
Capability Shader
|
||||||
Capability SampledRect
|
Capability SampledRect
|
||||||
@ -15,7 +15,7 @@ Linked fragment stage:
|
|||||||
Capability SampledCubeArray
|
Capability SampledCubeArray
|
||||||
1: ExtInstImport "GLSL.std.450"
|
1: ExtInstImport "GLSL.std.450"
|
||||||
MemoryModel Logical GLSL450
|
MemoryModel Logical GLSL450
|
||||||
EntryPoint Fragment 4 "main" 33 48 89 360 384
|
EntryPoint Fragment 4 "main" 33 48 89 360 388 400 418
|
||||||
ExecutionMode 4 OriginUpperLeft
|
ExecutionMode 4 OriginUpperLeft
|
||||||
Source GLSL 450
|
Source GLSL 450
|
||||||
SourceExtension "GL_ARB_sparse_texture2"
|
SourceExtension "GL_ARB_sparse_texture2"
|
||||||
@ -44,7 +44,12 @@ Linked fragment stage:
|
|||||||
Name 256 "sCubeShadow"
|
Name 256 "sCubeShadow"
|
||||||
Name 289 "s2DRectShadow"
|
Name 289 "s2DRectShadow"
|
||||||
Name 360 "offsets"
|
Name 360 "offsets"
|
||||||
Name 384 "outColor"
|
Name 385 "i2D"
|
||||||
|
Name 388 "ic2"
|
||||||
|
Name 397 "ii3D"
|
||||||
|
Name 400 "ic3"
|
||||||
|
Name 409 "i2DMS"
|
||||||
|
Name 418 "outColor"
|
||||||
Decorate 29(s2D) DescriptorSet 0
|
Decorate 29(s2D) DescriptorSet 0
|
||||||
Decorate 44(s3D) DescriptorSet 0
|
Decorate 44(s3D) DescriptorSet 0
|
||||||
Decorate 59(isCube) DescriptorSet 0
|
Decorate 59(isCube) DescriptorSet 0
|
||||||
@ -58,6 +63,11 @@ Linked fragment stage:
|
|||||||
Decorate 256(sCubeShadow) DescriptorSet 0
|
Decorate 256(sCubeShadow) DescriptorSet 0
|
||||||
Decorate 289(s2DRectShadow) DescriptorSet 0
|
Decorate 289(s2DRectShadow) DescriptorSet 0
|
||||||
Decorate 360(offsets) Flat
|
Decorate 360(offsets) Flat
|
||||||
|
Decorate 385(i2D) DescriptorSet 0
|
||||||
|
Decorate 388(ic2) Flat
|
||||||
|
Decorate 397(ii3D) DescriptorSet 0
|
||||||
|
Decorate 400(ic3) Flat
|
||||||
|
Decorate 409(i2DMS) DescriptorSet 0
|
||||||
2: TypeVoid
|
2: TypeVoid
|
||||||
3: TypeFunction 2
|
3: TypeFunction 2
|
||||||
6: TypeInt 32 1
|
6: TypeInt 32 1
|
||||||
@ -162,16 +172,29 @@ Linked fragment stage:
|
|||||||
358: TypeArray 143(ivec2) 357
|
358: TypeArray 143(ivec2) 357
|
||||||
359: TypePointer Input 358
|
359: TypePointer Input 358
|
||||||
360(offsets): 359(ptr) Variable Input
|
360(offsets): 359(ptr) Variable Input
|
||||||
383: TypePointer Output 11(fvec4)
|
383: TypeImage 10(float) 2D nonsampled format:Rgba32f
|
||||||
384(outColor): 383(ptr) Variable Output
|
384: TypePointer UniformConstant 383
|
||||||
387: TypeBool
|
385(i2D): 384(ptr) Variable UniformConstant
|
||||||
|
387: TypePointer Input 143(ivec2)
|
||||||
|
388(ic2): 387(ptr) Variable Input
|
||||||
|
395: TypeImage 6(int) 3D nonsampled format:Rgba32i
|
||||||
|
396: TypePointer UniformConstant 395
|
||||||
|
397(ii3D): 396(ptr) Variable UniformConstant
|
||||||
|
399: TypePointer Input 129(ivec3)
|
||||||
|
400(ic3): 399(ptr) Variable Input
|
||||||
|
407: TypeImage 10(float) 2D multi-sampled nonsampled format:Rgba32f
|
||||||
|
408: TypePointer UniformConstant 407
|
||||||
|
409(i2DMS): 408(ptr) Variable UniformConstant
|
||||||
|
417: TypePointer Output 11(fvec4)
|
||||||
|
418(outColor): 417(ptr) Variable Output
|
||||||
|
421: TypeBool
|
||||||
4(main): 2 Function None 3
|
4(main): 2 Function None 3
|
||||||
5: Label
|
5: Label
|
||||||
8(resident): 7(ptr) Variable Function
|
8(resident): 7(ptr) Variable Function
|
||||||
13(texel): 12(ptr) Variable Function
|
13(texel): 12(ptr) Variable Function
|
||||||
18(itexel): 17(ptr) Variable Function
|
18(itexel): 17(ptr) Variable Function
|
||||||
23(utexel): 22(ptr) Variable Function
|
23(utexel): 22(ptr) Variable Function
|
||||||
385: 12(ptr) Variable Function
|
419: 12(ptr) Variable Function
|
||||||
Store 8(resident) 9
|
Store 8(resident) 9
|
||||||
Store 13(texel) 15
|
Store 13(texel) 15
|
||||||
Store 18(itexel) 19
|
Store 18(itexel) 19
|
||||||
@ -515,24 +538,51 @@ Linked fragment stage:
|
|||||||
381: 6(int) Load 8(resident)
|
381: 6(int) Load 8(resident)
|
||||||
382: 6(int) BitwiseOr 381 380
|
382: 6(int) BitwiseOr 381 380
|
||||||
Store 8(resident) 382
|
Store 8(resident) 382
|
||||||
386: 6(int) Load 8(resident)
|
386: 383 Load 385(i2D)
|
||||||
388: 387(bool) ImageSparseTexelsResident 386
|
389: 143(ivec2) Load 388(ic2)
|
||||||
SelectionMerge 390 None
|
390: 35(ResType) ImageSparseRead 386 389
|
||||||
BranchConditional 388 389 392
|
391: 11(fvec4) CompositeExtract 390 1
|
||||||
389: Label
|
Store 13(texel) 391
|
||||||
391: 11(fvec4) Load 13(texel)
|
392: 6(int) CompositeExtract 390 0
|
||||||
Store 385 391
|
393: 6(int) Load 8(resident)
|
||||||
Branch 390
|
394: 6(int) BitwiseOr 393 392
|
||||||
392: Label
|
Store 8(resident) 394
|
||||||
393: 16(ivec4) Load 18(itexel)
|
398: 395 Load 397(ii3D)
|
||||||
394: 11(fvec4) ConvertSToF 393
|
401: 129(ivec3) Load 400(ic3)
|
||||||
395: 21(ivec4) Load 23(utexel)
|
402: 62(ResType) ImageSparseRead 398 401
|
||||||
396: 11(fvec4) ConvertUToF 395
|
403: 16(ivec4) CompositeExtract 402 1
|
||||||
397: 11(fvec4) FAdd 394 396
|
Store 18(itexel) 403
|
||||||
Store 385 397
|
404: 6(int) CompositeExtract 402 0
|
||||||
Branch 390
|
405: 6(int) Load 8(resident)
|
||||||
390: Label
|
406: 6(int) BitwiseOr 405 404
|
||||||
398: 11(fvec4) Load 385
|
Store 8(resident) 406
|
||||||
Store 384(outColor) 398
|
410: 407 Load 409(i2DMS)
|
||||||
|
411: 143(ivec2) Load 388(ic2)
|
||||||
|
412: 35(ResType) ImageSparseRead 410 411 Sample 144
|
||||||
|
413: 11(fvec4) CompositeExtract 412 1
|
||||||
|
Store 13(texel) 413
|
||||||
|
414: 6(int) CompositeExtract 412 0
|
||||||
|
415: 6(int) Load 8(resident)
|
||||||
|
416: 6(int) BitwiseOr 415 414
|
||||||
|
Store 8(resident) 416
|
||||||
|
420: 6(int) Load 8(resident)
|
||||||
|
422: 421(bool) ImageSparseTexelsResident 420
|
||||||
|
SelectionMerge 424 None
|
||||||
|
BranchConditional 422 423 426
|
||||||
|
423: Label
|
||||||
|
425: 11(fvec4) Load 13(texel)
|
||||||
|
Store 419 425
|
||||||
|
Branch 424
|
||||||
|
426: Label
|
||||||
|
427: 16(ivec4) Load 18(itexel)
|
||||||
|
428: 11(fvec4) ConvertSToF 427
|
||||||
|
429: 21(ivec4) Load 23(utexel)
|
||||||
|
430: 11(fvec4) ConvertUToF 429
|
||||||
|
431: 11(fvec4) FAdd 428 430
|
||||||
|
Store 419 431
|
||||||
|
Branch 424
|
||||||
|
424: Label
|
||||||
|
432: 11(fvec4) Load 419
|
||||||
|
Store 418(outColor) 432
|
||||||
Return
|
Return
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
@ -16,10 +16,17 @@ uniform isampler2DArray is2DArray;
|
|||||||
uniform usamplerCubeArray usCubeArray;
|
uniform usamplerCubeArray usCubeArray;
|
||||||
uniform usampler2DRect us2DRect;
|
uniform usampler2DRect us2DRect;
|
||||||
|
|
||||||
|
layout(rgba32f) uniform image2D i2D;
|
||||||
|
layout(rgba32i) uniform iimage3D ii3D;
|
||||||
|
layout(rgba32f) uniform image2DMS i2DMS;
|
||||||
|
|
||||||
in vec2 c2;
|
in vec2 c2;
|
||||||
in vec3 c3;
|
in vec3 c3;
|
||||||
in vec4 c4;
|
in vec4 c4;
|
||||||
|
|
||||||
|
in flat ivec2 ic2;
|
||||||
|
in flat ivec3 ic3;
|
||||||
|
|
||||||
in flat ivec2 offsets[4];
|
in flat ivec2 offsets[4];
|
||||||
|
|
||||||
out vec4 outColor;
|
out vec4 outColor;
|
||||||
@ -76,5 +83,9 @@ void main()
|
|||||||
resident |= sparseTextureGatherOffsetsARB(is2DArray, c3, offsets, itexel, 2);
|
resident |= sparseTextureGatherOffsetsARB(is2DArray, c3, offsets, itexel, 2);
|
||||||
resident |= sparseTextureGatherOffsetsARB(s2DRectShadow, c2, 2.0, offsets, texel);
|
resident |= sparseTextureGatherOffsetsARB(s2DRectShadow, c2, 2.0, offsets, texel);
|
||||||
|
|
||||||
|
resident |= sparseImageLoadARB(i2D, ic2, texel);
|
||||||
|
resident |= sparseImageLoadARB(ii3D, ic3, itexel);
|
||||||
|
resident |= sparseImageLoadARB(i2DMS, ic2, 3, texel);
|
||||||
|
|
||||||
outColor = sparseTexelsResidentARB(resident) ? texel : vec4(itexel) + vec4(utexel);
|
outColor = sparseTexelsResidentARB(resident) ? texel : vec4(itexel) + vec4(utexel);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user