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
27 #include "radv_private.h"
29 #include "util/disk_cache.h"
30 #include "util/strtod.h"
33 #include <xf86drmMode.h>
35 #include <amdgpu_drm.h>
36 #include "winsys/amdgpu/radv_amdgpu_winsys_public.h"
37 #include "ac_llvm_util.h"
38 #include "vk_format.h"
40 #include "util/debug.h"
41 #include "wsi_common_display.h"
43 #define MM_PER_PIXEL (1.0/96.0 * 25.4)
46 radv_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physical_device
,
47 uint32_t *property_count
,
48 VkDisplayPropertiesKHR
*properties
)
50 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
52 return wsi_display_get_physical_device_display_properties(
60 radv_GetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physical_device
,
61 uint32_t *property_count
,
62 VkDisplayProperties2KHR
*properties
)
64 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
66 return wsi_display_get_physical_device_display_properties2(
74 radv_GetPhysicalDeviceDisplayPlanePropertiesKHR(
75 VkPhysicalDevice physical_device
,
76 uint32_t *property_count
,
77 VkDisplayPlanePropertiesKHR
*properties
)
79 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
81 return wsi_display_get_physical_device_display_plane_properties(
89 radv_GetPhysicalDeviceDisplayPlaneProperties2KHR(
90 VkPhysicalDevice physical_device
,
91 uint32_t *property_count
,
92 VkDisplayPlaneProperties2KHR
*properties
)
94 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
96 return wsi_display_get_physical_device_display_plane_properties2(
104 radv_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physical_device
,
105 uint32_t plane_index
,
106 uint32_t *display_count
,
107 VkDisplayKHR
*displays
)
109 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
111 return wsi_display_get_display_plane_supported_displays(
113 &pdevice
->wsi_device
,
121 radv_GetDisplayModePropertiesKHR(VkPhysicalDevice physical_device
,
122 VkDisplayKHR display
,
123 uint32_t *property_count
,
124 VkDisplayModePropertiesKHR
*properties
)
126 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
128 return wsi_display_get_display_mode_properties(physical_device
,
129 &pdevice
->wsi_device
,
136 radv_GetDisplayModeProperties2KHR(VkPhysicalDevice physical_device
,
137 VkDisplayKHR display
,
138 uint32_t *property_count
,
139 VkDisplayModeProperties2KHR
*properties
)
141 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
143 return wsi_display_get_display_mode_properties2(physical_device
,
144 &pdevice
->wsi_device
,
151 radv_CreateDisplayModeKHR(VkPhysicalDevice physical_device
,
152 VkDisplayKHR display
,
153 const VkDisplayModeCreateInfoKHR
*create_info
,
154 const VkAllocationCallbacks
*allocator
,
155 VkDisplayModeKHR
*mode
)
157 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
159 return wsi_display_create_display_mode(physical_device
,
160 &pdevice
->wsi_device
,
168 radv_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physical_device
,
169 VkDisplayModeKHR mode_khr
,
170 uint32_t plane_index
,
171 VkDisplayPlaneCapabilitiesKHR
*capabilities
)
173 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
175 return wsi_get_display_plane_capabilities(physical_device
,
176 &pdevice
->wsi_device
,
183 radv_GetDisplayPlaneCapabilities2KHR(VkPhysicalDevice physical_device
,
184 const VkDisplayPlaneInfo2KHR
*pDisplayPlaneInfo
,
185 VkDisplayPlaneCapabilities2KHR
*capabilities
)
187 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
189 return wsi_get_display_plane_capabilities2(physical_device
,
190 &pdevice
->wsi_device
,
196 radv_CreateDisplayPlaneSurfaceKHR(
197 VkInstance _instance
,
198 const VkDisplaySurfaceCreateInfoKHR
*create_info
,
199 const VkAllocationCallbacks
*allocator
,
200 VkSurfaceKHR
*surface
)
202 RADV_FROM_HANDLE(radv_instance
, instance
, _instance
);
203 const VkAllocationCallbacks
*alloc
;
208 alloc
= &instance
->alloc
;
210 return wsi_create_display_surface(_instance
, alloc
,
211 create_info
, surface
);
215 radv_ReleaseDisplayEXT(VkPhysicalDevice physical_device
,
216 VkDisplayKHR display
)
218 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
220 return wsi_release_display(physical_device
,
221 &pdevice
->wsi_device
,
225 #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
227 radv_AcquireXlibDisplayEXT(VkPhysicalDevice physical_device
,
229 VkDisplayKHR display
)
231 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
233 return wsi_acquire_xlib_display(physical_device
,
234 &pdevice
->wsi_device
,
240 radv_GetRandROutputDisplayEXT(VkPhysicalDevice physical_device
,
243 VkDisplayKHR
*display
)
245 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
247 return wsi_get_randr_output_display(physical_device
,
248 &pdevice
->wsi_device
,
253 #endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
255 /* VK_EXT_display_control */
258 radv_DisplayPowerControlEXT(VkDevice _device
,
259 VkDisplayKHR display
,
260 const VkDisplayPowerInfoEXT
*display_power_info
)
262 RADV_FROM_HANDLE(radv_device
, device
, _device
);
264 return wsi_display_power_control(_device
,
265 &device
->physical_device
->wsi_device
,
271 radv_RegisterDeviceEventEXT(VkDevice _device
,
272 const VkDeviceEventInfoEXT
*device_event_info
,
273 const VkAllocationCallbacks
*allocator
,
276 RADV_FROM_HANDLE(radv_device
, device
, _device
);
277 struct radv_fence
*fence
;
280 fence
= vk_alloc2(&device
->instance
->alloc
, allocator
, sizeof (*fence
),
281 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
283 return VK_ERROR_OUT_OF_HOST_MEMORY
;
286 fence
->submitted
= true;
287 fence
->signalled
= false;
289 fence
->temp_syncobj
= 0;
291 ret
= wsi_register_device_event(_device
,
292 &device
->physical_device
->wsi_device
,
296 if (ret
== VK_SUCCESS
)
297 *_fence
= radv_fence_to_handle(fence
);
299 vk_free2(&device
->instance
->alloc
, allocator
, fence
);
304 radv_RegisterDisplayEventEXT(VkDevice _device
,
305 VkDisplayKHR display
,
306 const VkDisplayEventInfoEXT
*display_event_info
,
307 const VkAllocationCallbacks
*allocator
,
310 RADV_FROM_HANDLE(radv_device
, device
, _device
);
312 struct radv_fence
*fence
;
315 fence
= vk_alloc2(&device
->instance
->alloc
, allocator
, sizeof (*fence
),
316 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
318 return VK_ERROR_OUT_OF_HOST_MEMORY
;
321 fence
->submitted
= true;
322 fence
->signalled
= false;
324 fence
->temp_syncobj
= 0;
326 ret
= wsi_register_display_event(_device
,
327 &device
->physical_device
->wsi_device
,
331 &(fence
->fence_wsi
));
333 if (ret
== VK_SUCCESS
)
334 *_fence
= radv_fence_to_handle(fence
);
336 vk_free2(&device
->instance
->alloc
, allocator
, fence
);
341 radv_GetSwapchainCounterEXT(VkDevice _device
,
342 VkSwapchainKHR swapchain
,
343 VkSurfaceCounterFlagBitsEXT flag_bits
,
346 RADV_FROM_HANDLE(radv_device
, device
, _device
);
348 return wsi_get_swapchain_counter(_device
,
349 &device
->physical_device
->wsi_device
,