class StructType;
} // namespace spirv
-/// According to the Vulkan spec "14.5.4. Offset and Stride Assignment":
+/// According to the Vulkan spec "15.6.4. Offset and Stride Assignment":
/// "There are different alignment requirements depending on the specific
/// resources and on the features enabled on the device."
///
#include "mlir/Dialect/SPIRV/Utils/LayoutUtils.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "llvm/Support/FormatVariadic.h"
+
using namespace mlir;
namespace mlir {
SmallVector<NamedAttribute, 4> globalVarAttrs;
auto ptrType = op.getType().cast<spirv::PointerType>();
- auto structType = VulkanLayoutUtils::decorateType(
- ptrType.getPointeeType().cast<spirv::StructType>());
+ auto pointeeType = ptrType.getPointeeType().cast<spirv::StructType>();
+ spirv::StructType structType = VulkanLayoutUtils::decorateType(pointeeType);
if (!structType)
- return failure();
+ return op->emitError(llvm::formatv(
+ "failed to decorate (unsuported pointee type: '{0}')", pointeeType));
auto decoratedType =
spirv::PointerType::get(structType, ptrType.getStorageClass());
size = std::numeric_limits<Size>().max();
return decorateType(arrayType, alignment);
}
+ if (type.isa<spirv::PointerType>()) {
+ // TODO: Add support for `PhysicalStorageBufferAddresses`.
+ return nullptr;
+ }
llvm_unreachable("unhandled SPIR-V type");
}
// CHECK: spirv.GlobalVariable @var1 : !spirv.ptr<!spirv.struct<(i32 [0])>, PhysicalStorageBuffer>
spirv.GlobalVariable @var1 : !spirv.ptr<!spirv.struct<(i32)>, PhysicalStorageBuffer>
}
+
+// -----
+
+spirv.module Physical64 GLSL450 {
+ // expected-error @+2 {{failed to decorate (unsuported pointee type: '!spirv.struct<rec, (!spirv.ptr<!spirv.struct<rec>, StorageBuffer>)>')}}
+ // expected-error @+1 {{failed to legalize operation 'spirv.GlobalVariable'}}
+ spirv.GlobalVariable @recursive:
+ !spirv.ptr<!spirv.struct<rec, (!spirv.ptr<!spirv.struct<rec>, StorageBuffer>)>, StorageBuffer>
+}