2019-03-28 10:35:46 +00:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2019-03-28 10:35:46 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
2020-09-15 13:01:29 +00:00
|
|
|
#include "VideoBackends/D3D12/DX12Context.h"
|
2019-03-28 10:35:46 +00:00
|
|
|
#include "VideoCommon/PerfQueryBase.h"
|
|
|
|
|
|
|
|
namespace DX12
|
|
|
|
{
|
|
|
|
class PerfQuery final : public PerfQueryBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PerfQuery();
|
|
|
|
~PerfQuery();
|
|
|
|
|
|
|
|
static PerfQuery* GetInstance() { return static_cast<PerfQuery*>(g_perf_query.get()); }
|
|
|
|
|
2023-01-29 10:57:37 +00:00
|
|
|
bool Initialize() override;
|
2019-03-28 10:35:46 +00:00
|
|
|
void ResolveQueries();
|
|
|
|
|
2022-11-17 20:54:43 +00:00
|
|
|
void EnableQuery(PerfQueryGroup group) override;
|
|
|
|
void DisableQuery(PerfQueryGroup group) override;
|
2019-03-28 10:35:46 +00:00
|
|
|
void ResetQuery() override;
|
|
|
|
u32 GetQueryResult(PerfQueryType type) override;
|
|
|
|
void FlushResults() override;
|
|
|
|
bool IsFlushed() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct ActiveQuery
|
|
|
|
{
|
|
|
|
u64 fence_value;
|
2022-11-17 20:54:43 +00:00
|
|
|
PerfQueryGroup query_group;
|
2019-03-28 10:35:46 +00:00
|
|
|
bool has_value;
|
|
|
|
bool resolved;
|
|
|
|
};
|
|
|
|
|
|
|
|
void ResolveQueries(u32 query_count);
|
2019-04-01 10:13:39 +00:00
|
|
|
void ReadbackQueries(bool blocking);
|
|
|
|
void AccumulateQueriesFromBuffer(u32 query_count);
|
2019-03-28 10:35:46 +00:00
|
|
|
|
|
|
|
void PartialFlush(bool resolve, 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 = u64;
|
|
|
|
static const u32 PERF_QUERY_BUFFER_SIZE = 512;
|
|
|
|
std::array<ActiveQuery, PERF_QUERY_BUFFER_SIZE> m_query_buffer = {};
|
|
|
|
u32 m_unresolved_queries = 0;
|
|
|
|
u32 m_query_resolve_pos = 0;
|
|
|
|
u32 m_query_readback_pos = 0;
|
|
|
|
u32 m_query_next_pos = 0;
|
|
|
|
|
|
|
|
ComPtr<ID3D12QueryHeap> m_query_heap;
|
|
|
|
ComPtr<ID3D12Resource> m_query_readback_buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace DX12
|