blob: b8118fdc8a60d49315a6dbfeb2f60a217051dc16 [file] [log] [blame]
Mark Young0746fce2017-03-10 17:31:18 -07001/*
2 * Copyright (c) 2015-2017 The Khronos Group Inc.
3 * Copyright (c) 2015-2017 Valve Corporation
4 * Copyright (c) 2015-2017 LunarG, Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Young <marky@lunarg.com>
Lenny Komow99f647e2017-05-23 15:18:21 -060019 * Author: Lenny Komow <lenny@lunarg.com>
Mark Young0746fce2017-03-10 17:31:18 -070020 */
21
Tom Andersona8358802018-07-25 17:10:16 -070022#ifndef _GNU_SOURCE
Mark Young0746fce2017-03-10 17:31:18 -070023#define _GNU_SOURCE
Tom Andersona8358802018-07-25 17:10:16 -070024#endif
Mark Young0746fce2017-03-10 17:31:18 -070025#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include "vk_loader_platform.h"
29#include "loader.h"
30#include "vk_loader_extensions.h"
31#include <vulkan/vk_icd.h>
32#include "wsi.h"
Mark Younge3e9b562017-11-09 10:37:04 -070033#include "debug_utils.h"
Mark Young0746fce2017-03-10 17:31:18 -070034
35// ---- Manually added trampoline/terminator functions
36
37// These functions, for whatever reason, require more complex changes than
38// can easily be automatically generated.
Mark Young0746fce2017-03-10 17:31:18 -070039
Mark Lobodzinski7bc29f42017-09-18 16:28:27 -060040// ---- VK_KHR_device_group extension trampoline/terminators
Lenny Komow0e5b07e2017-06-01 13:32:28 -060041
Lenny Komow3d31f062017-05-30 13:04:46 -060042VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice,
43 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
44 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) {
45 const VkLayerInstanceDispatchTable *disp;
46 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
47 disp = loader_get_instance_layer_dispatch(physicalDevice);
48 return disp->GetPhysicalDeviceSurfaceCapabilities2KHR(unwrapped_phys_dev, pSurfaceInfo, pSurfaceCapabilities);
49}
50
51VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2KHR(
52 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
53 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) {
54 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
55 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
56
57 VkIcdSurface *icd_surface = (VkIcdSurface *)(pSurfaceInfo->surface);
58 uint8_t icd_index = phys_dev_term->icd_index;
59
60 if (icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2KHR != NULL) {
Sandeep Shinde594cb042019-07-09 13:47:42 +053061 VkBaseOutStructure *pNext = (VkBaseOutStructure *)pSurfaceCapabilities->pNext;
62 while (pNext != NULL) {
63 if ((int)pNext->sType == VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR) {
64 // Not all ICDs may be supporting VK_KHR_surface_protected_capabilities
65 // Initialize VkSurfaceProtectedCapabilitiesKHR.supportsProtected to false and
66 // if an ICD supports protected surfaces, it will reset it to true accordingly.
67 ((VkSurfaceProtectedCapabilitiesKHR *)pNext)->supportsProtected = VK_FALSE;
68 }
69 pNext = (VkBaseOutStructure *)pNext->pNext;
70 }
71
Lenny Komow3d31f062017-05-30 13:04:46 -060072 // Pass the call to the driver, possibly unwrapping the ICD surface
73 if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) {
74 VkPhysicalDeviceSurfaceInfo2KHR info_copy = *pSurfaceInfo;
75 info_copy.surface = icd_surface->real_icd_surfaces[icd_index];
76 return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2KHR(phys_dev_term->phys_dev, &info_copy,
77 pSurfaceCapabilities);
78 } else {
79 return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2KHR(phys_dev_term->phys_dev, pSurfaceInfo,
80 pSurfaceCapabilities);
81 }
82 } else {
83 // Emulate the call
84 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
85 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulating call in ICD \"%s\" using "
86 "vkGetPhysicalDeviceSurfaceCapabilitiesKHR",
87 icd_term->scanned_icd->lib_name);
88
89 if (pSurfaceInfo->pNext != NULL) {
90 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
91 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulation found unrecognized structure type in "
92 "pSurfaceInfo->pNext - this struct will be ignored");
93 }
94
95 // Write to the VkSurfaceCapabilities2KHR struct
96 VkSurfaceKHR surface = pSurfaceInfo->surface;
97 if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) {
98 surface = icd_surface->real_icd_surfaces[icd_index];
99 }
100 VkResult res = icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, surface,
101 &pSurfaceCapabilities->surfaceCapabilities);
102
103 if (pSurfaceCapabilities->pNext != NULL) {
104 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
105 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulation found unrecognized structure type in "
106 "pSurfaceCapabilities->pNext - this struct will be ignored");
107 }
108 return res;
109 }
110}
111
Lenny Komow31217432017-10-02 15:08:53 -0600112// ---- VK_NV_external_memory_capabilities extension trampoline/terminators
113
114VKAPI_ATTR VkResult VKAPI_CALL
115GetPhysicalDeviceExternalImageFormatPropertiesNV(
116 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
117 VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
118 VkExternalMemoryHandleTypeFlagsNV externalHandleType,
119 VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) {
120 const VkLayerInstanceDispatchTable *disp;
121 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
122 disp = loader_get_instance_layer_dispatch(physicalDevice);
123
124 return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV(
125 unwrapped_phys_dev, format, type, tiling, usage, flags,
126 externalHandleType, pExternalImageFormatProperties);
127}
128
129VKAPI_ATTR VkResult VKAPI_CALL
130terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV(
131 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
132 VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
133 VkExternalMemoryHandleTypeFlagsNV externalHandleType,
134 VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) {
135 struct loader_physical_device_term *phys_dev_term =
136 (struct loader_physical_device_term *)physicalDevice;
137 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
138
139 if (!icd_term->dispatch.GetPhysicalDeviceExternalImageFormatPropertiesNV) {
140 if (externalHandleType) {
141 return VK_ERROR_FORMAT_NOT_SUPPORTED;
142 }
143
144 if (!icd_term->dispatch.GetPhysicalDeviceImageFormatProperties) {
145 return VK_ERROR_INITIALIZATION_FAILED;
146 }
147
148 pExternalImageFormatProperties->externalMemoryFeatures = 0;
149 pExternalImageFormatProperties->exportFromImportedHandleTypes = 0;
150 pExternalImageFormatProperties->compatibleHandleTypes = 0;
151
152 return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties(
153 phys_dev_term->phys_dev, format, type, tiling, usage, flags,
154 &pExternalImageFormatProperties->imageFormatProperties);
155 }
156
157 return icd_term->dispatch.GetPhysicalDeviceExternalImageFormatPropertiesNV(
158 phys_dev_term->phys_dev, format, type, tiling, usage, flags,
159 externalHandleType, pExternalImageFormatProperties);
160}
161
Lenny Komow3d31f062017-05-30 13:04:46 -0600162VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice,
163 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
164 uint32_t *pSurfaceFormatCount,
165 VkSurfaceFormat2KHR *pSurfaceFormats) {
166 const VkLayerInstanceDispatchTable *disp;
167 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
168 disp = loader_get_instance_layer_dispatch(physicalDevice);
169 return disp->GetPhysicalDeviceSurfaceFormats2KHR(unwrapped_phys_dev, pSurfaceInfo, pSurfaceFormatCount, pSurfaceFormats);
170}
171
172VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice,
173 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
174 uint32_t *pSurfaceFormatCount,
175 VkSurfaceFormat2KHR *pSurfaceFormats) {
176 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
177 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
178
179 VkIcdSurface *icd_surface = (VkIcdSurface *)(pSurfaceInfo->surface);
180 uint8_t icd_index = phys_dev_term->icd_index;
181
182 if (icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR != NULL) {
183 // Pass the call to the driver, possibly unwrapping the ICD surface
184 if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) {
185 VkPhysicalDeviceSurfaceInfo2KHR info_copy = *pSurfaceInfo;
186 info_copy.surface = icd_surface->real_icd_surfaces[icd_index];
187 return icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR(phys_dev_term->phys_dev, &info_copy, pSurfaceFormatCount,
188 pSurfaceFormats);
189 } else {
190 return icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR(phys_dev_term->phys_dev, pSurfaceInfo,
191 pSurfaceFormatCount, pSurfaceFormats);
192 }
193 } else {
194 // Emulate the call
195 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
196 "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceSurfaceFormatsKHR",
197 icd_term->scanned_icd->lib_name);
198
199 if (pSurfaceInfo->pNext != NULL) {
200 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
201 "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulation found unrecognized structure type in pSurfaceInfo->pNext "
202 "- this struct will be ignored");
203 }
204
205 VkSurfaceKHR surface = pSurfaceInfo->surface;
206 if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) {
207 surface = icd_surface->real_icd_surfaces[icd_index];
208 }
209
210 if (*pSurfaceFormatCount == 0 || pSurfaceFormats == NULL) {
211 // Write to pSurfaceFormatCount
212 return icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface, pSurfaceFormatCount,
213 NULL);
214 } else {
215 // Allocate a temporary array for the output of the old function
216 VkSurfaceFormatKHR *formats = loader_stack_alloc(*pSurfaceFormatCount * sizeof(VkSurfaceFormatKHR));
217 if (formats == NULL) {
218 return VK_ERROR_OUT_OF_HOST_MEMORY;
219 }
220
221 VkResult res = icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface,
222 pSurfaceFormatCount, formats);
223 for (uint32_t i = 0; i < *pSurfaceFormatCount; ++i) {
224 pSurfaceFormats[i].surfaceFormat = formats[i];
225 if (pSurfaceFormats[i].pNext != NULL) {
226 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
227 "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulation found unrecognized structure type in "
228 "pSurfaceFormats[%d].pNext - this struct will be ignored",
229 i);
230 }
231 }
232 return res;
233 }
234 }
235}
236
Lenny Komow0e5b07e2017-06-01 13:32:28 -0600237// ---- VK_EXT_display_surface_counter extension trampoline/terminators
238
239VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
240 VkSurfaceCapabilities2EXT *pSurfaceCapabilities) {
241 const VkLayerInstanceDispatchTable *disp;
242 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
243 disp = loader_get_instance_layer_dispatch(physicalDevice);
244 return disp->GetPhysicalDeviceSurfaceCapabilities2EXT(unwrapped_phys_dev, surface, pSurfaceCapabilities);
245}
246
247VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2EXT(
248 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilities2EXT *pSurfaceCapabilities) {
249 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
250 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
251
252 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
253 uint8_t icd_index = phys_dev_term->icd_index;
254
255 // Unwrap the surface if needed
256 VkSurfaceKHR unwrapped_surface = surface;
257 if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) {
258 unwrapped_surface = icd_surface->real_icd_surfaces[icd_index];
259 }
260
261 if (icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2EXT != NULL) {
262 // Pass the call to the driver
263 return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2EXT(phys_dev_term->phys_dev, unwrapped_surface,
264 pSurfaceCapabilities);
265 } else {
266 // Emulate the call
267 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
268 "vkGetPhysicalDeviceSurfaceCapabilities2EXT: Emulating call in ICD \"%s\" using "
269 "vkGetPhysicalDeviceSurfaceCapabilitiesKHR",
270 icd_term->scanned_icd->lib_name);
271
272 VkSurfaceCapabilitiesKHR surface_caps;
273 VkResult res =
274 icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, unwrapped_surface, &surface_caps);
275 pSurfaceCapabilities->minImageCount = surface_caps.minImageCount;
276 pSurfaceCapabilities->maxImageCount = surface_caps.maxImageCount;
277 pSurfaceCapabilities->currentExtent = surface_caps.currentExtent;
278 pSurfaceCapabilities->minImageExtent = surface_caps.minImageExtent;
279 pSurfaceCapabilities->maxImageExtent = surface_caps.maxImageExtent;
280 pSurfaceCapabilities->maxImageArrayLayers = surface_caps.maxImageArrayLayers;
281 pSurfaceCapabilities->supportedTransforms = surface_caps.supportedTransforms;
282 pSurfaceCapabilities->currentTransform = surface_caps.currentTransform;
283 pSurfaceCapabilities->supportedCompositeAlpha = surface_caps.supportedCompositeAlpha;
284 pSurfaceCapabilities->supportedUsageFlags = surface_caps.supportedUsageFlags;
285 pSurfaceCapabilities->supportedSurfaceCounters = 0;
286
287 if (pSurfaceCapabilities->pNext != NULL) {
288 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
289 "vkGetPhysicalDeviceSurfaceCapabilities2EXT: Emulation found unrecognized structure type in "
290 "pSurfaceCapabilities->pNext - this struct will be ignored");
291 }
292
293 return res;
294 }
295}
296
297// ---- VK_EXT_direct_mode_display extension trampoline/terminators
298
299VKAPI_ATTR VkResult VKAPI_CALL ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) {
300 const VkLayerInstanceDispatchTable *disp;
301 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
302 disp = loader_get_instance_layer_dispatch(physicalDevice);
303 return disp->ReleaseDisplayEXT(unwrapped_phys_dev, display);
304}
305
306VKAPI_ATTR VkResult VKAPI_CALL terminator_ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) {
307 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
308 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
309
310 if (icd_term->dispatch.ReleaseDisplayEXT == NULL) {
311 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
312 "ICD \"%s\" associated with VkPhysicalDevice does not support vkReleaseDisplayEXT - Consequently, the call is "
313 "invalid because it should not be possible to acquire a display on this device",
314 icd_term->scanned_icd->lib_name);
315 }
316 return icd_term->dispatch.ReleaseDisplayEXT(phys_dev_term->phys_dev, display);
317}
318
319// ---- VK_EXT_acquire_xlib_display extension trampoline/terminators
320
321#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
322VKAPI_ATTR VkResult VKAPI_CALL AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, VkDisplayKHR display) {
323 const VkLayerInstanceDispatchTable *disp;
324 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
325 disp = loader_get_instance_layer_dispatch(physicalDevice);
326 return disp->AcquireXlibDisplayEXT(unwrapped_phys_dev, dpy, display);
327}
328
329VKAPI_ATTR VkResult VKAPI_CALL terminator_AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy,
330 VkDisplayKHR display) {
331 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
332 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
333
334 if (icd_term->dispatch.AcquireXlibDisplayEXT != NULL) {
335 // Pass the call to the driver
336 return icd_term->dispatch.AcquireXlibDisplayEXT(phys_dev_term->phys_dev, dpy, display);
337 } else {
338 // Emulate the call
339 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
340 "vkAcquireXLibDisplayEXT: Emulating call in ICD \"%s\" by returning error", icd_term->scanned_icd->lib_name);
341
342 // Fail for the unsupported command
343 return VK_ERROR_INITIALIZATION_FAILED;
344 }
345}
346
347VKAPI_ATTR VkResult VKAPI_CALL GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput,
348 VkDisplayKHR *pDisplay) {
349 const VkLayerInstanceDispatchTable *disp;
350 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
351 disp = loader_get_instance_layer_dispatch(physicalDevice);
352 return disp->GetRandROutputDisplayEXT(unwrapped_phys_dev, dpy, rrOutput, pDisplay);
353}
354
355VKAPI_ATTR VkResult VKAPI_CALL terminator_GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput,
356 VkDisplayKHR *pDisplay) {
357 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
358 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
359
360 if (icd_term->dispatch.GetRandROutputDisplayEXT != NULL) {
361 // Pass the call to the driver
362 return icd_term->dispatch.GetRandROutputDisplayEXT(phys_dev_term->phys_dev, dpy, rrOutput, pDisplay);
363 } else {
364 // Emulate the call
365 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
366 "vkGetRandROutputDisplayEXT: Emulating call in ICD \"%s\" by returning null display",
367 icd_term->scanned_icd->lib_name);
368
369 // Return a null handle to indicate this can't be done
370 *pDisplay = VK_NULL_HANDLE;
371 return VK_SUCCESS;
372 }
373}
374
375#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT
Lenny Komowc51f36f2019-04-15 14:49:58 -0600376
377#ifdef VK_USE_PLATFORM_WIN32_KHR
378VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModes2EXT(
379 VkPhysicalDevice physicalDevice,
380 const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
381 uint32_t* pPresentModeCount,
382 VkPresentModeKHR* pPresentModes) {
383 const VkLayerInstanceDispatchTable *disp;
384 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
385 disp = loader_get_instance_layer_dispatch(physicalDevice);
386 return disp->GetPhysicalDeviceSurfacePresentModes2EXT(unwrapped_phys_dev, pSurfaceInfo, pPresentModeCount, pPresentModes);
387}
388
389VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModes2EXT(
390 VkPhysicalDevice physicalDevice,
391 const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
392 uint32_t* pPresentModeCount,
393 VkPresentModeKHR* pPresentModes) {
394 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
395 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
396 if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfacePresentModes2EXT) {
397 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
398 "ICD associated with VkPhysicalDevice does not support GetPhysicalDeviceSurfacePresentModes2EXT");
399 }
400 VkIcdSurface *icd_surface = (VkIcdSurface *)(pSurfaceInfo->surface);
401 uint8_t icd_index = phys_dev_term->icd_index;
402 if (NULL != icd_surface->real_icd_surfaces && NULL != (void *)icd_surface->real_icd_surfaces[icd_index]) {
403 const VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy = {
404 .sType = pSurfaceInfo->sType,
405 .pNext = pSurfaceInfo->pNext,
406 .surface = icd_surface->real_icd_surfaces[icd_index],
407 };
408 return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModes2EXT(phys_dev_term->phys_dev, &surface_info_copy, pPresentModeCount, pPresentModes);
409 }
410 return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModes2EXT(phys_dev_term->phys_dev, pSurfaceInfo, pPresentModeCount, pPresentModes);
411}
Lenny Komowc51f36f2019-04-15 14:49:58 -0600412
413VKAPI_ATTR VkResult VKAPI_CALL GetDeviceGroupSurfacePresentModes2EXT(
414 VkDevice device,
415 const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
416 VkDeviceGroupPresentModeFlagsKHR* pModes) {
417 const VkLayerDispatchTable *disp = loader_get_dispatch(device);
418 return disp->GetDeviceGroupSurfacePresentModes2EXT(device, pSurfaceInfo, pModes);
419}
420
421VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDeviceGroupSurfacePresentModes2EXT(
422 VkDevice device,
423 const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
424 VkDeviceGroupPresentModeFlagsKHR* pModes) {
425 uint32_t icd_index = 0;
426 struct loader_device *dev;
427 struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index);
428 if (NULL != icd_term && NULL != icd_term->dispatch.GetDeviceGroupSurfacePresentModes2EXT) {
429 VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pSurfaceInfo->surface;
430 if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[icd_index]) {
431 const VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy = {
432 .sType = pSurfaceInfo->sType,
433 .pNext = pSurfaceInfo->pNext,
434 .surface = icd_surface->real_icd_surfaces[icd_index],
435 };
436 return icd_term->dispatch.GetDeviceGroupSurfacePresentModes2EXT(device, &surface_info_copy, pModes);
437 }
438 return icd_term->dispatch.GetDeviceGroupSurfacePresentModes2EXT(device, pSurfaceInfo, pModes);
439 }
440 return VK_SUCCESS;
441}
Shannon McPherson392a7eb2019-05-22 15:41:13 -0600442
443#endif // VK_USE_PLATFORM_WIN32_KHR
Lenny Komow20697982019-12-12 15:38:07 -0700444
445// ---- VK_EXT_tooling_info extension trampoline/terminators
446
447VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceToolPropertiesEXT(
448 VkPhysicalDevice physicalDevice,
449 uint32_t* pToolCount,
450 VkPhysicalDeviceToolPropertiesEXT* pToolProperties) {
451 const VkLayerInstanceDispatchTable *disp;
452 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
453 disp = loader_get_instance_layer_dispatch(physicalDevice);
454 return disp->GetPhysicalDeviceToolPropertiesEXT(unwrapped_phys_dev, pToolCount, pToolProperties);
455}
456
457VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceToolPropertiesEXT(
458 VkPhysicalDevice physicalDevice,
459 uint32_t* pToolCount,
460 VkPhysicalDeviceToolPropertiesEXT* pToolProperties) {
461 return VK_SUCCESS;
462}