1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-30 22:24:15 +01:00

[dxvk] Added Query stub

This commit is contained in:
Philip Rebohle 2018-02-08 19:32:53 +01:00
parent 8f134bafcf
commit 8a4fa0b1b8
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
5 changed files with 115 additions and 0 deletions

View File

@ -96,6 +96,15 @@ namespace dxvk {
}
void cmdBeginQuery(
VkQueryPool queryPool,
uint32_t query,
VkQueryControlFlags flags) {
m_vkd->vkCmdBeginQuery(m_buffer,
queryPool, query, flags);
}
void cmdBeginRenderPass(
const VkRenderPassBeginInfo* pRenderPassBegin,
VkSubpassContents contents) {
@ -300,6 +309,13 @@ namespace dxvk {
}
void cmdEndQuery(
VkQueryPool queryPool,
uint32_t query) {
m_vkd->vkCmdEndQuery(m_buffer, queryPool, query);
}
void cmdEndRenderPass() {
m_vkd->vkCmdEndRenderPass(m_buffer);
}
@ -344,6 +360,15 @@ namespace dxvk {
}
void cmdResetQueryPool(
VkQueryPool queryPool,
uint32_t firstQuery,
uint32_t queryCount) {
m_vkd->vkCmdResetQueryPool(m_buffer,
queryPool, firstQuery, queryCount);
}
void cmdResolveImage(
VkImage srcImage,
VkImageLayout srcImageLayout,
@ -399,6 +424,15 @@ namespace dxvk {
}
void cmdWriteTimestamp(
VkPipelineStageFlagBits pipelineStage,
VkQueryPool queryPool,
uint32_t query) {
m_vkd->vkCmdWriteTimestamp(m_buffer,
pipelineStage, queryPool, query);
}
DxvkStagingBufferSlice stagedAlloc(
VkDeviceSize size);

View File

@ -13,6 +13,7 @@ namespace dxvk {
MaxNumResourceSlots = 1096,
MaxNumActiveBindings = 128,
MaxNumQueuedCommandBuffers = 8,
MaxNumQueryCountPerPool = 16,
MaxVertexBindingStride = 2048,
MaxPushConstantSize = 128,
};

38
src/dxvk/dxvk_query.cpp Normal file
View File

@ -0,0 +1,38 @@
#include "dxvk_query.h"
namespace dxvk {
DxvkQuery::DxvkQuery(
const Rc<vk::DeviceFn>& vkd,
VkQueryType type)
: m_vkd(vkd), m_type(type) {
VkQueryPoolCreateInfo info;
info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
info.pNext = nullptr;
info.flags = 0;
info.queryType = type;
info.queryCount = MaxNumQueryCountPerPool;
info.pipelineStatistics
= VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT
| VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT
| VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT
| VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT
| VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT
| VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT
| VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT
| VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT
| VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT
| VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT
| VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT;
if (m_vkd->vkCreateQueryPool(m_vkd->device(), &info, nullptr, &m_queryPool) != VK_SUCCESS)
throw DxvkError("DXVK: Failed to create query pool");
}
DxvkQuery::~DxvkQuery() {
m_vkd->vkDestroyQueryPool(
m_vkd->device(), m_queryPool, nullptr);
}
}

41
src/dxvk/dxvk_query.h Normal file
View File

@ -0,0 +1,41 @@
#pragma once
#include "dxvk_limits.h"
namespace dxvk {
/**
* \brief DXVK query object
*
* Creates a Vulkan query pool that acts as if it
* were a single query. This approach is necessary
* in order to keep evaluating the query across
* multiple command submissions.
*/
class DxvkQuery {
public:
DxvkQuery(
const Rc<vk::DeviceFn>& vkd,
VkQueryType type);
~DxvkQuery();
/**
* \brief Query pool handle
* \returns Query pool handle
*/
VkQueryPool handle() const {
return m_queryPool;
}
private:
Rc<vk::DeviceFn> m_vkd = nullptr;
VkQueryType m_type = VK_QUERY_TYPE_END_RANGE;
VkQueryPool m_queryPool = VK_NULL_HANDLE;
uint32_t m_queryId = 0;
};
}

View File

@ -28,6 +28,7 @@ dxvk_src = files([
'dxvk_pipecache.cpp',
'dxvk_pipelayout.cpp',
'dxvk_pipemanager.cpp',
'dxvk_query.cpp',
'dxvk_queue.cpp',
'dxvk_renderpass.cpp',
'dxvk_resource.cpp',