diff options
| author | Connor McLaughlin <stenzek@gmail.com> | 2019-03-29 21:56:28 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-29 21:56:28 +1000 |
| commit | 377615b06fd61717edb39b51964e611fd2da8cdc (patch) | |
| tree | b95d2e759189c90cc598f311dcf4da69e3668c22 /Source/Core/VideoBackends/Vulkan/PerfQuery.h | |
| parent | f3fadd730218429a5f6472283d16d30d7e276f8d (diff) | |
| parent | 604ab67c7f28dc03a82ee7aa1bcc487d39ea6f8c (diff) | |
Merge pull request #7905 from stenzek/vulkan-cleanup
Vulkan: Simplify command buffer fence tracking
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/PerfQuery.h')
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/PerfQuery.h | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/PerfQuery.h b/Source/Core/VideoBackends/Vulkan/PerfQuery.h index 47ccf22a66..8ca91ac658 100644 --- a/Source/Core/VideoBackends/Vulkan/PerfQuery.h +++ b/Source/Core/VideoBackends/Vulkan/PerfQuery.h @@ -13,18 +13,15 @@ namespace Vulkan { -class StagingBuffer; - class PerfQuery : public PerfQueryBase { public: PerfQuery(); ~PerfQuery(); - static PerfQuery* GetInstance(); + static PerfQuery* GetInstance() { return static_cast<PerfQuery*>(g_perf_query.get()); } bool Initialize(); - void FlushQueries(); void EnableQuery(PerfQueryGroup type) override; void DisableQuery(PerfQueryGroup type) override; @@ -34,37 +31,30 @@ public: bool IsFlushed() const override; private: + // u32 is used for the sample counts. + using PerfQueryDataType = u32; + + // when testing in SMS: 64 was too small, 128 was ok + // TODO: This should be size_t, but the base class uses u32s + static const u32 PERF_QUERY_BUFFER_SIZE = 512; + struct ActiveQuery { + u64 fence_counter; PerfQueryType query_type; - VkFence pending_fence; - bool available; - bool active; + bool has_value; }; bool CreateQueryPool(); - bool CreateReadbackBuffer(); - void QueueCopyQueryResults(u32 start_index, u32 query_count); - void ProcessResults(u32 start_index, u32 query_count); - - void OnCommandBufferQueued(VkCommandBuffer command_buffer, VkFence fence); - void OnFenceSignaled(VkFence fence); - - void NonBlockingPartialFlush(); - void BlockingPartialFlush(); + void ReadbackQueries(); + void ReadbackQueries(u32 query_count); + void PartialFlush(bool blocking); - // when testing in SMS: 64 was too small, 128 was ok - // TODO: This should be size_t, but the base class uses u32s - using PerfQueryDataType = u32; - static const u32 PERF_QUERY_BUFFER_SIZE = 512; - std::array<ActiveQuery, PERF_QUERY_BUFFER_SIZE> m_query_buffer = {}; - u32 m_query_read_pos = 0; - - // TODO: Investigate using pipeline statistics to implement other query types VkQueryPool m_query_pool = VK_NULL_HANDLE; - - // Buffer containing query results. Each query is a u32. - std::unique_ptr<StagingBuffer> m_readback_buffer; + u32 m_query_readback_pos = 0; + u32 m_query_next_pos = 0; + std::array<ActiveQuery, PERF_QUERY_BUFFER_SIZE> m_query_buffer = {}; + std::array<PerfQueryDataType, PERF_QUERY_BUFFER_SIZE> m_query_result_buffer = {}; }; } // namespace Vulkan |
