Пример #1
0
        private void EndSingleTimeCommand(CommandBuffer[] buffers, CommandPool pool, Queue queue)
        {
            buffers[0].End();

            queue.Submit(new SubmitInfo {
                CommandBuffers = buffers
            }, null);
            queue.WaitIdle();

            pool.FreeCommandBuffers(buffers);
        }
Пример #2
0
        private static void TransferByCommand(Device device, int bufferSize, Buffer inBuffer, Buffer outBuffer, CommandPool commandPool)
        {
            var transferCommandBuffer = device.AllocateCommandBuffers(commandPool, CommandBufferLevel.Primary, 1).Single();

            transferCommandBuffer.Begin(CommandBufferUsageFlags.OneTimeSubmit);

            transferCommandBuffer.CopyBuffer(inBuffer, outBuffer, new[] { new BufferCopy(0, 0, bufferSize) });

            transferCommandBuffer.End();

            var transferQueue = device.GetQueue(0, 0);

            transferQueue.Submit(new[] { new SubmitInfo {
                                             CommandBuffers = new[] { transferCommandBuffer }
                                         } }, null);

            transferQueue.WaitIdle();

            commandPool.FreeCommandBuffers(new[] { transferCommandBuffer });
        }
Пример #3
0
        private void RecreateSwapChain()
        {
            device.WaitIdle();

            commandPool.FreeCommandBuffers(commandBuffers);

            foreach (var frameBuffer in frameBuffers)
            {
                frameBuffer.Dispose();
            }
            frameBuffers = null;

            pipeline.Dispose();
            pipeline = null;

            pipelineLayout.Dispose();
            pipelineLayout = null;

            foreach (var imageView in swapChainImageViews)
            {
                imageView.Dispose();
            }
            swapChainImageViews = null;

            renderPass.Dispose();
            renderPass = null;

            swapChain.Dispose();
            swapChain = null;

            CreateSwapChain();
            CreateImageViews();
            CreateRenderPass();
            CreateGraphicsPipeline();
            CreateFrameBuffers();
            CreateCommandBuffers();
        }