diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-02-14 17:35:03 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-02-14 22:44:26 +0100 |
commit | a2b6de7e9fd2a2e4956a83a16ded12f3ccfa0ed6 (patch) | |
tree | 5eda182bf4ddc84adb9e5465ac4e17c5c3a51133 /src/video_core/renderer_vulkan/vk_resource_manager.h | |
parent | vk_resource_manager: Implement VKResourceManager and fence allocator (diff) | |
download | yuzu-a2b6de7e9fd2a2e4956a83a16ded12f3ccfa0ed6.tar yuzu-a2b6de7e9fd2a2e4956a83a16ded12f3ccfa0ed6.tar.gz yuzu-a2b6de7e9fd2a2e4956a83a16ded12f3ccfa0ed6.tar.bz2 yuzu-a2b6de7e9fd2a2e4956a83a16ded12f3ccfa0ed6.tar.lz yuzu-a2b6de7e9fd2a2e4956a83a16ded12f3ccfa0ed6.tar.xz yuzu-a2b6de7e9fd2a2e4956a83a16ded12f3ccfa0ed6.tar.zst yuzu-a2b6de7e9fd2a2e4956a83a16ded12f3ccfa0ed6.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_resource_manager.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/vk_resource_manager.h b/src/video_core/renderer_vulkan/vk_resource_manager.h index c8759f779..1fd68bb4c 100644 --- a/src/video_core/renderer_vulkan/vk_resource_manager.h +++ b/src/video_core/renderer_vulkan/vk_resource_manager.h @@ -119,6 +119,38 @@ private: }; /** + * Handles a pool of resources protected by fences. Manages resource overflow allocating more + * resources. + */ +class VKFencedPool { +public: + explicit VKFencedPool(std::size_t grow_step); + virtual ~VKFencedPool(); + +protected: + /** + * Commits a free resource and protects it with a fence. It may allocate new resources. + * @param fence Fence that protects the commited resource. + * @returns Index of the resource commited. + */ + std::size_t CommitResource(VKFence& fence); + + /// Called when a chunk of resources have to be allocated. + virtual void Allocate(std::size_t begin, std::size_t end) = 0; + +private: + /// Manages pool overflow allocating new resources. + std::size_t ManageOverflow(); + + /// Allocates a new page of resources. + void Grow(); + + std::size_t grow_step = 0; ///< Number of new resources created after an overflow + std::size_t free_iterator = 0; ///< Hint to where the next free resources is likely to be found + std::vector<std::unique_ptr<VKFenceWatch>> watches; ///< Set of watched resources +}; + +/** * The resource manager handles all resources that can be protected with a fence avoiding * driver-side or GPU-side concurrent usage. Usage is documented in VKFence. */ |