2015-05-24 04:32:32 +00:00
|
|
|
// Copyright 2012 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-05-24 04:32:32 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2012-06-17 11:58:29 +00:00
|
|
|
|
2014-02-15 06:12:13 +00:00
|
|
|
#include <array>
|
2015-02-21 22:58:53 +00:00
|
|
|
#include <memory>
|
2014-10-21 06:01:38 +00:00
|
|
|
|
2015-09-18 16:40:00 +00:00
|
|
|
#include "Common/GL/GLExtensions/GLExtensions.h"
|
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/PerfQueryBase.h"
|
2012-06-17 11:58:29 +00:00
|
|
|
|
2014-08-15 18:09:53 +00:00
|
|
|
namespace OGL
|
|
|
|
{
|
2015-12-21 02:49:49 +00:00
|
|
|
std::unique_ptr<PerfQueryBase> GetPerfQuery();
|
2012-06-17 11:58:29 +00:00
|
|
|
|
|
|
|
class PerfQuery : public PerfQueryBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PerfQuery();
|
2015-02-21 22:58:53 +00:00
|
|
|
~PerfQuery() {}
|
2022-11-17 20:54:43 +00:00
|
|
|
void EnableQuery(PerfQueryGroup group) override;
|
|
|
|
void DisableQuery(PerfQueryGroup group) override;
|
2013-10-29 05:34:26 +00:00
|
|
|
void ResetQuery() override;
|
|
|
|
u32 GetQueryResult(PerfQueryType type) override;
|
|
|
|
void FlushResults() override;
|
2014-03-08 00:54:44 +00:00
|
|
|
bool IsFlushed() const override;
|
2013-03-01 18:30:37 +00:00
|
|
|
|
2015-02-21 22:58:53 +00:00
|
|
|
protected:
|
2013-02-16 23:50:40 +00:00
|
|
|
struct ActiveQuery
|
|
|
|
{
|
|
|
|
GLuint query_id;
|
2022-11-17 20:54:43 +00:00
|
|
|
PerfQueryGroup query_group;
|
2013-02-16 23:50:40 +00:00
|
|
|
};
|
2013-03-01 18:30:37 +00:00
|
|
|
|
2013-02-16 23:50:40 +00:00
|
|
|
// when testing in SMS: 64 was too small, 128 was ok
|
2013-03-03 04:59:55 +00:00
|
|
|
static const u32 PERF_QUERY_BUFFER_SIZE = 512;
|
2013-03-01 18:30:37 +00:00
|
|
|
|
2013-02-16 23:50:40 +00:00
|
|
|
// This contains gl query objects with unretrieved results.
|
2014-02-15 06:12:13 +00:00
|
|
|
std::array<ActiveQuery, PERF_QUERY_BUFFER_SIZE> m_query_buffer;
|
2013-03-03 04:59:55 +00:00
|
|
|
u32 m_query_read_pos;
|
2013-03-01 18:30:37 +00:00
|
|
|
|
2015-02-21 22:58:53 +00:00
|
|
|
private:
|
|
|
|
// Implementation
|
|
|
|
std::unique_ptr<PerfQuery> m_query;
|
2012-06-17 11:58:29 +00:00
|
|
|
};
|
|
|
|
|
2015-02-21 22:58:53 +00:00
|
|
|
// Implementations
|
|
|
|
class PerfQueryGL : public PerfQuery
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PerfQueryGL(GLenum query_type);
|
|
|
|
~PerfQueryGL();
|
|
|
|
|
2022-11-17 20:54:43 +00:00
|
|
|
void EnableQuery(PerfQueryGroup group) override;
|
|
|
|
void DisableQuery(PerfQueryGroup group) override;
|
2015-02-21 22:58:53 +00:00
|
|
|
void FlushResults() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void WeakFlush();
|
|
|
|
// Only use when non-empty
|
|
|
|
void FlushOne();
|
|
|
|
|
|
|
|
GLenum m_query_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PerfQueryGLESNV : public PerfQuery
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PerfQueryGLESNV();
|
|
|
|
~PerfQueryGLESNV();
|
|
|
|
|
2022-11-17 20:54:43 +00:00
|
|
|
void EnableQuery(PerfQueryGroup group) override;
|
|
|
|
void DisableQuery(PerfQueryGroup group) override;
|
2015-02-21 22:58:53 +00:00
|
|
|
void FlushResults() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void WeakFlush();
|
|
|
|
// Only use when non-empty
|
|
|
|
void FlushOne();
|
|
|
|
};
|
|
|
|
|
2019-05-05 23:48:12 +00:00
|
|
|
} // namespace OGL
|