MCPcopy Create free account
hub / github.com/a2flo/floor / queue_present

Method queue_present

compute/vulkan/vulkan_compute.cpp:2490–2543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2488}
2489
2490bool vulkan_compute::queue_present(const compute_queue& dev_queue, const drawable_image_info& drawable) NO_THREAD_SAFETY_ANALYSIS {
2491 if (vr_ctx && drawable.layer_count > 1) {
2492#if !defined(FLOOR_NO_OPENVR) || !defined(FLOOR_NO_OPENXR)
2493 compute_image* present_image = nullptr;
2494 if (vr_ctx->has_swapchain()) {
2495 present_image = vr_screen.external_swapchain_images[drawable.index];
2496 } else {
2497 present_image = vr_screen.images[drawable.index].get();
2498
2499 // keep image state in sync
2500 ((vulkan_image*)present_image)->update_with_external_vulkan_state(drawable.present_layout, VK_ACCESS_2_TRANSFER_READ_BIT);
2501 }
2502
2503 // present both eyes
2504 // for bad backends: also temporarily disable validation, because they will throw errors
2505#if defined(FLOOR_DEBUG)
2506 const auto should_ignore_validation = vr_ctx->ignore_vulkan_validation();
2507 if (should_ignore_validation) {
2508 ignore_validation = true;
2509 }
2510#endif
2511 vr_ctx->present(dev_queue, present_image);
2512#if defined(FLOOR_DEBUG)
2513 if (should_ignore_validation) {
2514 ignore_validation = false;
2515 }
2516#endif
2517
2518 // unlock image again
2519 vr_screen.image_locks[drawable.index].unlock();
2520#endif
2521 } else {
2522 const auto& vk_queue = (const vulkan_queue&)dev_queue;
2523
2524 // present window image
2525 const VkPresentInfoKHR present_info {
2526 .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
2527 .pNext = nullptr,
2528 .waitSemaphoreCount = 0,
2529 .pWaitSemaphores = nullptr,
2530 .swapchainCount = 1,
2531 .pSwapchains = &screen.swapchain,
2532 .pImageIndices = &drawable.index,
2533 .pResults = nullptr,
2534 };
2535 const auto present_result = vkQueuePresentKHR((VkQueue)const_cast<void*>(vk_queue.get_queue_ptr()), &present_info);
2536 if (present_result != VK_SUCCESS && present_result != VK_SUBOPTIMAL_KHR) {
2537 log_error("failed to present: $: $", present_result, vulkan_error_to_string(present_result));
2538 return false;
2539 }
2540 }
2541
2542 return true;
2543}
2544
2545shared_ptr<compute_queue> vulkan_compute::create_queue_internal(const compute_device& dev, const uint32_t family_index,
2546 const compute_queue::QUEUE_TYPE queue_type,

Callers 1

commit_internalMethod · 0.80

Calls 8

vulkan_error_to_stringFunction · 0.85
unlockMethod · 0.80
has_swapchainMethod · 0.45
getMethod · 0.45
presentMethod · 0.45
get_queue_ptrMethod · 0.45

Tested by

no test coverage detected