diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-02-22 05:27:25 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-02-22 05:33:32 +0100 |
commit | f546fb35edd87f7837e74ee03e29b89bcb1559ea (patch) | |
tree | 00e98e17b2407296d7142239cb68b104d181642e /src/video_core/renderer_vulkan/vk_scheduler.h | |
parent | Merge pull request #2138 from ReinUsesLisp/vulkan-memory-manager (diff) | |
download | yuzu-f546fb35edd87f7837e74ee03e29b89bcb1559ea.tar yuzu-f546fb35edd87f7837e74ee03e29b89bcb1559ea.tar.gz yuzu-f546fb35edd87f7837e74ee03e29b89bcb1559ea.tar.bz2 yuzu-f546fb35edd87f7837e74ee03e29b89bcb1559ea.tar.lz yuzu-f546fb35edd87f7837e74ee03e29b89bcb1559ea.tar.xz yuzu-f546fb35edd87f7837e74ee03e29b89bcb1559ea.tar.zst yuzu-f546fb35edd87f7837e74ee03e29b89bcb1559ea.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_scheduler.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h new file mode 100644 index 000000000..cfaf5376f --- /dev/null +++ b/src/video_core/renderer_vulkan/vk_scheduler.h @@ -0,0 +1,69 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "common/common_types.h" +#include "video_core/renderer_vulkan/declarations.h" + +namespace Vulkan { + +class VKDevice; +class VKExecutionContext; +class VKFence; +class VKResourceManager; + +/// The scheduler abstracts command buffer and fence management with an interface that's able to do +/// OpenGL-like operations on Vulkan command buffers. +class VKScheduler { +public: + explicit VKScheduler(const VKDevice& device, VKResourceManager& resource_manager); + ~VKScheduler(); + + /// Gets the current execution context. + [[nodiscard]] VKExecutionContext GetExecutionContext() const; + + /// Sends the current execution context to the GPU. It invalidates the current execution context + /// and returns a new one. + VKExecutionContext Flush(vk::Semaphore semaphore = nullptr); + + /// Sends the current execution context to the GPU and waits for it to complete. It invalidates + /// the current execution context and returns a new one. + VKExecutionContext Finish(vk::Semaphore semaphore = nullptr); + +private: + void SubmitExecution(vk::Semaphore semaphore); + + void AllocateNewContext(); + + const VKDevice& device; + VKResourceManager& resource_manager; + vk::CommandBuffer current_cmdbuf; + VKFence* current_fence = nullptr; + VKFence* next_fence = nullptr; +}; + +class VKExecutionContext { + friend class VKScheduler; + +public: + VKExecutionContext() = default; + + VKFence& GetFence() const { + return *fence; + } + + vk::CommandBuffer GetCommandBuffer() const { + return cmdbuf; + } + +private: + explicit VKExecutionContext(VKFence* fence, vk::CommandBuffer cmdbuf) + : fence{fence}, cmdbuf{cmdbuf} {} + + VKFence* fence{}; + vk::CommandBuffer cmdbuf; +}; + +} // namespace Vulkan |