2015-05-24 07:32:32 +03:00
|
|
|
// Copyright 2012 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2014-02-10 20:54:46 +02:00
|
|
|
#pragma once
|
2012-06-17 14:58:29 +03:00
|
|
|
|
2014-02-15 08:12:13 +02:00
|
|
|
#include <array>
|
2015-02-22 00:58:53 +02:00
|
|
|
#include <memory>
|
2014-10-21 09:01:38 +03:00
|
|
|
|
2015-09-18 19:40:00 +03:00
|
|
|
#include "Common/GL/GLExtensions/GLExtensions.h"
|
|
|
|
|
2014-02-17 12:18:15 +02:00
|
|
|
#include "VideoCommon/PerfQueryBase.h"
|
2012-06-17 14:58:29 +03:00
|
|
|
|
2014-08-15 21:09:53 +03:00
|
|
|
namespace OGL
|
|
|
|
{
|
2015-12-21 04:49:49 +02:00
|
|
|
std::unique_ptr<PerfQueryBase> GetPerfQuery();
|
2012-06-17 14:58:29 +03:00
|
|
|
|
|
|
|
class PerfQuery : public PerfQueryBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PerfQuery();
|
2015-02-22 00:58:53 +02:00
|
|
|
~PerfQuery() {}
|
2012-06-17 14:58:29 +03:00
|
|
|
|
2013-10-29 07:34:26 +02:00
|
|
|
void EnableQuery(PerfQueryGroup type) override;
|
|
|
|
void DisableQuery(PerfQueryGroup type) override;
|
|
|
|
void ResetQuery() override;
|
|
|
|
u32 GetQueryResult(PerfQueryType type) override;
|
|
|
|
void FlushResults() override;
|
2014-03-08 02:54:44 +02:00
|
|
|
bool IsFlushed() const override;
|
2013-03-01 20:30:37 +02:00
|
|
|
|
2015-02-22 00:58:53 +02:00
|
|
|
protected:
|
2013-02-17 01:50:40 +02:00
|
|
|
struct ActiveQuery
|
|
|
|
{
|
|
|
|
GLuint query_id;
|
|
|
|
PerfQueryGroup query_type;
|
|
|
|
};
|
2013-03-01 20:30:37 +02:00
|
|
|
|
2013-02-17 01:50:40 +02:00
|
|
|
// when testing in SMS: 64 was too small, 128 was ok
|
2013-03-03 06:59:55 +02:00
|
|
|
static const u32 PERF_QUERY_BUFFER_SIZE = 512;
|
2013-03-01 20:30:37 +02:00
|
|
|
|
2013-02-17 01:50:40 +02:00
|
|
|
// This contains gl query objects with unretrieved results.
|
2014-02-15 08:12:13 +02:00
|
|
|
std::array<ActiveQuery, PERF_QUERY_BUFFER_SIZE> m_query_buffer;
|
2013-03-03 06:59:55 +02:00
|
|
|
u32 m_query_read_pos;
|
2013-03-01 20:30:37 +02:00
|
|
|
|
2015-02-22 00:58:53 +02:00
|
|
|
private:
|
|
|
|
// Implementation
|
|
|
|
std::unique_ptr<PerfQuery> m_query;
|
2012-06-17 14:58:29 +03:00
|
|
|
};
|
|
|
|
|
2015-02-22 00:58:53 +02: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();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-06-17 14:58:29 +03:00
|
|
|
} // namespace
|