Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/intel/vulkan/anv_wsi_display.c
4547 views
1
/*
2
* Copyright © 2017 Keith Packard
3
*
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.
13
*
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
20
* OF THIS SOFTWARE.
21
*/
22
23
#include "anv_private.h"
24
#include "wsi_common.h"
25
#include "vk_util.h"
26
#include "wsi_common_display.h"
27
28
VkResult
29
anv_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physical_device,
30
uint32_t *property_count,
31
VkDisplayPropertiesKHR *properties)
32
{
33
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
34
35
return wsi_display_get_physical_device_display_properties(
36
physical_device,
37
&pdevice->wsi_device,
38
property_count,
39
properties);
40
}
41
42
VkResult
43
anv_GetPhysicalDeviceDisplayProperties2KHR(
44
VkPhysicalDevice physicalDevice,
45
uint32_t* pPropertyCount,
46
VkDisplayProperties2KHR* pProperties)
47
{
48
ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
49
50
return wsi_display_get_physical_device_display_properties2(
51
physicalDevice, &pdevice->wsi_device,
52
pPropertyCount, pProperties);
53
}
54
55
VkResult
56
anv_GetPhysicalDeviceDisplayPlanePropertiesKHR(
57
VkPhysicalDevice physical_device,
58
uint32_t *property_count,
59
VkDisplayPlanePropertiesKHR *properties)
60
{
61
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
62
63
return wsi_display_get_physical_device_display_plane_properties(
64
physical_device, &pdevice->wsi_device,
65
property_count, properties);
66
}
67
68
VkResult
69
anv_GetPhysicalDeviceDisplayPlaneProperties2KHR(
70
VkPhysicalDevice physicalDevice,
71
uint32_t* pPropertyCount,
72
VkDisplayPlaneProperties2KHR* pProperties)
73
{
74
ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
75
76
return wsi_display_get_physical_device_display_plane_properties2(
77
physicalDevice, &pdevice->wsi_device,
78
pPropertyCount, pProperties);
79
}
80
81
VkResult
82
anv_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physical_device,
83
uint32_t plane_index,
84
uint32_t *display_count,
85
VkDisplayKHR *displays)
86
{
87
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
88
89
return wsi_display_get_display_plane_supported_displays(physical_device,
90
&pdevice->wsi_device,
91
plane_index,
92
display_count,
93
displays);
94
}
95
96
97
VkResult
98
anv_GetDisplayModePropertiesKHR(VkPhysicalDevice physical_device,
99
VkDisplayKHR display,
100
uint32_t *property_count,
101
VkDisplayModePropertiesKHR *properties)
102
{
103
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
104
105
return wsi_display_get_display_mode_properties(physical_device,
106
&pdevice->wsi_device,
107
display,
108
property_count,
109
properties);
110
}
111
112
VkResult
113
anv_GetDisplayModeProperties2KHR(
114
VkPhysicalDevice physicalDevice,
115
VkDisplayKHR display,
116
uint32_t* pPropertyCount,
117
VkDisplayModeProperties2KHR* pProperties)
118
{
119
ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
120
121
return wsi_display_get_display_mode_properties2(physicalDevice,
122
&pdevice->wsi_device,
123
display,
124
pPropertyCount,
125
pProperties);
126
}
127
128
VkResult
129
anv_CreateDisplayModeKHR(VkPhysicalDevice physical_device,
130
VkDisplayKHR display,
131
const VkDisplayModeCreateInfoKHR *create_info,
132
const VkAllocationCallbacks *allocator,
133
VkDisplayModeKHR *mode)
134
{
135
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
136
137
return wsi_display_create_display_mode(physical_device,
138
&pdevice->wsi_device,
139
display,
140
create_info,
141
allocator,
142
mode);
143
}
144
145
VkResult
146
anv_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physical_device,
147
VkDisplayModeKHR mode_khr,
148
uint32_t plane_index,
149
VkDisplayPlaneCapabilitiesKHR *capabilities)
150
{
151
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
152
153
return wsi_get_display_plane_capabilities(physical_device,
154
&pdevice->wsi_device,
155
mode_khr,
156
plane_index,
157
capabilities);
158
}
159
160
VkResult
161
anv_GetDisplayPlaneCapabilities2KHR(
162
VkPhysicalDevice physicalDevice,
163
const VkDisplayPlaneInfo2KHR* pDisplayPlaneInfo,
164
VkDisplayPlaneCapabilities2KHR* pCapabilities)
165
{
166
ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
167
168
return wsi_get_display_plane_capabilities2(physicalDevice,
169
&pdevice->wsi_device,
170
pDisplayPlaneInfo,
171
pCapabilities);
172
}
173
174
VkResult
175
anv_CreateDisplayPlaneSurfaceKHR(
176
VkInstance _instance,
177
const VkDisplaySurfaceCreateInfoKHR *create_info,
178
const VkAllocationCallbacks *allocator,
179
VkSurfaceKHR *surface)
180
{
181
ANV_FROM_HANDLE(anv_instance, instance, _instance);
182
const VkAllocationCallbacks *alloc;
183
184
if (allocator)
185
alloc = allocator;
186
else
187
alloc = &instance->vk.alloc;
188
189
return wsi_create_display_surface(_instance, alloc, create_info, surface);
190
}
191
192
VkResult
193
anv_ReleaseDisplayEXT(VkPhysicalDevice physical_device,
194
VkDisplayKHR display)
195
{
196
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
197
198
return wsi_release_display(physical_device,
199
&pdevice->wsi_device,
200
display);
201
}
202
203
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
204
VkResult
205
anv_AcquireXlibDisplayEXT(VkPhysicalDevice physical_device,
206
Display *dpy,
207
VkDisplayKHR display)
208
{
209
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
210
211
return wsi_acquire_xlib_display(physical_device,
212
&pdevice->wsi_device,
213
dpy,
214
display);
215
}
216
217
VkResult
218
anv_GetRandROutputDisplayEXT(VkPhysicalDevice physical_device,
219
Display *dpy,
220
RROutput output,
221
VkDisplayKHR *display)
222
{
223
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
224
225
return wsi_get_randr_output_display(physical_device,
226
&pdevice->wsi_device,
227
dpy,
228
output,
229
display);
230
}
231
#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
232
233
/* VK_EXT_display_control */
234
235
VkResult
236
anv_DisplayPowerControlEXT(VkDevice _device,
237
VkDisplayKHR display,
238
const VkDisplayPowerInfoEXT *display_power_info)
239
{
240
ANV_FROM_HANDLE(anv_device, device, _device);
241
242
return wsi_display_power_control(
243
_device, &device->physical->wsi_device,
244
display, display_power_info);
245
}
246
247
VkResult
248
anv_RegisterDeviceEventEXT(VkDevice _device,
249
const VkDeviceEventInfoEXT *device_event_info,
250
const VkAllocationCallbacks *allocator,
251
VkFence *_fence)
252
{
253
ANV_FROM_HANDLE(anv_device, device, _device);
254
struct anv_fence *fence;
255
VkResult ret;
256
257
fence = vk_zalloc2(&device->vk.alloc, allocator, sizeof (*fence), 8,
258
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
259
if (!fence)
260
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
261
262
fence->permanent.type = ANV_FENCE_TYPE_WSI;
263
264
ret = wsi_register_device_event(_device,
265
&device->physical->wsi_device,
266
device_event_info,
267
allocator,
268
&fence->permanent.fence_wsi,
269
-1);
270
if (ret == VK_SUCCESS)
271
*_fence = anv_fence_to_handle(fence);
272
else
273
vk_free2(&device->vk.alloc, allocator, fence);
274
return ret;
275
}
276
277
VkResult
278
anv_RegisterDisplayEventEXT(VkDevice _device,
279
VkDisplayKHR display,
280
const VkDisplayEventInfoEXT *display_event_info,
281
const VkAllocationCallbacks *allocator,
282
VkFence *_fence)
283
{
284
ANV_FROM_HANDLE(anv_device, device, _device);
285
struct anv_fence *fence;
286
VkResult ret;
287
288
fence = vk_zalloc2(&device->vk.alloc, allocator, sizeof (*fence), 8,
289
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
290
if (!fence)
291
return VK_ERROR_OUT_OF_HOST_MEMORY;
292
293
fence->permanent.type = ANV_FENCE_TYPE_WSI;
294
295
ret = wsi_register_display_event(
296
_device, &device->physical->wsi_device,
297
display, display_event_info, allocator, &fence->permanent.fence_wsi, -1);
298
299
if (ret == VK_SUCCESS)
300
*_fence = anv_fence_to_handle(fence);
301
else
302
vk_free2(&device->vk.alloc, allocator, fence);
303
return ret;
304
}
305
306
VkResult
307
anv_GetSwapchainCounterEXT(VkDevice _device,
308
VkSwapchainKHR swapchain,
309
VkSurfaceCounterFlagBitsEXT flag_bits,
310
uint64_t *value)
311
{
312
ANV_FROM_HANDLE(anv_device, device, _device);
313
314
return wsi_get_swapchain_counter(
315
_device, &device->physical->wsi_device,
316
swapchain, flag_bits, value);
317
}
318
319
VkResult
320
anv_AcquireDrmDisplayEXT(VkPhysicalDevice physical_device,
321
int32_t drm_fd,
322
VkDisplayKHR display)
323
{
324
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
325
326
return wsi_acquire_drm_display(physical_device, &pdevice->wsi_device, drm_fd, display);
327
}
328
329
VkResult
330
anv_GetDrmDisplayEXT(VkPhysicalDevice physical_device,
331
int32_t drm_fd,
332
uint32_t connector_id,
333
VkDisplayKHR *display)
334
{
335
ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
336
337
return wsi_get_drm_display(physical_device, &pdevice->wsi_device, drm_fd, connector_id, display);
338
}
339
340