xref: /aosp_15_r20/external/mesa3d/src/vulkan/wsi/wsi_common.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard Worker /*
2*61046927SAndroid Build Coastguard Worker  * Copyright © 2015 Intel Corporation
3*61046927SAndroid Build Coastguard Worker  *
4*61046927SAndroid Build Coastguard Worker  * Permission is hereby granted, free of charge, to any person obtaining a
5*61046927SAndroid Build Coastguard Worker  * copy of this software and associated documentation files (the "Software"),
6*61046927SAndroid Build Coastguard Worker  * to deal in the Software without restriction, including without limitation
7*61046927SAndroid Build Coastguard Worker  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*61046927SAndroid Build Coastguard Worker  * and/or sell copies of the Software, and to permit persons to whom the
9*61046927SAndroid Build Coastguard Worker  * Software is furnished to do so, subject to the following conditions:
10*61046927SAndroid Build Coastguard Worker  *
11*61046927SAndroid Build Coastguard Worker  * The above copyright notice and this permission notice (including the next
12*61046927SAndroid Build Coastguard Worker  * paragraph) shall be included in all copies or substantial portions of the
13*61046927SAndroid Build Coastguard Worker  * Software.
14*61046927SAndroid Build Coastguard Worker  *
15*61046927SAndroid Build Coastguard Worker  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*61046927SAndroid Build Coastguard Worker  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*61046927SAndroid Build Coastguard Worker  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18*61046927SAndroid Build Coastguard Worker  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*61046927SAndroid Build Coastguard Worker  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*61046927SAndroid Build Coastguard Worker  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21*61046927SAndroid Build Coastguard Worker  * IN THE SOFTWARE.
22*61046927SAndroid Build Coastguard Worker  */
23*61046927SAndroid Build Coastguard Worker #ifndef WSI_COMMON_H
24*61046927SAndroid Build Coastguard Worker #define WSI_COMMON_H
25*61046927SAndroid Build Coastguard Worker 
26*61046927SAndroid Build Coastguard Worker #include <stdint.h>
27*61046927SAndroid Build Coastguard Worker #include <stdbool.h>
28*61046927SAndroid Build Coastguard Worker 
29*61046927SAndroid Build Coastguard Worker #include "util/log.h"
30*61046927SAndroid Build Coastguard Worker #include "vk_alloc.h"
31*61046927SAndroid Build Coastguard Worker #include "vk_dispatch_table.h"
32*61046927SAndroid Build Coastguard Worker #include <vulkan/vulkan.h>
33*61046927SAndroid Build Coastguard Worker #include <vulkan/vk_icd.h>
34*61046927SAndroid Build Coastguard Worker 
35*61046927SAndroid Build Coastguard Worker #ifdef __cplusplus
36*61046927SAndroid Build Coastguard Worker extern "C" {
37*61046927SAndroid Build Coastguard Worker #endif
38*61046927SAndroid Build Coastguard Worker 
39*61046927SAndroid Build Coastguard Worker #ifndef WSI_ENTRYPOINTS_H
40*61046927SAndroid Build Coastguard Worker extern const struct vk_instance_entrypoint_table wsi_instance_entrypoints;
41*61046927SAndroid Build Coastguard Worker extern const struct vk_physical_device_entrypoint_table wsi_physical_device_entrypoints;
42*61046927SAndroid Build Coastguard Worker extern const struct vk_device_entrypoint_table wsi_device_entrypoints;
43*61046927SAndroid Build Coastguard Worker #endif
44*61046927SAndroid Build Coastguard Worker 
45*61046927SAndroid Build Coastguard Worker #include <util/list.h>
46*61046927SAndroid Build Coastguard Worker 
47*61046927SAndroid Build Coastguard Worker /* This is guaranteed to not collide with anything because it's in the
48*61046927SAndroid Build Coastguard Worker  * VK_KHR_swapchain namespace but not actually used by the extension.
49*61046927SAndroid Build Coastguard Worker  */
50*61046927SAndroid Build Coastguard Worker #define VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA (VkStructureType)1000001002
51*61046927SAndroid Build Coastguard Worker #define VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA (VkStructureType)1000001003
52*61046927SAndroid Build Coastguard Worker #define VK_STRUCTURE_TYPE_WSI_SURFACE_SUPPORTED_COUNTERS_MESA (VkStructureType)1000001005
53*61046927SAndroid Build Coastguard Worker #define VK_STRUCTURE_TYPE_WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA (VkStructureType)1000001006
54*61046927SAndroid Build Coastguard Worker 
55*61046927SAndroid Build Coastguard Worker #define VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA_cast struct wsi_image_create_info
56*61046927SAndroid Build Coastguard Worker #define VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA_cast struct wsi_memory_allocate_info
57*61046927SAndroid Build Coastguard Worker #define VK_STRUCTURE_TYPE_WSI_SURFACE_SUPPORTED_COUNTERS_MESA_cast struct wsi_surface_supported_counters
58*61046927SAndroid Build Coastguard Worker #define VK_STRUCTURE_TYPE_WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA_cast struct wsi_memory_signal_submit_info
59*61046927SAndroid Build Coastguard Worker 
60*61046927SAndroid Build Coastguard Worker /* This is always chained to VkImageCreateInfo when a wsi image is created.
61*61046927SAndroid Build Coastguard Worker  * It indicates that the image can be transitioned to/from
62*61046927SAndroid Build Coastguard Worker  * VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.
63*61046927SAndroid Build Coastguard Worker  */
64*61046927SAndroid Build Coastguard Worker struct wsi_image_create_info {
65*61046927SAndroid Build Coastguard Worker     VkStructureType sType;
66*61046927SAndroid Build Coastguard Worker     const void *pNext;
67*61046927SAndroid Build Coastguard Worker     bool scanout;
68*61046927SAndroid Build Coastguard Worker 
69*61046927SAndroid Build Coastguard Worker     /* if true, the image is a blit source */
70*61046927SAndroid Build Coastguard Worker     bool blit_src;
71*61046927SAndroid Build Coastguard Worker };
72*61046927SAndroid Build Coastguard Worker 
73*61046927SAndroid Build Coastguard Worker struct wsi_memory_allocate_info {
74*61046927SAndroid Build Coastguard Worker     VkStructureType sType;
75*61046927SAndroid Build Coastguard Worker     const void *pNext;
76*61046927SAndroid Build Coastguard Worker     bool implicit_sync;
77*61046927SAndroid Build Coastguard Worker };
78*61046927SAndroid Build Coastguard Worker 
79*61046927SAndroid Build Coastguard Worker /* To be chained into VkSurfaceCapabilities2KHR */
80*61046927SAndroid Build Coastguard Worker struct wsi_surface_supported_counters {
81*61046927SAndroid Build Coastguard Worker    VkStructureType sType;
82*61046927SAndroid Build Coastguard Worker    const void *pNext;
83*61046927SAndroid Build Coastguard Worker 
84*61046927SAndroid Build Coastguard Worker    VkSurfaceCounterFlagsEXT supported_surface_counters;
85*61046927SAndroid Build Coastguard Worker 
86*61046927SAndroid Build Coastguard Worker };
87*61046927SAndroid Build Coastguard Worker 
88*61046927SAndroid Build Coastguard Worker /* To be chained into VkSubmitInfo */
89*61046927SAndroid Build Coastguard Worker struct wsi_memory_signal_submit_info {
90*61046927SAndroid Build Coastguard Worker     VkStructureType sType;
91*61046927SAndroid Build Coastguard Worker     const void *pNext;
92*61046927SAndroid Build Coastguard Worker     VkDeviceMemory memory;
93*61046927SAndroid Build Coastguard Worker };
94*61046927SAndroid Build Coastguard Worker 
95*61046927SAndroid Build Coastguard Worker struct wsi_interface;
96*61046927SAndroid Build Coastguard Worker struct vk_instance;
97*61046927SAndroid Build Coastguard Worker 
98*61046927SAndroid Build Coastguard Worker struct driOptionCache;
99*61046927SAndroid Build Coastguard Worker 
100*61046927SAndroid Build Coastguard Worker #define VK_ICD_WSI_PLATFORM_MAX (VK_ICD_WSI_PLATFORM_METAL + 1)
101*61046927SAndroid Build Coastguard Worker 
102*61046927SAndroid Build Coastguard Worker struct wsi_device {
103*61046927SAndroid Build Coastguard Worker    /* Allocator for the instance */
104*61046927SAndroid Build Coastguard Worker    VkAllocationCallbacks instance_alloc;
105*61046927SAndroid Build Coastguard Worker 
106*61046927SAndroid Build Coastguard Worker    VkPhysicalDevice pdevice;
107*61046927SAndroid Build Coastguard Worker    VkPhysicalDeviceMemoryProperties memory_props;
108*61046927SAndroid Build Coastguard Worker    uint32_t queue_family_count;
109*61046927SAndroid Build Coastguard Worker    uint64_t queue_supports_blit;
110*61046927SAndroid Build Coastguard Worker 
111*61046927SAndroid Build Coastguard Worker    VkPhysicalDeviceDrmPropertiesEXT drm_info;
112*61046927SAndroid Build Coastguard Worker    VkPhysicalDevicePCIBusInfoPropertiesEXT pci_bus_info;
113*61046927SAndroid Build Coastguard Worker 
114*61046927SAndroid Build Coastguard Worker    VkExternalSemaphoreHandleTypeFlags semaphore_export_handle_types;
115*61046927SAndroid Build Coastguard Worker    VkExternalSemaphoreHandleTypeFlags timeline_semaphore_export_handle_types;
116*61046927SAndroid Build Coastguard Worker 
117*61046927SAndroid Build Coastguard Worker    bool has_import_memory_host;
118*61046927SAndroid Build Coastguard Worker    bool has_timeline_semaphore;
119*61046927SAndroid Build Coastguard Worker 
120*61046927SAndroid Build Coastguard Worker    /** Indicates if wsi_image_create_info::scanout is supported
121*61046927SAndroid Build Coastguard Worker     *
122*61046927SAndroid Build Coastguard Worker     * If false, WSI will always use either modifiers or the prime blit path.
123*61046927SAndroid Build Coastguard Worker     */
124*61046927SAndroid Build Coastguard Worker    bool supports_scanout;
125*61046927SAndroid Build Coastguard Worker    bool supports_modifiers;
126*61046927SAndroid Build Coastguard Worker    uint32_t maxImageDimension2D;
127*61046927SAndroid Build Coastguard Worker    uint32_t optimalBufferCopyRowPitchAlignment;
128*61046927SAndroid Build Coastguard Worker    VkPresentModeKHR override_present_mode;
129*61046927SAndroid Build Coastguard Worker    bool force_bgra8_unorm_first;
130*61046927SAndroid Build Coastguard Worker 
131*61046927SAndroid Build Coastguard Worker    /* Whether to enable adaptive sync for a swapchain if implemented and
132*61046927SAndroid Build Coastguard Worker     * available. Not all window systems might support this. */
133*61046927SAndroid Build Coastguard Worker    bool enable_adaptive_sync;
134*61046927SAndroid Build Coastguard Worker 
135*61046927SAndroid Build Coastguard Worker    /* List of fences to signal when hotplug event happens. */
136*61046927SAndroid Build Coastguard Worker    struct list_head hotplug_fences;
137*61046927SAndroid Build Coastguard Worker 
138*61046927SAndroid Build Coastguard Worker    /* Create headless swapchains. */
139*61046927SAndroid Build Coastguard Worker    bool force_headless_swapchain;
140*61046927SAndroid Build Coastguard Worker 
141*61046927SAndroid Build Coastguard Worker    bool force_swapchain_to_currentExtent;
142*61046927SAndroid Build Coastguard Worker 
143*61046927SAndroid Build Coastguard Worker    struct {
144*61046927SAndroid Build Coastguard Worker       /* Override the minimum number of images on the swapchain.
145*61046927SAndroid Build Coastguard Worker        * 0 = no override */
146*61046927SAndroid Build Coastguard Worker       uint32_t override_minImageCount;
147*61046927SAndroid Build Coastguard Worker 
148*61046927SAndroid Build Coastguard Worker       /* Forces strict number of image on the swapchain using application
149*61046927SAndroid Build Coastguard Worker        * provided VkSwapchainCreateInfoKH::RminImageCount.
150*61046927SAndroid Build Coastguard Worker        */
151*61046927SAndroid Build Coastguard Worker       bool strict_imageCount;
152*61046927SAndroid Build Coastguard Worker 
153*61046927SAndroid Build Coastguard Worker       /* Ensures to create at least the number of image specified by the
154*61046927SAndroid Build Coastguard Worker        * driver in VkSurfaceCapabilitiesKHR::minImageCount.
155*61046927SAndroid Build Coastguard Worker        */
156*61046927SAndroid Build Coastguard Worker       bool ensure_minImageCount;
157*61046927SAndroid Build Coastguard Worker 
158*61046927SAndroid Build Coastguard Worker       /* Wait for fences before submitting buffers to Xwayland. Defaults to
159*61046927SAndroid Build Coastguard Worker        * true.
160*61046927SAndroid Build Coastguard Worker        */
161*61046927SAndroid Build Coastguard Worker       bool xwaylandWaitReady;
162*61046927SAndroid Build Coastguard Worker 
163*61046927SAndroid Build Coastguard Worker       /* adds an extra minImageCount when running under xwayland */
164*61046927SAndroid Build Coastguard Worker       bool extra_xwayland_image;
165*61046927SAndroid Build Coastguard Worker 
166*61046927SAndroid Build Coastguard Worker       /* Never report VK_SUBOPTIMAL_KHR. Used to workaround
167*61046927SAndroid Build Coastguard Worker        * games that cannot handle SUBOPTIMAL correctly. */
168*61046927SAndroid Build Coastguard Worker       bool ignore_suboptimal;
169*61046927SAndroid Build Coastguard Worker    } x11;
170*61046927SAndroid Build Coastguard Worker 
171*61046927SAndroid Build Coastguard Worker    struct {
172*61046927SAndroid Build Coastguard Worker       void *(*get_d3d12_command_queue)(VkDevice device);
173*61046927SAndroid Build Coastguard Worker       /* Needs to be per VkDevice, not VkPhysicalDevice, depends on queue config */
174*61046927SAndroid Build Coastguard Worker       bool (*requires_blits)(VkDevice device);
175*61046927SAndroid Build Coastguard Worker       VkResult (*create_image_memory)(VkDevice device, void *resource,
176*61046927SAndroid Build Coastguard Worker                                       const VkAllocationCallbacks *alloc,
177*61046927SAndroid Build Coastguard Worker                                       VkDeviceMemory *out);
178*61046927SAndroid Build Coastguard Worker    } win32;
179*61046927SAndroid Build Coastguard Worker 
180*61046927SAndroid Build Coastguard Worker    bool sw;
181*61046927SAndroid Build Coastguard Worker 
182*61046927SAndroid Build Coastguard Worker    /* Set to true if the implementation is ok with linear WSI images. */
183*61046927SAndroid Build Coastguard Worker    bool wants_linear;
184*61046927SAndroid Build Coastguard Worker 
185*61046927SAndroid Build Coastguard Worker    /* Signals the semaphore such that any wait on the semaphore will wait on
186*61046927SAndroid Build Coastguard Worker     * any reads or writes on the give memory object.  This is used to
187*61046927SAndroid Build Coastguard Worker     * implement the semaphore signal operation in vkAcquireNextImage.  This
188*61046927SAndroid Build Coastguard Worker     * requires the driver to implement vk_device::create_sync_for_memory.
189*61046927SAndroid Build Coastguard Worker     */
190*61046927SAndroid Build Coastguard Worker    bool signal_semaphore_with_memory;
191*61046927SAndroid Build Coastguard Worker 
192*61046927SAndroid Build Coastguard Worker    /* Signals the fence such that any wait on the fence will wait on any reads
193*61046927SAndroid Build Coastguard Worker     * or writes on the give memory object.  This is used to implement the
194*61046927SAndroid Build Coastguard Worker     * semaphore signal operation in vkAcquireNextImage.  This requires the
195*61046927SAndroid Build Coastguard Worker     * driver to implement vk_device::create_sync_for_memory.  The resulting
196*61046927SAndroid Build Coastguard Worker     * vk_sync must support CPU waits.
197*61046927SAndroid Build Coastguard Worker     */
198*61046927SAndroid Build Coastguard Worker    bool signal_fence_with_memory;
199*61046927SAndroid Build Coastguard Worker 
200*61046927SAndroid Build Coastguard Worker    /* Whether present_wait functionality is enabled on the device.
201*61046927SAndroid Build Coastguard Worker     * In this case, we have to create an extra timeline semaphore
202*61046927SAndroid Build Coastguard Worker     * to be able to synchronize with the WSI present semaphore being unsignalled.
203*61046927SAndroid Build Coastguard Worker     * This requires VK_KHR_timeline_semaphore. */
204*61046927SAndroid Build Coastguard Worker    bool khr_present_wait;
205*61046927SAndroid Build Coastguard Worker 
206*61046927SAndroid Build Coastguard Worker    /*
207*61046927SAndroid Build Coastguard Worker     * This sets the ownership for a WSI memory object:
208*61046927SAndroid Build Coastguard Worker     *
209*61046927SAndroid Build Coastguard Worker     * The ownership is true if and only if the application is allowed to submit
210*61046927SAndroid Build Coastguard Worker     * command buffers that reference the buffer.
211*61046927SAndroid Build Coastguard Worker     *
212*61046927SAndroid Build Coastguard Worker     * This can be used to prune BO lists without too many adverse affects on
213*61046927SAndroid Build Coastguard Worker     * implicit sync.
214*61046927SAndroid Build Coastguard Worker     *
215*61046927SAndroid Build Coastguard Worker     * Side note: care needs to be taken for internally delayed submissions wrt
216*61046927SAndroid Build Coastguard Worker     * timeline semaphores.
217*61046927SAndroid Build Coastguard Worker     */
218*61046927SAndroid Build Coastguard Worker    void (*set_memory_ownership)(VkDevice device,
219*61046927SAndroid Build Coastguard Worker                                 VkDeviceMemory memory,
220*61046927SAndroid Build Coastguard Worker                                 VkBool32 ownership);
221*61046927SAndroid Build Coastguard Worker 
222*61046927SAndroid Build Coastguard Worker    /*
223*61046927SAndroid Build Coastguard Worker     * If this is set, the WSI device will call it to let the driver backend
224*61046927SAndroid Build Coastguard Worker     * decide if it can present images directly on the given device fd.
225*61046927SAndroid Build Coastguard Worker     */
226*61046927SAndroid Build Coastguard Worker    bool (*can_present_on_device)(VkPhysicalDevice pdevice, int fd);
227*61046927SAndroid Build Coastguard Worker 
228*61046927SAndroid Build Coastguard Worker    /*
229*61046927SAndroid Build Coastguard Worker     * A driver can implement this callback to return a special queue to execute
230*61046927SAndroid Build Coastguard Worker     * buffer blits.
231*61046927SAndroid Build Coastguard Worker     */
232*61046927SAndroid Build Coastguard Worker    VkQueue (*get_blit_queue)(VkDevice device);
233*61046927SAndroid Build Coastguard Worker 
234*61046927SAndroid Build Coastguard Worker #define WSI_CB(cb) PFN_vk##cb cb
235*61046927SAndroid Build Coastguard Worker    WSI_CB(AllocateMemory);
236*61046927SAndroid Build Coastguard Worker    WSI_CB(AllocateCommandBuffers);
237*61046927SAndroid Build Coastguard Worker    WSI_CB(BindBufferMemory);
238*61046927SAndroid Build Coastguard Worker    WSI_CB(BindImageMemory);
239*61046927SAndroid Build Coastguard Worker    WSI_CB(BeginCommandBuffer);
240*61046927SAndroid Build Coastguard Worker    WSI_CB(CmdPipelineBarrier);
241*61046927SAndroid Build Coastguard Worker    WSI_CB(CmdCopyImage);
242*61046927SAndroid Build Coastguard Worker    WSI_CB(CmdCopyImageToBuffer);
243*61046927SAndroid Build Coastguard Worker    WSI_CB(CreateBuffer);
244*61046927SAndroid Build Coastguard Worker    WSI_CB(CreateCommandPool);
245*61046927SAndroid Build Coastguard Worker    WSI_CB(CreateFence);
246*61046927SAndroid Build Coastguard Worker    WSI_CB(CreateImage);
247*61046927SAndroid Build Coastguard Worker    WSI_CB(CreateSemaphore);
248*61046927SAndroid Build Coastguard Worker    WSI_CB(DestroyBuffer);
249*61046927SAndroid Build Coastguard Worker    WSI_CB(DestroyCommandPool);
250*61046927SAndroid Build Coastguard Worker    WSI_CB(DestroyFence);
251*61046927SAndroid Build Coastguard Worker    WSI_CB(DestroyImage);
252*61046927SAndroid Build Coastguard Worker    WSI_CB(DestroySemaphore);
253*61046927SAndroid Build Coastguard Worker    WSI_CB(EndCommandBuffer);
254*61046927SAndroid Build Coastguard Worker    WSI_CB(FreeMemory);
255*61046927SAndroid Build Coastguard Worker    WSI_CB(FreeCommandBuffers);
256*61046927SAndroid Build Coastguard Worker    WSI_CB(GetBufferMemoryRequirements);
257*61046927SAndroid Build Coastguard Worker    WSI_CB(GetFenceStatus);
258*61046927SAndroid Build Coastguard Worker    WSI_CB(GetImageDrmFormatModifierPropertiesEXT);
259*61046927SAndroid Build Coastguard Worker    WSI_CB(GetImageMemoryRequirements);
260*61046927SAndroid Build Coastguard Worker    WSI_CB(GetImageSubresourceLayout);
261*61046927SAndroid Build Coastguard Worker    WSI_CB(GetMemoryFdKHR);
262*61046927SAndroid Build Coastguard Worker    WSI_CB(GetPhysicalDeviceFormatProperties);
263*61046927SAndroid Build Coastguard Worker    WSI_CB(GetPhysicalDeviceFormatProperties2);
264*61046927SAndroid Build Coastguard Worker    WSI_CB(GetPhysicalDeviceImageFormatProperties2);
265*61046927SAndroid Build Coastguard Worker    WSI_CB(GetSemaphoreFdKHR);
266*61046927SAndroid Build Coastguard Worker    WSI_CB(ResetFences);
267*61046927SAndroid Build Coastguard Worker    WSI_CB(QueueSubmit);
268*61046927SAndroid Build Coastguard Worker    WSI_CB(WaitForFences);
269*61046927SAndroid Build Coastguard Worker    WSI_CB(MapMemory);
270*61046927SAndroid Build Coastguard Worker    WSI_CB(UnmapMemory);
271*61046927SAndroid Build Coastguard Worker    WSI_CB(WaitSemaphores);
272*61046927SAndroid Build Coastguard Worker #undef WSI_CB
273*61046927SAndroid Build Coastguard Worker 
274*61046927SAndroid Build Coastguard Worker     struct wsi_interface *                  wsi[VK_ICD_WSI_PLATFORM_MAX];
275*61046927SAndroid Build Coastguard Worker };
276*61046927SAndroid Build Coastguard Worker 
277*61046927SAndroid Build Coastguard Worker typedef PFN_vkVoidFunction (VKAPI_PTR *WSI_FN_GetPhysicalDeviceProcAddr)(VkPhysicalDevice physicalDevice, const char* pName);
278*61046927SAndroid Build Coastguard Worker 
279*61046927SAndroid Build Coastguard Worker struct wsi_device_options {
280*61046927SAndroid Build Coastguard Worker    bool sw_device;
281*61046927SAndroid Build Coastguard Worker    bool extra_xwayland_image;
282*61046927SAndroid Build Coastguard Worker };
283*61046927SAndroid Build Coastguard Worker 
284*61046927SAndroid Build Coastguard Worker VkResult
285*61046927SAndroid Build Coastguard Worker wsi_device_init(struct wsi_device *wsi,
286*61046927SAndroid Build Coastguard Worker                 VkPhysicalDevice pdevice,
287*61046927SAndroid Build Coastguard Worker                 WSI_FN_GetPhysicalDeviceProcAddr proc_addr,
288*61046927SAndroid Build Coastguard Worker                 const VkAllocationCallbacks *alloc,
289*61046927SAndroid Build Coastguard Worker                 int display_fd,
290*61046927SAndroid Build Coastguard Worker                 const struct driOptionCache *dri_options,
291*61046927SAndroid Build Coastguard Worker                 const struct wsi_device_options *device_options);
292*61046927SAndroid Build Coastguard Worker 
293*61046927SAndroid Build Coastguard Worker void
294*61046927SAndroid Build Coastguard Worker wsi_device_finish(struct wsi_device *wsi,
295*61046927SAndroid Build Coastguard Worker                   const VkAllocationCallbacks *alloc);
296*61046927SAndroid Build Coastguard Worker 
297*61046927SAndroid Build Coastguard Worker /* Setup file descriptor to be used with imported sync_fd's in wsi fences. */
298*61046927SAndroid Build Coastguard Worker void
299*61046927SAndroid Build Coastguard Worker wsi_device_setup_syncobj_fd(struct wsi_device *wsi_device,
300*61046927SAndroid Build Coastguard Worker                             int fd);
301*61046927SAndroid Build Coastguard Worker 
302*61046927SAndroid Build Coastguard Worker #define ICD_DEFINE_NONDISP_HANDLE_CASTS(__VkIcdType, __VkType)             \
303*61046927SAndroid Build Coastguard Worker                                                                            \
304*61046927SAndroid Build Coastguard Worker    static inline __VkIcdType *                                             \
305*61046927SAndroid Build Coastguard Worker    __VkIcdType ## _from_handle(__VkType _handle)                           \
306*61046927SAndroid Build Coastguard Worker    {                                                                       \
307*61046927SAndroid Build Coastguard Worker       return (__VkIcdType *)(uintptr_t) _handle;                           \
308*61046927SAndroid Build Coastguard Worker    }                                                                       \
309*61046927SAndroid Build Coastguard Worker                                                                            \
310*61046927SAndroid Build Coastguard Worker    static inline __VkType                                                  \
311*61046927SAndroid Build Coastguard Worker    __VkIcdType ## _to_handle(__VkIcdType *_obj)                            \
312*61046927SAndroid Build Coastguard Worker    {                                                                       \
313*61046927SAndroid Build Coastguard Worker       return (__VkType)(uintptr_t) _obj;                                   \
314*61046927SAndroid Build Coastguard Worker    }
315*61046927SAndroid Build Coastguard Worker 
316*61046927SAndroid Build Coastguard Worker #define ICD_FROM_HANDLE(__VkIcdType, __name, __handle) \
317*61046927SAndroid Build Coastguard Worker    __VkIcdType *__name = __VkIcdType ## _from_handle(__handle)
318*61046927SAndroid Build Coastguard Worker 
319*61046927SAndroid Build Coastguard Worker ICD_DEFINE_NONDISP_HANDLE_CASTS(VkIcdSurfaceBase, VkSurfaceKHR)
320*61046927SAndroid Build Coastguard Worker 
321*61046927SAndroid Build Coastguard Worker VkResult
322*61046927SAndroid Build Coastguard Worker wsi_common_get_images(VkSwapchainKHR _swapchain,
323*61046927SAndroid Build Coastguard Worker                       uint32_t *pSwapchainImageCount,
324*61046927SAndroid Build Coastguard Worker                       VkImage *pSwapchainImages);
325*61046927SAndroid Build Coastguard Worker 
326*61046927SAndroid Build Coastguard Worker VkImage
327*61046927SAndroid Build Coastguard Worker wsi_common_get_image(VkSwapchainKHR _swapchain, uint32_t index);
328*61046927SAndroid Build Coastguard Worker 
329*61046927SAndroid Build Coastguard Worker VkResult
330*61046927SAndroid Build Coastguard Worker wsi_common_acquire_next_image2(const struct wsi_device *wsi,
331*61046927SAndroid Build Coastguard Worker                                VkDevice device,
332*61046927SAndroid Build Coastguard Worker                                const VkAcquireNextImageInfoKHR *pAcquireInfo,
333*61046927SAndroid Build Coastguard Worker                                uint32_t *pImageIndex);
334*61046927SAndroid Build Coastguard Worker 
335*61046927SAndroid Build Coastguard Worker VkResult
336*61046927SAndroid Build Coastguard Worker wsi_common_queue_present(const struct wsi_device *wsi,
337*61046927SAndroid Build Coastguard Worker                          VkDevice device_h,
338*61046927SAndroid Build Coastguard Worker                          VkQueue queue_h,
339*61046927SAndroid Build Coastguard Worker                          int queue_family_index,
340*61046927SAndroid Build Coastguard Worker                          const VkPresentInfoKHR *pPresentInfo);
341*61046927SAndroid Build Coastguard Worker 
342*61046927SAndroid Build Coastguard Worker VkResult
343*61046927SAndroid Build Coastguard Worker wsi_common_create_swapchain_image(const struct wsi_device *wsi,
344*61046927SAndroid Build Coastguard Worker                                   const VkImageCreateInfo *pCreateInfo,
345*61046927SAndroid Build Coastguard Worker                                   VkSwapchainKHR _swapchain,
346*61046927SAndroid Build Coastguard Worker                                   VkImage *pImage);
347*61046927SAndroid Build Coastguard Worker VkResult
348*61046927SAndroid Build Coastguard Worker wsi_common_bind_swapchain_image(const struct wsi_device *wsi,
349*61046927SAndroid Build Coastguard Worker                                 VkImage vk_image,
350*61046927SAndroid Build Coastguard Worker                                 VkSwapchainKHR _swapchain,
351*61046927SAndroid Build Coastguard Worker                                 uint32_t image_idx);
352*61046927SAndroid Build Coastguard Worker 
353*61046927SAndroid Build Coastguard Worker bool
354*61046927SAndroid Build Coastguard Worker wsi_common_vk_instance_supports_present_wait(const struct vk_instance *instance);
355*61046927SAndroid Build Coastguard Worker 
356*61046927SAndroid Build Coastguard Worker VkImageUsageFlags
357*61046927SAndroid Build Coastguard Worker wsi_caps_get_image_usage(void);
358*61046927SAndroid Build Coastguard Worker 
359*61046927SAndroid Build Coastguard Worker bool
360*61046927SAndroid Build Coastguard Worker wsi_device_supports_explicit_sync(struct wsi_device *device);
361*61046927SAndroid Build Coastguard Worker 
362*61046927SAndroid Build Coastguard Worker #define wsi_common_vk_warn_once(warning) \
363*61046927SAndroid Build Coastguard Worker    do { \
364*61046927SAndroid Build Coastguard Worker       static int warned = false; \
365*61046927SAndroid Build Coastguard Worker       if (!warned) { \
366*61046927SAndroid Build Coastguard Worker          mesa_loge(warning); \
367*61046927SAndroid Build Coastguard Worker          warned = true; \
368*61046927SAndroid Build Coastguard Worker       } \
369*61046927SAndroid Build Coastguard Worker    } while (0)
370*61046927SAndroid Build Coastguard Worker 
371*61046927SAndroid Build Coastguard Worker #ifdef __cplusplus
372*61046927SAndroid Build Coastguard Worker }
373*61046927SAndroid Build Coastguard Worker #endif
374*61046927SAndroid Build Coastguard Worker 
375*61046927SAndroid Build Coastguard Worker #endif
376