Debian Codegraph @

Source/Core/VideoCommon/PerfQueryBase.h

raw symbols SCIP
1 // Copyright 2012 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <array>
7 #include <atomic>
8 #include <memory>
9
10 #include "Common/CommonTypes.h"
11
12 enum PerfQueryType
13 {
14 PQ_ZCOMP_INPUT_ZCOMPLOC = 0,
15 PQ_ZCOMP_OUTPUT_ZCOMPLOC,
16 PQ_ZCOMP_INPUT,
17 PQ_ZCOMP_OUTPUT,
18 PQ_BLEND_INPUT,
19 PQ_EFB_COPY_CLOCKS,
20 PQ_NUM_MEMBERS
21 };
22
23 enum PerfQueryGroup
24 {
25 PQG_ZCOMP_ZCOMPLOC,
26 PQG_ZCOMP,
27 PQG_EFB_COPY_CLOCKS,
28 PQG_NUM_MEMBERS,
29 };
30
31 class PerfQueryBase
32 {
33 public:
34 PerfQueryBase() : m_query_count(0) {}
35 virtual ~PerfQueryBase() {}
36
37 virtual bool Initialize() { return true; }
38
39 // Checks if performance queries are enabled in the gameini configuration.
40 // NOTE: Called from CPU+GPU thread
41 static bool ShouldEmulate();
42
43 // Begin querying the specified value for the following host GPU commands
44 // The call to EnableQuery() should be placed immediately before the draw command, otherwise
45 // there is a risk of GPU resets if the query is left open and the buffer is submitted during
46 // resource binding (D3D12/Vulkan).
47 virtual void EnableQuery(PerfQueryGroup type) {}
48
49 // Stop querying the specified value for the following host GPU commands
50 virtual void DisableQuery(PerfQueryGroup type) {}
51
52 // Reset query counters to zero and drop any pending queries
53 virtual void ResetQuery() {}
54
55 // Return the measured value for the specified query type
56 // NOTE: Called from CPU thread
57 virtual u32 GetQueryResult(PerfQueryType type) { return 0; }
58
59 // Request the value of any pending queries - causes a pipeline flush and thus should be used
60 // carefully!
61 virtual void FlushResults() {}
62
63 // True if there are no further pending query results
64 // NOTE: Called from CPU thread
65 virtual bool IsFlushed() const { return true; }
66
67 protected:
68 std::atomic<u32> m_query_count;
69 std::array<std::atomic<u32>, PQG_NUM_MEMBERS> m_results;
70 };
71
72 extern std::unique_ptr<PerfQueryBase> g_perf_query;