2019-03-28 04:35:46 -06:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2019-03-28 04:35:46 -06:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
2020-09-15 07:01:29 -06:00
|
|
|
#include "VideoBackends/D3D12/DX12Context.h"
|
2019-03-28 04:35:46 -06: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()); }
|
|
|
|
|
|
|
|
bool Initialize();
|
|
|
|
void ResolveQueries();
|
|
|
|
|
|
|
|
void EnableQuery(PerfQueryGroup type) override;
|
|
|
|
void DisableQuery(PerfQueryGroup type) override;
|
|
|
|
void ResetQuery() override;
|
|
|
|
u32 GetQueryResult(PerfQueryType type) override;
|
|
|
|
void FlushResults() override;
|
|
|
|
bool IsFlushed() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct ActiveQuery
|
|
|
|
{
|
|
|
|
u64 fence_value;
|
|
|
|
PerfQueryType query_type;
|
|
|
|
bool has_value;
|
|
|
|
bool resolved;
|
|
|
|
};
|
|
|
|
|
|
|
|
void ResolveQueries(u32 query_count);
|
2019-04-01 04:13:39 -06:00
|
|
|
void ReadbackQueries(bool blocking);
|
|
|
|
void AccumulateQueriesFromBuffer(u32 query_count);
|
2019-03-28 04:35:46 -06: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
|