/src/vulkan-loader/loader/extension_manual.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2015-2022 The Khronos Group Inc. |
3 | | * Copyright (c) 2015-2022 Valve Corporation |
4 | | * Copyright (c) 2015-2022 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> |
19 | | * Author: Lenny Komow <lenny@lunarg.com> |
20 | | * Author: Charles Giessen <charles@lunarg.com> |
21 | | */ |
22 | | |
23 | | #include "extension_manual.h" |
24 | | |
25 | | #include <stdio.h> |
26 | | #include <stdlib.h> |
27 | | #include <string.h> |
28 | | |
29 | | #include "allocation.h" |
30 | | #include "debug_utils.h" |
31 | | #include "loader.h" |
32 | | #include "log.h" |
33 | | #include "wsi.h" |
34 | | |
35 | | // ---- Manually added trampoline/terminator functions |
36 | | |
37 | | // These functions, for whatever reason, require more complex changes than |
38 | | // can easily be automatically generated. |
39 | | |
40 | | // ---- VK_NV_external_memory_capabilities extension trampoline/terminators |
41 | | |
42 | | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceExternalImageFormatPropertiesNV( |
43 | | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, |
44 | | VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, |
45 | 0 | VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { |
46 | 0 | const VkLayerInstanceDispatchTable *disp; |
47 | 0 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
48 | 0 | if (VK_NULL_HANDLE == unwrapped_phys_dev) { |
49 | 0 | loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0, |
50 | 0 | "vkGetPhysicalDeviceExternalImageFormatPropertiesNV: Invalid physicalDevice " |
51 | 0 | "[VUID-vkGetPhysicalDeviceExternalImageFormatPropertiesNV-physicalDevice-parameter]"); |
52 | 0 | abort(); /* Intentionally fail so user can correct issue. */ |
53 | 0 | } |
54 | 0 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
55 | |
|
56 | 0 | return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV(unwrapped_phys_dev, format, type, tiling, usage, flags, |
57 | 0 | externalHandleType, pExternalImageFormatProperties); |
58 | 0 | } |
59 | | |
60 | | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV( |
61 | | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, |
62 | | VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, |
63 | 0 | VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { |
64 | 0 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
65 | 0 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
66 | |
|
67 | 0 | if (!icd_term->dispatch.GetPhysicalDeviceExternalImageFormatPropertiesNV) { |
68 | 0 | if (externalHandleType) { |
69 | 0 | return VK_ERROR_FORMAT_NOT_SUPPORTED; |
70 | 0 | } |
71 | | |
72 | 0 | if (!icd_term->dispatch.GetPhysicalDeviceImageFormatProperties) { |
73 | 0 | return VK_ERROR_INITIALIZATION_FAILED; |
74 | 0 | } |
75 | | |
76 | 0 | pExternalImageFormatProperties->externalMemoryFeatures = 0; |
77 | 0 | pExternalImageFormatProperties->exportFromImportedHandleTypes = 0; |
78 | 0 | pExternalImageFormatProperties->compatibleHandleTypes = 0; |
79 | |
|
80 | 0 | return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties( |
81 | 0 | phys_dev_term->phys_dev, format, type, tiling, usage, flags, &pExternalImageFormatProperties->imageFormatProperties); |
82 | 0 | } |
83 | | |
84 | 0 | return icd_term->dispatch.GetPhysicalDeviceExternalImageFormatPropertiesNV( |
85 | 0 | phys_dev_term->phys_dev, format, type, tiling, usage, flags, externalHandleType, pExternalImageFormatProperties); |
86 | 0 | } |
87 | | |
88 | | // ---- VK_EXT_display_surface_counter extension trampoline/terminators |
89 | | |
90 | | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, |
91 | 0 | VkSurfaceCapabilities2EXT *pSurfaceCapabilities) { |
92 | 0 | const VkLayerInstanceDispatchTable *disp; |
93 | 0 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
94 | 0 | if (VK_NULL_HANDLE == unwrapped_phys_dev) { |
95 | 0 | loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0, |
96 | 0 | "vkGetPhysicalDeviceExternalImageFormatPropertiesNV: Invalid physicalDevice " |
97 | 0 | "[VUID-vkGetPhysicalDeviceSurfaceCapabilities2EXT-physicalDevice-parameter]"); |
98 | 0 | abort(); /* Intentionally fail so user can correct issue. */ |
99 | 0 | } |
100 | 0 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
101 | 0 | return disp->GetPhysicalDeviceSurfaceCapabilities2EXT(unwrapped_phys_dev, surface, pSurfaceCapabilities); |
102 | 0 | } |
103 | | |
104 | | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2EXT( |
105 | 0 | VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilities2EXT *pSurfaceCapabilities) { |
106 | 0 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
107 | 0 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
108 | |
|
109 | 0 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)(surface); |
110 | | |
111 | | // Unwrap the surface if needed |
112 | 0 | VkSurfaceKHR unwrapped_surface = surface; |
113 | 0 | if (NULL != phys_dev_term->this_icd_term->surface_list.list && |
114 | 0 | phys_dev_term->this_icd_term->surface_list.capacity > icd_surface->surface_index * sizeof(VkSurfaceKHR) && |
115 | 0 | phys_dev_term->this_icd_term->surface_list.list[icd_surface->surface_index]) { |
116 | 0 | unwrapped_surface = phys_dev_term->this_icd_term->surface_list.list[icd_surface->surface_index]; |
117 | 0 | } |
118 | |
|
119 | 0 | if (NULL != icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2EXT) { |
120 | | // Pass the call to the driver |
121 | 0 | return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2EXT(phys_dev_term->phys_dev, unwrapped_surface, |
122 | 0 | pSurfaceCapabilities); |
123 | 0 | } else { |
124 | | // Emulate the call |
125 | 0 | loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, |
126 | 0 | "vkGetPhysicalDeviceSurfaceCapabilities2EXT: Emulating call in ICD \"%s\" using " |
127 | 0 | "vkGetPhysicalDeviceSurfaceCapabilitiesKHR", |
128 | 0 | icd_term->scanned_icd->lib_name); |
129 | |
|
130 | 0 | VkSurfaceCapabilitiesKHR surface_caps; |
131 | 0 | VkResult res = |
132 | 0 | icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, unwrapped_surface, &surface_caps); |
133 | 0 | pSurfaceCapabilities->minImageCount = surface_caps.minImageCount; |
134 | 0 | pSurfaceCapabilities->maxImageCount = surface_caps.maxImageCount; |
135 | 0 | pSurfaceCapabilities->currentExtent = surface_caps.currentExtent; |
136 | 0 | pSurfaceCapabilities->minImageExtent = surface_caps.minImageExtent; |
137 | 0 | pSurfaceCapabilities->maxImageExtent = surface_caps.maxImageExtent; |
138 | 0 | pSurfaceCapabilities->maxImageArrayLayers = surface_caps.maxImageArrayLayers; |
139 | 0 | pSurfaceCapabilities->supportedTransforms = surface_caps.supportedTransforms; |
140 | 0 | pSurfaceCapabilities->currentTransform = surface_caps.currentTransform; |
141 | 0 | pSurfaceCapabilities->supportedCompositeAlpha = surface_caps.supportedCompositeAlpha; |
142 | 0 | pSurfaceCapabilities->supportedUsageFlags = surface_caps.supportedUsageFlags; |
143 | 0 | pSurfaceCapabilities->supportedSurfaceCounters = 0; |
144 | |
|
145 | 0 | if (pSurfaceCapabilities->pNext != NULL) { |
146 | 0 | loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, |
147 | 0 | "vkGetPhysicalDeviceSurfaceCapabilities2EXT: Emulation found unrecognized structure type in " |
148 | 0 | "pSurfaceCapabilities->pNext - this struct will be ignored"); |
149 | 0 | } |
150 | |
|
151 | 0 | return res; |
152 | 0 | } |
153 | 0 | } |
154 | | |
155 | | // ---- VK_EXT_direct_mode_display extension trampoline/terminators |
156 | | |
157 | 0 | VKAPI_ATTR VkResult VKAPI_CALL ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) { |
158 | 0 | const VkLayerInstanceDispatchTable *disp; |
159 | 0 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
160 | 0 | if (VK_NULL_HANDLE == unwrapped_phys_dev) { |
161 | 0 | loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0, |
162 | 0 | "vkReleaseDisplayEXT: Invalid physicalDevice [VUID-vkReleaseDisplayEXT-physicalDevice-parameter]"); |
163 | 0 | abort(); /* Intentionally fail so user can correct issue. */ |
164 | 0 | } |
165 | 0 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
166 | 0 | return disp->ReleaseDisplayEXT(unwrapped_phys_dev, display); |
167 | 0 | } |
168 | | |
169 | 0 | VKAPI_ATTR VkResult VKAPI_CALL terminator_ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) { |
170 | 0 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
171 | 0 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
172 | |
|
173 | 0 | if (icd_term->dispatch.ReleaseDisplayEXT == NULL) { |
174 | 0 | loader_log(icd_term->this_instance, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT, 0, |
175 | 0 | "ICD \"%s\" associated with VkPhysicalDevice does not support vkReleaseDisplayEXT - Consequently, the call is " |
176 | 0 | "invalid because it should not be possible to acquire a display on this device", |
177 | 0 | icd_term->scanned_icd->lib_name); |
178 | 0 | abort(); |
179 | 0 | } |
180 | 0 | return icd_term->dispatch.ReleaseDisplayEXT(phys_dev_term->phys_dev, display); |
181 | 0 | } |
182 | | |
183 | | // ---- VK_EXT_acquire_xlib_display extension trampoline/terminators |
184 | | |
185 | | #if defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT) |
186 | 0 | VKAPI_ATTR VkResult VKAPI_CALL AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, VkDisplayKHR display) { |
187 | 0 | const VkLayerInstanceDispatchTable *disp; |
188 | 0 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
189 | 0 | if (VK_NULL_HANDLE == unwrapped_phys_dev) { |
190 | 0 | loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0, |
191 | 0 | "vkAcquireXlibDisplayEXT: Invalid physicalDevice [VUID-vkAcquireXlibDisplayEXT-physicalDevice-parameter]"); |
192 | 0 | abort(); /* Intentionally fail so user can correct issue. */ |
193 | 0 | } |
194 | 0 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
195 | 0 | return disp->AcquireXlibDisplayEXT(unwrapped_phys_dev, dpy, display); |
196 | 0 | } |
197 | | |
198 | | VKAPI_ATTR VkResult VKAPI_CALL terminator_AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, |
199 | 0 | VkDisplayKHR display) { |
200 | 0 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
201 | 0 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
202 | |
|
203 | 0 | if (icd_term->dispatch.AcquireXlibDisplayEXT != NULL) { |
204 | | // Pass the call to the driver |
205 | 0 | return icd_term->dispatch.AcquireXlibDisplayEXT(phys_dev_term->phys_dev, dpy, display); |
206 | 0 | } else { |
207 | | // Emulate the call |
208 | 0 | loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, |
209 | 0 | "vkAcquireXLibDisplayEXT: Emulating call in ICD \"%s\" by returning error", icd_term->scanned_icd->lib_name); |
210 | | |
211 | | // Fail for the unsupported command |
212 | 0 | return VK_ERROR_INITIALIZATION_FAILED; |
213 | 0 | } |
214 | 0 | } |
215 | | |
216 | | VKAPI_ATTR VkResult VKAPI_CALL GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput, |
217 | 0 | VkDisplayKHR *pDisplay) { |
218 | 0 | const VkLayerInstanceDispatchTable *disp; |
219 | 0 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
220 | 0 | if (VK_NULL_HANDLE == unwrapped_phys_dev) { |
221 | 0 | loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0, |
222 | 0 | "vkGetRandROutputDisplayEXT: Invalid physicalDevice [VUID-vkGetRandROutputDisplayEXT-physicalDevice-parameter]"); |
223 | 0 | abort(); /* Intentionally fail so user can correct issue. */ |
224 | 0 | } |
225 | 0 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
226 | 0 | return disp->GetRandROutputDisplayEXT(unwrapped_phys_dev, dpy, rrOutput, pDisplay); |
227 | 0 | } |
228 | | |
229 | | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput, |
230 | 0 | VkDisplayKHR *pDisplay) { |
231 | 0 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
232 | 0 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
233 | |
|
234 | 0 | if (icd_term->dispatch.GetRandROutputDisplayEXT != NULL) { |
235 | | // Pass the call to the driver |
236 | 0 | return icd_term->dispatch.GetRandROutputDisplayEXT(phys_dev_term->phys_dev, dpy, rrOutput, pDisplay); |
237 | 0 | } else { |
238 | | // Emulate the call |
239 | 0 | loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, |
240 | 0 | "vkGetRandROutputDisplayEXT: Emulating call in ICD \"%s\" by returning null display", |
241 | 0 | icd_term->scanned_icd->lib_name); |
242 | | |
243 | | // Return a null handle to indicate this can't be done |
244 | 0 | *pDisplay = VK_NULL_HANDLE; |
245 | 0 | return VK_SUCCESS; |
246 | 0 | } |
247 | 0 | } |
248 | | |
249 | | #endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT |
250 | | |
251 | | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
252 | | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModes2EXT(VkPhysicalDevice physicalDevice, |
253 | | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
254 | | uint32_t *pPresentModeCount, |
255 | | VkPresentModeKHR *pPresentModes) { |
256 | | const VkLayerInstanceDispatchTable *disp; |
257 | | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
258 | | if (VK_NULL_HANDLE == unwrapped_phys_dev) { |
259 | | loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0, |
260 | | "vkGetPhysicalDeviceSurfacePresentModes2EXT: Invalid physicalDevice " |
261 | | "[VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-physicalDevice-parameter]"); |
262 | | abort(); /* Intentionally fail so user can correct issue. */ |
263 | | } |
264 | | disp = loader_get_instance_layer_dispatch(physicalDevice); |
265 | | return disp->GetPhysicalDeviceSurfacePresentModes2EXT(unwrapped_phys_dev, pSurfaceInfo, pPresentModeCount, pPresentModes); |
266 | | } |
267 | | |
268 | | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModes2EXT( |
269 | | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount, |
270 | | VkPresentModeKHR *pPresentModes) { |
271 | | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
272 | | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
273 | | if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfacePresentModes2EXT) { |
274 | | loader_log(icd_term->this_instance, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT, 0, |
275 | | "ICD associated with VkPhysicalDevice does not support GetPhysicalDeviceSurfacePresentModes2EXT"); |
276 | | abort(); |
277 | | } |
278 | | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)(pSurfaceInfo->surface); |
279 | | if (NULL != icd_term->surface_list.list && |
280 | | icd_term->surface_list.capacity > icd_surface->surface_index * sizeof(VkSurfaceKHR) && |
281 | | icd_term->surface_list.list[icd_surface->surface_index]) { |
282 | | VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy; |
283 | | surface_info_copy.sType = pSurfaceInfo->sType; |
284 | | surface_info_copy.pNext = pSurfaceInfo->pNext; |
285 | | surface_info_copy.surface = icd_term->surface_list.list[icd_surface->surface_index]; |
286 | | return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModes2EXT(phys_dev_term->phys_dev, &surface_info_copy, |
287 | | pPresentModeCount, pPresentModes); |
288 | | } |
289 | | return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModes2EXT(phys_dev_term->phys_dev, pSurfaceInfo, pPresentModeCount, |
290 | | pPresentModes); |
291 | | } |
292 | | |
293 | | VKAPI_ATTR VkResult VKAPI_CALL GetDeviceGroupSurfacePresentModes2EXT(VkDevice device, |
294 | | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
295 | | VkDeviceGroupPresentModeFlagsKHR *pModes) { |
296 | | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
297 | | if (NULL == disp) { |
298 | | loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0, |
299 | | "vkGetDeviceGroupSurfacePresentModes2EXT: Invalid device " |
300 | | "[VUID-vkGetDeviceGroupSurfacePresentModes2EXT-device-parameter]"); |
301 | | abort(); /* Intentionally fail so user can correct issue. */ |
302 | | } |
303 | | return disp->GetDeviceGroupSurfacePresentModes2EXT(device, pSurfaceInfo, pModes); |
304 | | } |
305 | | |
306 | | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDeviceGroupSurfacePresentModes2EXT(VkDevice device, |
307 | | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
308 | | VkDeviceGroupPresentModeFlagsKHR *pModes) { |
309 | | struct loader_device *dev; |
310 | | struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev); |
311 | | if (NULL == icd_term || NULL == dev || |
312 | | NULL == dev->loader_dispatch.extension_terminator_dispatch.GetDeviceGroupSurfacePresentModes2EXT) { |
313 | | loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0, |
314 | | "vkGetDeviceGroupSurfacePresentModes2EXT Terminator: Invalid device handle. This is likely the result of a " |
315 | | "layer wrapping device handles and failing to unwrap them in all functions. " |
316 | | "[VUID-vkGetDeviceGroupSurfacePresentModes2EXT-device-parameter]"); |
317 | | abort(); /* Intentionally fail so user can correct issue. */ |
318 | | } |
319 | | if (NULL == pSurfaceInfo) { |
320 | | loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0, |
321 | | "vkGetDeviceGroupSurfacePresentModes2EXT: Invalid pSurfaceInfo pointer " |
322 | | "[VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter]"); |
323 | | abort(); /* Intentionally fail so user can correct issue. */ |
324 | | } |
325 | | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)(pSurfaceInfo->surface); |
326 | | if (NULL != icd_term->surface_list.list && |
327 | | icd_term->surface_list.capacity > icd_surface->surface_index * sizeof(VkSurfaceKHR) && |
328 | | icd_term->surface_list.list[icd_surface->surface_index]) { |
329 | | VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy; |
330 | | surface_info_copy.sType = pSurfaceInfo->sType; |
331 | | surface_info_copy.pNext = pSurfaceInfo->pNext; |
332 | | surface_info_copy.surface = icd_term->surface_list.list[icd_surface->surface_index]; |
333 | | return dev->loader_dispatch.extension_terminator_dispatch.GetDeviceGroupSurfacePresentModes2EXT(device, &surface_info_copy, |
334 | | pModes); |
335 | | } |
336 | | return dev->loader_dispatch.extension_terminator_dispatch.GetDeviceGroupSurfacePresentModes2EXT(device, pSurfaceInfo, pModes); |
337 | | } |
338 | | |
339 | | #endif // VK_USE_PLATFORM_WIN32_KHR |
340 | | |
341 | | // ---- VK_EXT_tooling_info extension trampoline/terminators |
342 | | |
343 | | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceToolPropertiesEXT(VkPhysicalDevice physicalDevice, uint32_t *pToolCount, |
344 | 0 | VkPhysicalDeviceToolPropertiesEXT *pToolProperties) { |
345 | 0 | const VkLayerInstanceDispatchTable *disp; |
346 | 0 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
347 | 0 | if (VK_NULL_HANDLE == unwrapped_phys_dev) { |
348 | 0 | loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0, |
349 | 0 | "vkGetPhysicalDeviceToolPropertiesEXT: Invalid physicalDevice " |
350 | 0 | "[VUID-vkGetPhysicalDeviceToolPropertiesEXT-physicalDevice-parameter]"); |
351 | 0 | abort(); /* Intentionally fail so user can correct issue. */ |
352 | 0 | } |
353 | 0 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
354 | 0 | return disp->GetPhysicalDeviceToolPropertiesEXT(unwrapped_phys_dev, pToolCount, pToolProperties); |
355 | 0 | } |
356 | | |
357 | | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceToolPropertiesEXT(VkPhysicalDevice physicalDevice, uint32_t *pToolCount, |
358 | 0 | VkPhysicalDeviceToolPropertiesEXT *pToolProperties) { |
359 | 0 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
360 | 0 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
361 | |
|
362 | 0 | bool tooling_info_supported = false; |
363 | 0 | uint32_t ext_count = 0; |
364 | 0 | VkExtensionProperties *ext_props = NULL; |
365 | 0 | VkResult res = VK_SUCCESS; |
366 | 0 | VkResult enumerate_res = VK_SUCCESS; |
367 | |
|
368 | 0 | enumerate_res = icd_term->dispatch.EnumerateDeviceExtensionProperties(phys_dev_term->phys_dev, NULL, &ext_count, NULL); |
369 | 0 | if (enumerate_res != VK_SUCCESS) { |
370 | 0 | goto out; |
371 | 0 | } |
372 | | |
373 | 0 | ext_props = loader_instance_heap_alloc(icd_term->this_instance, sizeof(VkExtensionProperties) * ext_count, |
374 | 0 | VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); |
375 | 0 | if (!ext_props) { |
376 | 0 | res = VK_ERROR_OUT_OF_HOST_MEMORY; |
377 | 0 | goto out; |
378 | 0 | } |
379 | | |
380 | 0 | enumerate_res = icd_term->dispatch.EnumerateDeviceExtensionProperties(phys_dev_term->phys_dev, NULL, &ext_count, ext_props); |
381 | 0 | if (enumerate_res != VK_SUCCESS) { |
382 | 0 | goto out; |
383 | 0 | } |
384 | | |
385 | 0 | for (uint32_t i = 0; i < ext_count; i++) { |
386 | 0 | if (strncmp(ext_props[i].extensionName, VK_EXT_TOOLING_INFO_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE) == 0) { |
387 | 0 | tooling_info_supported = true; |
388 | 0 | break; |
389 | 0 | } |
390 | 0 | } |
391 | |
|
392 | 0 | if (tooling_info_supported && icd_term->dispatch.GetPhysicalDeviceToolPropertiesEXT) { |
393 | 0 | res = icd_term->dispatch.GetPhysicalDeviceToolPropertiesEXT(phys_dev_term->phys_dev, pToolCount, pToolProperties); |
394 | 0 | } |
395 | |
|
396 | 0 | out: |
397 | | // In the case the driver didn't support the extension, make sure that the first layer doesn't find the count uninitialized |
398 | 0 | if (!tooling_info_supported || !icd_term->dispatch.GetPhysicalDeviceToolPropertiesEXT) { |
399 | 0 | *pToolCount = 0; |
400 | 0 | } |
401 | |
|
402 | 0 | loader_instance_heap_free(icd_term->this_instance, ext_props); |
403 | |
|
404 | 0 | return res; |
405 | 0 | } |