mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-29 16:55:28 +03:00
Allow manual allocation of ActiveCommandBuffer
`CommandScheduler` API users can now directly allocate an active command buffer that they need to manage alongside its fence, this can allow for more efficient recording as it doesn't need to be immediately submitted after, it can also allow attaching objects to a `FenceCycle` prior to submission that can be useful for locking resources.
This commit is contained in:
parent
8989305637
commit
aeea3e6f66
@ -31,6 +31,22 @@ namespace skyline::gpu {
|
|||||||
static bool AllocateIfFree(CommandBufferSlot &slot);
|
static bool AllocateIfFree(CommandBufferSlot &slot);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GPU &gpu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A command pool designed to be thread-local to respect external synchronization for all command buffers and the associated pool
|
||||||
|
* @note If we utilized a single global pool there would need to be a mutex around command buffer recording which would incur significant costs
|
||||||
|
*/
|
||||||
|
struct CommandPool {
|
||||||
|
vk::raii::CommandPool vkCommandPool;
|
||||||
|
std::list<CommandBufferSlot> buffers;
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
constexpr CommandPool(Args &&... args) : vkCommandPool(std::forward<Args>(args)...) {}
|
||||||
|
};
|
||||||
|
ThreadLocal<CommandPool> pool;
|
||||||
|
|
||||||
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief An active command buffer occupies a slot and ensures that its status is updated correctly
|
* @brief An active command buffer occupies a slot and ensures that its status is updated correctly
|
||||||
*/
|
*/
|
||||||
@ -60,22 +76,20 @@ namespace skyline::gpu {
|
|||||||
vk::raii::CommandBuffer *operator->() {
|
vk::raii::CommandBuffer *operator->() {
|
||||||
return &slot.commandBuffer;
|
return &slot.commandBuffer;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
GPU &gpu;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A command pool designed to be thread-local to respect external synchronization for all command buffers and the associated pool
|
* @brief Resets the state of the command buffer with a new FenceCycle
|
||||||
* @note If we utilized a single global pool there would need to be a mutex around command buffer recording which would incur significant costs
|
* @note This should be used when a single allocated command buffer is used for all submissions from a component
|
||||||
*/
|
*/
|
||||||
struct CommandPool {
|
std::shared_ptr<FenceCycle> Reset() {
|
||||||
vk::raii::CommandPool vkCommandPool;
|
slot.cycle->Wait();
|
||||||
std::list<CommandBufferSlot> buffers;
|
slot.cycle = std::make_shared<FenceCycle>(slot.device, *slot.fence);
|
||||||
|
slot.commandBuffer.reset();
|
||||||
template<typename... Args>
|
return slot.cycle;
|
||||||
constexpr CommandPool(Args &&... args) : vkCommandPool(std::forward<Args>(args)...) {}
|
}
|
||||||
};
|
};
|
||||||
ThreadLocal<CommandPool> pool;
|
|
||||||
|
CommandScheduler(GPU &gpu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Allocates an existing or new primary command buffer from the pool
|
* @brief Allocates an existing or new primary command buffer from the pool
|
||||||
@ -87,9 +101,6 @@ namespace skyline::gpu {
|
|||||||
*/
|
*/
|
||||||
void SubmitCommandBuffer(const vk::raii::CommandBuffer &commandBuffer, vk::Fence fence = {});
|
void SubmitCommandBuffer(const vk::raii::CommandBuffer &commandBuffer, vk::Fence fence = {});
|
||||||
|
|
||||||
public:
|
|
||||||
CommandScheduler(GPU &gpu);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Submits a command buffer recorded with the supplied function synchronously
|
* @brief Submits a command buffer recorded with the supplied function synchronously
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user