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