Explorar el Código

Updated spirv-tools.

Бранимир Караџић hace 4 años
padre
commit
fe54a8720f

+ 1 - 1
3rdparty/spirv-tools/include/generated/build-version.inc

@@ -1 +1 @@
-"v2021.4-dev", "SPIRV-Tools v2021.4-dev 133b7ce91f51ffb26e674a856ec6692cca650ab3"
+"v2021.4-dev", "SPIRV-Tools v2021.4-dev e180849b89618fde67379735eae3a633a97e293c"

+ 20 - 11
3rdparty/spirv-tools/source/opt/eliminate_dead_members_pass.cpp

@@ -20,6 +20,7 @@
 namespace {
 const uint32_t kRemovedMember = 0xFFFFFFFF;
 const uint32_t kSpecConstOpOpcodeIdx = 0;
+constexpr uint32_t kArrayElementTypeIdx = 0;
 }  // namespace
 
 namespace spvtools {
@@ -64,6 +65,10 @@ void EliminateDeadMembersPass::FindLiveMembers() {
           MarkPointeeTypeAsFullUsed(inst.type_id());
           break;
         default:
+          // Ignore structured buffers as layout(offset) qualifiers cannot be
+          // applied to structure fields
+          if (inst.IsVulkanStorageBufferVariable())
+            MarkPointeeTypeAsFullUsed(inst.type_id());
           break;
       }
     }
@@ -136,18 +141,22 @@ void EliminateDeadMembersPass::MarkMembersAsLiveForStore(
 void EliminateDeadMembersPass::MarkTypeAsFullyUsed(uint32_t type_id) {
   Instruction* type_inst = get_def_use_mgr()->GetDef(type_id);
   assert(type_inst != nullptr);
-  if (type_inst->opcode() != SpvOpTypeStruct) {
-    return;
-  }
-
-  // Mark every member of the current struct as used.
-  for (uint32_t i = 0; i < type_inst->NumInOperands(); ++i) {
-    used_members_[type_id].insert(i);
-  }
 
-  // Mark any sub struct as fully used.
-  for (uint32_t i = 0; i < type_inst->NumInOperands(); ++i) {
-    MarkTypeAsFullyUsed(type_inst->GetSingleWordInOperand(i));
+  switch (type_inst->opcode()) {
+    case SpvOpTypeStruct:
+      // Mark every member and its type as fully used.
+      for (uint32_t i = 0; i < type_inst->NumInOperands(); ++i) {
+        used_members_[type_id].insert(i);
+        MarkTypeAsFullyUsed(type_inst->GetSingleWordInOperand(i));
+      }
+      break;
+    case SpvOpTypeArray:
+    case SpvOpTypeRuntimeArray:
+      MarkTypeAsFullyUsed(
+          type_inst->GetSingleWordInOperand(kArrayElementTypeIdx));
+      break;
+    default:
+      break;
   }
 }
 

+ 16 - 0
3rdparty/spirv-tools/source/opt/instruction.cpp

@@ -30,6 +30,7 @@ namespace {
 const uint32_t kTypeImageDimIndex = 1;
 const uint32_t kLoadBaseIndex = 0;
 const uint32_t kPointerTypeStorageClassIndex = 0;
+const uint32_t kVariableStorageClassIndex = 0;
 const uint32_t kTypeImageSampledIndex = 5;
 
 // Constants for OpenCL.DebugInfo.100 / NonSemantic.Shader.DebugInfo.100
@@ -403,6 +404,21 @@ bool Instruction::IsVulkanStorageBuffer() const {
   return false;
 }
 
+bool Instruction::IsVulkanStorageBufferVariable() const {
+  if (opcode() != SpvOpVariable) {
+    return false;
+  }
+
+  uint32_t storage_class = GetSingleWordInOperand(kVariableStorageClassIndex);
+  if (storage_class == SpvStorageClassStorageBuffer ||
+      storage_class == SpvStorageClassUniform) {
+    Instruction* var_type = context()->get_def_use_mgr()->GetDef(type_id());
+    return var_type != nullptr && var_type->IsVulkanStorageBuffer();
+  }
+
+  return false;
+}
+
 bool Instruction::IsVulkanUniformBuffer() const {
   if (opcode() != SpvOpTypePointer) {
     return false;

+ 4 - 0
3rdparty/spirv-tools/source/opt/instruction.h

@@ -464,6 +464,10 @@ class Instruction : public utils::IntrusiveNodeBase<Instruction> {
   // storage buffer.
   bool IsVulkanStorageBuffer() const;
 
+  // Returns true if the instruction defines a variable in StorageBuffer or
+  // Uniform storage class with a pointer type that points to a storage buffer.
+  bool IsVulkanStorageBufferVariable() const;
+
   // Returns true if the instruction defines a pointer type that points to a
   // uniform buffer.
   bool IsVulkanUniformBuffer() const;

+ 2 - 1
3rdparty/spirv-tools/source/text_handler.cpp

@@ -120,7 +120,8 @@ spv_result_t getWord(spv_text text, spv_position position, std::string* word) {
         case '\n':
         case '\r':
           if (escaping || quoting) break;
-        // Fall through.
+          word->assign(text->str + start_index, text->str + position->index);
+          return SPV_SUCCESS;
         case '\0': {  // NOTE: End of word found!
           word->assign(text->str + start_index, text->str + position->index);
           return SPV_SUCCESS;

+ 7 - 5
3rdparty/spirv-tools/source/val/validate_derivatives.cpp

@@ -79,11 +79,13 @@ spv_result_t DerivativesPass(ValidationState_t& _, const Instruction* inst) {
                                         std::string* message) {
             const auto* models = state.GetExecutionModels(entry_point->id());
             const auto* modes = state.GetExecutionModes(entry_point->id());
-            if (models->find(SpvExecutionModelGLCompute) != models->end() &&
-                modes->find(SpvExecutionModeDerivativeGroupLinearNV) ==
-                    modes->end() &&
-                modes->find(SpvExecutionModeDerivativeGroupQuadsNV) ==
-                    modes->end()) {
+            if (models &&
+                models->find(SpvExecutionModelGLCompute) != models->end() &&
+                (!modes ||
+                 (modes->find(SpvExecutionModeDerivativeGroupLinearNV) ==
+                      modes->end() &&
+                  modes->find(SpvExecutionModeDerivativeGroupQuadsNV) ==
+                      modes->end()))) {
               if (message) {
                 *message = std::string(
                                "Derivative instructions require "