@@ -4753,12 +4753,15 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
4753
4753
4754
4754
const bool isUnsignedResult = node->getType ().getBasicType () == glslang::EbtUint;
4755
4755
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
+ }
4756
4763
// Check for queries
4757
4764
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
-
4762
4765
switch (node->getOp ()) {
4763
4766
case glslang::EOpImageQuerySize:
4764
4767
case glslang::EOpTextureQuerySize:
@@ -5012,10 +5015,6 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
5012
5015
auto opIt = arguments.begin ();
5013
5016
std::vector<spv::Id> operands;
5014
5017
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
-
5019
5018
operands.push_back (params.sampler );
5020
5019
++opIt;
5021
5020
@@ -5076,13 +5075,6 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
5076
5075
bias = true ;
5077
5076
}
5078
5077
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
-
5086
5078
#ifndef GLSLANG_WEB
5087
5079
if (cracked.gather ) {
5088
5080
const auto & sourceExtensions = glslangIntermediate->getRequestedExtensions ();
0 commit comments