vulkan/wsi: Add wrappers for all of the surface queries
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 16 Nov 2017 20:26:26 +0000 (12:26 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 4 Dec 2017 18:04:19 +0000 (10:04 -0800)
This lets us move wsi_interface to wsi_common_private.h

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
src/amd/vulkan/radv_wsi.c
src/intel/vulkan/anv_wsi.c
src/vulkan/wsi/wsi_common.c
src/vulkan/wsi/wsi_common.h
src/vulkan/wsi/wsi_common_private.h

index 14431f471f1df8011fb9a37ea47e54bc724d4b0b..676050531da3a02aa94a4a574c29e80b91304932 100644 (file)
@@ -105,56 +105,57 @@ void radv_DestroySurfaceKHR(
 VkResult radv_GetPhysicalDeviceSurfaceSupportKHR(
        VkPhysicalDevice                            physicalDevice,
        uint32_t                                    queueFamilyIndex,
-       VkSurfaceKHR                                _surface,
+       VkSurfaceKHR                                surface,
        VkBool32*                                   pSupported)
 {
        RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
-       ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-       struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-       return iface->get_support(surface, &device->wsi_device,
-                                 &device->instance->alloc,
-                                 queueFamilyIndex, device->local_fd, pSupported);
+       return wsi_common_get_surface_support(&device->wsi_device,
+                                             device->local_fd,
+                                             queueFamilyIndex,
+                                             surface,
+                                             &device->instance->alloc,
+                                             pSupported);
 }
 
 VkResult radv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
        VkPhysicalDevice                            physicalDevice,
-       VkSurfaceKHR                                _surface,
+       VkSurfaceKHR                                surface,
        VkSurfaceCapabilitiesKHR*                   pSurfaceCapabilities)
 {
        RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
-       ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-       struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-       return iface->get_capabilities(surface, pSurfaceCapabilities);
+       return wsi_common_get_surface_capabilities(&device->wsi_device,
+                                                  surface,
+                                                  pSurfaceCapabilities);
 }
 
 VkResult radv_GetPhysicalDeviceSurfaceFormatsKHR(
        VkPhysicalDevice                            physicalDevice,
-       VkSurfaceKHR                                _surface,
+       VkSurfaceKHR                                surface,
        uint32_t*                                   pSurfaceFormatCount,
        VkSurfaceFormatKHR*                         pSurfaceFormats)
 {
        RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
-       ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-       struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-       return iface->get_formats(surface, &device->wsi_device, pSurfaceFormatCount,
-                                 pSurfaceFormats);
+       return wsi_common_get_surface_formats(&device->wsi_device,
+                                             surface,
+                                             pSurfaceFormatCount,
+                                             pSurfaceFormats);
 }
 
 VkResult radv_GetPhysicalDeviceSurfacePresentModesKHR(
        VkPhysicalDevice                            physicalDevice,
-       VkSurfaceKHR                                _surface,
+       VkSurfaceKHR                                surface,
        uint32_t*                                   pPresentModeCount,
        VkPresentModeKHR*                           pPresentModes)
 {
        RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
-       ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-       struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-       return iface->get_present_modes(surface, pPresentModeCount,
-                                       pPresentModes);
+       return wsi_common_get_surface_present_modes(&device->wsi_device,
+                                                   surface,
+                                                   pPresentModeCount,
+                                                   pPresentModes);
 }
 
 VkResult radv_CreateSwapchainKHR(
index 5c09d3b98373c8f3772ec4c8de7dede60ab7b651..6ff8ebd26a52b46fd15072255d724b23868b372e 100644 (file)
@@ -107,28 +107,29 @@ void anv_DestroySurfaceKHR(
 VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(
     VkPhysicalDevice                            physicalDevice,
     uint32_t                                    queueFamilyIndex,
-    VkSurfaceKHR                                _surface,
+    VkSurfaceKHR                                surface,
     VkBool32*                                   pSupported)
 {
    ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-   struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-   return iface->get_support(surface, &device->wsi_device,
-                             &device->instance->alloc,
-                             queueFamilyIndex, device->local_fd, pSupported);
+   return wsi_common_get_surface_support(&device->wsi_device,
+                                         device->local_fd,
+                                         queueFamilyIndex,
+                                         surface,
+                                         &device->instance->alloc,
+                                         pSupported);
 }
 
 VkResult anv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
     VkPhysicalDevice                            physicalDevice,
-    VkSurfaceKHR                                _surface,
+    VkSurfaceKHR                                surface,
     VkSurfaceCapabilitiesKHR*                   pSurfaceCapabilities)
 {
    ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-   struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-   return iface->get_capabilities(surface, pSurfaceCapabilities);
+   return wsi_common_get_surface_capabilities(&device->wsi_device,
+                                              surface,
+                                              pSurfaceCapabilities);
 }
 
 VkResult anv_GetPhysicalDeviceSurfaceCapabilities2KHR(
@@ -137,25 +138,22 @@ VkResult anv_GetPhysicalDeviceSurfaceCapabilities2KHR(
     VkSurfaceCapabilities2KHR*                  pSurfaceCapabilities)
 {
    ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, pSurfaceInfo->surface);
-   struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-   return iface->get_capabilities2(surface, pSurfaceInfo->pNext,
-                                   pSurfaceCapabilities);
+   return wsi_common_get_surface_capabilities2(&device->wsi_device,
+                                               pSurfaceInfo,
+                                               pSurfaceCapabilities);
 }
 
 VkResult anv_GetPhysicalDeviceSurfaceFormatsKHR(
     VkPhysicalDevice                            physicalDevice,
-    VkSurfaceKHR                                _surface,
+    VkSurfaceKHR                                surface,
     uint32_t*                                   pSurfaceFormatCount,
     VkSurfaceFormatKHR*                         pSurfaceFormats)
 {
    ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-   struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-   return iface->get_formats(surface, &device->wsi_device, pSurfaceFormatCount,
-                             pSurfaceFormats);
+   return wsi_common_get_surface_formats(&device->wsi_device, surface,
+                                         pSurfaceFormatCount, pSurfaceFormats);
 }
 
 VkResult anv_GetPhysicalDeviceSurfaceFormats2KHR(
@@ -165,25 +163,22 @@ VkResult anv_GetPhysicalDeviceSurfaceFormats2KHR(
     VkSurfaceFormat2KHR*                        pSurfaceFormats)
 {
    ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, pSurfaceInfo->surface);
-   struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-   return iface->get_formats2(surface, &device->wsi_device, pSurfaceInfo->pNext,
-                              pSurfaceFormatCount, pSurfaceFormats);
+   return wsi_common_get_surface_formats2(&device->wsi_device, pSurfaceInfo,
+                                          pSurfaceFormatCount, pSurfaceFormats);
 }
 
 VkResult anv_GetPhysicalDeviceSurfacePresentModesKHR(
     VkPhysicalDevice                            physicalDevice,
-    VkSurfaceKHR                                _surface,
+    VkSurfaceKHR                                surface,
     uint32_t*                                   pPresentModeCount,
     VkPresentModeKHR*                           pPresentModes)
 {
    ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
-   struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
-   return iface->get_present_modes(surface, pPresentModeCount,
-                                   pPresentModes);
+   return wsi_common_get_surface_present_modes(&device->wsi_device, surface,
+                                               pPresentModeCount,
+                                               pPresentModes);
 }
 
 VkResult anv_CreateSwapchainKHR(
index 50680a6fd751d3029575058b8ee0c6ecd9bcaa30..a303aabf2c47a6de080fa0282539650f228dfb91 100644 (file)
@@ -487,6 +487,83 @@ wsi_destroy_image(const struct wsi_swapchain *chain,
    wsi->DestroyBuffer(chain->device, image->prime.buffer, &chain->alloc);
 }
 
+VkResult
+wsi_common_get_surface_support(struct wsi_device *wsi_device,
+                               int local_fd,
+                               uint32_t queueFamilyIndex,
+                               VkSurfaceKHR _surface,
+                               const VkAllocationCallbacks *alloc,
+                               VkBool32* pSupported)
+{
+   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
+   struct wsi_interface *iface = wsi_device->wsi[surface->platform];
+
+   return iface->get_support(surface, wsi_device, alloc,
+                             queueFamilyIndex, local_fd, pSupported);
+}
+
+VkResult
+wsi_common_get_surface_capabilities(struct wsi_device *wsi_device,
+                                    VkSurfaceKHR _surface,
+                                    VkSurfaceCapabilitiesKHR *pSurfaceCapabilities)
+{
+   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
+   struct wsi_interface *iface = wsi_device->wsi[surface->platform];
+
+   return iface->get_capabilities(surface, pSurfaceCapabilities);
+}
+
+VkResult
+wsi_common_get_surface_capabilities2(struct wsi_device *wsi_device,
+                                     const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
+                                     VkSurfaceCapabilities2KHR *pSurfaceCapabilities)
+{
+   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, pSurfaceInfo->surface);
+   struct wsi_interface *iface = wsi_device->wsi[surface->platform];
+
+   return iface->get_capabilities2(surface, pSurfaceInfo->pNext,
+                                   pSurfaceCapabilities);
+}
+
+VkResult
+wsi_common_get_surface_formats(struct wsi_device *wsi_device,
+                               VkSurfaceKHR _surface,
+                               uint32_t *pSurfaceFormatCount,
+                               VkSurfaceFormatKHR *pSurfaceFormats)
+{
+   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
+   struct wsi_interface *iface = wsi_device->wsi[surface->platform];
+
+   return iface->get_formats(surface, wsi_device,
+                             pSurfaceFormatCount, pSurfaceFormats);
+}
+
+VkResult
+wsi_common_get_surface_formats2(struct wsi_device *wsi_device,
+                                const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
+                                uint32_t *pSurfaceFormatCount,
+                                VkSurfaceFormat2KHR *pSurfaceFormats)
+{
+   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, pSurfaceInfo->surface);
+   struct wsi_interface *iface = wsi_device->wsi[surface->platform];
+
+   return iface->get_formats2(surface, wsi_device, pSurfaceInfo->pNext,
+                              pSurfaceFormatCount, pSurfaceFormats);
+}
+
+VkResult
+wsi_common_get_surface_present_modes(struct wsi_device *wsi_device,
+                                     VkSurfaceKHR _surface,
+                                     uint32_t *pPresentModeCount,
+                                     VkPresentModeKHR *pPresentModes)
+{
+   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
+   struct wsi_interface *iface = wsi_device->wsi[surface->platform];
+
+   return iface->get_present_modes(surface, pPresentModeCount,
+                                   pPresentModes);
+}
+
 VkResult
 wsi_common_create_swapchain(struct wsi_device *wsi,
                             VkDevice device,
index 32a7e731321df6d6849e3398d939d1a576a8751a..5e70575501926e174c4f3f5c6e6e370dd1b613ed 100644 (file)
@@ -48,41 +48,7 @@ struct wsi_memory_allocate_info {
     bool implicit_sync;
 };
 
-struct wsi_device;
-struct wsi_swapchain;
-
-struct wsi_interface {
-   VkResult (*get_support)(VkIcdSurfaceBase *surface,
-                           struct wsi_device *wsi_device,
-                           const VkAllocationCallbacks *alloc,
-                           uint32_t queueFamilyIndex,
-                           int local_fd,
-                           VkBool32* pSupported);
-   VkResult (*get_capabilities)(VkIcdSurfaceBase *surface,
-                                VkSurfaceCapabilitiesKHR* pSurfaceCapabilities);
-   VkResult (*get_capabilities2)(VkIcdSurfaceBase *surface,
-                                 const void *info_next,
-                                 VkSurfaceCapabilities2KHR* pSurfaceCapabilities);
-   VkResult (*get_formats)(VkIcdSurfaceBase *surface,
-                           struct wsi_device *wsi_device,
-                           uint32_t* pSurfaceFormatCount,
-                           VkSurfaceFormatKHR* pSurfaceFormats);
-   VkResult (*get_formats2)(VkIcdSurfaceBase *surface,
-                            struct wsi_device *wsi_device,
-                            const void *info_next,
-                            uint32_t* pSurfaceFormatCount,
-                            VkSurfaceFormat2KHR* pSurfaceFormats);
-   VkResult (*get_present_modes)(VkIcdSurfaceBase *surface,
-                                 uint32_t* pPresentModeCount,
-                                 VkPresentModeKHR* pPresentModes);
-   VkResult (*create_swapchain)(VkIcdSurfaceBase *surface,
-                                VkDevice device,
-                                struct wsi_device *wsi_device,
-                                int local_fd,
-                                const VkSwapchainCreateInfoKHR* pCreateInfo,
-                                const VkAllocationCallbacks* pAllocator,
-                                struct wsi_swapchain **swapchain);
-};
+struct wsi_interface;
 
 #define VK_ICD_WSI_PLATFORM_MAX 5
 
@@ -170,6 +136,42 @@ VkResult wsi_wl_init_wsi(struct wsi_device *wsi_device,
 void wsi_wl_finish_wsi(struct wsi_device *wsi_device,
                        const VkAllocationCallbacks *alloc);
 
+VkResult
+wsi_common_get_surface_support(struct wsi_device *wsi_device,
+                               int local_fd,
+                               uint32_t queueFamilyIndex,
+                               VkSurfaceKHR surface,
+                               const VkAllocationCallbacks *alloc,
+                               VkBool32* pSupported);
+
+VkResult
+wsi_common_get_surface_capabilities(struct wsi_device *wsi_device,
+                                    VkSurfaceKHR surface,
+                                    VkSurfaceCapabilitiesKHR *pSurfaceCapabilities);
+
+VkResult
+wsi_common_get_surface_capabilities2(struct wsi_device *wsi_device,
+                                     const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
+                                     VkSurfaceCapabilities2KHR *pSurfaceCapabilities);
+
+VkResult
+wsi_common_get_surface_formats(struct wsi_device *wsi_device,
+                               VkSurfaceKHR surface,
+                               uint32_t *pSurfaceFormatCount,
+                               VkSurfaceFormatKHR *pSurfaceFormats);
+
+VkResult
+wsi_common_get_surface_formats2(struct wsi_device *wsi_device,
+                                const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
+                                uint32_t *pSurfaceFormatCount,
+                                VkSurfaceFormat2KHR *pSurfaceFormats);
+
+VkResult
+wsi_common_get_surface_present_modes(struct wsi_device *wsi_device,
+                                     VkSurfaceKHR surface,
+                                     uint32_t *pPresentModeCount,
+                                     VkPresentModeKHR *pPresentModes);
+
 VkResult
 wsi_common_get_images(VkSwapchainKHR _swapchain,
                       uint32_t *pSwapchainImageCount,
index 3fa68f03249bd24932c8c6e7f51f68be002b19c7..e29a239bd782ecb9d69100f082a2603c5067c720 100644 (file)
@@ -91,6 +91,40 @@ wsi_destroy_image(const struct wsi_swapchain *chain,
                   struct wsi_image *image);
 
 
+struct wsi_interface {
+   VkResult (*get_support)(VkIcdSurfaceBase *surface,
+                           struct wsi_device *wsi_device,
+                           const VkAllocationCallbacks *alloc,
+                           uint32_t queueFamilyIndex,
+                           int local_fd,
+                           VkBool32* pSupported);
+   VkResult (*get_capabilities)(VkIcdSurfaceBase *surface,
+                                VkSurfaceCapabilitiesKHR* pSurfaceCapabilities);
+   VkResult (*get_capabilities2)(VkIcdSurfaceBase *surface,
+                                 const void *info_next,
+                                 VkSurfaceCapabilities2KHR* pSurfaceCapabilities);
+   VkResult (*get_formats)(VkIcdSurfaceBase *surface,
+                           struct wsi_device *wsi_device,
+                           uint32_t* pSurfaceFormatCount,
+                           VkSurfaceFormatKHR* pSurfaceFormats);
+   VkResult (*get_formats2)(VkIcdSurfaceBase *surface,
+                            struct wsi_device *wsi_device,
+                            const void *info_next,
+                            uint32_t* pSurfaceFormatCount,
+                            VkSurfaceFormat2KHR* pSurfaceFormats);
+   VkResult (*get_present_modes)(VkIcdSurfaceBase *surface,
+                                 uint32_t* pPresentModeCount,
+                                 VkPresentModeKHR* pPresentModes);
+   VkResult (*create_swapchain)(VkIcdSurfaceBase *surface,
+                                VkDevice device,
+                                struct wsi_device *wsi_device,
+                                int local_fd,
+                                const VkSwapchainCreateInfoKHR* pCreateInfo,
+                                const VkAllocationCallbacks* pAllocator,
+                                struct wsi_swapchain **swapchain);
+};
+
+
 #define WSI_DEFINE_NONDISP_HANDLE_CASTS(__wsi_type, __VkType)              \
                                                                            \
    static inline struct __wsi_type *                                       \