mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 06:53:40 +00:00
- add VulkanQueryPool and QueryPoolBuilder
This commit is contained in:
parent
5634b67981
commit
d504acad68
2 changed files with 93 additions and 0 deletions
|
@ -159,6 +159,19 @@ private:
|
|||
VkDescriptorPoolCreateInfo poolInfo = {};
|
||||
};
|
||||
|
||||
class QueryPoolBuilder
|
||||
{
|
||||
public:
|
||||
QueryPoolBuilder();
|
||||
|
||||
void setQueryType(VkQueryType type, int count, VkQueryPipelineStatisticFlags pipelineStatistics = 0);
|
||||
|
||||
std::unique_ptr<VulkanQueryPool> create(VulkanDevice *device);
|
||||
|
||||
private:
|
||||
VkQueryPoolCreateInfo poolInfo = {};
|
||||
};
|
||||
|
||||
class FramebufferBuilder
|
||||
{
|
||||
public:
|
||||
|
@ -641,6 +654,29 @@ inline std::unique_ptr<VulkanDescriptorPool> DescriptorPoolBuilder::create(Vulka
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline QueryPoolBuilder::QueryPoolBuilder()
|
||||
{
|
||||
poolInfo.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
|
||||
}
|
||||
|
||||
inline void QueryPoolBuilder::setQueryType(VkQueryType type, int count, VkQueryPipelineStatisticFlags pipelineStatistics)
|
||||
{
|
||||
poolInfo.queryType = type;
|
||||
poolInfo.queryCount = count;
|
||||
poolInfo.pipelineStatistics = pipelineStatistics;
|
||||
}
|
||||
|
||||
inline std::unique_ptr<VulkanQueryPool> QueryPoolBuilder::create(VulkanDevice *device)
|
||||
{
|
||||
VkQueryPool queryPool;
|
||||
VkResult result = vkCreateQueryPool(device->device, &poolInfo, nullptr, &queryPool);
|
||||
if (result != VK_SUCCESS)
|
||||
I_FatalError("Could not create query pool");
|
||||
return std::make_unique<VulkanQueryPool>(device, queryPool);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline FramebufferBuilder::FramebufferBuilder()
|
||||
{
|
||||
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||
|
|
|
@ -202,6 +202,22 @@ private:
|
|||
VulkanDescriptorPool &operator=(const VulkanDescriptorPool &) = delete;
|
||||
};
|
||||
|
||||
class VulkanQueryPool
|
||||
{
|
||||
public:
|
||||
VulkanQueryPool(VulkanDevice *device, VkQueryPool pool);
|
||||
~VulkanQueryPool();
|
||||
|
||||
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_QUERY_POOL); }
|
||||
|
||||
VulkanDevice *device = nullptr;
|
||||
VkQueryPool pool = VK_NULL_HANDLE;
|
||||
|
||||
private:
|
||||
VulkanQueryPool(const VulkanQueryPool &) = delete;
|
||||
VulkanQueryPool &operator=(const VulkanQueryPool &) = delete;
|
||||
};
|
||||
|
||||
class VulkanPipeline
|
||||
{
|
||||
public:
|
||||
|
@ -317,10 +333,15 @@ public:
|
|||
void resetEvent(VkEvent event, VkPipelineStageFlags stageMask);
|
||||
void waitEvents(uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers);
|
||||
void pipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers);
|
||||
void beginQuery(VulkanQueryPool *queryPool, uint32_t query, VkQueryControlFlags flags);
|
||||
void beginQuery(VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags);
|
||||
void endQuery(VulkanQueryPool *queryPool, uint32_t query);
|
||||
void endQuery(VkQueryPool queryPool, uint32_t query);
|
||||
void resetQueryPool(VulkanQueryPool *queryPool, uint32_t firstQuery, uint32_t queryCount);
|
||||
void resetQueryPool(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount);
|
||||
void writeTimestamp(VkPipelineStageFlagBits pipelineStage, VulkanQueryPool *queryPool, uint32_t query);
|
||||
void writeTimestamp(VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query);
|
||||
void copyQueryPoolResults(VulkanQueryPool *queryPool, uint32_t firstQuery, uint32_t queryCount, VulkanBuffer *dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags);
|
||||
void copyQueryPoolResults(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags);
|
||||
void pushConstants(VulkanPipelineLayout *layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void* pValues);
|
||||
void pushConstants(VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void* pValues);
|
||||
|
@ -775,26 +796,51 @@ inline void VulkanCommandBuffer::pipelineBarrier(VkPipelineStageFlags srcStageMa
|
|||
vkCmdPipelineBarrier(buffer, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::beginQuery(VulkanQueryPool *queryPool, uint32_t query, VkQueryControlFlags flags)
|
||||
{
|
||||
beginQuery(queryPool->pool, query, flags);
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::beginQuery(VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags)
|
||||
{
|
||||
vkCmdBeginQuery(buffer, queryPool, query, flags);
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::endQuery(VulkanQueryPool *queryPool, uint32_t query)
|
||||
{
|
||||
endQuery(queryPool->pool, query);
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::endQuery(VkQueryPool queryPool, uint32_t query)
|
||||
{
|
||||
vkCmdEndQuery(buffer, queryPool, query);
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::resetQueryPool(VulkanQueryPool *queryPool, uint32_t firstQuery, uint32_t queryCount)
|
||||
{
|
||||
resetQueryPool(queryPool->pool, firstQuery, queryCount);
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::resetQueryPool(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
|
||||
{
|
||||
vkCmdResetQueryPool(buffer, queryPool, firstQuery, queryCount);
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::writeTimestamp(VkPipelineStageFlagBits pipelineStage, VulkanQueryPool *queryPool, uint32_t query)
|
||||
{
|
||||
writeTimestamp(pipelineStage, queryPool, query);
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::writeTimestamp(VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query)
|
||||
{
|
||||
vkCmdWriteTimestamp(buffer, pipelineStage, queryPool, query);
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::copyQueryPoolResults(VulkanQueryPool *queryPool, uint32_t firstQuery, uint32_t queryCount, VulkanBuffer *dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags)
|
||||
{
|
||||
copyQueryPoolResults(queryPool->pool, firstQuery, queryCount, dstBuffer->buffer, dstOffset, stride, flags);
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::copyQueryPoolResults(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags)
|
||||
{
|
||||
vkCmdCopyQueryPoolResults(buffer, queryPool, firstQuery, queryCount, dstBuffer, dstOffset, stride, flags);
|
||||
|
@ -902,6 +948,17 @@ inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::allocate(Vulka
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline VulkanQueryPool::VulkanQueryPool(VulkanDevice *device, VkQueryPool pool) : device(device), pool(pool)
|
||||
{
|
||||
}
|
||||
|
||||
inline VulkanQueryPool::~VulkanQueryPool()
|
||||
{
|
||||
vkDestroyQueryPool(device->device, pool, nullptr);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline VulkanFramebuffer::VulkanFramebuffer(VulkanDevice *device, VkFramebuffer framebuffer) : device(device), framebuffer(framebuffer)
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue