2016-08-13 12:57:50 +00:00
|
|
|
// Copyright 2016 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2016-08-13 12:57:50 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <memory>
|
|
|
|
|
2016-10-01 03:07:50 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2016-08-13 12:57:50 +00:00
|
|
|
#include "VideoBackends/Vulkan/Constants.h"
|
|
|
|
#include "VideoCommon/PerfQueryBase.h"
|
|
|
|
|
|
|
|
namespace Vulkan
|
|
|
|
{
|
|
|
|
class PerfQuery : public PerfQueryBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PerfQuery();
|
|
|
|
~PerfQuery();
|
|
|
|
|
2019-03-17 14:09:26 +00:00
|
|
|
static PerfQuery* GetInstance() { return static_cast<PerfQuery*>(g_perf_query.get()); }
|
2016-10-22 10:50:36 +00:00
|
|
|
|
|
|
|
bool Initialize();
|
2016-08-13 12:57:50 +00:00
|
|
|
|
2022-11-17 20:54:43 +00:00
|
|
|
void EnableQuery(PerfQueryGroup group) override;
|
|
|
|
void DisableQuery(PerfQueryGroup group) override;
|
2016-08-13 12:57:50 +00:00
|
|
|
void ResetQuery() override;
|
|
|
|
u32 GetQueryResult(PerfQueryType type) override;
|
|
|
|
void FlushResults() override;
|
|
|
|
bool IsFlushed() const override;
|
|
|
|
|
|
|
|
private:
|
2019-03-17 14:09:26 +00:00
|
|
|
// 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;
|
|
|
|
|
2016-08-13 12:57:50 +00:00
|
|
|
struct ActiveQuery
|
|
|
|
{
|
2019-03-17 05:59:22 +00:00
|
|
|
u64 fence_counter;
|
2022-11-17 20:54:43 +00:00
|
|
|
PerfQueryGroup query_group;
|
2019-03-17 14:09:26 +00:00
|
|
|
bool has_value;
|
2016-08-13 12:57:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool CreateQueryPool();
|
2019-03-17 14:09:26 +00:00
|
|
|
void ReadbackQueries();
|
|
|
|
void ReadbackQueries(u32 query_count);
|
|
|
|
void PartialFlush(bool blocking);
|
2016-08-13 12:57:50 +00:00
|
|
|
|
|
|
|
VkQueryPool m_query_pool = VK_NULL_HANDLE;
|
2019-03-17 14:09:26 +00:00
|
|
|
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 = {};
|
2016-08-13 12:57:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Vulkan
|