From 63ce674c470bf3a52919794de44908d5ab54e0fd Mon Sep 17 00:00:00 2001
From: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Date: Fri, 8 Nov 2024 19:31:21 +0100
Subject: [PATCH] [dxvk] Add context feature flag for debug utils support

---
 src/dxvk/dxvk_context.cpp     | 16 +++++++++++-----
 src/dxvk/dxvk_context.h       |  1 +
 src/dxvk/dxvk_context_state.h |  1 +
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp
index 9dc614b0e..801e5e899 100644
--- a/src/dxvk/dxvk_context.cpp
+++ b/src/dxvk/dxvk_context.cpp
@@ -63,6 +63,10 @@ namespace dxvk {
     // Maintenance5 introduced a bounded BindIndexBuffer function
     if (m_device->features().khrMaintenance5.maintenance5)
       m_features.set(DxvkContextFeature::IndexBufferRobustness);
+
+    // Add a fast path to query debug utils support
+    if (m_device->isDebugEnabled())
+      m_features.set(DxvkContextFeature::DebugUtils);
   }
   
   
@@ -101,6 +105,8 @@ namespace dxvk {
       m_cmd->trackDescriptorPool(m_descriptorPool, m_descriptorManager);
       m_descriptorPool = m_descriptorManager->getDescriptorPool();
     }
+
+    m_renderPassIndex = 0u;
   }
 
 
@@ -2477,20 +2483,20 @@ namespace dxvk {
   }
 
 
-  void DxvkContext::beginDebugLabel(VkDebugUtilsLabelEXT* label) {
-    if (m_device->isDebugEnabled())
+  void DxvkContext::beginDebugLabel(VkDebugUtilsLabelEXT *label) {
+    if (m_features.test(DxvkContextFeature::DebugUtils))
       m_cmd->cmdBeginDebugUtilsLabel(DxvkCmdBuffer::ExecBuffer, *label);
   }
 
 
   void DxvkContext::endDebugLabel() {
-    if (m_device->isDebugEnabled())
+    if (m_features.test(DxvkContextFeature::DebugUtils))
       m_cmd->cmdEndDebugUtilsLabel(DxvkCmdBuffer::ExecBuffer);
   }
 
 
-  void DxvkContext::insertDebugLabel(VkDebugUtilsLabelEXT* label) {
-    if (m_device->isDebugEnabled())
+  void DxvkContext::insertDebugLabel(VkDebugUtilsLabelEXT *label) {
+    if (m_features.test(DxvkContextFeature::DebugUtils))
       m_cmd->cmdInsertDebugUtilsLabel(DxvkCmdBuffer::ExecBuffer, *label);
   }
   
diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h
index c08e9bf19..d119f6f29 100644
--- a/src/dxvk/dxvk_context.h
+++ b/src/dxvk/dxvk_context.h
@@ -1371,6 +1371,7 @@ namespace dxvk {
     DxvkObjects*            m_common;
 
     uint64_t                m_trackingId = 0u;
+    uint32_t                m_renderPassIndex = 0u;
     
     Rc<DxvkCommandList>     m_cmd;
     Rc<DxvkBuffer>          m_zeroBuffer;
diff --git a/src/dxvk/dxvk_context_state.h b/src/dxvk/dxvk_context_state.h
index b6066cb8a..c29bb4439 100644
--- a/src/dxvk/dxvk_context_state.h
+++ b/src/dxvk/dxvk_context_state.h
@@ -66,6 +66,7 @@ namespace dxvk {
     TrackGraphicsPipeline,
     VariableMultisampleRate,
     IndexBufferRobustness,
+    DebugUtils,
     FeatureCount
   };