Skip to content

Commit 5806431

Browse files
SPV: Add NonUniform decoration for OpImages created during lowering.
By directly creating the OpImage instructions we were not propagating the appropriate decorations. Since this had a lot of cases I centralized the OpImage creation a bit too.
1 parent de949a2 commit 5806431

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

SPIRV/GlslangToSpv.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4753,12 +4753,15 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
47534753

47544754
const bool isUnsignedResult = node->getType().getBasicType() == glslang::EbtUint;
47554755

4756+
if (builder.isSampledImage(params.sampler) &&
4757+
((cracked.query && node->getOp() != glslang::EOpTextureQueryLod) || cracked.fragMask || cracked.fetch)) {
4758+
params.sampler = builder.createUnaryOp(spv::OpImage, builder.getImageType(params.sampler), params.sampler);
4759+
if (imageType.getQualifier().isNonUniform()) {
4760+
builder.addDecoration(params.sampler, spv::DecorationNonUniformEXT);
4761+
}
4762+
}
47564763
// Check for queries
47574764
if (cracked.query) {
4758-
// OpImageQueryLod works on a sampled image, for other queries the image has to be extracted first
4759-
if (node->getOp() != glslang::EOpTextureQueryLod && builder.isSampledImage(params.sampler))
4760-
params.sampler = builder.createUnaryOp(spv::OpImage, builder.getImageType(params.sampler), params.sampler);
4761-
47624765
switch (node->getOp()) {
47634766
case glslang::EOpImageQuerySize:
47644767
case glslang::EOpTextureQuerySize:
@@ -5012,10 +5015,6 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
50125015
auto opIt = arguments.begin();
50135016
std::vector<spv::Id> operands;
50145017

5015-
// Extract the image if necessary
5016-
if (builder.isSampledImage(params.sampler))
5017-
params.sampler = builder.createUnaryOp(spv::OpImage, builder.getImageType(params.sampler), params.sampler);
5018-
50195018
operands.push_back(params.sampler);
50205019
++opIt;
50215020

@@ -5076,13 +5075,6 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
50765075
bias = true;
50775076
}
50785077

5079-
// See if the sampler param should really be just the SPV image part
5080-
if (cracked.fetch) {
5081-
// a fetch needs to have the image extracted first
5082-
if (builder.isSampledImage(params.sampler))
5083-
params.sampler = builder.createUnaryOp(spv::OpImage, builder.getImageType(params.sampler), params.sampler);
5084-
}
5085-
50865078
#ifndef GLSLANG_WEB
50875079
if (cracked.gather) {
50885080
const auto& sourceExtensions = glslangIntermediate->getRequestedExtensions();

0 commit comments

Comments
 (0)