Debian Codegraph @

Source/Core/VideoBackends/Vulkan/VKPerfQuery.h

raw symbols SCIP
1 // Copyright 2016 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <array>
7 #include <memory>
8
9 #include "Common/CommonTypes.h"
10 #include "VideoBackends/Vulkan/Constants.h"
11 #include "VideoCommon/PerfQueryBase.h"
12
13 namespace Vulkan
14 {
15 class PerfQuery : public PerfQueryBase
16 {
17 public:
18 PerfQuery();
19 ~PerfQuery() override;
20
21 static PerfQuery* GetInstance() { return static_cast<PerfQuery*>(g_perf_query.get()); }
22
23 bool Initialize() override;
24
25 void EnableQuery(PerfQueryGroup group) override;
26 void DisableQuery(PerfQueryGroup group) override;
27 void ResetQuery() override;
28 u32 GetQueryResult(PerfQueryType type) override;
29 void FlushResults() override;
30 bool IsFlushed() const override;
31
32 private:
33 // u32 is used for the sample counts.
34 using PerfQueryDataType = u32;
35
36 // when testing in SMS: 64 was too small, 128 was ok
37 // TODO: This should be size_t, but the base class uses u32s
38 static const u32 PERF_QUERY_BUFFER_SIZE = 512;
39
40 struct ActiveQuery
41 {
42 u64 fence_counter;
43 PerfQueryGroup query_group;
44 bool has_value;
45 };
46
47 bool CreateQueryPool();
48 void ReadbackQueries();
49 void ReadbackQueries(u32 query_count);
50 void PartialFlush(bool blocking);
51
52 VkQueryPool m_query_pool = VK_NULL_HANDLE;
53 u32 m_query_readback_pos = 0;
54 u32 m_query_next_pos = 0;
55 std::array<ActiveQuery, PERF_QUERY_BUFFER_SIZE> m_query_buffer = {};
56 std::array<PerfQueryDataType, PERF_QUERY_BUFFER_SIZE> m_query_result_buffer = {};
57 };
58
59 } // namespace Vulkan