MCPcopy Create free account
hub / github.com/SFML/SFML / draw

Method draw

examples/vulkan/Vulkan.cpp:2447–2529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2445 }
2446
2447 void draw()
2448 {
2449 std::uint32_t imageIndex = 0;
2450
2451 // If the objects we need to submit this frame are still pending, wait here
2452 vkWaitForFences(device, 1, &fences[currentFrame], VK_TRUE, std::numeric_limits<std::uint64_t>::max());
2453
2454 {
2455 // Get the next image in the swapchain
2456 const VkResult result = vkAcquireNextImageKHR(device,
2457 swapchain,
2458 std::numeric_limits<std::uint64_t>::max(),
2459 imageAvailableSemaphores[currentFrame],
2460 VK_NULL_HANDLE,
2461 &imageIndex);
2462
2463 // Check if we need to re-create the swapchain (e.g. if the window was resized)
2464 if (result == VK_ERROR_OUT_OF_DATE_KHR)
2465 {
2466 recreateSwapchain();
2467 swapchainOutOfDate = false;
2468 return;
2469 }
2470
2471 if ((result != VK_SUCCESS) && (result != VK_TIMEOUT) && (result != VK_NOT_READY) &&
2472 (result != VK_SUBOPTIMAL_KHR))
2473 {
2474 vulkanAvailable = false;
2475 return;
2476 }
2477 }
2478
2479 // Wait for the swapchain image to be available in the color attachment stage before submitting the queue
2480 const VkPipelineStageFlags waitStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
2481
2482 // Signal the render finished semaphore once the queue has been processed
2483 VkSubmitInfo submitInfo = VkSubmitInfo();
2484 submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
2485 submitInfo.waitSemaphoreCount = 1;
2486 submitInfo.pWaitSemaphores = &imageAvailableSemaphores[currentFrame];
2487 submitInfo.pWaitDstStageMask = &waitStages;
2488 submitInfo.commandBufferCount = 1;
2489 submitInfo.pCommandBuffers = &commandBuffers[imageIndex];
2490 submitInfo.signalSemaphoreCount = 1;
2491 submitInfo.pSignalSemaphores = &renderFinishedSemaphores[currentFrame];
2492
2493 vkResetFences(device, 1, &fences[currentFrame]);
2494
2495 if (vkQueueSubmit(queue, 1, &submitInfo, fences[currentFrame]) != VK_SUCCESS)
2496 {
2497 vulkanAvailable = false;
2498 return;
2499 }
2500
2501 // Wait for rendering to complete before presenting
2502 VkPresentInfoKHR presentInfo = VkPresentInfoKHR();
2503 presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
2504 presentInfo.waitSemaphoreCount = 1;

Callers

nothing calls this directly

Calls 2

VkSubmitInfoClass · 0.70
VkPresentInfoKHRClass · 0.70

Tested by

no test coverage detected