Skip to content

Commit

Permalink
[dxvk] Add support for debug utils labels
Browse files Browse the repository at this point in the history
Reviewed-by: Oleg Kuznetsov <[email protected]>
  • Loading branch information
liam-middlebrook authored and doitsujin committed Apr 8, 2021
1 parent c89b274 commit 5ce5999
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/dxvk/dxvk_cmdlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -206,4 +207,15 @@ namespace dxvk {
return m_vkd->vkQueueSubmit(queue, 1, &submitInfo, fence);
}

}
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);
}
}
9 changes: 8 additions & 1 deletion src/dxvk/dxvk_cmdlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,10 +762,17 @@ namespace dxvk {
pipelineStage, queryPool, query);
}

void cmdBeginDebugUtilsLabel(VkDebugUtilsLabelEXT *pLabelInfo);

void cmdEndDebugUtilsLabel();

void cmdInsertDebugUtilsLabel(VkDebugUtilsLabelEXT *pLabelInfo);

private:

DxvkDevice* m_device;
Rc<vk::DeviceFn> m_vkd;
Rc<vk::InstanceFn> m_vki;

VkFence m_fence;

Expand Down Expand Up @@ -801,4 +808,4 @@ namespace dxvk {

};

}
}
23 changes: 22 additions & 1 deletion src/dxvk/dxvk_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -5026,4 +5047,4 @@ namespace dxvk {
return m_zeroBuffer;
}

}
}
29 changes: 27 additions & 2 deletions src/dxvk/dxvk_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<DxvkDevice> m_device;
Expand Down Expand Up @@ -1246,4 +1271,4 @@ namespace dxvk {

};

}
}
3 changes: 2 additions & 1 deletion src/dxvk/dxvk_extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};

}
}
8 changes: 7 additions & 1 deletion src/dxvk/dxvk_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,17 @@ namespace dxvk {
VkInstance DxvkInstance::createInstance() {
DxvkInstanceExtensions insExtensions;

std::array<DxvkExt*, 2> insExtensionList = {{
std::vector<DxvkExt*> 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);

Expand Down
8 changes: 7 additions & 1 deletion src/vulkan/vulkan_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -343,4 +349,4 @@ namespace dxvk::vk {
#endif
};

}
}

0 comments on commit 5ce5999

Please sign in to comment.