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"
27 #include "vulkan/util/vk_object.h"
31 VkDeviceMemory memory
;
35 VkDeviceMemory memory
;
36 VkCommandBuffer
*blit_cmd_buffers
;
39 uint64_t drm_modifier
;
43 uint32_t row_pitches
[4];
47 struct wsi_swapchain
{
48 struct vk_object_base base
;
50 const struct wsi_device
*wsi
;
53 VkAllocationCallbacks alloc
;
55 VkPresentModeKHR present_mode
;
60 /* Command pools, one per queue family */
61 VkCommandPool
*cmd_pools
;
63 VkResult (*destroy
)(struct wsi_swapchain
*swapchain
,
64 const VkAllocationCallbacks
*pAllocator
);
65 struct wsi_image
*(*get_wsi_image
)(struct wsi_swapchain
*swapchain
,
66 uint32_t image_index
);
67 VkResult (*acquire_next_image
)(struct wsi_swapchain
*swap_chain
,
68 const VkAcquireNextImageInfoKHR
*info
,
69 uint32_t *image_index
);
70 VkResult (*queue_present
)(struct wsi_swapchain
*swap_chain
,
72 const VkPresentRegionKHR
*damage
);
76 wsi_device_matches_drm_fd(const struct wsi_device
*wsi
, int drm_fd
);
79 wsi_swapchain_init(const struct wsi_device
*wsi
,
80 struct wsi_swapchain
*chain
,
82 const VkSwapchainCreateInfoKHR
*pCreateInfo
,
83 const VkAllocationCallbacks
*pAllocator
);
86 wsi_swapchain_get_present_mode(struct wsi_device
*wsi
,
87 const VkSwapchainCreateInfoKHR
*pCreateInfo
);
89 void wsi_swapchain_finish(struct wsi_swapchain
*chain
);
92 wsi_create_native_image(const struct wsi_swapchain
*chain
,
93 const VkSwapchainCreateInfoKHR
*pCreateInfo
,
94 uint32_t num_modifier_lists
,
95 const uint32_t *num_modifiers
,
96 const uint64_t *const *modifiers
,
97 struct wsi_image
*image
);
100 wsi_create_prime_image(const struct wsi_swapchain
*chain
,
101 const VkSwapchainCreateInfoKHR
*pCreateInfo
,
103 struct wsi_image
*image
);
106 wsi_destroy_image(const struct wsi_swapchain
*chain
,
107 struct wsi_image
*image
);
110 struct wsi_interface
{
111 VkResult (*get_support
)(VkIcdSurfaceBase
*surface
,
112 struct wsi_device
*wsi_device
,
113 uint32_t queueFamilyIndex
,
114 VkBool32
* pSupported
);
115 VkResult (*get_capabilities2
)(VkIcdSurfaceBase
*surface
,
116 struct wsi_device
*wsi_device
,
117 const void *info_next
,
118 VkSurfaceCapabilities2KHR
* pSurfaceCapabilities
);
119 VkResult (*get_formats
)(VkIcdSurfaceBase
*surface
,
120 struct wsi_device
*wsi_device
,
121 uint32_t* pSurfaceFormatCount
,
122 VkSurfaceFormatKHR
* pSurfaceFormats
);
123 VkResult (*get_formats2
)(VkIcdSurfaceBase
*surface
,
124 struct wsi_device
*wsi_device
,
125 const void *info_next
,
126 uint32_t* pSurfaceFormatCount
,
127 VkSurfaceFormat2KHR
* pSurfaceFormats
);
128 VkResult (*get_present_modes
)(VkIcdSurfaceBase
*surface
,
129 uint32_t* pPresentModeCount
,
130 VkPresentModeKHR
* pPresentModes
);
131 VkResult (*get_present_rectangles
)(VkIcdSurfaceBase
*surface
,
132 struct wsi_device
*wsi_device
,
133 uint32_t* pRectCount
,
135 VkResult (*create_swapchain
)(VkIcdSurfaceBase
*surface
,
137 struct wsi_device
*wsi_device
,
138 const VkSwapchainCreateInfoKHR
* pCreateInfo
,
139 const VkAllocationCallbacks
* pAllocator
,
140 struct wsi_swapchain
**swapchain
);
143 VkResult
wsi_x11_init_wsi(struct wsi_device
*wsi_device
,
144 const VkAllocationCallbacks
*alloc
,
145 const struct driOptionCache
*dri_options
);
146 void wsi_x11_finish_wsi(struct wsi_device
*wsi_device
,
147 const VkAllocationCallbacks
*alloc
);
148 VkResult
wsi_wl_init_wsi(struct wsi_device
*wsi_device
,
149 const VkAllocationCallbacks
*alloc
,
150 VkPhysicalDevice physical_device
);
151 void wsi_wl_finish_wsi(struct wsi_device
*wsi_device
,
152 const VkAllocationCallbacks
*alloc
);
156 wsi_display_init_wsi(struct wsi_device
*wsi_device
,
157 const VkAllocationCallbacks
*alloc
,
161 wsi_display_finish_wsi(struct wsi_device
*wsi_device
,
162 const VkAllocationCallbacks
*alloc
);
164 VK_DEFINE_NONDISP_HANDLE_CASTS(wsi_swapchain
, base
, VkSwapchainKHR
,
165 VK_OBJECT_TYPE_SWAPCHAIN_KHR
)
167 #endif /* WSI_COMMON_PRIVATE_H */