From c6c7a0047c06fbc9184f46fc6149701f28be6b62 Mon Sep 17 00:00:00 2001 From: Simon Zeni <simon.zeni@collabora.com> Date: Thu, 17 Oct 2024 11:01:27 -0400 Subject: [PATCH] c/main: pick composite alpha from surface caps in swapchain creation Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2332> --- src/xrt/compositor/main/comp_target_swapchain.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/xrt/compositor/main/comp_target_swapchain.c b/src/xrt/compositor/main/comp_target_swapchain.c index 95b3084cc..29bb2644e 100644 --- a/src/xrt/compositor/main/comp_target_swapchain.c +++ b/src/xrt/compositor/main/comp_target_swapchain.c @@ -731,6 +731,20 @@ comp_target_swapchain_create_images(struct comp_target *ct, const struct comp_ta // Get the image count. uint32_t image_count = select_image_count(cts, surface_caps, preferred_at_least_image_count); + /* + * VUID-VkSwapchainCreateInfoKHR-compositeAlpha-01280 + * compositeAlpha must be one of the bits present in the supportedCompositeAlpha member of the + * VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface. + */ + VkCompositeAlphaFlagsKHR composite_alpha = 0; + if (surface_caps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR) { + composite_alpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; + } else if (surface_caps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) { + composite_alpha = VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR; + } else { + COMP_ERROR(ct->c, "Unsupported composite alpha"); + goto error_print_and_free; + } /* * Do the creation. @@ -753,7 +767,7 @@ comp_target_swapchain_create_images(struct comp_target *ct, const struct comp_ta .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE, .queueFamilyIndexCount = 0, .preTransform = surface_caps.currentTransform, - .compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, + .compositeAlpha = composite_alpha, .presentMode = cts->present_mode, .clipped = VK_TRUE, .oldSwapchain = old_swapchain_handle,