public override void DrawFrame() { if (!initialized) { return; } uint nextIndex = device.AcquireNextImageKHR(swapchain, ulong.MaxValue, semaphore); device.ResetFence(fence); var submitInfo = new SubmitInfo { WaitSemaphores = new Semaphore [] { semaphore }, WaitDstStageMask = new PipelineStageFlags [] { PipelineStageFlags.AllGraphics }, CommandBuffers = new CommandBuffer [] { commandBuffers [nextIndex] } }; queue.Submit(submitInfo, fence); device.WaitForFence(fence, true, 100000000); var presentInfo = new PresentInfoKhr { Swapchains = new SwapchainKhr [] { swapchain }, ImageIndices = new uint [] { nextIndex } }; queue.PresentKHR(presentInfo); }
public void DrawFrame() { vkPresentQueue.WaitIdle(); uint imageIndex = vkDevice.AcquireNextImageKHR(vkSwapChain, ulong.MaxValue, vkImageAvailableSemaphore); var submitInfo = new SubmitInfo() { WaitSemaphores = new Semaphore[] { vkImageAvailableSemaphore }, WaitDstStageMask = new PipelineStageFlags[] { PipelineStageFlags.ColorAttachmentOutput }, CommandBuffers = new CommandBuffer[] { vkCommandBuffers[imageIndex] }, SignalSemaphores = new Semaphore[] { vkRenderFinishedSemaphore }, }; vkGraphicsQueue.Submit(submitInfo); var presentInfo = new PresentInfoKhr() { WaitSemaphores = new Semaphore[] { vkRenderFinishedSemaphore }, Swapchains = new SwapchainKhr[] { vkSwapChain }, ImageIndices = new uint[] { imageIndex }, }; vkPresentQueue.PresentKHR(presentInfo); }
public void QueuePresent(Queue queue, int currentBuffer) { var presentInfo = new PresentInfoKhr { SwapchainCount = 1, Swapchains = new[] {Swapchain}, ImageIndices = new []{(uint)currentBuffer}, }; queue.PresentKHR(presentInfo); }
void DrawFrame() { uint nextIndex = device.AcquireNextImageKHR(swapchain, ulong.MaxValue, semaphore, fences [0]); device.ResetFences(fences); var submitInfo = new SubmitInfo { WaitSemaphores = new Semaphore [] { semaphore }, CommandBuffers = new CommandBuffer [] { commandBuffers [nextIndex] } }; queue.Submit(new SubmitInfo [] { submitInfo }, fences [0]); device.WaitForFences(fences, true, 100000000); var presentInfo = new PresentInfoKhr { Swapchains = new SwapchainKhr [] { swapchain }, ImageIndices = new uint [] { nextIndex } }; queue.PresentKHR(presentInfo); }
private void DrawFrame() { uint nextIndex = _device.AcquireNextImageKHR (_swapchain, ulong.MaxValue, _semaphore, _fences [0]); _device.ResetFences(_fences); var submitInfo = new SubmitInfo { WaitSemaphores = new [] { _semaphore }, CommandBuffers = new [] { _commandBuffers [nextIndex] } }; _queue.Submit(new [] { submitInfo }, _fences [0]); _device.WaitForFences(_fences, true, 100000000); var presentInfo = new PresentInfoKhr { Swapchains = new [] { _swapchain }, ImageIndices = new [] { nextIndex } }; _queue.PresentKHR(presentInfo); }
internal void QueuePresent(Semaphore sem, int imageIndex, string presQueueName) { PresentInfoKhr pik = new PresentInfoKhr( new Semaphore[] { sem }, new SwapchainKhr[] { mSwapChain }, new int[1] { imageIndex }); try { mQueueNames[presQueueName].PresentKhr(pik); } catch (VulkanException ex) { if (ex.Result == Result.ErrorOutOfDateKhr) { Misc.SafeInvoke(eSwapChainOutOfDate, null); } } }
internal void DrawFrame(DrawDelegate drawDelegate) { var nextIndex = _device.AcquireNextImageKHR(_swapchainKhr, ulong.MaxValue, _semaphore); _device.ResetFence(_fence); var submitInfo = new SubmitInfo { WaitSemaphores = new[] { _semaphore }, WaitDstStageMask = new[] { PipelineStageFlags.AllGraphics }, CommandBuffers = new[] { _commandBuffers[nextIndex] } }; _queue.Submit(submitInfo, _fence); _device.WaitForFence(_fence, true, 100000000); var presentInfo = new PresentInfoKhr { Swapchains = new[] { _swapchainKhr }, ImageIndices = new[] { nextIndex } }; _queue.PresentKHR(presentInfo); }
public virtual void Initialize(InstanceCreateData data) { this.data = data; var graphicsQueue = new DeviceQueueCreateInfo { QueuePriorities = new float[] { 1.0f }, QueueFamilyIndex = (uint)data.queueFamilyIndices.GraphicsFamily }; var presentQueue = new DeviceQueueCreateInfo { QueuePriorities = new float[] { 1.0f }, QueueFamilyIndex = (uint)data.queueFamilyIndices.PresentFamily }; var deviceInfo = new DeviceCreateInfo { EnabledExtensionNames = data.enabledDeviceExtensions, EnabledExtensionCount = (uint)data.enabledDeviceExtensions.Length, EnabledLayerNames = data.enabledLayers, EnabledLayerCount = (data.enabledLayers == null ? 0 : (uint)data.enabledLayers.Length), QueueCreateInfos = new DeviceQueueCreateInfo[] { graphicsQueue, presentQueue }, EnabledFeatures = new PhysicalDeviceFeatures { SamplerAnisotropy = true } }; device = data.physicalDevice.CreateDevice(deviceInfo); this.graphicsQueue = device.GetQueue((uint)data.queueFamilyIndices.GraphicsFamily, 0); this.presentQueue = device.GetQueue((uint)data.queueFamilyIndices.PresentFamily, 0); CreateSwapChain(); CreateImageViews(); CreateRenderPass(); CreateDescriptorSetLayout(); CreateGraphicsPipeline(); CreateFrameBuffers(); CreateCommandPool(); CreateBuffers(); CreateDescriptorPool(); CreateDescriptorSets(); CreateCommandBuffers(); CreateSyncObjects(); submitInfo = new SubmitInfo { WaitSemaphoreCount = 1, WaitDstStageMask = waitStages, CommandBufferCount = 1, SignalSemaphoreCount = 1, }; presentInfo = new PresentInfoKhr { WaitSemaphoreCount = 1, SwapchainCount = 1, }; initialized = running = true; _lastFrame = DateTime.Now; Start(); //data.control.ParentForm.ResizeBegin += ResizeBegin; //data.control.ParentForm.ResizeEnd += ResizeEnd; }