blob: e723df9f756488fdf3fb0908733dab74823b9c06 [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) {
61 // Pass the call to the driver, possibly unwrapping the ICD surface
62 if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) {
63 VkPhysicalDeviceSurfaceInfo2KHR info_copy = *pSurfaceInfo;
64 info_copy.surface = icd_surface->real_icd_surfaces[icd_index];
65 return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2KHR(phys_dev_term->phys_dev, &info_copy,
66 pSurfaceCapabilities);
67 } else {
68 return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2KHR(phys_dev_term->phys_dev, pSurfaceInfo,
69 pSurfaceCapabilities);
70 }
71 } else {
72 // Emulate the call
73 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
74 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulating call in ICD \"%s\" using "
75 "vkGetPhysicalDeviceSurfaceCapabilitiesKHR",
76 icd_term->scanned_icd->lib_name);
77
78 if (pSurfaceInfo->pNext != NULL) {
79 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
80 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulation found unrecognized structure type in "
81 "pSurfaceInfo->pNext - this struct will be ignored");
82 }
83
84 // Write to the VkSurfaceCapabilities2KHR struct
85 VkSurfaceKHR surface = pSurfaceInfo->surface;
86 if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) {
87 surface = icd_surface->real_icd_surfaces[icd_index];
88 }
89 VkResult res = icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, surface,
90 &pSurfaceCapabilities->surfaceCapabilities);
91
92 if (pSurfaceCapabilities->pNext != NULL) {
93 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
94 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulation found unrecognized structure type in "
95 "pSurfaceCapabilities->pNext - this struct will be ignored");
96 }
97 return res;
98 }
99}
100
Lenny Komow31217432017-10-02 15:08:53 -0600101// ---- VK_NV_external_memory_capabilities extension trampoline/terminators
102
103VKAPI_ATTR VkResult VKAPI_CALL
104GetPhysicalDeviceExternalImageFormatPropertiesNV(
105 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
106 VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
107 VkExternalMemoryHandleTypeFlagsNV externalHandleType,
108 VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) {
109 const VkLayerInstanceDispatchTable *disp;
110 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
111 disp = loader_get_instance_layer_dispatch(physicalDevice);
112
113 return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV(
114 unwrapped_phys_dev, format, type, tiling, usage, flags,
115 externalHandleType, pExternalImageFormatProperties);
116}
117
118VKAPI_ATTR VkResult VKAPI_CALL
119terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV(
120 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
121 VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
122 VkExternalMemoryHandleTypeFlagsNV externalHandleType,
123 VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) {
124 struct loader_physical_device_term *phys_dev_term =
125 (struct loader_physical_device_term *)physicalDevice;
126 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
127
128 if (!icd_term->dispatch.GetPhysicalDeviceExternalImageFormatPropertiesNV) {
129 if (externalHandleType) {
130 return VK_ERROR_FORMAT_NOT_SUPPORTED;
131 }
132
133 if (!icd_term->dispatch.GetPhysicalDeviceImageFormatProperties) {
134 return VK_ERROR_INITIALIZATION_FAILED;
135 }
136
137 pExternalImageFormatProperties->externalMemoryFeatures = 0;
138 pExternalImageFormatProperties->exportFromImportedHandleTypes = 0;
139 pExternalImageFormatProperties->compatibleHandleTypes = 0;
140
141 return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties(
142 phys_dev_term->phys_dev, format, type, tiling, usage, flags,
143 &pExternalImageFormatProperties->imageFormatProperties);
144 }
145
146 return icd_term->dispatch.GetPhysicalDeviceExternalImageFormatPropertiesNV(
147 phys_dev_term->phys_dev, format, type, tiling, usage, flags,
148 externalHandleType, pExternalImageFormatProperties);
149}
150
Lenny Komow3d31f062017-05-30 13:04:46 -0600151VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice,
152 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
153 uint32_t *pSurfaceFormatCount,
154 VkSurfaceFormat2KHR *pSurfaceFormats) {
155 const VkLayerInstanceDispatchTable *disp;
156 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
157 disp = loader_get_instance_layer_dispatch(physicalDevice);
158 return disp->GetPhysicalDeviceSurfaceFormats2KHR(unwrapped_phys_dev, pSurfaceInfo, pSurfaceFormatCount, pSurfaceFormats);
159}
160
161VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice,
162 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
163 uint32_t *pSurfaceFormatCount,
164 VkSurfaceFormat2KHR *pSurfaceFormats) {
165 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
166 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
167
168 VkIcdSurface *icd_surface = (VkIcdSurface *)(pSurfaceInfo->surface);
169 uint8_t icd_index = phys_dev_term->icd_index;
170
171 if (icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR != NULL) {
172 // Pass the call to the driver, possibly unwrapping the ICD surface
173 if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) {
174 VkPhysicalDeviceSurfaceInfo2KHR info_copy = *pSurfaceInfo;
175 info_copy.surface = icd_surface->real_icd_surfaces[icd_index];
176 return icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR(phys_dev_term->phys_dev, &info_copy, pSurfaceFormatCount,
177 pSurfaceFormats);
178 } else {
179 return icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR(phys_dev_term->phys_dev, pSurfaceInfo,
180 pSurfaceFormatCount, pSurfaceFormats);
181 }
182 } else {
183 // Emulate the call
184 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
185 "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceSurfaceFormatsKHR",
186 icd_term->scanned_icd->lib_name);
187
188 if (pSurfaceInfo->pNext != NULL) {
189 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
190 "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulation found unrecognized structure type in pSurfaceInfo->pNext "
191 "- this struct will be ignored");
192 }
193
194 VkSurfaceKHR surface = pSurfaceInfo->surface;
195 if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) {
196 surface = icd_surface->real_icd_surfaces[icd_index];
197 }
198
199 if (*pSurfaceFormatCount == 0 || pSurfaceFormats == NULL) {
200 // Write to pSurfaceFormatCount
201 return icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface, pSurfaceFormatCount,
202 NULL);
203 } else {
204 // Allocate a temporary array for the output of the old function
205 VkSurfaceFormatKHR *formats = loader_stack_alloc(*pSurfaceFormatCount * sizeof(VkSurfaceFormatKHR));
206 if (formats == NULL) {
207 return VK_ERROR_OUT_OF_HOST_MEMORY;
208 }
209
210 VkResult res = icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface,
211 pSurfaceFormatCount, formats);
212 for (uint32_t i = 0; i < *pSurfaceFormatCount; ++i) {
213 pSurfaceFormats[i].surfaceFormat = formats[i];
214 if (pSurfaceFormats[i].pNext != NULL) {
215 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
216 "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulation found unrecognized structure type in "
217 "pSurfaceFormats[%d].pNext - this struct will be ignored",
218 i);
219 }
220 }
221 return res;
222 }
223 }
224}
225
Lenny Komow0e5b07e2017-06-01 13:32:28 -0600226// ---- VK_EXT_display_surface_counter extension trampoline/terminators
227
228VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
229 VkSurfaceCapabilities2EXT *pSurfaceCapabilities) {
230 const VkLayerInstanceDispatchTable *disp;
231 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
232 disp = loader_get_instance_layer_dispatch(physicalDevice);
233 return disp->GetPhysicalDeviceSurfaceCapabilities2EXT(unwrapped_phys_dev, surface, pSurfaceCapabilities);
234}
235
236VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2EXT(
237 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilities2EXT *pSurfaceCapabilities) {
238 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
239 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
240
241 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
242 uint8_t icd_index = phys_dev_term->icd_index;
243
244 // Unwrap the surface if needed
245 VkSurfaceKHR unwrapped_surface = surface;
246 if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) {
247 unwrapped_surface = icd_surface->real_icd_surfaces[icd_index];
248 }
249
250 if (icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2EXT != NULL) {
251 // Pass the call to the driver
252 return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2EXT(phys_dev_term->phys_dev, unwrapped_surface,
253 pSurfaceCapabilities);
254 } else {
255 // Emulate the call
256 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
257 "vkGetPhysicalDeviceSurfaceCapabilities2EXT: Emulating call in ICD \"%s\" using "
258 "vkGetPhysicalDeviceSurfaceCapabilitiesKHR",
259 icd_term->scanned_icd->lib_name);
260
261 VkSurfaceCapabilitiesKHR surface_caps;
262 VkResult res =
263 icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, unwrapped_surface, &surface_caps);
264 pSurfaceCapabilities->minImageCount = surface_caps.minImageCount;
265 pSurfaceCapabilities->maxImageCount = surface_caps.maxImageCount;
266 pSurfaceCapabilities->currentExtent = surface_caps.currentExtent;
267 pSurfaceCapabilities->minImageExtent = surface_caps.minImageExtent;
268 pSurfaceCapabilities->maxImageExtent = surface_caps.maxImageExtent;
269 pSurfaceCapabilities->maxImageArrayLayers = surface_caps.maxImageArrayLayers;
270 pSurfaceCapabilities->supportedTransforms = surface_caps.supportedTransforms;
271 pSurfaceCapabilities->currentTransform = surface_caps.currentTransform;
272 pSurfaceCapabilities->supportedCompositeAlpha = surface_caps.supportedCompositeAlpha;
273 pSurfaceCapabilities->supportedUsageFlags = surface_caps.supportedUsageFlags;
274 pSurfaceCapabilities->supportedSurfaceCounters = 0;
275
276 if (pSurfaceCapabilities->pNext != NULL) {
277 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
278 "vkGetPhysicalDeviceSurfaceCapabilities2EXT: Emulation found unrecognized structure type in "
279 "pSurfaceCapabilities->pNext - this struct will be ignored");
280 }
281
282 return res;
283 }
284}
285
286// ---- VK_EXT_direct_mode_display extension trampoline/terminators
287
288VKAPI_ATTR VkResult VKAPI_CALL ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) {
289 const VkLayerInstanceDispatchTable *disp;
290 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
291 disp = loader_get_instance_layer_dispatch(physicalDevice);
292 return disp->ReleaseDisplayEXT(unwrapped_phys_dev, display);
293}
294
295VKAPI_ATTR VkResult VKAPI_CALL terminator_ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) {
296 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
297 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
298
299 if (icd_term->dispatch.ReleaseDisplayEXT == NULL) {
300 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
301 "ICD \"%s\" associated with VkPhysicalDevice does not support vkReleaseDisplayEXT - Consequently, the call is "
302 "invalid because it should not be possible to acquire a display on this device",
303 icd_term->scanned_icd->lib_name);
304 }
305 return icd_term->dispatch.ReleaseDisplayEXT(phys_dev_term->phys_dev, display);
306}
307
308// ---- VK_EXT_acquire_xlib_display extension trampoline/terminators
309
310#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
311VKAPI_ATTR VkResult VKAPI_CALL AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, VkDisplayKHR display) {
312 const VkLayerInstanceDispatchTable *disp;
313 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
314 disp = loader_get_instance_layer_dispatch(physicalDevice);
315 return disp->AcquireXlibDisplayEXT(unwrapped_phys_dev, dpy, display);
316}
317
318VKAPI_ATTR VkResult VKAPI_CALL terminator_AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy,
319 VkDisplayKHR display) {
320 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
321 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
322
323 if (icd_term->dispatch.AcquireXlibDisplayEXT != NULL) {
324 // Pass the call to the driver
325 return icd_term->dispatch.AcquireXlibDisplayEXT(phys_dev_term->phys_dev, dpy, display);
326 } else {
327 // Emulate the call
328 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
329 "vkAcquireXLibDisplayEXT: Emulating call in ICD \"%s\" by returning error", icd_term->scanned_icd->lib_name);
330
331 // Fail for the unsupported command
332 return VK_ERROR_INITIALIZATION_FAILED;
333 }
334}
335
336VKAPI_ATTR VkResult VKAPI_CALL GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput,
337 VkDisplayKHR *pDisplay) {
338 const VkLayerInstanceDispatchTable *disp;
339 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
340 disp = loader_get_instance_layer_dispatch(physicalDevice);
341 return disp->GetRandROutputDisplayEXT(unwrapped_phys_dev, dpy, rrOutput, pDisplay);
342}
343
344VKAPI_ATTR VkResult VKAPI_CALL terminator_GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput,
345 VkDisplayKHR *pDisplay) {
346 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
347 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
348
349 if (icd_term->dispatch.GetRandROutputDisplayEXT != NULL) {
350 // Pass the call to the driver
351 return icd_term->dispatch.GetRandROutputDisplayEXT(phys_dev_term->phys_dev, dpy, rrOutput, pDisplay);
352 } else {
353 // Emulate the call
354 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
355 "vkGetRandROutputDisplayEXT: Emulating call in ICD \"%s\" by returning null display",
356 icd_term->scanned_icd->lib_name);
357
358 // Return a null handle to indicate this can't be done
359 *pDisplay = VK_NULL_HANDLE;
360 return VK_SUCCESS;
361 }
362}
363
364#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT
Lenny Komowc51f36f2019-04-15 14:49:58 -0600365
366#ifdef VK_USE_PLATFORM_WIN32_KHR
367VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModes2EXT(
368 VkPhysicalDevice physicalDevice,
369 const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
370 uint32_t* pPresentModeCount,
371 VkPresentModeKHR* pPresentModes) {
372 const VkLayerInstanceDispatchTable *disp;
373 VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
374 disp = loader_get_instance_layer_dispatch(physicalDevice);
375 return disp->GetPhysicalDeviceSurfacePresentModes2EXT(unwrapped_phys_dev, pSurfaceInfo, pPresentModeCount, pPresentModes);
376}
377
378VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModes2EXT(
379 VkPhysicalDevice physicalDevice,
380 const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
381 uint32_t* pPresentModeCount,
382 VkPresentModeKHR* pPresentModes) {
383 struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
384 struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
385 if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfacePresentModes2EXT) {
386 loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
387 "ICD associated with VkPhysicalDevice does not support GetPhysicalDeviceSurfacePresentModes2EXT");
388 }
389 VkIcdSurface *icd_surface = (VkIcdSurface *)(pSurfaceInfo->surface);
390 uint8_t icd_index = phys_dev_term->icd_index;
391 if (NULL != icd_surface->real_icd_surfaces && NULL != (void *)icd_surface->real_icd_surfaces[icd_index]) {
392 const VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy = {
393 .sType = pSurfaceInfo->sType,
394 .pNext = pSurfaceInfo->pNext,
395 .surface = icd_surface->real_icd_surfaces[icd_index],
396 };
397 return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModes2EXT(phys_dev_term->phys_dev, &surface_info_copy, pPresentModeCount, pPresentModes);
398 }
399 return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModes2EXT(phys_dev_term->phys_dev, pSurfaceInfo, pPresentModeCount, pPresentModes);
400}
401#endif // VK_USE_PLATFORM_WIN32_KHR
402
403VKAPI_ATTR VkResult VKAPI_CALL GetDeviceGroupSurfacePresentModes2EXT(
404 VkDevice device,
405 const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
406 VkDeviceGroupPresentModeFlagsKHR* pModes) {
407 const VkLayerDispatchTable *disp = loader_get_dispatch(device);
408 return disp->GetDeviceGroupSurfacePresentModes2EXT(device, pSurfaceInfo, pModes);
409}
410
411VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDeviceGroupSurfacePresentModes2EXT(
412 VkDevice device,
413 const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
414 VkDeviceGroupPresentModeFlagsKHR* pModes) {
415 uint32_t icd_index = 0;
416 struct loader_device *dev;
417 struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index);
418 if (NULL != icd_term && NULL != icd_term->dispatch.GetDeviceGroupSurfacePresentModes2EXT) {
419 VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pSurfaceInfo->surface;
420 if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[icd_index]) {
421 const VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy = {
422 .sType = pSurfaceInfo->sType,
423 .pNext = pSurfaceInfo->pNext,
424 .surface = icd_surface->real_icd_surfaces[icd_index],
425 };
426 return icd_term->dispatch.GetDeviceGroupSurfacePresentModes2EXT(device, &surface_info_copy, pModes);
427 }
428 return icd_term->dispatch.GetDeviceGroupSurfacePresentModes2EXT(device, pSurfaceInfo, pModes);
429 }
430 return VK_SUCCESS;
431}