[Mlir-commits] [mlir] 32e6cbe - [mlir][spirv] Add missing interface storage classes in serializer
Lei Zhang
llvmlistbot at llvm.org
Mon Apr 13 10:35:05 PDT 2020
Author: Lei Zhang
Date: 2020-04-13T13:34:58-04:00
New Revision: 32e6cbe2032004f3114b20f272b0e33d2b9d6bfb
URL: https://github.com/llvm/llvm-project/commit/32e6cbe2032004f3114b20f272b0e33d2b9d6bfb
DIFF: https://github.com/llvm/llvm-project/commit/32e6cbe2032004f3114b20f272b0e33d2b9d6bfb.diff
LOG: [mlir][spirv] Add missing interface storage classes in serializer
Differential Revision: https://reviews.llvm.org/D78037
Added:
Modified:
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
index 400f40d70ee1..5dbc4600db5a 100644
--- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
+++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
@@ -239,8 +239,8 @@ class Serializer {
bool isVoidType(Type type) const { return type.isa<NoneType>(); }
- /// Returns true if the given type is a pointer type to a struct in Uniform or
- /// StorageBuffer storage class.
+ /// Returns true if the given type is a pointer type to a struct in some
+ /// interface storage class.
bool isInterfaceStructPtrType(Type type) const;
/// Main dispatch method for serializing a type. The result <id> of the
@@ -900,12 +900,19 @@ Serializer::processGlobalVariableOp(spirv::GlobalVariableOp varOp) {
// Type
//===----------------------------------------------------------------------===//
+// According to the SPIR-V spec "Validation Rules for Shader Capabilities":
+// "Composite objects in the StorageBuffer, PhysicalStorageBuffer, Uniform, and
+// PushConstant Storage Classes must be explicitly laid out."
bool Serializer::isInterfaceStructPtrType(Type type) const {
if (auto ptrType = type.dyn_cast<spirv::PointerType>()) {
- auto storageClass = ptrType.getStorageClass();
- if (storageClass == spirv::StorageClass::Uniform ||
- storageClass == spirv::StorageClass::StorageBuffer) {
+ switch (ptrType.getStorageClass()) {
+ case spirv::StorageClass::PhysicalStorageBuffer:
+ case spirv::StorageClass::PushConstant:
+ case spirv::StorageClass::StorageBuffer:
+ case spirv::StorageClass::Uniform:
return ptrType.getPointeeType().isa<spirv::StructType>();
+ default:
+ break;
}
}
return false;
More information about the Mlir-commits
mailing list