[Mlir-commits] [mlir] [mlir][SPIR-V] Refine OpTypeImage capability inference (PR #195060)
Arseniy Obolenskiy
llvmlistbot at llvm.org
Mon May 4 04:10:55 PDT 2026
================
@@ -423,13 +425,102 @@ ImageSamplerUseInfo ImageType::getSamplerUseInfo() const {
ImageFormat ImageType::getImageFormat() const { return getImpl()->format; }
+void TypeExtensionVisitor::addConcrete(ImageType type) {
+ // OpTypeImage with a 64-bit integer Sampled Type requires the
+ // SPV_EXT_shader_image_int64 extension (companion to Int64ImageEXT).
+ if (auto intTy = dyn_cast<IntegerType>(type.getElementType());
+ intTy && intTy.getWidth() == 64) {
+ static constexpr auto ext = Extension::SPV_EXT_shader_image_int64;
+ extensions.push_back(ext);
+ }
+ add(type.getElementType());
+}
+
void TypeCapabilityVisitor::addConcrete(ImageType type) {
- if (auto dimCaps = spirv::getCapabilities(type.getDim()))
- capabilities.push_back(*dimCaps);
+ // Capability requirements for OpTypeImage are determined jointly by Dim,
+ // Sampled, MS, and Arrayed - see the SPIR-V spec's "Capabilities" column on
+ // OpTypeImage.
+ Dim dim = type.getDim();
+ bool isMultisampled =
+ type.getSamplingInfo() == ImageSamplingInfo::MultiSampled;
+ bool isArrayed = type.getArrayedInfo() == ImageArrayedInfo::Arrayed;
+ ImageSamplerUseInfo sampler = type.getSamplerUseInfo();
+ bool noSampler = sampler == ImageSamplerUseInfo::NoSampler;
+ bool needSampler = sampler == ImageSamplerUseInfo::NeedSampler;
+
+ switch (dim) {
+ case Dim::Dim1D: {
+ if (needSampler) {
+ static constexpr auto cap = Capability::Sampled1D;
+ capabilities.push_back(cap);
----------------
aobolensk wrote:
Made a templated function instead of lambda, what do you think about that?
https://github.com/llvm/llvm-project/pull/195060
More information about the Mlir-commits
mailing list