mesa: Revert INTEL_fragment_shader_ordering support
[mesa.git] / src / intel / vulkan / anv_wsi_display.c
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_format_info.h"
26 #include "vk_util.h"
27 #include "wsi_common_display.h"
28
29 VkResult
30 anv_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physical_device,
31 uint32_t *property_count,
32 VkDisplayPropertiesKHR *properties)
33 {
34 ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
35
36 return wsi_display_get_physical_device_display_properties(
37 physical_device,
38 &pdevice->wsi_device,
39 property_count,
40 properties);
41 }
42
43 VkResult
44 anv_GetPhysicalDeviceDisplayProperties2KHR(
45 VkPhysicalDevice physicalDevice,
46 uint32_t* pPropertyCount,
47 VkDisplayProperties2KHR* pProperties)
48 {
49 ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
50
51 return wsi_display_get_physical_device_display_properties2(
52 physicalDevice, &pdevice->wsi_device,
53 pPropertyCount, pProperties);
54 }
55
56 VkResult
57 anv_GetPhysicalDeviceDisplayPlanePropertiesKHR(
58 VkPhysicalDevice physical_device,
59 uint32_t *property_count,
60 VkDisplayPlanePropertiesKHR *properties)
61 {
62 ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
63
64 return wsi_display_get_physical_device_display_plane_properties(
65 physical_device, &pdevice->wsi_device,
66 property_count, properties);
67 }
68
69 VkResult
70 anv_GetPhysicalDeviceDisplayPlaneProperties2KHR(
71 VkPhysicalDevice physicalDevice,
72 uint32_t* pPropertyCount,
73 VkDisplayPlaneProperties2KHR* pProperties)
74 {
75 ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
76
77 return wsi_display_get_physical_device_display_plane_properties2(
78 physicalDevice, &pdevice->wsi_device,
79 pPropertyCount, pProperties);
80 }
81
82 VkResult
83 anv_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physical_device,
84 uint32_t plane_index,
85 uint32_t *display_count,
86 VkDisplayKHR *displays)
87 {
88 ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
89
90 return wsi_display_get_display_plane_supported_displays(physical_device,
91 &pdevice->wsi_device,
92 plane_index,
93 display_count,
94 displays);
95 }
96
97
98 VkResult
99 anv_GetDisplayModePropertiesKHR(VkPhysicalDevice physical_device,
100 VkDisplayKHR display,
101 uint32_t *property_count,
102 VkDisplayModePropertiesKHR *properties)
103 {
104 ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
105
106 return wsi_display_get_display_mode_properties(physical_device,
107 &pdevice->wsi_device,
108 display,
109 property_count,
110 properties);
111 }
112
113 VkResult
114 anv_GetDisplayModeProperties2KHR(
115 VkPhysicalDevice physicalDevice,
116 VkDisplayKHR display,
117 uint32_t* pPropertyCount,
118 VkDisplayModeProperties2KHR* pProperties)
119 {
120 ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
121
122 return wsi_display_get_display_mode_properties2(physicalDevice,
123 &pdevice->wsi_device,
124 display,
125 pPropertyCount,
126 pProperties);
127 }
128
129 VkResult
130 anv_CreateDisplayModeKHR(VkPhysicalDevice physical_device,
131 VkDisplayKHR display,
132 const VkDisplayModeCreateInfoKHR *create_info,
133 const VkAllocationCallbacks *allocator,
134 VkDisplayModeKHR *mode)
135 {
136 ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
137
138 return wsi_display_create_display_mode(physical_device,
139 &pdevice->wsi_device,
140 display,
141 create_info,
142 allocator,
143 mode);
144 }
145
146 VkResult
147 anv_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physical_device,
148 VkDisplayModeKHR mode_khr,
149 uint32_t plane_index,
150 VkDisplayPlaneCapabilitiesKHR *capabilities)
151 {
152 ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
153
154 return wsi_get_display_plane_capabilities(physical_device,
155 &pdevice->wsi_device,
156 mode_khr,
157 plane_index,
158 capabilities);
159 }
160
161 VkResult
162 anv_GetDisplayPlaneCapabilities2KHR(
163 VkPhysicalDevice physicalDevice,
164 const VkDisplayPlaneInfo2KHR* pDisplayPlaneInfo,
165 VkDisplayPlaneCapabilities2KHR* pCapabilities)
166 {
167 ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
168
169 return wsi_get_display_plane_capabilities2(physicalDevice,
170 &pdevice->wsi_device,
171 pDisplayPlaneInfo,
172 pCapabilities);
173 }
174
175 VkResult
176 anv_CreateDisplayPlaneSurfaceKHR(
177 VkInstance _instance,
178 const VkDisplaySurfaceCreateInfoKHR *create_info,
179 const VkAllocationCallbacks *allocator,
180 VkSurfaceKHR *surface)
181 {
182 ANV_FROM_HANDLE(anv_instance, instance, _instance);
183 const VkAllocationCallbacks *alloc;
184
185 if (allocator)
186 alloc = allocator;
187 else
188 alloc = &instance->alloc;
189
190 return wsi_create_display_surface(_instance, alloc, create_info, surface);
191 }
192
193 VkResult
194 anv_ReleaseDisplayEXT(VkPhysicalDevice physical_device,
195 VkDisplayKHR display)
196 {
197 ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
198
199 return wsi_release_display(physical_device,
200 &pdevice->wsi_device,
201 display);
202 }
203
204 #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
205 VkResult
206 anv_AcquireXlibDisplayEXT(VkPhysicalDevice physical_device,
207 Display *dpy,
208 VkDisplayKHR display)
209 {
210 ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
211
212 return wsi_acquire_xlib_display(physical_device,
213 &pdevice->wsi_device,
214 dpy,
215 display);
216 }
217
218 VkResult
219 anv_GetRandROutputDisplayEXT(VkPhysicalDevice physical_device,
220 Display *dpy,
221 RROutput output,
222 VkDisplayKHR *display)
223 {
224 ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device);
225
226 return wsi_get_randr_output_display(physical_device,
227 &pdevice->wsi_device,
228 dpy,
229 output,
230 display);
231 }
232 #endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
233
234 /* VK_EXT_display_control */
235
236 VkResult
237 anv_DisplayPowerControlEXT(VkDevice _device,
238 VkDisplayKHR display,
239 const VkDisplayPowerInfoEXT *display_power_info)
240 {
241 ANV_FROM_HANDLE(anv_device, device, _device);
242
243 return wsi_display_power_control(
244 _device, &device->instance->physicalDevice.wsi_device,
245 display, display_power_info);
246 }
247
248 VkResult
249 anv_RegisterDeviceEventEXT(VkDevice _device,
250 const VkDeviceEventInfoEXT *device_event_info,
251 const VkAllocationCallbacks *allocator,
252 VkFence *_fence)
253 {
254 ANV_FROM_HANDLE(anv_device, device, _device);
255 struct anv_fence *fence;
256 VkResult ret;
257
258 fence = vk_zalloc2(&device->instance->alloc, allocator, sizeof (*fence), 8,
259 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
260 if (!fence)
261 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
262
263 fence->permanent.type = ANV_FENCE_TYPE_WSI;
264
265 ret = wsi_register_device_event(_device,
266 &device->instance->physicalDevice.wsi_device,
267 device_event_info,
268 allocator,
269 &fence->permanent.fence_wsi);
270 if (ret == VK_SUCCESS)
271 *_fence = anv_fence_to_handle(fence);
272 else
273 vk_free2(&device->instance->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->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->instance->physicalDevice.wsi_device,
297 display, display_event_info, allocator, &(fence->permanent.fence_wsi));
298
299 if (ret == VK_SUCCESS)
300 *_fence = anv_fence_to_handle(fence);
301 else
302 vk_free2(&device->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->instance->physicalDevice.wsi_device,
316 swapchain, flag_bits, value);
317 }