2019-07-28 00:40:10 +02:00
|
|
|
// Copyright 2019 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-11-26 22:52:15 +01:00
|
|
|
#include <array>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-07-28 00:40:10 +02:00
|
|
|
#include "common/common_types.h"
|
2020-02-11 20:02:41 +01:00
|
|
|
#include "video_core/query_cache.h"
|
2019-11-26 22:52:15 +01:00
|
|
|
#include "video_core/rasterizer_interface.h"
|
2019-07-28 00:40:10 +02:00
|
|
|
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
|
|
|
|
2019-11-26 22:52:15 +01:00
|
|
|
namespace Core {
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
2019-07-28 00:40:10 +02:00
|
|
|
namespace OpenGL {
|
|
|
|
|
2019-11-26 22:52:15 +01:00
|
|
|
class CachedQuery;
|
|
|
|
class HostCounter;
|
|
|
|
class QueryCache;
|
2020-02-11 20:02:41 +01:00
|
|
|
class RasterizerOpenGL;
|
2019-11-26 22:52:15 +01:00
|
|
|
|
2020-02-11 20:02:41 +01:00
|
|
|
using CounterStream = VideoCommon::CounterStreamBase<QueryCache, HostCounter>;
|
2019-11-26 22:52:15 +01:00
|
|
|
|
2020-09-10 08:43:30 +02:00
|
|
|
class QueryCache final
|
|
|
|
: public VideoCommon::QueryCacheBase<QueryCache, CachedQuery, CounterStream, HostCounter> {
|
2019-11-26 22:52:15 +01:00
|
|
|
public:
|
2020-12-05 17:40:14 +01:00
|
|
|
explicit QueryCache(RasterizerOpenGL& rasterizer_, Tegra::Engines::Maxwell3D& maxwell3d_,
|
|
|
|
Tegra::MemoryManager& gpu_memory_);
|
2019-11-26 22:52:15 +01:00
|
|
|
~QueryCache();
|
|
|
|
|
2020-02-11 20:02:41 +01:00
|
|
|
OGLQuery AllocateQuery(VideoCore::QueryType type);
|
2019-07-28 00:40:10 +02:00
|
|
|
|
2019-11-26 22:52:15 +01:00
|
|
|
void Reserve(VideoCore::QueryType type, OGLQuery&& query);
|
2019-07-28 00:40:10 +02:00
|
|
|
|
2020-02-11 20:02:41 +01:00
|
|
|
bool AnyCommandQueued() const noexcept;
|
2019-11-26 22:52:15 +01:00
|
|
|
|
|
|
|
private:
|
2020-02-11 20:02:41 +01:00
|
|
|
RasterizerOpenGL& gl_rasterizer;
|
2020-09-10 08:43:30 +02:00
|
|
|
std::array<std::vector<OGLQuery>, VideoCore::NumQueryTypes> query_pools;
|
2019-11-26 22:52:15 +01:00
|
|
|
};
|
|
|
|
|
2020-02-11 20:02:41 +01:00
|
|
|
class HostCounter final : public VideoCommon::HostCounterBase<QueryCache, HostCounter> {
|
2019-11-26 22:52:15 +01:00
|
|
|
public:
|
2020-12-05 17:40:14 +01:00
|
|
|
explicit HostCounter(QueryCache& cache_, std::shared_ptr<HostCounter> dependency_,
|
2020-12-04 20:39:12 +01:00
|
|
|
VideoCore::QueryType type_);
|
2019-11-26 22:52:15 +01:00
|
|
|
~HostCounter();
|
2019-07-28 00:40:10 +02:00
|
|
|
|
2020-02-11 20:02:41 +01:00
|
|
|
void EndQuery();
|
2019-11-28 06:15:34 +01:00
|
|
|
|
2019-07-28 00:40:10 +02:00
|
|
|
private:
|
2020-02-11 20:02:41 +01:00
|
|
|
u64 BlockingQuery() const override;
|
|
|
|
|
2019-11-26 22:52:15 +01:00
|
|
|
QueryCache& cache;
|
2020-02-11 22:59:44 +01:00
|
|
|
const VideoCore::QueryType type;
|
2020-02-11 20:02:41 +01:00
|
|
|
OGLQuery query;
|
2019-11-26 22:52:15 +01:00
|
|
|
};
|
|
|
|
|
2020-02-11 20:02:41 +01:00
|
|
|
class CachedQuery final : public VideoCommon::CachedQueryBase<HostCounter> {
|
2019-11-26 22:52:15 +01:00
|
|
|
public:
|
2020-12-05 17:40:14 +01:00
|
|
|
explicit CachedQuery(QueryCache& cache_, VideoCore::QueryType type_, VAddr cpu_addr_,
|
|
|
|
u8* host_ptr_);
|
2020-09-10 08:43:30 +02:00
|
|
|
~CachedQuery() override;
|
2019-11-28 06:15:34 +01:00
|
|
|
|
2020-09-10 08:43:30 +02:00
|
|
|
CachedQuery(CachedQuery&& rhs) noexcept;
|
2020-02-11 20:02:41 +01:00
|
|
|
CachedQuery& operator=(CachedQuery&& rhs) noexcept;
|
2020-09-10 08:43:30 +02:00
|
|
|
|
|
|
|
CachedQuery(const CachedQuery&) = delete;
|
2020-02-14 01:11:21 +01:00
|
|
|
CachedQuery& operator=(const CachedQuery&) = delete;
|
2019-07-28 00:40:10 +02:00
|
|
|
|
2020-02-11 20:02:41 +01:00
|
|
|
void Flush() override;
|
2019-11-26 22:52:15 +01:00
|
|
|
|
|
|
|
private:
|
2020-02-11 20:02:41 +01:00
|
|
|
QueryCache* cache;
|
|
|
|
VideoCore::QueryType type;
|
2019-07-28 00:40:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace OpenGL
|