Beispiel #1
0
        public void Submit(CommandBuffer buffer, VkSemaphore?wait = null, VkPipelineStageFlag waitStage = 0,
                           VkSemaphore?signal = null,
                           VkFence?submit     = null)
        {
            buffer.AssertBuilt();
            var buff = buffer.Handle;

            unsafe
            {
                var waitH   = wait ?? VkSemaphore.Null;
                var signalH = signal ?? VkSemaphore.Null;
                var submitH = submit ?? VkFence.Null;
                var info    = new VkSubmitInfo()
                {
                    SType = VkStructureType.SubmitInfo,
                    PNext = IntPtr.Zero,
                    CommandBufferCount   = 1,
                    PCommandBuffers      = &buff,
                    SignalSemaphoreCount = signalH != VkSemaphore.Null ? 1u : 0u,
                    PSignalSemaphores    = &signalH,
                    WaitSemaphoreCount   = waitH != VkSemaphore.Null ? 1u : 0u,
                    PWaitSemaphores      = &waitH,
                    PWaitDstStageMask    = &waitStage,
                };
                if (buffer is CommandBufferPooledExclusiveUse peu)
                {
                    Debug.Assert(submitH == VkFence.Null, "Can't use a submit fence on a pooled handle");
                    peu.DoSubmit(Handle, info);
                }
                else
                {
                    VkException.Check(VkQueue.vkQueueSubmit(Handle, 1, &info, submitH));
                }
            }
        }
Beispiel #2
0
        public void Submit(CommandBuffer[] buffers, VkSemaphore[] wait, VkPipelineStageFlag[] waitStages,
                           VkSemaphore[] signal, VkFence submit)
        {
            unsafe
            {
                // ReSharper disable once PossibleNullReferenceException
                Debug.Assert((waitStages == null && wait == null) || waitStages.Length == wait.Length);
                var arrayBuffers = buffers.Where(x => !(x is CommandBufferPooledExclusiveUse)).Select(x =>
                {
                    x.AssertBuilt();
                    return(x.Handle);
                }).ToArray();
                var pooledBuffers = buffers.OfType <CommandBufferPooledExclusiveUse>().ToArray();
                Debug.Assert(pooledBuffers.Length == 0 || submit == VkFence.Null,
                             "Can't use custom submit fence on pooled buffers");
                fixed(VkSemaphore *waitPtr = wait)
                fixed(VkPipelineStageFlag * waitStagePtr = waitStages)
                fixed(VkSemaphore * signalPtr            = signal)
                {
                    if (arrayBuffers.Length > 0)
                        fixed(VkCommandBuffer *buffer = arrayBuffers)
                        {
                            var info = new VkSubmitInfo()
                            {
                                SType = VkStructureType.SubmitInfo,
                                PNext = IntPtr.Zero,
                                CommandBufferCount   = (uint)arrayBuffers.Length,
                                PCommandBuffers      = buffer,
                                SignalSemaphoreCount = (uint)(signal?.Length ?? 0),
                                PSignalSemaphores    = signalPtr,
                                WaitSemaphoreCount   = (uint)(wait?.Length ?? 0),
                                PWaitSemaphores      = waitPtr,
                                PWaitDstStageMask    = waitStagePtr,
                            };

                            VkException.Check(VkQueue.vkQueueSubmit(Handle, 1, &info, submit));
                        }
                    foreach (var pooled in pooledBuffers)
                    {
                        var handle = pooled.Handle;
                        var info   = new VkSubmitInfo()
                        {
                            SType = VkStructureType.SubmitInfo,
                            PNext = IntPtr.Zero,
                            CommandBufferCount   = 1,
                            PCommandBuffers      = &handle,
                            SignalSemaphoreCount = (uint)(signal?.Length ?? 0),
                            PSignalSemaphores    = signalPtr,
                            WaitSemaphoreCount   = (uint)(wait?.Length ?? 0),
                            PWaitSemaphores      = waitPtr,
                            PWaitDstStageMask    = waitStagePtr,
                        };
                        pooled.DoSubmit(Handle, info);
                    }
                }
            }
        }