2 * Copyright © 2017 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 #include "anv_private.h"
24 #include "wsi_common.h"
25 #include "vk_format_info.h"
27 #include "wsi_common_display.h"
30 anv_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physical_device
,
31 uint32_t *property_count
,
32 VkDisplayPropertiesKHR
*properties
)
34 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physical_device
);
36 return wsi_display_get_physical_device_display_properties(
44 anv_GetPhysicalDeviceDisplayProperties2KHR(
45 VkPhysicalDevice physicalDevice
,
46 uint32_t* pPropertyCount
,
47 VkDisplayProperties2KHR
* pProperties
)
49 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physicalDevice
);
51 return wsi_display_get_physical_device_display_properties2(
52 physicalDevice
, &pdevice
->wsi_device
,
53 pPropertyCount
, pProperties
);
57 anv_GetPhysicalDeviceDisplayPlanePropertiesKHR(
58 VkPhysicalDevice physical_device
,
59 uint32_t *property_count
,
60 VkDisplayPlanePropertiesKHR
*properties
)
62 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physical_device
);
64 return wsi_display_get_physical_device_display_plane_properties(
65 physical_device
, &pdevice
->wsi_device
,
66 property_count
, properties
);
70 anv_GetPhysicalDeviceDisplayPlaneProperties2KHR(
71 VkPhysicalDevice physicalDevice
,
72 uint32_t* pPropertyCount
,
73 VkDisplayPlaneProperties2KHR
* pProperties
)
75 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physicalDevice
);
77 return wsi_display_get_physical_device_display_plane_properties2(
78 physicalDevice
, &pdevice
->wsi_device
,
79 pPropertyCount
, pProperties
);
83 anv_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physical_device
,
85 uint32_t *display_count
,
86 VkDisplayKHR
*displays
)
88 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physical_device
);
90 return wsi_display_get_display_plane_supported_displays(physical_device
,
99 anv_GetDisplayModePropertiesKHR(VkPhysicalDevice physical_device
,
100 VkDisplayKHR display
,
101 uint32_t *property_count
,
102 VkDisplayModePropertiesKHR
*properties
)
104 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physical_device
);
106 return wsi_display_get_display_mode_properties(physical_device
,
107 &pdevice
->wsi_device
,
114 anv_GetDisplayModeProperties2KHR(
115 VkPhysicalDevice physicalDevice
,
116 VkDisplayKHR display
,
117 uint32_t* pPropertyCount
,
118 VkDisplayModeProperties2KHR
* pProperties
)
120 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physicalDevice
);
122 return wsi_display_get_display_mode_properties2(physicalDevice
,
123 &pdevice
->wsi_device
,
130 anv_CreateDisplayModeKHR(VkPhysicalDevice physical_device
,
131 VkDisplayKHR display
,
132 const VkDisplayModeCreateInfoKHR
*create_info
,
133 const VkAllocationCallbacks
*allocator
,
134 VkDisplayModeKHR
*mode
)
136 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physical_device
);
138 return wsi_display_create_display_mode(physical_device
,
139 &pdevice
->wsi_device
,
147 anv_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physical_device
,
148 VkDisplayModeKHR mode_khr
,
149 uint32_t plane_index
,
150 VkDisplayPlaneCapabilitiesKHR
*capabilities
)
152 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physical_device
);
154 return wsi_get_display_plane_capabilities(physical_device
,
155 &pdevice
->wsi_device
,
162 anv_GetDisplayPlaneCapabilities2KHR(
163 VkPhysicalDevice physicalDevice
,
164 const VkDisplayPlaneInfo2KHR
* pDisplayPlaneInfo
,
165 VkDisplayPlaneCapabilities2KHR
* pCapabilities
)
167 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physicalDevice
);
169 return wsi_get_display_plane_capabilities2(physicalDevice
,
170 &pdevice
->wsi_device
,
176 anv_CreateDisplayPlaneSurfaceKHR(
177 VkInstance _instance
,
178 const VkDisplaySurfaceCreateInfoKHR
*create_info
,
179 const VkAllocationCallbacks
*allocator
,
180 VkSurfaceKHR
*surface
)
182 ANV_FROM_HANDLE(anv_instance
, instance
, _instance
);
183 const VkAllocationCallbacks
*alloc
;
188 alloc
= &instance
->alloc
;
190 return wsi_create_display_surface(_instance
, alloc
, create_info
, surface
);
194 anv_ReleaseDisplayEXT(VkPhysicalDevice physical_device
,
195 VkDisplayKHR display
)
197 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physical_device
);
199 return wsi_release_display(physical_device
,
200 &pdevice
->wsi_device
,
204 #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
206 anv_AcquireXlibDisplayEXT(VkPhysicalDevice physical_device
,
208 VkDisplayKHR display
)
210 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physical_device
);
212 return wsi_acquire_xlib_display(physical_device
,
213 &pdevice
->wsi_device
,
219 anv_GetRandROutputDisplayEXT(VkPhysicalDevice physical_device
,
222 VkDisplayKHR
*display
)
224 ANV_FROM_HANDLE(anv_physical_device
, pdevice
, physical_device
);
226 return wsi_get_randr_output_display(physical_device
,
227 &pdevice
->wsi_device
,
232 #endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
234 /* VK_EXT_display_control */
237 anv_DisplayPowerControlEXT(VkDevice _device
,
238 VkDisplayKHR display
,
239 const VkDisplayPowerInfoEXT
*display_power_info
)
241 ANV_FROM_HANDLE(anv_device
, device
, _device
);
243 return wsi_display_power_control(
244 _device
, &device
->instance
->physicalDevice
.wsi_device
,
245 display
, display_power_info
);
249 anv_RegisterDeviceEventEXT(VkDevice _device
,
250 const VkDeviceEventInfoEXT
*device_event_info
,
251 const VkAllocationCallbacks
*allocator
,
254 ANV_FROM_HANDLE(anv_device
, device
, _device
);
255 struct anv_fence
*fence
;
258 fence
= vk_zalloc2(&device
->instance
->alloc
, allocator
, sizeof (*fence
), 8,
259 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
261 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
263 fence
->permanent
.type
= ANV_FENCE_TYPE_WSI
;
265 ret
= wsi_register_device_event(_device
,
266 &device
->instance
->physicalDevice
.wsi_device
,
269 &fence
->permanent
.fence_wsi
);
270 if (ret
== VK_SUCCESS
)
271 *_fence
= anv_fence_to_handle(fence
);
273 vk_free2(&device
->instance
->alloc
, allocator
, fence
);
278 anv_RegisterDisplayEventEXT(VkDevice _device
,
279 VkDisplayKHR display
,
280 const VkDisplayEventInfoEXT
*display_event_info
,
281 const VkAllocationCallbacks
*allocator
,
284 ANV_FROM_HANDLE(anv_device
, device
, _device
);
285 struct anv_fence
*fence
;
288 fence
= vk_zalloc2(&device
->alloc
, allocator
, sizeof (*fence
), 8,
289 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
291 return VK_ERROR_OUT_OF_HOST_MEMORY
;
293 fence
->permanent
.type
= ANV_FENCE_TYPE_WSI
;
295 ret
= wsi_register_display_event(
296 _device
, &device
->instance
->physicalDevice
.wsi_device
,
297 display
, display_event_info
, allocator
, &(fence
->permanent
.fence_wsi
));
299 if (ret
== VK_SUCCESS
)
300 *_fence
= anv_fence_to_handle(fence
);
302 vk_free2(&device
->alloc
, allocator
, fence
);
307 anv_GetSwapchainCounterEXT(VkDevice _device
,
308 VkSwapchainKHR swapchain
,
309 VkSurfaceCounterFlagBitsEXT flag_bits
,
312 ANV_FROM_HANDLE(anv_device
, device
, _device
);
314 return wsi_get_swapchain_counter(
315 _device
, &device
->instance
->physicalDevice
.wsi_device
,
316 swapchain
, flag_bits
, value
);