Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / gallium / frontends / vallium / val_wsi.c
1 /*
2 * Copyright © 2015 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #include "val_wsi.h"
25
26 static PFN_vkVoidFunction
27 val_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
28 {
29 return val_lookup_entrypoint(pName);
30 }
31
32 VkResult
33 val_init_wsi(struct val_physical_device *physical_device)
34 {
35 return wsi_device_init(&physical_device->wsi_device,
36 val_physical_device_to_handle(physical_device),
37 val_wsi_proc_addr,
38 &physical_device->instance->alloc,
39 -1, NULL, true);
40 }
41
42 void
43 val_finish_wsi(struct val_physical_device *physical_device)
44 {
45 wsi_device_finish(&physical_device->wsi_device,
46 &physical_device->instance->alloc);
47 }
48
49 void val_DestroySurfaceKHR(
50 VkInstance _instance,
51 VkSurfaceKHR _surface,
52 const VkAllocationCallbacks* pAllocator)
53 {
54 VAL_FROM_HANDLE(val_instance, instance, _instance);
55 ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface);
56
57 vk_free2(&instance->alloc, pAllocator, surface);
58 }
59
60 VkResult val_GetPhysicalDeviceSurfaceSupportKHR(
61 VkPhysicalDevice physicalDevice,
62 uint32_t queueFamilyIndex,
63 VkSurfaceKHR surface,
64 VkBool32* pSupported)
65 {
66 VAL_FROM_HANDLE(val_physical_device, device, physicalDevice);
67
68 return wsi_common_get_surface_support(&device->wsi_device,
69 queueFamilyIndex,
70 surface,
71 pSupported);
72 }
73
74 VkResult val_GetPhysicalDeviceSurfaceCapabilitiesKHR(
75 VkPhysicalDevice physicalDevice,
76 VkSurfaceKHR surface,
77 VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
78 {
79 VAL_FROM_HANDLE(val_physical_device, device, physicalDevice);
80
81 return wsi_common_get_surface_capabilities(&device->wsi_device,
82 surface,
83 pSurfaceCapabilities);
84 }
85
86 VkResult val_GetPhysicalDeviceSurfaceCapabilities2KHR(
87 VkPhysicalDevice physicalDevice,
88 const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
89 VkSurfaceCapabilities2KHR* pSurfaceCapabilities)
90 {
91 VAL_FROM_HANDLE(val_physical_device, device, physicalDevice);
92
93 return wsi_common_get_surface_capabilities2(&device->wsi_device,
94 pSurfaceInfo,
95 pSurfaceCapabilities);
96 }
97
98 VkResult val_GetPhysicalDeviceSurfaceCapabilities2EXT(
99 VkPhysicalDevice physicalDevice,
100 VkSurfaceKHR surface,
101 VkSurfaceCapabilities2EXT* pSurfaceCapabilities)
102 {
103 VAL_FROM_HANDLE(val_physical_device, device, physicalDevice);
104
105 return wsi_common_get_surface_capabilities2ext(&device->wsi_device,
106 surface,
107 pSurfaceCapabilities);
108 }
109
110 VkResult val_GetPhysicalDeviceSurfaceFormatsKHR(
111 VkPhysicalDevice physicalDevice,
112 VkSurfaceKHR surface,
113 uint32_t* pSurfaceFormatCount,
114 VkSurfaceFormatKHR* pSurfaceFormats)
115 {
116 VAL_FROM_HANDLE(val_physical_device, device, physicalDevice);
117 return wsi_common_get_surface_formats(&device->wsi_device,
118 surface,
119 pSurfaceFormatCount,
120 pSurfaceFormats);
121 }
122
123 VkResult val_GetPhysicalDeviceSurfacePresentModesKHR(
124 VkPhysicalDevice physicalDevice,
125 VkSurfaceKHR surface,
126 uint32_t* pPresentModeCount,
127 VkPresentModeKHR* pPresentModes)
128 {
129 VAL_FROM_HANDLE(val_physical_device, device, physicalDevice);
130
131 return wsi_common_get_surface_present_modes(&device->wsi_device,
132 surface,
133 pPresentModeCount,
134 pPresentModes);
135 }
136
137 VkResult val_CreateSwapchainKHR(
138 VkDevice _device,
139 const VkSwapchainCreateInfoKHR* pCreateInfo,
140 const VkAllocationCallbacks* pAllocator,
141 VkSwapchainKHR* pSwapchain)
142 {
143 VAL_FROM_HANDLE(val_device, device, _device);
144 const VkAllocationCallbacks *alloc;
145 if (pAllocator)
146 alloc = pAllocator;
147 else
148 alloc = &device->alloc;
149
150 return wsi_common_create_swapchain(&device->physical_device->wsi_device,
151 val_device_to_handle(device),
152 pCreateInfo,
153 alloc,
154 pSwapchain);
155 }
156
157 void val_DestroySwapchainKHR(
158 VkDevice _device,
159 VkSwapchainKHR swapchain,
160 const VkAllocationCallbacks* pAllocator)
161 {
162 VAL_FROM_HANDLE(val_device, device, _device);
163 const VkAllocationCallbacks *alloc;
164
165 if (pAllocator)
166 alloc = pAllocator;
167 else
168 alloc = &device->alloc;
169
170 wsi_common_destroy_swapchain(_device, swapchain, alloc);
171 }
172
173 VkResult val_GetSwapchainImagesKHR(
174 VkDevice device,
175 VkSwapchainKHR swapchain,
176 uint32_t* pSwapchainImageCount,
177 VkImage* pSwapchainImages)
178 {
179 return wsi_common_get_images(swapchain,
180 pSwapchainImageCount,
181 pSwapchainImages);
182 }
183
184 VkResult val_AcquireNextImageKHR(
185 VkDevice device,
186 VkSwapchainKHR swapchain,
187 uint64_t timeout,
188 VkSemaphore semaphore,
189 VkFence fence,
190 uint32_t* pImageIndex)
191 {
192 VkAcquireNextImageInfoKHR acquire_info = {
193 .sType = VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR,
194 .swapchain = swapchain,
195 .timeout = timeout,
196 .semaphore = semaphore,
197 .fence = fence,
198 .deviceMask = 0,
199 };
200
201 return val_AcquireNextImage2KHR(device, &acquire_info, pImageIndex);
202 }
203
204 VkResult val_AcquireNextImage2KHR(
205 VkDevice _device,
206 const VkAcquireNextImageInfoKHR* pAcquireInfo,
207 uint32_t* pImageIndex)
208 {
209 VAL_FROM_HANDLE(val_device, device, _device);
210 struct val_physical_device *pdevice = device->physical_device;
211
212 VkResult result = wsi_common_acquire_next_image2(&pdevice->wsi_device,
213 _device,
214 pAcquireInfo,
215 pImageIndex);
216 #if 0
217 VAL_FROM_HANDLE(val_fence, fence, pAcquireInfo->fence);
218
219 if (fence && (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR)) {
220 if (fence->fence)
221 device->ws->signal_fence(fence->fence);
222 if (fence->temp_syncobj) {
223 device->ws->signal_syncobj(device->ws, fence->temp_syncobj);
224 } else if (fence->syncobj) {
225 device->ws->signal_syncobj(device->ws, fence->syncobj);
226 }
227 }
228 #endif
229 return result;
230 }
231
232 VkResult val_QueuePresentKHR(
233 VkQueue _queue,
234 const VkPresentInfoKHR* pPresentInfo)
235 {
236 VAL_FROM_HANDLE(val_queue, queue, _queue);
237 return wsi_common_queue_present(&queue->device->physical_device->wsi_device,
238 val_device_to_handle(queue->device),
239 _queue, 0,
240 pPresentInfo);
241 }
242
243
244 VkResult val_GetDeviceGroupPresentCapabilitiesKHR(
245 VkDevice device,
246 VkDeviceGroupPresentCapabilitiesKHR* pCapabilities)
247 {
248 memset(pCapabilities->presentMask, 0,
249 sizeof(pCapabilities->presentMask));
250 pCapabilities->presentMask[0] = 0x1;
251 pCapabilities->modes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
252
253 return VK_SUCCESS;
254 }
255
256 VkResult val_GetDeviceGroupSurfacePresentModesKHR(
257 VkDevice device,
258 VkSurfaceKHR surface,
259 VkDeviceGroupPresentModeFlagsKHR* pModes)
260 {
261 *pModes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
262
263 return VK_SUCCESS;
264 }
265
266 VkResult val_GetPhysicalDevicePresentRectanglesKHR(
267 VkPhysicalDevice physicalDevice,
268 VkSurfaceKHR surface,
269 uint32_t* pRectCount,
270 VkRect2D* pRects)
271 {
272 VAL_FROM_HANDLE(val_physical_device, device, physicalDevice);
273
274 return wsi_common_get_present_rectangles(&device->wsi_device,
275 surface,
276 pRectCount, pRects);
277 }