VulkanRenderer: Improve transient command buffer usage
Allocate and reuse them between frames, by resetting the command pool
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandPool.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Fence.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Semaphore.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -26,7 +25,7 @@ namespace Nz
|
||||
VulkanRenderImage(VulkanSwapchain& owner);
|
||||
VulkanRenderImage(const VulkanRenderImage&) = delete;
|
||||
VulkanRenderImage(VulkanRenderImage&&) = delete;
|
||||
~VulkanRenderImage();
|
||||
~VulkanRenderImage() = default;
|
||||
|
||||
void Execute(const FunctionRef<void(CommandBufferBuilder& builder)>& callback, QueueTypeFlags queueTypeFlags) override;
|
||||
|
||||
@@ -47,9 +46,9 @@ namespace Nz
|
||||
VulkanRenderImage& operator=(VulkanRenderImage&&) = delete;
|
||||
|
||||
private:
|
||||
std::size_t m_currentCommandBuffer;
|
||||
std::vector<Vk::AutoCommandBuffer> m_inFlightCommandBuffers;
|
||||
std::vector<VkCommandBuffer> m_graphicalCommandsBuffers;
|
||||
std::size_t m_freeCommandBufferIndex;
|
||||
std::vector<VkCommandBuffer> m_allocatedCommandBuffers;;
|
||||
std::vector<VkCommandBuffer> m_graphicalCommandBuffers;
|
||||
VulkanSwapchain& m_owner;
|
||||
Vk::CommandPool m_commandPool;
|
||||
Vk::Fence m_inFlightFence;
|
||||
|
||||
@@ -30,9 +30,10 @@ namespace Nz
|
||||
{
|
||||
FlushReleaseQueue();
|
||||
|
||||
m_graphicalCommandsBuffers.clear();
|
||||
m_currentCommandBuffer = 0;
|
||||
m_graphicalCommandBuffers.clear();
|
||||
m_freeCommandBufferIndex = 0;
|
||||
m_imageIndex = imageIndex;
|
||||
m_commandPool.Reset();
|
||||
m_uploadPool.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Nz::Vk
|
||||
|
||||
public:
|
||||
inline CommandBuffer();
|
||||
inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle);
|
||||
CommandBuffer(const CommandBuffer&) = delete;
|
||||
inline CommandBuffer(CommandBuffer&& commandBuffer) noexcept;
|
||||
~CommandBuffer() = default;
|
||||
@@ -111,8 +112,6 @@ namespace Nz::Vk
|
||||
inline operator VkCommandBuffer() const;
|
||||
|
||||
private:
|
||||
inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle);
|
||||
|
||||
CommandPool* m_pool;
|
||||
VkCommandBuffer m_handle;
|
||||
VkResult m_lastErrorCode;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Nz
|
||||
using DeviceObject::Create;
|
||||
inline bool Create(Device& device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr);
|
||||
|
||||
inline bool Reset(VkCommandPoolResetFlags flags);
|
||||
inline bool Reset(VkCommandPoolResetFlags flags = 0);
|
||||
|
||||
CommandPool& operator=(const CommandPool&) = delete;
|
||||
CommandPool& operator=(CommandPool&&) = delete;
|
||||
|
||||
Reference in New Issue
Block a user