Don't add variable pointers due to images and samplers (#447)
Fixes #438
* Do not add VariablePointersStorageBuffer capability due to image or
sampler function parameters
* new tests
diff --git a/lib/SPIRVProducerPass.cpp b/lib/SPIRVProducerPass.cpp
index 7d5d550..33a5c7c 100644
--- a/lib/SPIRVProducerPass.cpp
+++ b/lib/SPIRVProducerPass.cpp
@@ -5067,7 +5067,11 @@
FunctionType *CalleeFTy = cast<FunctionType>(Call->getFunctionType());
for (unsigned i = 0; i < CalleeFTy->getNumParams(); i++) {
auto *operand = Call->getOperand(i);
- if (operand->getType()->isPointerTy()) {
+ auto *operand_type = operand->getType();
+ // Images and samplers can be passed as function parameters without
+ // variable pointers.
+ if (operand_type->isPointerTy() && !IsImageType(operand_type) &&
+ !IsSamplerType(operand_type)) {
auto sc =
GetStorageClass(operand->getType()->getPointerAddressSpace());
if (sc == spv::StorageClassStorageBuffer) {