From 56901c9ea4d419aad68fd75b0e89aff600730587 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 17 Mar 2017 14:04:57 -0700 Subject: [PATCH] vulkan/wsi/x11: Add support for VK_KHR_get_surface_capabilities2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Samuel Iglesias Gonsálvez --- src/vulkan/wsi/wsi_common_x11.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 35801947f8e..5be56f1232f 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -511,6 +511,16 @@ x11_surface_get_capabilities(VkIcdSurfaceBase *icd_surface, return VK_SUCCESS; } +static VkResult +x11_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface, + const void *info_next, + VkSurfaceCapabilities2KHR *caps) +{ + assert(caps->sType == VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR); + + return x11_surface_get_capabilities(icd_surface, &caps->surfaceCapabilities); +} + static VkResult x11_surface_get_formats(VkIcdSurfaceBase *surface, struct wsi_device *wsi_device, @@ -529,6 +539,26 @@ x11_surface_get_formats(VkIcdSurfaceBase *surface, return vk_outarray_status(&out); } +static VkResult +x11_surface_get_formats2(VkIcdSurfaceBase *surface, + struct wsi_device *wsi_device, + const void *info_next, + uint32_t *pSurfaceFormatCount, + VkSurfaceFormat2KHR *pSurfaceFormats) +{ + VK_OUTARRAY_MAKE(out, pSurfaceFormats, pSurfaceFormatCount); + + for (unsigned i = 0; i < ARRAY_SIZE(formats); i++) { + vk_outarray_append(&out, f) { + assert(f->sType == VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR); + f->surfaceFormat.format = formats[i]; + f->surfaceFormat.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; + } + } + + return vk_outarray_status(&out); +} + static VkResult x11_surface_get_present_modes(VkIcdSurfaceBase *surface, uint32_t *pPresentModeCount, @@ -1243,7 +1273,9 @@ wsi_x11_init_wsi(struct wsi_device *wsi_device, wsi->base.get_support = x11_surface_get_support; wsi->base.get_capabilities = x11_surface_get_capabilities; + wsi->base.get_capabilities2 = x11_surface_get_capabilities2; wsi->base.get_formats = x11_surface_get_formats; + wsi->base.get_formats2 = x11_surface_get_formats2; wsi->base.get_present_modes = x11_surface_get_present_modes; wsi->base.create_swapchain = x11_surface_create_swapchain; -- 2.30.2