Преглед на файлове

[spirv] Specify proper interface type for structs.

Ehsan преди 6 години
родител
ревизия
4fb651241f
променени са 2 файла, в които са добавени 5 реда и са изтрити 2 реда
  1. 2 0
      tools/clang/lib/SPIRV/EmitVisitor.cpp
  2. 3 2
      tools/clang/lib/SPIRV/SPIRVContext.cpp

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

@@ -1617,6 +1617,8 @@ void EmitTypeHandler::emitDecoration(uint32_t typeResultId,
 void EmitTypeHandler::emitNameForType(llvm::StringRef name,
                                       uint32_t targetTypeId,
                                       llvm::Optional<uint32_t> memberIndex) {
+  if (name.empty())
+    return;
   std::vector<uint32_t> nameInstr;
   auto op = memberIndex.hasValue() ? spv::Op::OpMemberName : spv::Op::OpName;
   nameInstr.push_back(static_cast<uint32_t>(op));

+ 3 - 2
tools/clang/lib/SPIRV/SPIRVContext.cpp

@@ -361,7 +361,7 @@ const StructType *SpirvContext::getByteAddressBufferType(bool isWritable) {
   return getStructType({StructType::FieldInfo(raType)},
                        isWritable ? "type.RWByteAddressBuffer"
                                   : "type.ByteAddressBuffer",
-                       !isWritable);
+                       !isWritable, StructInterfaceType::StorageBuffer);
 }
 
 const StructType *SpirvContext::getACSBufferCounterType() {
@@ -370,7 +370,8 @@ const StructType *SpirvContext::getACSBufferCounterType() {
 
   // Create a struct containing the integer counter as its only member.
   const StructType *type =
-      getStructType({int32Type}, "type.ACSBuffer.counter", {"counter"});
+      getStructType({int32Type}, "type.ACSBuffer.counter", {"counter"},
+                    StructInterfaceType::StorageBuffer);
 
   return type;
 }