Merge pull request #1029 from amdrexu/feature2
Implement extension GL_AMD_shader_image_load_store_lod
This commit is contained in:
commit
fc3436941e
12 changed files with 298 additions and 1 deletions
|
|
@ -33,7 +33,7 @@ enum Decoration;
|
|||
enum Op;
|
||||
|
||||
static const int GLSLextAMDVersion = 100;
|
||||
static const int GLSLextAMDRevision = 4;
|
||||
static const int GLSLextAMDRevision = 5;
|
||||
|
||||
// SPV_AMD_shader_ballot
|
||||
static const char* const E_SPV_AMD_shader_ballot = "SPV_AMD_shader_ballot";
|
||||
|
|
@ -101,4 +101,9 @@ static const char* const E_SPV_AMD_texture_gather_bias_lod = "SPV_AMD_texture_ga
|
|||
// SPV_AMD_gpu_shader_int16
|
||||
static const char* const E_SPV_AMD_gpu_shader_int16 = "SPV_AMD_gpu_shader_int16";
|
||||
|
||||
// SPV_AMD_shader_image_load_store_lod
|
||||
static const char* const E_SPV_AMD_shader_image_load_store_lod = "SPV_AMD_shader_image_load_store_lod";
|
||||
|
||||
static const Capability CapabilityImageReadWriteLodAMD = static_cast<Capability>(5015);
|
||||
|
||||
#endif // #ifndef GLSLextAMD_H
|
||||
|
|
|
|||
|
|
@ -1453,7 +1453,11 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
|||
builder.setAccessChainRValue(result);
|
||||
|
||||
return false;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
} else if (node->getOp() == glslang::EOpImageStore || node->getOp() == glslang::EOpImageStoreLod) {
|
||||
#else
|
||||
} else if (node->getOp() == glslang::EOpImageStore) {
|
||||
#endif
|
||||
// "imageStore" is a special case, which has no result
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3137,6 +3141,10 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate&
|
|||
if (i == 4)
|
||||
lvalue = true;
|
||||
break;
|
||||
case glslang::EOpSparseImageLoadLod:
|
||||
if (i == 3)
|
||||
lvalue = true;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
|
|
@ -3239,26 +3247,55 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
|||
}
|
||||
|
||||
operands.push_back(*(opIt++));
|
||||
#ifdef AMD_EXTENSIONS
|
||||
if (node->getOp() == glslang::EOpImageLoad || node->getOp() == glslang::EOpImageLoadLod) {
|
||||
#else
|
||||
if (node->getOp() == glslang::EOpImageLoad) {
|
||||
#endif
|
||||
if (sampler.ms) {
|
||||
operands.push_back(spv::ImageOperandsSampleMask);
|
||||
operands.push_back(*opIt);
|
||||
#ifdef AMD_EXTENSIONS
|
||||
} else if (cracked.lod) {
|
||||
builder.addExtension(spv::E_SPV_AMD_shader_image_load_store_lod);
|
||||
builder.addCapability(spv::CapabilityImageReadWriteLodAMD);
|
||||
|
||||
operands.push_back(spv::ImageOperandsLodMask);
|
||||
operands.push_back(*opIt);
|
||||
#endif
|
||||
}
|
||||
if (builder.getImageTypeFormat(builder.getImageType(operands.front())) == spv::ImageFormatUnknown)
|
||||
builder.addCapability(spv::CapabilityStorageImageReadWithoutFormat);
|
||||
return builder.createOp(spv::OpImageRead, resultType(), operands);
|
||||
#ifdef AMD_EXTENSIONS
|
||||
} else if (node->getOp() == glslang::EOpImageStore || node->getOp() == glslang::EOpImageStoreLod) {
|
||||
#else
|
||||
} else if (node->getOp() == glslang::EOpImageStore) {
|
||||
#endif
|
||||
if (sampler.ms) {
|
||||
operands.push_back(*(opIt + 1));
|
||||
operands.push_back(spv::ImageOperandsSampleMask);
|
||||
operands.push_back(*opIt);
|
||||
#ifdef AMD_EXTENSIONS
|
||||
} else if (cracked.lod) {
|
||||
builder.addExtension(spv::E_SPV_AMD_shader_image_load_store_lod);
|
||||
builder.addCapability(spv::CapabilityImageReadWriteLodAMD);
|
||||
|
||||
operands.push_back(*(opIt + 1));
|
||||
operands.push_back(spv::ImageOperandsLodMask);
|
||||
operands.push_back(*opIt);
|
||||
#endif
|
||||
} else
|
||||
operands.push_back(*opIt);
|
||||
builder.createNoResultOp(spv::OpImageWrite, operands);
|
||||
if (builder.getImageTypeFormat(builder.getImageType(operands.front())) == spv::ImageFormatUnknown)
|
||||
builder.addCapability(spv::CapabilityStorageImageWriteWithoutFormat);
|
||||
return spv::NoResult;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
} else if (node->getOp() == glslang::EOpSparseImageLoad || node->getOp() == glslang::EOpSparseImageLoadLod) {
|
||||
#else
|
||||
} else if (node->getOp() == glslang::EOpSparseImageLoad) {
|
||||
#endif
|
||||
builder.addCapability(spv::CapabilitySparseResidency);
|
||||
if (builder.getImageTypeFormat(builder.getImageType(operands.front())) == spv::ImageFormatUnknown)
|
||||
builder.addCapability(spv::CapabilityStorageImageReadWithoutFormat);
|
||||
|
|
@ -3266,6 +3303,14 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
|||
if (sampler.ms) {
|
||||
operands.push_back(spv::ImageOperandsSampleMask);
|
||||
operands.push_back(*opIt++);
|
||||
#ifdef AMD_EXTENSIONS
|
||||
} else if (cracked.lod) {
|
||||
builder.addExtension(spv::E_SPV_AMD_shader_image_load_store_lod);
|
||||
builder.addCapability(spv::CapabilityImageReadWriteLodAMD);
|
||||
|
||||
operands.push_back(spv::ImageOperandsLodMask);
|
||||
operands.push_back(*opIt++);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Create the return type that was a special structure
|
||||
|
|
|
|||
|
|
@ -847,6 +847,7 @@ const char* CapabilityString(int info)
|
|||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case 5009: return "ImageGatherBiasLodAMD";
|
||||
case 5015: return "ImageReadWriteLodAMD";
|
||||
#endif
|
||||
|
||||
case 4445: return "AtomicStorageOps";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue