2 * Copyright © 2017 Intel Corporation
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:
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
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
23 #ifndef WSI_COMMON_PRIVATE_H
24 #define WSI_COMMON_PRIVATE_H
26 #include "wsi_common.h"
30 VkDeviceMemory memory
;
34 VkDeviceMemory memory
;
35 VkCommandBuffer
*blit_cmd_buffers
;
41 uint32_t row_pitches
[4];
45 struct wsi_swapchain
{
46 const struct wsi_device
*wsi
;
49 VkAllocationCallbacks alloc
;
51 VkPresentModeKHR present_mode
;
56 /* Command pools, one per queue family */
57 VkCommandPool
*cmd_pools
;
59 VkResult (*destroy
)(struct wsi_swapchain
*swapchain
,
60 const VkAllocationCallbacks
*pAllocator
);
61 struct wsi_image
*(*get_wsi_image
)(struct wsi_swapchain
*swapchain
,
62 uint32_t image_index
);
63 VkResult (*acquire_next_image
)(struct wsi_swapchain
*swap_chain
,
64 uint64_t timeout
, VkSemaphore semaphore
,
65 uint32_t *image_index
);
66 VkResult (*queue_present
)(struct wsi_swapchain
*swap_chain
,
68 const VkPresentRegionKHR
*damage
);
72 wsi_swapchain_init(const struct wsi_device
*wsi
,
73 struct wsi_swapchain
*chain
,
75 const VkSwapchainCreateInfoKHR
*pCreateInfo
,
76 const VkAllocationCallbacks
*pAllocator
);
78 void wsi_swapchain_finish(struct wsi_swapchain
*chain
);
81 wsi_create_native_image(const struct wsi_swapchain
*chain
,
82 const VkSwapchainCreateInfoKHR
*pCreateInfo
,
83 struct wsi_image
*image
);
86 wsi_create_prime_image(const struct wsi_swapchain
*chain
,
87 const VkSwapchainCreateInfoKHR
*pCreateInfo
,
88 struct wsi_image
*image
);
91 wsi_destroy_image(const struct wsi_swapchain
*chain
,
92 struct wsi_image
*image
);
95 struct wsi_interface
{
96 VkResult (*get_support
)(VkIcdSurfaceBase
*surface
,
97 struct wsi_device
*wsi_device
,
98 const VkAllocationCallbacks
*alloc
,
99 uint32_t queueFamilyIndex
,
101 VkBool32
* pSupported
);
102 VkResult (*get_capabilities
)(VkIcdSurfaceBase
*surface
,
103 VkSurfaceCapabilitiesKHR
* pSurfaceCapabilities
);
104 VkResult (*get_capabilities2
)(VkIcdSurfaceBase
*surface
,
105 const void *info_next
,
106 VkSurfaceCapabilities2KHR
* pSurfaceCapabilities
);
107 VkResult (*get_formats
)(VkIcdSurfaceBase
*surface
,
108 struct wsi_device
*wsi_device
,
109 uint32_t* pSurfaceFormatCount
,
110 VkSurfaceFormatKHR
* pSurfaceFormats
);
111 VkResult (*get_formats2
)(VkIcdSurfaceBase
*surface
,
112 struct wsi_device
*wsi_device
,
113 const void *info_next
,
114 uint32_t* pSurfaceFormatCount
,
115 VkSurfaceFormat2KHR
* pSurfaceFormats
);
116 VkResult (*get_present_modes
)(VkIcdSurfaceBase
*surface
,
117 uint32_t* pPresentModeCount
,
118 VkPresentModeKHR
* pPresentModes
);
119 VkResult (*create_swapchain
)(VkIcdSurfaceBase
*surface
,
121 struct wsi_device
*wsi_device
,
123 const VkSwapchainCreateInfoKHR
* pCreateInfo
,
124 const VkAllocationCallbacks
* pAllocator
,
125 struct wsi_swapchain
**swapchain
);
128 VkResult
wsi_x11_init_wsi(struct wsi_device
*wsi_device
,
129 const VkAllocationCallbacks
*alloc
);
130 void wsi_x11_finish_wsi(struct wsi_device
*wsi_device
,
131 const VkAllocationCallbacks
*alloc
);
132 VkResult
wsi_wl_init_wsi(struct wsi_device
*wsi_device
,
133 const VkAllocationCallbacks
*alloc
,
134 VkPhysicalDevice physical_device
);
135 void wsi_wl_finish_wsi(struct wsi_device
*wsi_device
,
136 const VkAllocationCallbacks
*alloc
);
139 #define WSI_DEFINE_NONDISP_HANDLE_CASTS(__wsi_type, __VkType) \
141 static inline struct __wsi_type * \
142 __wsi_type ## _from_handle(__VkType _handle) \
144 return (struct __wsi_type *)(uintptr_t) _handle; \
147 static inline __VkType \
148 __wsi_type ## _to_handle(struct __wsi_type *_obj) \
150 return (__VkType)(uintptr_t) _obj; \
153 #define WSI_FROM_HANDLE(__wsi_type, __name, __handle) \
154 struct __wsi_type *__name = __wsi_type ## _from_handle(__handle)
156 WSI_DEFINE_NONDISP_HANDLE_CASTS(wsi_swapchain
, VkSwapchainKHR
)
158 #endif /* WSI_COMMON_PRIVATE_H */