Implement the extension GL_AMD_shader_fragment_mask
This commit is contained in:
@@ -3204,9 +3204,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
||||
glslang::TCrackedTextureOp cracked;
|
||||
node->crackTexture(sampler, cracked);
|
||||
|
||||
const bool isUnsignedResult =
|
||||
node->getType().getBasicType() == glslang::EbtUint64 ||
|
||||
node->getType().getBasicType() == glslang::EbtUint;
|
||||
const bool isUnsignedResult = node->getType().getBasicType() == glslang::EbtUint;
|
||||
|
||||
// Check for queries
|
||||
if (cracked.query) {
|
||||
@@ -3358,6 +3356,45 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
// Check for fragment mask functions other than queries
|
||||
if (cracked.fragMask) {
|
||||
assert(sampler.ms);
|
||||
|
||||
auto opIt = arguments.begin();
|
||||
std::vector<spv::Id> operands;
|
||||
|
||||
// Extract the image if necessary
|
||||
if (builder.isSampledImage(params.sampler))
|
||||
params.sampler = builder.createUnaryOp(spv::OpImage, builder.getImageType(params.sampler), params.sampler);
|
||||
|
||||
operands.push_back(params.sampler);
|
||||
++opIt;
|
||||
|
||||
if (sampler.isSubpass()) {
|
||||
// add on the (0,0) coordinate
|
||||
spv::Id zero = builder.makeIntConstant(0);
|
||||
std::vector<spv::Id> comps;
|
||||
comps.push_back(zero);
|
||||
comps.push_back(zero);
|
||||
operands.push_back(builder.makeCompositeConstant(builder.makeVectorType(builder.makeIntType(32), 2), comps));
|
||||
}
|
||||
|
||||
for (; opIt != arguments.end(); ++opIt)
|
||||
operands.push_back(*opIt);
|
||||
|
||||
spv::Op fragMaskOp = spv::OpNop;
|
||||
if (node->getOp() == glslang::EOpFragmentMaskFetch)
|
||||
fragMaskOp = spv::OpFragmentMaskFetchAMD;
|
||||
else if (node->getOp() == glslang::EOpFragmentFetch)
|
||||
fragMaskOp = spv::OpFragmentFetchAMD;
|
||||
|
||||
builder.addExtension(spv::E_SPV_AMD_shader_fragment_mask);
|
||||
builder.addCapability(spv::CapabilityFragmentMaskAMD);
|
||||
return builder.createOp(fragMaskOp, resultType(), operands);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check for texture functions other than queries
|
||||
bool sparse = node->isSparseTexture();
|
||||
bool cubeCompare = sampler.dim == glslang::EsdCube && sampler.arrayed && sampler.shadow;
|
||||
|
||||
Reference in New Issue
Block a user