namespace Brutal.VulkanApi.Abstractions; /// /// Provides extension methods for submitting command buffers and handling synchronization for Vulkan queues. /// public static class QueueExtensions { /// /// Submits command buffers to a Vulkan queue with specified wait and signal semaphores, and a fence for synchronization. /// /// The Vulkan queue to submit command buffers to. /// A span of semaphores to wait on before executing the command buffers. /// A span of pipeline stage flags indicating the stages to wait for. /// A span of command buffers to execute. /// A span of semaphores to signal after executing the command buffers. /// A fence that is signaled when the queue finishes executing the submitted command buffers. public static void Submit( this Queue queue, Span waitSemaphores, Span waitDstStageMask, Span commandBuffers, Span signalSemaphores, VkFence fence ) { unsafe { var commandBuffersPtr = stackalloc VkCommandBuffer[commandBuffers.Length]; for (var i = 0; i < commandBuffers.Length; i++) commandBuffersPtr[i] = commandBuffers[i].Handle; fixed (VkSemaphore* waitSemaphoresPtr = waitSemaphores) fixed (VkPipelineStageFlags* waitDstStageMaskPtr = waitDstStageMask) fixed (VkSemaphore* signalSemaphoresPtr = signalSemaphores) { var submitInfo = new VkSubmitInfo { WaitSemaphoreCount = waitSemaphores.Length, WaitSemaphores = waitSemaphoresPtr, WaitDstStageMask = waitDstStageMaskPtr, CommandBufferCount = commandBuffers.Length, CommandBuffers = commandBuffersPtr, SignalSemaphoreCount = signalSemaphores.Length, SignalSemaphores = signalSemaphoresPtr, }; queue.Submit([submitInfo], fence); } } } }