Skip to content

Commit

Permalink
alan feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rjodinchr committed Sep 20, 2023
1 parent 8574223 commit 73f3313
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions lib/SamplerUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
// limitations under the License.

#include "SamplerUtils.h"
#include "Types.h"
#include "Builtins.h"
#include "BuiltinsEnum.h"
#include "Constants.h"
#include "Types.h"

using namespace llvm;

Expand Down Expand Up @@ -44,20 +46,27 @@ Value *NormalizedCoordinate(Module &M, IRBuilder<> &B, Value *Coord,
}

bool isReadImage3DWithNonLiteralSampler(CallInst *call) {
DenseMap<Value *, Type *> cache;
auto Name = call->getCalledFunction()->getName();
if (Name.contains("read_image") && Name.contains("ocl_sampler")) {
Type *ImgTy =
clspv::InferType(call->getOperand(0), call->getContext(), &cache);
auto sampler_call = dyn_cast<CallInst>(call->getOperand(1));
bool literal_sampler =
sampler_call && (sampler_call->getCalledFunction()->getName().contains(
TranslateSamplerInitializerFunction()) ||
sampler_call->getCalledFunction()->getName().contains(
LiteralSamplerFunction()));
if (clspv::ImageDimensionality(ImgTy) == spv::Dim3D && !literal_sampler) {
return true;
auto FI = Builtins::Lookup(call->getCalledFunction());
switch (FI.getType()) {
case Builtins::kReadImagef:
case Builtins::kReadImagei:
case Builtins::kReadImageui: {
if (FI.getParameter(1).isSampler()) {
Type *ImgTy = call->getOperand(0)->getType();
auto sampler_call = dyn_cast<CallInst>(call->getOperand(1));
bool literal_sampler =
sampler_call &&
(sampler_call->getCalledFunction()->getName().contains(
TranslateSamplerInitializerFunction()) ||
sampler_call->getCalledFunction()->getName().contains(
LiteralSamplerFunction()));
if (clspv::ImageDimensionality(ImgTy) == spv::Dim3D && !literal_sampler) {
return true;
}
}
} break;
default:
break;
}
return false;
}
Expand Down

0 comments on commit 73f3313

Please sign in to comment.