namespace Brutal.VulkanApi.Abstractions; /// /// Structure to hold synchronization objects for the Renderer /// public class SyncObjects(Device inDevice) : IDisposable { /// /// Semaphore signalled when the acquired swapchain image is ready to be rendered to. /// public required VkSemaphore ImageReadySemaphore; /// /// Semaphore signalled when rendering has finished and the image can be presented. /// public required VkSemaphore RenderingFinishedSemaphore; /// /// Signaled Fence /// public required VkFence Fence; /// /// A CommandBuffer from the Graphics pool which can be used for rendering commands. /// public required CommandBuffer CommandBuffer; /// /// The command pool that was allocated from. /// When set, frees the command buffer back to this pool; when left /// default, the caller retains ownership of the command buffer and must free it themselves /// (otherwise every rebuild permanently grows the pool). /// public VkCommandPool CommandPool = default; /// /// The allocator the sync objects were created with /// public required VkAllocator? Allocator; public void Dispose() { if (!CommandPool.IsNull()) inDevice.FreeCommandBuffers(CommandPool, [CommandBuffer]); inDevice.DestroyFence(Fence, Allocator); inDevice.DestroySemaphore(ImageReadySemaphore, Allocator); inDevice.DestroySemaphore(RenderingFinishedSemaphore, Allocator); } }