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_GetPhysicalDeviceDisplayPlanePropertiesKHR(
61 VkPhysicalDevice physical_device
,
62 uint32_t *property_count
,
63 VkDisplayPlanePropertiesKHR
*properties
)
65 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
67 return wsi_display_get_physical_device_display_plane_properties(
75 radv_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physical_device
,
77 uint32_t *display_count
,
78 VkDisplayKHR
*displays
)
80 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
82 return wsi_display_get_display_plane_supported_displays(
92 radv_GetDisplayModePropertiesKHR(VkPhysicalDevice physical_device
,
94 uint32_t *property_count
,
95 VkDisplayModePropertiesKHR
*properties
)
97 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
99 return wsi_display_get_display_mode_properties(physical_device
,
100 &pdevice
->wsi_device
,
107 radv_CreateDisplayModeKHR(VkPhysicalDevice physical_device
,
108 VkDisplayKHR display
,
109 const VkDisplayModeCreateInfoKHR
*create_info
,
110 const VkAllocationCallbacks
*allocator
,
111 VkDisplayModeKHR
*mode
)
113 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
115 return wsi_display_create_display_mode(physical_device
,
116 &pdevice
->wsi_device
,
124 radv_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physical_device
,
125 VkDisplayModeKHR mode_khr
,
126 uint32_t plane_index
,
127 VkDisplayPlaneCapabilitiesKHR
*capabilities
)
129 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
131 return wsi_get_display_plane_capabilities(physical_device
,
132 &pdevice
->wsi_device
,
139 radv_CreateDisplayPlaneSurfaceKHR(
140 VkInstance _instance
,
141 const VkDisplaySurfaceCreateInfoKHR
*create_info
,
142 const VkAllocationCallbacks
*allocator
,
143 VkSurfaceKHR
*surface
)
145 RADV_FROM_HANDLE(radv_instance
, instance
, _instance
);
146 const VkAllocationCallbacks
*alloc
;
151 alloc
= &instance
->alloc
;
153 return wsi_create_display_surface(_instance
, alloc
,
154 create_info
, surface
);
158 radv_ReleaseDisplayEXT(VkPhysicalDevice physical_device
,
159 VkDisplayKHR display
)
161 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
163 return wsi_release_display(physical_device
,
164 &pdevice
->wsi_device
,
168 #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
170 radv_AcquireXlibDisplayEXT(VkPhysicalDevice physical_device
,
172 VkDisplayKHR display
)
174 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
176 return wsi_acquire_xlib_display(physical_device
,
177 &pdevice
->wsi_device
,
183 radv_GetRandROutputDisplayEXT(VkPhysicalDevice physical_device
,
186 VkDisplayKHR
*display
)
188 RADV_FROM_HANDLE(radv_physical_device
, pdevice
, physical_device
);
190 return wsi_get_randr_output_display(physical_device
,
191 &pdevice
->wsi_device
,
196 #endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
198 /* VK_EXT_display_control */
201 radv_DisplayPowerControlEXT(VkDevice _device
,
202 VkDisplayKHR display
,
203 const VkDisplayPowerInfoEXT
*display_power_info
)
205 RADV_FROM_HANDLE(radv_device
, device
, _device
);
207 return wsi_display_power_control(_device
,
208 &device
->physical_device
->wsi_device
,
214 radv_RegisterDeviceEventEXT(VkDevice _device
,
215 const VkDeviceEventInfoEXT
*device_event_info
,
216 const VkAllocationCallbacks
*allocator
,
219 RADV_FROM_HANDLE(radv_device
, device
, _device
);
220 struct radv_fence
*fence
;
223 fence
= vk_alloc2(&device
->instance
->alloc
, allocator
, sizeof (*fence
),
224 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
226 return VK_ERROR_OUT_OF_HOST_MEMORY
;
229 fence
->submitted
= true;
230 fence
->signalled
= false;
232 fence
->temp_syncobj
= 0;
234 ret
= wsi_register_device_event(_device
,
235 &device
->physical_device
->wsi_device
,
239 if (ret
== VK_SUCCESS
)
240 *_fence
= radv_fence_to_handle(fence
);
242 vk_free2(&device
->instance
->alloc
, allocator
, fence
);
247 radv_RegisterDisplayEventEXT(VkDevice _device
,
248 VkDisplayKHR display
,
249 const VkDisplayEventInfoEXT
*display_event_info
,
250 const VkAllocationCallbacks
*allocator
,
253 RADV_FROM_HANDLE(radv_device
, device
, _device
);
255 struct radv_fence
*fence
;
258 fence
= vk_alloc2(&device
->instance
->alloc
, allocator
, sizeof (*fence
),
259 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
261 return VK_ERROR_OUT_OF_HOST_MEMORY
;
264 fence
->submitted
= true;
265 fence
->signalled
= false;
267 fence
->temp_syncobj
= 0;
269 ret
= wsi_register_display_event(_device
,
270 &device
->physical_device
->wsi_device
,
274 &(fence
->fence_wsi
));
276 if (ret
== VK_SUCCESS
)
277 *_fence
= radv_fence_to_handle(fence
);
279 vk_free2(&device
->instance
->alloc
, allocator
, fence
);
284 radv_GetSwapchainCounterEXT(VkDevice _device
,
285 VkSwapchainKHR swapchain
,
286 VkSurfaceCounterFlagBitsEXT flag_bits
,
289 RADV_FROM_HANDLE(radv_device
, device
, _device
);
291 return wsi_get_swapchain_counter(_device
,
292 &device
->physical_device
->wsi_device
,