vulkan/wsi/x11: Add support for VK_KHR_get_surface_capabilities2
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 17 Mar 2017 21:04:57 +0000 (14:04 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 16 May 2017 15:38:43 +0000 (08:38 -0700)
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
src/vulkan/wsi/wsi_common_x11.c

index 35801947f8e2cb65ae9cdd319343f41697646551..5be56f1232fbb2fd9a2c29a294771bbbb1b67458 100644 (file)
@@ -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;