diff --git a/README.md b/README.md index e4b8bc46..82a1fc1a 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,7 @@ The following environment variables can be used for **debugging** purposes. - `DXVK_LOG_LEVEL=none|error|warn|info|debug` Controls message logging. - `DXVK_LOG_PATH=/some/directory` Changes path where log files are stored. Set to `none` to disable log file creation entirely, without disabling logging. - `DXVK_CONFIG_FILE=/xxx/dxvk.conf` Sets path to the configuration file. +- `DXVK_PERF_EVENTS=1` Enables use of the VK_EXT_debug_utils extension for translating performance event markers. ## Troubleshooting DXVK requires threading support from your mingw-w64 build environment. If you diff --git a/src/dxvk/dxvk_cmdlist.cpp b/src/dxvk/dxvk_cmdlist.cpp index e510313a..edda53db 100644 --- a/src/dxvk/dxvk_cmdlist.cpp +++ b/src/dxvk/dxvk_cmdlist.cpp @@ -6,6 +6,7 @@ namespace dxvk { DxvkCommandList::DxvkCommandList(DxvkDevice* device) : m_device (device), m_vkd (device->vkd()), + m_vki (device->instance()->vki()), m_cmdBuffersUsed(0), m_descriptorPoolTracker(device) { const auto& graphicsQueue = m_device->queues().graphics; @@ -206,4 +207,15 @@ namespace dxvk { return m_vkd->vkQueueSubmit(queue, 1, &submitInfo, fence); } -} \ No newline at end of file + void DxvkCommandList::cmdBeginDebugUtilsLabel(VkDebugUtilsLabelEXT *pLabelInfo) { + m_vki->vkCmdBeginDebugUtilsLabelEXT(m_execBuffer, pLabelInfo); + } + + void DxvkCommandList::cmdEndDebugUtilsLabel() { + m_vki->vkCmdEndDebugUtilsLabelEXT(m_execBuffer); + } + + void DxvkCommandList::cmdInsertDebugUtilsLabel(VkDebugUtilsLabelEXT *pLabelInfo) { + m_vki->vkCmdInsertDebugUtilsLabelEXT(m_execBuffer, pLabelInfo); + } +} diff --git a/src/dxvk/dxvk_cmdlist.h b/src/dxvk/dxvk_cmdlist.h index 28f11cd9..29761af2 100644 --- a/src/dxvk/dxvk_cmdlist.h +++ b/src/dxvk/dxvk_cmdlist.h @@ -762,10 +762,17 @@ namespace dxvk { pipelineStage, queryPool, query); } + void cmdBeginDebugUtilsLabel(VkDebugUtilsLabelEXT *pLabelInfo); + + void cmdEndDebugUtilsLabel(); + + void cmdInsertDebugUtilsLabel(VkDebugUtilsLabelEXT *pLabelInfo); + private: DxvkDevice* m_device; Rc m_vkd; + Rc m_vki; VkFence m_fence; @@ -801,4 +808,4 @@ namespace dxvk { }; -} \ No newline at end of file +} diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index e7130d02..d798a819 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -2485,6 +2485,27 @@ namespace dxvk { void DxvkContext::trimStagingBuffers() { m_staging.trim(); } + + void DxvkContext::beginDebugLabel(VkDebugUtilsLabelEXT *label) { + if (!m_device->instance()->extensions().extDebugUtils) + return; + + m_cmd->cmdBeginDebugUtilsLabel(label); + } + + void DxvkContext::endDebugLabel() { + if (!m_device->instance()->extensions().extDebugUtils) + return; + + m_cmd->cmdEndDebugUtilsLabel(); + } + + void DxvkContext::insertDebugLabel(VkDebugUtilsLabelEXT *label) { + if (!m_device->instance()->extensions().extDebugUtils) + return; + + m_cmd->cmdInsertDebugUtilsLabel(label); + } void DxvkContext::blitImageFb( @@ -5026,4 +5047,4 @@ namespace dxvk { return m_zeroBuffer; } -} \ No newline at end of file +} diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 4b5231f3..ad5391dc 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -981,7 +981,32 @@ namespace dxvk { * given context are rare. */ void trimStagingBuffers(); - + + /** + * \brief Begins a debug label region + * \param [in] label The debug label + * + * Marks the start of a debug label region. Used by debugging/profiling + * tools to mark different workloads within a frame. + */ + void beginDebugLabel(VkDebugUtilsLabelEXT *label); + + /** + * \brief Ends a debug label region + * + * Marks the close of a debug label region. Used by debugging/profiling + * tools to mark different workloads within a frame. + */ + void endDebugLabel(); + + /** + * \brief Inserts a debug label + * \param [in] label The debug label + * + * Inserts an instantaneous debug label. Used by debugging/profiling + * tools to mark different workloads within a frame. + */ + void insertDebugLabel(VkDebugUtilsLabelEXT *label); private: Rc m_device; @@ -1246,4 +1271,4 @@ namespace dxvk { }; -} \ No newline at end of file +} diff --git a/src/dxvk/dxvk_extensions.h b/src/dxvk/dxvk_extensions.h index 0a21a6cb..a9de1966 100644 --- a/src/dxvk/dxvk_extensions.h +++ b/src/dxvk/dxvk_extensions.h @@ -292,8 +292,9 @@ namespace dxvk { * used by DXVK if supported by the implementation. */ struct DxvkInstanceExtensions { + DxvkExt extDebugUtils = { VK_EXT_DEBUG_UTILS_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt khrGetSurfaceCapabilities2 = { VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt khrSurface = { VK_KHR_SURFACE_EXTENSION_NAME, DxvkExtMode::Required }; }; -} \ No newline at end of file +} diff --git a/src/dxvk/dxvk_instance.cpp b/src/dxvk/dxvk_instance.cpp index 0ce7d568..8af4a051 100644 --- a/src/dxvk/dxvk_instance.cpp +++ b/src/dxvk/dxvk_instance.cpp @@ -91,11 +91,17 @@ namespace dxvk { VkInstance DxvkInstance::createInstance() { DxvkInstanceExtensions insExtensions; - std::array insExtensionList = {{ + std::vector insExtensionList = {{ &insExtensions.khrGetSurfaceCapabilities2, &insExtensions.khrSurface, }}; + // Hide VK_EXT_debug_utils behind an environment variable. This extension + // adds additional overhead to winevulkan + if (env::getEnvVar("DXVK_PERF_EVENTS") == "1") { + insExtensionList.push_back(&insExtensions.extDebugUtils); + } + DxvkNameSet extensionsEnabled; DxvkNameSet extensionsAvailable = DxvkNameSet::enumInstanceExtensions(m_vkl); diff --git a/src/vulkan/vulkan_loader.h b/src/vulkan/vulkan_loader.h index 852b3f52..bf1deeb6 100644 --- a/src/vulkan/vulkan_loader.h +++ b/src/vulkan/vulkan_loader.h @@ -140,6 +140,12 @@ namespace dxvk::vk { VULKAN_FN(vkDebugReportMessageEXT); #endif + #ifdef VK_EXT_debug_utils + VULKAN_FN(vkCmdBeginDebugUtilsLabelEXT); + VULKAN_FN(vkCmdEndDebugUtilsLabelEXT); + VULKAN_FN(vkCmdInsertDebugUtilsLabelEXT); + #endif + #ifdef VK_EXT_full_screen_exclusive VULKAN_FN(vkGetPhysicalDeviceSurfacePresentModes2EXT); #endif @@ -343,4 +349,4 @@ namespace dxvk::vk { #endif }; -} \ No newline at end of file +}