1
0
Fork 0
forked from suyu/suyu

video_core: Replace VKQueryCache with QueryCache

This commit is contained in:
german77 2022-06-25 23:38:44 -05:00
parent 9775fae4eb
commit a5e419535f
6 changed files with 27 additions and 28 deletions

View file

@ -44,7 +44,7 @@ void InnerFence::Wait() {
FenceManager::FenceManager(VideoCore::RasterizerInterface& rasterizer_, Tegra::GPU& gpu_, FenceManager::FenceManager(VideoCore::RasterizerInterface& rasterizer_, Tegra::GPU& gpu_,
TextureCache& texture_cache_, BufferCache& buffer_cache_, TextureCache& texture_cache_, BufferCache& buffer_cache_,
VKQueryCache& query_cache_, const Device& device_, Scheduler& scheduler_) QueryCache& query_cache_, const Device& device_, Scheduler& scheduler_)
: GenericFenceManager{rasterizer_, gpu_, texture_cache_, buffer_cache_, query_cache_}, : GenericFenceManager{rasterizer_, gpu_, texture_cache_, buffer_cache_, query_cache_},
scheduler{scheduler_} {} scheduler{scheduler_} {}

View file

@ -20,7 +20,7 @@ class RasterizerInterface;
namespace Vulkan { namespace Vulkan {
class Device; class Device;
class VKQueryCache; class QueryCache;
class Scheduler; class Scheduler;
class InnerFence : public VideoCommon::FenceBase { class InnerFence : public VideoCommon::FenceBase {
@ -41,14 +41,13 @@ private:
}; };
using Fence = std::shared_ptr<InnerFence>; using Fence = std::shared_ptr<InnerFence>;
using GenericFenceManager = using GenericFenceManager = VideoCommon::FenceManager<Fence, TextureCache, BufferCache, QueryCache>;
VideoCommon::FenceManager<Fence, TextureCache, BufferCache, VKQueryCache>;
class FenceManager final : public GenericFenceManager { class FenceManager final : public GenericFenceManager {
public: public:
explicit FenceManager(VideoCore::RasterizerInterface& rasterizer, Tegra::GPU& gpu, explicit FenceManager(VideoCore::RasterizerInterface& rasterizer, Tegra::GPU& gpu,
TextureCache& texture_cache, BufferCache& buffer_cache, TextureCache& texture_cache, BufferCache& buffer_cache,
VKQueryCache& query_cache, const Device& device, Scheduler& scheduler); QueryCache& query_cache, const Device& device, Scheduler& scheduler);
protected: protected:
Fence CreateFence(u32 value, bool is_stubbed) override; Fence CreateFence(u32 value, bool is_stubbed) override;

View file

@ -65,7 +65,7 @@ void QueryPool::Reserve(std::pair<VkQueryPool, u32> query) {
usage[pool_index * GROW_STEP + static_cast<std::ptrdiff_t>(query.second)] = false; usage[pool_index * GROW_STEP + static_cast<std::ptrdiff_t>(query.second)] = false;
} }
VKQueryCache::VKQueryCache(VideoCore::RasterizerInterface& rasterizer_, QueryCache::QueryCache(VideoCore::RasterizerInterface& rasterizer_,
Tegra::Engines::Maxwell3D& maxwell3d_, Tegra::MemoryManager& gpu_memory_, Tegra::Engines::Maxwell3D& maxwell3d_, Tegra::MemoryManager& gpu_memory_,
const Device& device_, Scheduler& scheduler_) const Device& device_, Scheduler& scheduler_)
: QueryCacheBase{rasterizer_, maxwell3d_, gpu_memory_}, device{device_}, scheduler{scheduler_}, : QueryCacheBase{rasterizer_, maxwell3d_, gpu_memory_}, device{device_}, scheduler{scheduler_},
@ -73,7 +73,7 @@ VKQueryCache::VKQueryCache(VideoCore::RasterizerInterface& rasterizer_,
QueryPool{device_, scheduler_, QueryType::SamplesPassed}, QueryPool{device_, scheduler_, QueryType::SamplesPassed},
} {} } {}
VKQueryCache::~VKQueryCache() { QueryCache::~QueryCache() {
// TODO(Rodrigo): This is a hack to destroy all HostCounter instances before the base class // TODO(Rodrigo): This is a hack to destroy all HostCounter instances before the base class
// destructor is called. The query cache should be redesigned to have a proper ownership model // destructor is called. The query cache should be redesigned to have a proper ownership model
// instead of using shared pointers. // instead of using shared pointers.
@ -84,15 +84,15 @@ VKQueryCache::~VKQueryCache() {
} }
} }
std::pair<VkQueryPool, u32> VKQueryCache::AllocateQuery(QueryType type) { std::pair<VkQueryPool, u32> QueryCache::AllocateQuery(QueryType type) {
return query_pools[static_cast<std::size_t>(type)].Commit(); return query_pools[static_cast<std::size_t>(type)].Commit();
} }
void VKQueryCache::Reserve(QueryType type, std::pair<VkQueryPool, u32> query) { void QueryCache::Reserve(QueryType type, std::pair<VkQueryPool, u32> query) {
query_pools[static_cast<std::size_t>(type)].Reserve(query); query_pools[static_cast<std::size_t>(type)].Reserve(query);
} }
HostCounter::HostCounter(VKQueryCache& cache_, std::shared_ptr<HostCounter> dependency_, HostCounter::HostCounter(QueryCache& cache_, std::shared_ptr<HostCounter> dependency_,
QueryType type_) QueryType type_)
: HostCounterBase{std::move(dependency_)}, cache{cache_}, type{type_}, : HostCounterBase{std::move(dependency_)}, cache{cache_}, type{type_},
query{cache_.AllocateQuery(type_)}, tick{cache_.GetScheduler().CurrentTick()} { query{cache_.AllocateQuery(type_)}, tick{cache_.GetScheduler().CurrentTick()} {

View file

@ -22,10 +22,10 @@ namespace Vulkan {
class CachedQuery; class CachedQuery;
class Device; class Device;
class HostCounter; class HostCounter;
class VKQueryCache; class QueryCache;
class Scheduler; class Scheduler;
using CounterStream = VideoCommon::CounterStreamBase<VKQueryCache, HostCounter>; using CounterStream = VideoCommon::CounterStreamBase<QueryCache, HostCounter>;
class QueryPool final : public ResourcePool { class QueryPool final : public ResourcePool {
public: public:
@ -49,13 +49,13 @@ private:
std::vector<bool> usage; std::vector<bool> usage;
}; };
class VKQueryCache final class QueryCache final
: public VideoCommon::QueryCacheBase<VKQueryCache, CachedQuery, CounterStream, HostCounter> { : public VideoCommon::QueryCacheBase<QueryCache, CachedQuery, CounterStream, HostCounter> {
public: public:
explicit VKQueryCache(VideoCore::RasterizerInterface& rasterizer_, explicit QueryCache(VideoCore::RasterizerInterface& rasterizer_,
Tegra::Engines::Maxwell3D& maxwell3d_, Tegra::MemoryManager& gpu_memory_, Tegra::Engines::Maxwell3D& maxwell3d_, Tegra::MemoryManager& gpu_memory_,
const Device& device_, Scheduler& scheduler_); const Device& device_, Scheduler& scheduler_);
~VKQueryCache(); ~QueryCache();
std::pair<VkQueryPool, u32> AllocateQuery(VideoCore::QueryType type); std::pair<VkQueryPool, u32> AllocateQuery(VideoCore::QueryType type);
@ -75,9 +75,9 @@ private:
std::array<QueryPool, VideoCore::NumQueryTypes> query_pools; std::array<QueryPool, VideoCore::NumQueryTypes> query_pools;
}; };
class HostCounter final : public VideoCommon::HostCounterBase<VKQueryCache, HostCounter> { class HostCounter final : public VideoCommon::HostCounterBase<QueryCache, HostCounter> {
public: public:
explicit HostCounter(VKQueryCache& cache_, std::shared_ptr<HostCounter> dependency_, explicit HostCounter(QueryCache& cache_, std::shared_ptr<HostCounter> dependency_,
VideoCore::QueryType type_); VideoCore::QueryType type_);
~HostCounter(); ~HostCounter();
@ -86,7 +86,7 @@ public:
private: private:
u64 BlockingQuery() const override; u64 BlockingQuery() const override;
VKQueryCache& cache; QueryCache& cache;
const VideoCore::QueryType type; const VideoCore::QueryType type;
const std::pair<VkQueryPool, u32> query; const std::pair<VkQueryPool, u32> query;
const u64 tick; const u64 tick;
@ -94,7 +94,7 @@ private:
class CachedQuery : public VideoCommon::CachedQueryBase<HostCounter> { class CachedQuery : public VideoCommon::CachedQueryBase<HostCounter> {
public: public:
explicit CachedQuery(VKQueryCache&, VideoCore::QueryType, VAddr cpu_addr_, u8* host_ptr_) explicit CachedQuery(QueryCache&, VideoCore::QueryType, VAddr cpu_addr_, u8* host_ptr_)
: CachedQueryBase{cpu_addr_, host_ptr_} {} : CachedQueryBase{cpu_addr_, host_ptr_} {}
}; };

View file

@ -156,7 +156,7 @@ private:
BufferCacheRuntime buffer_cache_runtime; BufferCacheRuntime buffer_cache_runtime;
BufferCache buffer_cache; BufferCache buffer_cache;
PipelineCache pipeline_cache; PipelineCache pipeline_cache;
VKQueryCache query_cache; QueryCache query_cache;
AccelerateDMA accelerate_dma; AccelerateDMA accelerate_dma;
FenceManager fence_manager; FenceManager fence_manager;

View file

@ -22,7 +22,7 @@ class Device;
class Framebuffer; class Framebuffer;
class GraphicsPipeline; class GraphicsPipeline;
class StateTracker; class StateTracker;
class VKQueryCache; class QueryCache;
/// The scheduler abstracts command buffer and fence management with an interface that's able to do /// The scheduler abstracts command buffer and fence management with an interface that's able to do
/// OpenGL-like operations on Vulkan command buffers. /// OpenGL-like operations on Vulkan command buffers.
@ -61,7 +61,7 @@ public:
void InvalidateState(); void InvalidateState();
/// Assigns the query cache. /// Assigns the query cache.
void SetQueryCache(VKQueryCache& query_cache_) { void SetQueryCache(QueryCache& query_cache_) {
query_cache = &query_cache_; query_cache = &query_cache_;
} }
@ -212,7 +212,7 @@ private:
std::unique_ptr<MasterSemaphore> master_semaphore; std::unique_ptr<MasterSemaphore> master_semaphore;
std::unique_ptr<CommandPool> command_pool; std::unique_ptr<CommandPool> command_pool;
VKQueryCache* query_cache = nullptr; QueryCache* query_cache = nullptr;
vk::CommandBuffer current_cmdbuf; vk::CommandBuffer current_cmdbuf;