1 /*
2  * Copyright © 2015 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #pragma once
25 
26 #include "lvp_private.h"
27 
28 struct lvp_swapchain;
29 
30 struct lvp_wsi_interface {
31    VkResult (*get_support)(VkIcdSurfaceBase *surface,
32                            struct lvp_physical_device *device,
33                            uint32_t queueFamilyIndex,
34                            VkBool32* pSupported);
35    VkResult (*get_capabilities)(VkIcdSurfaceBase *surface,
36                                 struct lvp_physical_device *device,
37                                 VkSurfaceCapabilitiesKHR* pSurfaceCapabilities);
38    VkResult (*get_formats)(VkIcdSurfaceBase *surface,
39                            struct lvp_physical_device *device,
40                            uint32_t* pSurfaceFormatCount,
41                            VkSurfaceFormatKHR* pSurfaceFormats);
42    VkResult (*get_present_modes)(VkIcdSurfaceBase *surface,
43                                  struct lvp_physical_device *device,
44                                  uint32_t* pPresentModeCount,
45                                  VkPresentModeKHR* pPresentModes);
46    VkResult (*create_swapchain)(VkIcdSurfaceBase *surface,
47                                 struct lvp_device *device,
48                                 const VkSwapchainCreateInfoKHR* pCreateInfo,
49                                 const VkAllocationCallbacks* pAllocator,
50                                 struct lvp_swapchain **swapchain);
51 };
52 
53 struct lvp_swapchain {
54    struct lvp_device *device;
55 
56    VkResult (*destroy)(struct lvp_swapchain *swapchain,
57                        const VkAllocationCallbacks *pAllocator);
58    VkResult (*get_images)(struct lvp_swapchain *swapchain,
59                           uint32_t *pCount, VkImage *pSwapchainImages);
60    VkResult (*acquire_next_image)(struct lvp_swapchain *swap_chain,
61                                   uint64_t timeout, VkSemaphore semaphore,
62                                   uint32_t *image_index);
63    VkResult (*queue_present)(struct lvp_swapchain *swap_chain,
64                              struct lvp_queue *queue,
65                              uint32_t image_index);
66 };
67 
68 VkResult lvp_x11_init_wsi(struct lvp_instance *instance);
69 void lvp_x11_finish_wsi(struct lvp_instance *instance);
70 VkResult lvp_wl_init_wsi(struct lvp_instance *instance);
71 void lvp_wl_finish_wsi(struct lvp_instance *instance);
72