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
;
38 uint64_t drm_modifier
;
42 uint32_t row_pitches
[4];
46 struct wsi_swapchain
{
47 const struct wsi_device
*wsi
;
50 VkAllocationCallbacks alloc
;
52 VkPresentModeKHR present_mode
;
57 /* Command pools, one per queue family */
58 VkCommandPool
*cmd_pools
;
60 VkResult (*destroy
)(struct wsi_swapchain
*swapchain
,
61 const VkAllocationCallbacks
*pAllocator
);
62 struct wsi_image
*(*get_wsi_image
)(struct wsi_swapchain
*swapchain
,
63 uint32_t image_index
);
64 VkResult (*acquire_next_image
)(struct wsi_swapchain
*swap_chain
,
65 const VkAcquireNextImageInfoKHR
*info
,
66 uint32_t *image_index
);
67 VkResult (*queue_present
)(struct wsi_swapchain
*swap_chain
,
69 const VkPresentRegionKHR
*damage
);
73 wsi_device_matches_drm_fd(const struct wsi_device
*wsi
, int drm_fd
);
76 wsi_swapchain_init(const struct wsi_device
*wsi
,
77 struct wsi_swapchain
*chain
,
79 const VkSwapchainCreateInfoKHR
*pCreateInfo
,
80 const VkAllocationCallbacks
*pAllocator
);
83 wsi_swapchain_get_present_mode(struct wsi_device
*wsi
,
84 const VkSwapchainCreateInfoKHR
*pCreateInfo
);
86 void wsi_swapchain_finish(struct wsi_swapchain
*chain
);
89 wsi_create_native_image(const struct wsi_swapchain
*chain
,
90 const VkSwapchainCreateInfoKHR
*pCreateInfo
,
91 uint32_t num_modifier_lists
,
92 const uint32_t *num_modifiers
,
93 const uint64_t *const *modifiers
,
94 struct wsi_image
*image
);
97 wsi_create_prime_image(const struct wsi_swapchain
*chain
,
98 const VkSwapchainCreateInfoKHR
*pCreateInfo
,
100 struct wsi_image
*image
);
103 wsi_destroy_image(const struct wsi_swapchain
*chain
,
104 struct wsi_image
*image
);
107 struct wsi_interface
{
108 VkResult (*get_support
)(VkIcdSurfaceBase
*surface
,
109 struct wsi_device
*wsi_device
,
110 uint32_t queueFamilyIndex
,
111 VkBool32
* pSupported
);
112 VkResult (*get_capabilities2
)(VkIcdSurfaceBase
*surface
,
113 struct wsi_device
*wsi_device
,
114 const void *info_next
,
115 VkSurfaceCapabilities2KHR
* pSurfaceCapabilities
);
116 VkResult (*get_formats
)(VkIcdSurfaceBase
*surface
,
117 struct wsi_device
*wsi_device
,
118 uint32_t* pSurfaceFormatCount
,
119 VkSurfaceFormatKHR
* pSurfaceFormats
);
120 VkResult (*get_formats2
)(VkIcdSurfaceBase
*surface
,
121 struct wsi_device
*wsi_device
,
122 const void *info_next
,
123 uint32_t* pSurfaceFormatCount
,
124 VkSurfaceFormat2KHR
* pSurfaceFormats
);
125 VkResult (*get_present_modes
)(VkIcdSurfaceBase
*surface
,
126 uint32_t* pPresentModeCount
,
127 VkPresentModeKHR
* pPresentModes
);
128 VkResult (*get_present_rectangles
)(VkIcdSurfaceBase
*surface
,
129 struct wsi_device
*wsi_device
,
130 uint32_t* pRectCount
,
132 VkResult (*create_swapchain
)(VkIcdSurfaceBase
*surface
,
134 struct wsi_device
*wsi_device
,
135 const VkSwapchainCreateInfoKHR
* pCreateInfo
,
136 const VkAllocationCallbacks
* pAllocator
,
137 struct wsi_swapchain
**swapchain
);
140 VkResult
wsi_x11_init_wsi(struct wsi_device
*wsi_device
,
141 const VkAllocationCallbacks
*alloc
);
142 void wsi_x11_finish_wsi(struct wsi_device
*wsi_device
,
143 const VkAllocationCallbacks
*alloc
);
144 VkResult
wsi_wl_init_wsi(struct wsi_device
*wsi_device
,
145 const VkAllocationCallbacks
*alloc
,
146 VkPhysicalDevice physical_device
);
147 void wsi_wl_finish_wsi(struct wsi_device
*wsi_device
,
148 const VkAllocationCallbacks
*alloc
);
152 wsi_display_init_wsi(struct wsi_device
*wsi_device
,
153 const VkAllocationCallbacks
*alloc
,
157 wsi_display_finish_wsi(struct wsi_device
*wsi_device
,
158 const VkAllocationCallbacks
*alloc
);
160 #define WSI_DEFINE_NONDISP_HANDLE_CASTS(__wsi_type, __VkType) \
162 static inline struct __wsi_type * \
163 __wsi_type ## _from_handle(__VkType _handle) \
165 return (struct __wsi_type *)(uintptr_t) _handle; \
168 static inline __VkType \
169 __wsi_type ## _to_handle(struct __wsi_type *_obj) \
171 return (__VkType)(uintptr_t) _obj; \
174 #define WSI_FROM_HANDLE(__wsi_type, __name, __handle) \
175 struct __wsi_type *__name = __wsi_type ## _from_handle(__handle)
177 WSI_DEFINE_NONDISP_HANDLE_CASTS(wsi_swapchain
, VkSwapchainKHR
)
179 #endif /* WSI_COMMON_PRIVATE_H */