ソースを参照

[spirv] Can't compute ArrayStride for RAs of Images

RuntimeArray types could contain images in which case we cannot
calculate the array stride.
Ehsan Nasiri 6 年 前
コミット
e6b0351371
1 ファイル変更4 行追加2 行削除
  1. 4 2
      tools/clang/lib/SPIRV/EmitVisitor.cpp

+ 4 - 2
tools/clang/lib/SPIRV/EmitVisitor.cpp

@@ -1101,8 +1101,10 @@ void EmitTypeHandler::getDecorationsForType(const SpirvType *type,
   }
   // RuntimeArray types
   else if (const auto *raType = dyn_cast<RuntimeArrayType>(type)) {
-    // ArrayStride decoration is needed for runtime array types.
-    if (rule != SpirvLayoutRule::Void) {
+    // ArrayStride decoration is needed for runtime arrays containing structures
+    // (StructuredBuffers).
+    if (rule != SpirvLayoutRule::Void &&
+        !isa<ImageType>(raType->getElementType())) {
       uint32_t stride = 0;
       (void)getAlignmentAndSize(type, rule, &stride);
       decs->push_back(DecorationInfo(spv::Decoration::ArrayStride, {stride}));