mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-14 22:29:15 +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:
parent
3d53f318fd
commit
209248e26d
@ -546,16 +546,21 @@ namespace dxvk {
|
|||||||
VkQueryPool queryPool,
|
VkQueryPool queryPool,
|
||||||
uint32_t queryId,
|
uint32_t queryId,
|
||||||
VkEvent event) {
|
VkEvent event) {
|
||||||
m_cmdBuffersUsed.set(DxvkCmdBufferFlag::InitBuffer);
|
if (event == VK_NULL_HANDLE) {
|
||||||
|
m_vkd->vkResetQueryPoolEXT(
|
||||||
|
m_vkd->device(), queryPool, queryId, 1);
|
||||||
|
} else {
|
||||||
|
m_cmdBuffersUsed.set(DxvkCmdBufferFlag::InitBuffer);
|
||||||
|
|
||||||
m_vkd->vkResetEvent(
|
m_vkd->vkResetEvent(
|
||||||
m_vkd->device(), event);
|
m_vkd->device(), event);
|
||||||
|
|
||||||
m_vkd->vkCmdResetQueryPool(
|
m_vkd->vkCmdResetQueryPool(
|
||||||
m_initBuffer, queryPool, queryId, 1);
|
m_initBuffer, queryPool, queryId, 1);
|
||||||
|
|
||||||
m_vkd->vkCmdSetEvent(m_initBuffer,
|
m_vkd->vkCmdSetEvent(m_initBuffer,
|
||||||
event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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)),
|
||||||
|
@ -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;
|
||||||
m_vkd->device(), handle.resetEvent);
|
|
||||||
|
|
||||||
if (result == VK_EVENT_RESET)
|
if (handle.resetEvent) {
|
||||||
return DxvkGpuQueryStatus::Pending;
|
result = m_vkd->vkGetEventStatus(
|
||||||
else if (result != VK_EVENT_SET)
|
m_vkd->device(), handle.resetEvent);
|
||||||
return DxvkGpuQueryStatus::Failed;
|
|
||||||
|
if (result == VK_EVENT_RESET)
|
||||||
|
return DxvkGpuQueryStatus::Pending;
|
||||||
|
else if (result != VK_EVENT_SET)
|
||||||
|
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) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user