diff --git a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp --- a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp @@ -205,6 +205,11 @@ // from TargetEnvAttr to selected between Physical32 and Physical64. if (cap == Capability::Kernel) return spirv::AddressingModel::Physical64; + // TODO PhysicalStorageBuffer64 is hard-coded here, but some information + // should come from TargetEnvAttr to select between PhysicalStorageBuffer64 + // and PhysicalStorageBuffer64EXT + if (cap == Capability::PhysicalStorageBufferAddresses) + return spirv::AddressingModel::PhysicalStorageBuffer64; } // Logical addressing doesn't need any capabilities so return it as default. return spirv::AddressingModel::Logical; diff --git a/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir b/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir @@ -49,6 +49,18 @@ } } +// Test Physical Storage Buffers are deduced correctly. + +// CHECK: spv.module PhysicalStorageBuffer64 GLSL450 requires #spv.vce +spv.module PhysicalStorageBuffer64 GLSL450 attributes { + spv.target_env = #spv.target_env< + #spv.vce, {}> +} { + spv.func @physical_ptr(%val : !spv.ptr) "None" { + spv.Return + } +} + // Test deducing implied capability. // AtomicStorage implies Shader.