1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-15 07:29:17 +01:00

[dxvk] Use vkResetQueryPoolEXT to reset individual queries

This is much faster than the fallback path which uses GPU functions.
This commit is contained in:
Philip Rebohle 2019-03-14 22:27:47 +01:00
parent 3d53f318fd
commit 209248e26d
4 changed files with 39 additions and 26 deletions

View File

@ -546,6 +546,10 @@ namespace dxvk {
VkQueryPool queryPool, VkQueryPool queryPool,
uint32_t queryId, uint32_t queryId,
VkEvent event) { VkEvent event) {
if (event == VK_NULL_HANDLE) {
m_vkd->vkResetQueryPoolEXT(
m_vkd->device(), queryPool, queryId, 1);
} else {
m_cmdBuffersUsed.set(DxvkCmdBufferFlag::InitBuffer); m_cmdBuffersUsed.set(DxvkCmdBufferFlag::InitBuffer);
m_vkd->vkResetEvent( m_vkd->vkResetEvent(
@ -557,6 +561,7 @@ namespace dxvk {
m_vkd->vkCmdSetEvent(m_initBuffer, m_vkd->vkCmdSetEvent(m_initBuffer,
event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
} }
}
void cmdResetQueryPool( void cmdResetQueryPool(

View File

@ -20,7 +20,7 @@ namespace dxvk {
m_renderPassPool (new DxvkRenderPassPool (vkd)), m_renderPassPool (new DxvkRenderPassPool (vkd)),
m_pipelineManager (new DxvkPipelineManager (this, m_renderPassPool.ptr())), m_pipelineManager (new DxvkPipelineManager (this, m_renderPassPool.ptr())),
m_gpuEventPool (new DxvkGpuEventPool (vkd)), m_gpuEventPool (new DxvkGpuEventPool (vkd)),
m_gpuQueryPool (new DxvkGpuQueryPool (vkd)), m_gpuQueryPool (new DxvkGpuQueryPool (this)),
m_metaClearObjects (new DxvkMetaClearObjects (vkd)), m_metaClearObjects (new DxvkMetaClearObjects (vkd)),
m_metaCopyObjects (new DxvkMetaCopyObjects (vkd)), m_metaCopyObjects (new DxvkMetaCopyObjects (vkd)),
m_metaMipGenObjects (new DxvkMetaMipGenObjects (vkd)), m_metaMipGenObjects (new DxvkMetaMipGenObjects (vkd)),

View File

@ -1,6 +1,7 @@
#include <algorithm> #include <algorithm>
#include "dxvk_cmdlist.h" #include "dxvk_cmdlist.h"
#include "dxvk_device.h"
#include "dxvk_gpu_query.h" #include "dxvk_gpu_query.h"
namespace dxvk { namespace dxvk {
@ -90,13 +91,17 @@ namespace dxvk {
DxvkQueryData tmpData; DxvkQueryData tmpData;
// Wait for the query to be reset first // Wait for the query to be reset first
VkResult result = m_vkd->vkGetEventStatus( VkResult result;
if (handle.resetEvent) {
result = m_vkd->vkGetEventStatus(
m_vkd->device(), handle.resetEvent); m_vkd->device(), handle.resetEvent);
if (result == VK_EVENT_RESET) if (result == VK_EVENT_RESET)
return DxvkGpuQueryStatus::Pending; return DxvkGpuQueryStatus::Pending;
else if (result != VK_EVENT_SET) else if (result != VK_EVENT_SET)
return DxvkGpuQueryStatus::Failed; return DxvkGpuQueryStatus::Failed;
}
// Try to copy query data to temporary structure // Try to copy query data to temporary structure
result = m_vkd->vkGetQueryPoolResults(m_vkd->device(), result = m_vkd->vkGetQueryPoolResults(m_vkd->device(),
@ -150,10 +155,11 @@ namespace dxvk {
DxvkGpuQueryAllocator::DxvkGpuQueryAllocator( DxvkGpuQueryAllocator::DxvkGpuQueryAllocator(
const Rc<vk::DeviceFn>& vkd, const Rc<DxvkDevice>& device,
VkQueryType queryType, VkQueryType queryType,
uint32_t queryPoolSize) uint32_t queryPoolSize)
: m_vkd (vkd), : m_device (device),
m_vkd (device->vkd()),
m_queryType (queryType), m_queryType (queryType),
m_queryPoolSize (queryPoolSize) { m_queryPoolSize (queryPoolSize) {
@ -235,7 +241,8 @@ namespace dxvk {
for (uint32_t i = 0; i < m_queryPoolSize; i++) { for (uint32_t i = 0; i < m_queryPoolSize; i++) {
VkEvent event = VK_NULL_HANDLE; VkEvent event = VK_NULL_HANDLE;
if (m_vkd->vkCreateEvent(m_vkd->device(), &eventInfo, nullptr, &event)) { if (!m_device->features().extHostQueryReset.hostQueryReset
&& m_vkd->vkCreateEvent(m_vkd->device(), &eventInfo, nullptr, &event) != VK_SUCCESS) {
Logger::err("DXVK: Failed to create query reset event"); Logger::err("DXVK: Failed to create query reset event");
return; return;
} }
@ -247,11 +254,11 @@ namespace dxvk {
DxvkGpuQueryPool::DxvkGpuQueryPool(const Rc<vk::DeviceFn>& vkd) DxvkGpuQueryPool::DxvkGpuQueryPool(const Rc<DxvkDevice>& device)
: m_occlusion(vkd, VK_QUERY_TYPE_OCCLUSION, 256), : m_occlusion(device, VK_QUERY_TYPE_OCCLUSION, 256),
m_statistic(vkd, VK_QUERY_TYPE_PIPELINE_STATISTICS, 64), m_statistic(device, VK_QUERY_TYPE_PIPELINE_STATISTICS, 64),
m_timestamp(vkd, VK_QUERY_TYPE_TIMESTAMP, 64), m_timestamp(device, VK_QUERY_TYPE_TIMESTAMP, 64),
m_xfbStream(vkd, VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT, 64) { m_xfbStream(device, VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT, 64) {
} }

View File

@ -247,7 +247,7 @@ namespace dxvk {
public: public:
DxvkGpuQueryAllocator( DxvkGpuQueryAllocator(
const Rc<vk::DeviceFn>& vkd, const Rc<DxvkDevice>& device,
VkQueryType queryType, VkQueryType queryType,
uint32_t queryPoolSize); uint32_t queryPoolSize);
@ -275,6 +275,7 @@ namespace dxvk {
private: private:
Rc<DxvkDevice> m_device;
Rc<vk::DeviceFn> m_vkd; Rc<vk::DeviceFn> m_vkd;
VkQueryType m_queryType; VkQueryType m_queryType;
uint32_t m_queryPoolSize; uint32_t m_queryPoolSize;
@ -299,7 +300,7 @@ namespace dxvk {
public: public:
DxvkGpuQueryPool( DxvkGpuQueryPool(
const Rc<vk::DeviceFn>& vkd); const Rc<DxvkDevice>& device);
~DxvkGpuQueryPool(); ~DxvkGpuQueryPool();