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