diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-09-10 08:43:30 +0200 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-09-19 06:46:37 +0200 |
commit | 58b0ae84b56996304b6ad373e4f6cff2cf6bdd41 (patch) | |
tree | 9b7c3e28fa7445c78304902efe660356c59cad57 /src/video_core/renderer_vulkan/vk_resource_pool.h | |
parent | Merge pull request #4663 from ReinUsesLisp/wswitch (diff) | |
download | yuzu-58b0ae84b56996304b6ad373e4f6cff2cf6bdd41.tar yuzu-58b0ae84b56996304b6ad373e4f6cff2cf6bdd41.tar.gz yuzu-58b0ae84b56996304b6ad373e4f6cff2cf6bdd41.tar.bz2 yuzu-58b0ae84b56996304b6ad373e4f6cff2cf6bdd41.tar.lz yuzu-58b0ae84b56996304b6ad373e4f6cff2cf6bdd41.tar.xz yuzu-58b0ae84b56996304b6ad373e4f6cff2cf6bdd41.tar.zst yuzu-58b0ae84b56996304b6ad373e4f6cff2cf6bdd41.zip |
Diffstat (limited to 'src/video_core/renderer_vulkan/vk_resource_pool.h')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_resource_pool.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/vk_resource_pool.h b/src/video_core/renderer_vulkan/vk_resource_pool.h new file mode 100644 index 000000000..a018c7ec2 --- /dev/null +++ b/src/video_core/renderer_vulkan/vk_resource_pool.h @@ -0,0 +1,43 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <vector> + +#include "common/common_types.h" + +namespace Vulkan { + +class MasterSemaphore; + +/** + * Handles a pool of resources protected by fences. Manages resource overflow allocating more + * resources. + */ +class ResourcePool { +public: + explicit ResourcePool(MasterSemaphore& master_semaphore, size_t grow_step); + virtual ~ResourcePool(); + +protected: + size_t CommitResource(); + + /// Called when a chunk of resources have to be allocated. + virtual void Allocate(size_t begin, size_t end) = 0; + +private: + /// Manages pool overflow allocating new resources. + size_t ManageOverflow(); + + /// Allocates a new page of resources. + void Grow(); + + MasterSemaphore& master_semaphore; + size_t grow_step = 0; ///< Number of new resources created after an overflow + size_t free_iterator = 0; ///< Hint to where the next free resources is likely to be found + std::vector<u64> ticks; ///< Ticks for each resource +}; + +} // namespace Vulkan |