@@ -761,6 +761,22 @@ SPIRVToOCLBase::mutateCallImageOperands(CallInst *CI, StringRef NewFuncName,
761
761
return Mutator;
762
762
}
763
763
764
+ static bool isOCLDepthImage (Type *Ty) {
765
+ if (auto *TET = dyn_cast<TargetExtType>(Ty)) {
766
+ if (TET->getName () != " spirv.Image" )
767
+ return false ;
768
+ assert (TET->getNumIntParameters () > 2 &&
769
+ " unexpected image TargetExtType parameter count" );
770
+ return TET->getIntParameter (1 );
771
+ }
772
+
773
+ StringRef ImageTypeName;
774
+ if (isOCLImageType (Ty, &ImageTypeName))
775
+ return ImageTypeName.contains (" _depth_" );
776
+
777
+ return false ;
778
+ }
779
+
764
780
void SPIRVToOCLBase::visitCallSPIRVImageSampleExplicitLodBuiltIn (CallInst *CI,
765
781
Op OC) {
766
782
Type *T = CI->getType ();
@@ -772,12 +788,8 @@ void SPIRVToOCLBase::visitCallSPIRVImageSampleExplicitLodBuiltIn(CallInst *CI,
772
788
CallInst *CallSampledImg = cast<CallInst>(CI->getArgOperand (0 ));
773
789
auto Img = getCallValue (CallSampledImg, 0 );
774
790
auto Sampler = getCallValue (CallSampledImg, 1 );
775
- bool IsDepthImage = false ;
791
+ const bool IsDepthImage = isOCLDepthImage (Img. second ) ;
776
792
Mutator.mapArg (0 , [&](Value *SampledImg) {
777
- StringRef ImageTypeName;
778
- if (isOCLImageType (Img.second , &ImageTypeName))
779
- IsDepthImage = ImageTypeName.contains (" _depth_" );
780
-
781
793
if (CallSampledImg->hasOneUse ()) {
782
794
CallSampledImg->replaceAllUsesWith (
783
795
PoisonValue::get (CallSampledImg->getType ()));
0 commit comments