blob: 08f1ded6602d924e66bd52b76eb81ff81330f850 [file] [log] [blame]
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -06001/*
2 * Copyright (c) 2015-2016 The Khronos Group Inc.
3 * Copyright (c) 2015-2016 Valve Corporation
4 * Copyright (c) 2015-2016 LunarG, Inc.
5 * Copyright (c) 2015-2016 Google, Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * Author: Tobin Ehlis <tobine@google.com>
20 * Author: Mark Lobodzinski <mark@lunarg.com>
21 */
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26#include <unordered_map>
27#include <vector>
28#include <list>
29#include <memory>
30
Mike Weiblen6a27de52016-12-09 17:36:28 -070031// For Windows, this #include must come before other Vk headers.
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -060032#include "vk_loader_platform.h"
Mike Weiblen6a27de52016-12-09 17:36:28 -070033
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -060034#include "unique_objects.h"
35#include "vk_dispatch_table_helper.h"
Mike Weiblen6a27de52016-12-09 17:36:28 -070036#include "vk_layer_config.h"
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -060037#include "vk_layer_data.h"
Mike Weiblen6a27de52016-12-09 17:36:28 -070038#include "vk_layer_extension_utils.h"
39#include "vk_layer_logging.h"
40#include "vk_layer_table.h"
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -060041#include "vk_layer_utils.h"
Mike Weiblen6a27de52016-12-09 17:36:28 -070042#include "vk_layer_utils.h"
Mark Lobodzinski9acd2e32016-12-21 15:22:39 -070043#include "vk_enum_string_helper.h"
Mike Weiblen6a27de52016-12-09 17:36:28 -070044#include "vk_validation_error_messages.h"
45#include "vulkan/vk_layer.h"
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -060046
Mike Stroyanb985fca2016-11-01 11:50:16 -060047// This intentionally includes a cpp file
48#include "vk_safe_struct.cpp"
49
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -060050#include "unique_objects_wrappers.h"
51
52namespace unique_objects {
53
Mark Young39389872017-01-19 21:10:49 -070054static uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION;
55
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -060056static void initUniqueObjects(layer_data *instance_data, const VkAllocationCallbacks *pAllocator) {
57 layer_debug_actions(instance_data->report_data, instance_data->logging_callback, pAllocator, "google_unique_objects");
58}
59
60// Handle CreateInstance Extensions
61static void checkInstanceRegisterExtensions(const VkInstanceCreateInfo *pCreateInfo, VkInstance instance) {
62 uint32_t i;
63 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
64 VkLayerInstanceDispatchTable *disp_table = instance_data->instance_dispatch_table;
65 instance_ext_map[disp_table] = {};
66
67 for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
68 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
69 instance_ext_map[disp_table].wsi_enabled = true;
70 }
71 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_EXTENSION_NAME) == 0) {
72 instance_ext_map[disp_table].display_enabled = true;
73 }
74#ifdef VK_USE_PLATFORM_XLIB_KHR
75 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
76 instance_ext_map[disp_table].xlib_enabled = true;
77 }
78#endif
79#ifdef VK_USE_PLATFORM_XCB_KHR
80 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
81 instance_ext_map[disp_table].xcb_enabled = true;
82 }
83#endif
84#ifdef VK_USE_PLATFORM_WAYLAND_KHR
85 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
86 instance_ext_map[disp_table].wayland_enabled = true;
87 }
88#endif
89#ifdef VK_USE_PLATFORM_MIR_KHR
90 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
91 instance_ext_map[disp_table].mir_enabled = true;
92 }
93#endif
94#ifdef VK_USE_PLATFORM_ANDROID_KHR
95 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) {
96 instance_ext_map[disp_table].android_enabled = true;
97 }
98#endif
99#ifdef VK_USE_PLATFORM_WIN32_KHR
100 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
101 instance_ext_map[disp_table].win32_enabled = true;
102 }
103#endif
104
105 // Check for recognized instance extensions
106 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
107 if (!white_list(pCreateInfo->ppEnabledExtensionNames[i], kUniqueObjectsSupportedInstanceExtensions)) {
108 log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
Mike Weiblen6a27de52016-12-09 17:36:28 -0700109 VALIDATION_ERROR_UNDEFINED, "UniqueObjects",
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600110 "Instance Extension %s is not supported by this layer. Using this extension may adversely affect "
111 "validation results and/or produce undefined behavior.",
112 pCreateInfo->ppEnabledExtensionNames[i]);
113 }
114 }
115}
116
117// Handle CreateDevice Extensions
118static void createDeviceRegisterExtensions(const VkDeviceCreateInfo *pCreateInfo, VkDevice device) {
119 layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
120 VkLayerDispatchTable *disp_table = device_data->device_dispatch_table;
121 PFN_vkGetDeviceProcAddr gpa = disp_table->GetDeviceProcAddr;
122
123 device_data->device_dispatch_table->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR)gpa(device, "vkCreateSwapchainKHR");
124 disp_table->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR)gpa(device, "vkDestroySwapchainKHR");
125 disp_table->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)gpa(device, "vkGetSwapchainImagesKHR");
126 disp_table->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR)gpa(device, "vkAcquireNextImageKHR");
127 disp_table->QueuePresentKHR = (PFN_vkQueuePresentKHR)gpa(device, "vkQueuePresentKHR");
128 device_data->wsi_enabled = false;
129
130 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
131 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) {
132 device_data->wsi_enabled = true;
133 }
134 // Check for recognized device extensions
135 if (!white_list(pCreateInfo->ppEnabledExtensionNames[i], kUniqueObjectsSupportedDeviceExtensions)) {
136 log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
Mike Weiblen6a27de52016-12-09 17:36:28 -0700137 VALIDATION_ERROR_UNDEFINED, "UniqueObjects",
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600138 "Device Extension %s is not supported by this layer. Using this extension may adversely affect "
139 "validation results and/or produce undefined behavior.",
140 pCreateInfo->ppEnabledExtensionNames[i]);
141 }
142 }
143}
144
145VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
146 VkInstance *pInstance) {
147 VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
148
149 assert(chain_info->u.pLayerInfo);
150 PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
151 PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance");
152 if (fpCreateInstance == NULL) {
153 return VK_ERROR_INITIALIZATION_FAILED;
154 }
155
156 // Advance the link info for the next element on the chain
157 chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
158
159 VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
160 if (result != VK_SUCCESS) {
161 return result;
162 }
163
164 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map);
165 instance_data->instance = *pInstance;
166 instance_data->instance_dispatch_table = new VkLayerInstanceDispatchTable;
167 layer_init_instance_dispatch_table(*pInstance, instance_data->instance_dispatch_table, fpGetInstanceProcAddr);
168
169 instance_data->instance = *pInstance;
170 instance_data->report_data =
171 debug_report_create_instance(instance_data->instance_dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount,
172 pCreateInfo->ppEnabledExtensionNames);
173
174 // Set up temporary debug callbacks to output messages at CreateInstance-time
175 if (!layer_copy_tmp_callbacks(pCreateInfo->pNext, &instance_data->num_tmp_callbacks, &instance_data->tmp_dbg_create_infos,
176 &instance_data->tmp_callbacks)) {
177 if (instance_data->num_tmp_callbacks > 0) {
178 if (layer_enable_tmp_callbacks(instance_data->report_data, instance_data->num_tmp_callbacks,
179 instance_data->tmp_dbg_create_infos, instance_data->tmp_callbacks)) {
180 layer_free_tmp_callbacks(instance_data->tmp_dbg_create_infos, instance_data->tmp_callbacks);
181 instance_data->num_tmp_callbacks = 0;
182 }
183 }
184 }
185
186 initUniqueObjects(instance_data, pAllocator);
187 checkInstanceRegisterExtensions(pCreateInfo, *pInstance);
188
189 // Disable and free tmp callbacks, no longer necessary
190 if (instance_data->num_tmp_callbacks > 0) {
191 layer_disable_tmp_callbacks(instance_data->report_data, instance_data->num_tmp_callbacks, instance_data->tmp_callbacks);
192 layer_free_tmp_callbacks(instance_data->tmp_dbg_create_infos, instance_data->tmp_callbacks);
193 instance_data->num_tmp_callbacks = 0;
194 }
195
196 return result;
197}
198
199VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
200 dispatch_key key = get_dispatch_key(instance);
201 layer_data *instance_data = get_my_data_ptr(key, layer_data_map);
202 VkLayerInstanceDispatchTable *disp_table = instance_data->instance_dispatch_table;
203 instance_ext_map.erase(disp_table);
204 disp_table->DestroyInstance(instance, pAllocator);
205
206 // Clean up logging callback, if any
207 while (instance_data->logging_callback.size() > 0) {
208 VkDebugReportCallbackEXT callback = instance_data->logging_callback.back();
209 layer_destroy_msg_callback(instance_data->report_data, callback, pAllocator);
210 instance_data->logging_callback.pop_back();
211 }
212
213 layer_debug_report_destroy_instance(instance_data->report_data);
214 layer_data_map.erase(key);
215}
216
217VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo,
218 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) {
219 layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map);
220 VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
221
222 assert(chain_info->u.pLayerInfo);
223 PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
224 PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;
225 PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(my_instance_data->instance, "vkCreateDevice");
226 if (fpCreateDevice == NULL) {
227 return VK_ERROR_INITIALIZATION_FAILED;
228 }
229
230 // Advance the link info for the next element on the chain
231 chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
232
233 VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice);
234 if (result != VK_SUCCESS) {
235 return result;
236 }
237
238 layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map);
239 my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice);
240
241 // Setup layer's device dispatch table
242 my_device_data->device_dispatch_table = new VkLayerDispatchTable;
243 layer_init_device_dispatch_table(*pDevice, my_device_data->device_dispatch_table, fpGetDeviceProcAddr);
244
245 createDeviceRegisterExtensions(pCreateInfo, *pDevice);
246 // Set gpu for this device in order to get at any objects mapped at instance level
247
248 my_device_data->gpu = gpu;
249
250 return result;
251}
252
253VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) {
254 dispatch_key key = get_dispatch_key(device);
255 layer_data *dev_data = get_my_data_ptr(key, layer_data_map);
256
257 layer_debug_report_destroy_device(device);
258 dev_data->device_dispatch_table->DestroyDevice(device, pAllocator);
259 layer_data_map.erase(key);
260}
261
262static const VkLayerProperties globalLayerProps = {"VK_LAYER_GOOGLE_unique_objects",
263 VK_LAYER_API_VERSION, // specVersion
264 1, // implementationVersion
265 "Google Validation Layer"};
266
Mark Young39389872017-01-19 21:10:49 -0700267/// Declare prototype for these functions
268VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName);
269
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600270static inline PFN_vkVoidFunction layer_intercept_proc(const char *name) {
Jamie Madill6069c822016-12-15 09:35:36 -0500271 for (unsigned int i = 0; i < sizeof(procmap) / sizeof(procmap[0]); i++) {
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600272 if (!strcmp(name, procmap[i].name))
273 return procmap[i].pFunc;
274 }
Mark Young39389872017-01-19 21:10:49 -0700275 if (0 == strcmp(name, "vk_layerGetPhysicalDeviceProcAddr")) {
276 return (PFN_vkVoidFunction)GetPhysicalDeviceProcAddr;
277 }
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600278 return NULL;
279}
280
281VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) {
282 return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties);
283}
284
285VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
286 VkLayerProperties *pProperties) {
287 return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties);
288}
289
290VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount,
291 VkExtensionProperties *pProperties) {
292 if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName))
293 return util_GetExtensionProperties(0, NULL, pCount, pProperties);
294
295 return VK_ERROR_LAYER_NOT_PRESENT;
296}
297
298VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName,
299 uint32_t *pCount, VkExtensionProperties *pProperties) {
300 if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName))
301 return util_GetExtensionProperties(0, nullptr, pCount, pProperties);
302
303 assert(physicalDevice);
304
305 dispatch_key key = get_dispatch_key(physicalDevice);
306 layer_data *instance_data = get_my_data_ptr(key, layer_data_map);
307 return instance_data->instance_dispatch_table->EnumerateDeviceExtensionProperties(physicalDevice, NULL, pCount, pProperties);
308}
309
310VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) {
311 PFN_vkVoidFunction addr;
312 assert(device);
313 addr = layer_intercept_proc(funcName);
314 if (addr) {
315 return addr;
316 }
317
318 layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
319 VkLayerDispatchTable *disp_table = dev_data->device_dispatch_table;
320 if (disp_table->GetDeviceProcAddr == NULL) {
321 return NULL;
322 }
323 return disp_table->GetDeviceProcAddr(device, funcName);
324}
325
326VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) {
327 PFN_vkVoidFunction addr;
328
329 addr = layer_intercept_proc(funcName);
330 if (addr) {
331 return addr;
332 }
333 assert(instance);
334
335 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
336 addr = debug_report_get_instance_proc_addr(instance_data->report_data, funcName);
337 if (addr) {
338 return addr;
339 }
340
341 VkLayerInstanceDispatchTable *disp_table = instance_data->instance_dispatch_table;
342 if (disp_table->GetInstanceProcAddr == NULL) {
343 return NULL;
344 }
345 return disp_table->GetInstanceProcAddr(instance, funcName);
346}
347
Mark Young39389872017-01-19 21:10:49 -0700348VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) {
349 assert(instance);
350
351 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
352 VkLayerInstanceDispatchTable *disp_table = instance_data->instance_dispatch_table;
353 if (disp_table->GetPhysicalDeviceProcAddr == NULL) {
354 return NULL;
355 }
356 return disp_table->GetPhysicalDeviceProcAddr(instance, funcName);
357}
358
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600359VKAPI_ATTR VkResult VKAPI_CALL AllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
360 const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory) {
361 const VkMemoryAllocateInfo *input_allocate_info = pAllocateInfo;
362 std::unique_ptr<safe_VkMemoryAllocateInfo> safe_allocate_info;
Mark Lobodzinskid2443222016-10-07 14:13:38 -0600363 std::unique_ptr<safe_VkDedicatedAllocationMemoryAllocateInfoNV> safe_dedicated_allocate_info;
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600364 layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
365
366 if ((pAllocateInfo != nullptr) &&
367 ContainsExtStruct(pAllocateInfo, VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV)) {
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600368 // Assuming there is only one extension struct of this type in the list for now
369 safe_dedicated_allocate_info =
370 std::unique_ptr<safe_VkDedicatedAllocationMemoryAllocateInfoNV>(new safe_VkDedicatedAllocationMemoryAllocateInfoNV);
371 safe_allocate_info = std::unique_ptr<safe_VkMemoryAllocateInfo>(new safe_VkMemoryAllocateInfo(pAllocateInfo));
372 input_allocate_info = reinterpret_cast<const VkMemoryAllocateInfo *>(safe_allocate_info.get());
373
374 const GenericHeader *orig_pnext = reinterpret_cast<const GenericHeader *>(pAllocateInfo->pNext);
375 GenericHeader *input_pnext = reinterpret_cast<GenericHeader *>(safe_allocate_info.get());
376 while (orig_pnext != nullptr) {
377 if (orig_pnext->sType == VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV) {
378 safe_dedicated_allocate_info->initialize(
379 reinterpret_cast<const VkDedicatedAllocationMemoryAllocateInfoNV *>(orig_pnext));
380
381 std::unique_lock<std::mutex> lock(global_lock);
382
383 if (safe_dedicated_allocate_info->buffer != VK_NULL_HANDLE) {
384 uint64_t local_buffer = reinterpret_cast<uint64_t &>(safe_dedicated_allocate_info->buffer);
385 safe_dedicated_allocate_info->buffer =
386 reinterpret_cast<VkBuffer &>(device_data->unique_id_mapping[local_buffer]);
387 }
388
389 if (safe_dedicated_allocate_info->image != VK_NULL_HANDLE) {
390 uint64_t local_image = reinterpret_cast<uint64_t &>(safe_dedicated_allocate_info->image);
391 safe_dedicated_allocate_info->image = reinterpret_cast<VkImage &>(device_data->unique_id_mapping[local_image]);
392 }
393
394 lock.unlock();
395
396 input_pnext->pNext = reinterpret_cast<GenericHeader *>(safe_dedicated_allocate_info.get());
397 input_pnext = reinterpret_cast<GenericHeader *>(input_pnext->pNext);
398 } else {
399 // TODO: generic handling of pNext copies
400 }
401
402 orig_pnext = reinterpret_cast<const GenericHeader *>(orig_pnext->pNext);
403 }
404 }
405
406 VkResult result = device_data->device_dispatch_table->AllocateMemory(device, input_allocate_info, pAllocator, pMemory);
407
408 if (VK_SUCCESS == result) {
409 std::lock_guard<std::mutex> lock(global_lock);
410 uint64_t unique_id = global_unique_id++;
411 device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(*pMemory);
412 *pMemory = reinterpret_cast<VkDeviceMemory &>(unique_id);
413 }
414
415 return result;
416}
417
418VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
419 const VkComputePipelineCreateInfo *pCreateInfos,
420 const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) {
421 layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
422 safe_VkComputePipelineCreateInfo *local_pCreateInfos = NULL;
423 if (pCreateInfos) {
424 std::lock_guard<std::mutex> lock(global_lock);
425 local_pCreateInfos = new safe_VkComputePipelineCreateInfo[createInfoCount];
426 for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
427 local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]);
428 if (pCreateInfos[idx0].basePipelineHandle) {
429 local_pCreateInfos[idx0].basePipelineHandle =
430 (VkPipeline)my_device_data
431 ->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].basePipelineHandle)];
432 }
433 if (pCreateInfos[idx0].layout) {
434 local_pCreateInfos[idx0].layout =
435 (VkPipelineLayout)
436 my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].layout)];
437 }
438 if (pCreateInfos[idx0].stage.module) {
439 local_pCreateInfos[idx0].stage.module =
440 (VkShaderModule)
441 my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].stage.module)];
442 }
443 }
444 }
445 if (pipelineCache) {
446 std::lock_guard<std::mutex> lock(global_lock);
447 pipelineCache = (VkPipelineCache)my_device_data->unique_id_mapping[reinterpret_cast<uint64_t &>(pipelineCache)];
448 }
449
450 VkResult result = my_device_data->device_dispatch_table->CreateComputePipelines(
451 device, pipelineCache, createInfoCount, (const VkComputePipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines);
452 delete[] local_pCreateInfos;
Maciej Jesionowski42200702016-11-23 10:44:34 +0100453 {
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600454 uint64_t unique_id = 0;
455 std::lock_guard<std::mutex> lock(global_lock);
456 for (uint32_t i = 0; i < createInfoCount; ++i) {
Maciej Jesionowski42200702016-11-23 10:44:34 +0100457 if (pPipelines[i] != VK_NULL_HANDLE) {
458 unique_id = global_unique_id++;
459 my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pPipelines[i]);
460 pPipelines[i] = reinterpret_cast<VkPipeline &>(unique_id);
461 }
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600462 }
463 }
464 return result;
465}
466
467VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
468 const VkGraphicsPipelineCreateInfo *pCreateInfos,
469 const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) {
470 layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
471 safe_VkGraphicsPipelineCreateInfo *local_pCreateInfos = NULL;
472 if (pCreateInfos) {
473 local_pCreateInfos = new safe_VkGraphicsPipelineCreateInfo[createInfoCount];
474 std::lock_guard<std::mutex> lock(global_lock);
475 for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
476 local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]);
477 if (pCreateInfos[idx0].basePipelineHandle) {
478 local_pCreateInfos[idx0].basePipelineHandle =
479 (VkPipeline)my_device_data
480 ->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].basePipelineHandle)];
481 }
482 if (pCreateInfos[idx0].layout) {
483 local_pCreateInfos[idx0].layout =
484 (VkPipelineLayout)
485 my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].layout)];
486 }
487 if (pCreateInfos[idx0].pStages) {
488 for (uint32_t idx1 = 0; idx1 < pCreateInfos[idx0].stageCount; ++idx1) {
489 if (pCreateInfos[idx0].pStages[idx1].module) {
490 local_pCreateInfos[idx0].pStages[idx1].module =
491 (VkShaderModule)my_device_data
492 ->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].pStages[idx1].module)];
493 }
494 }
495 }
496 if (pCreateInfos[idx0].renderPass) {
497 local_pCreateInfos[idx0].renderPass =
498 (VkRenderPass)
499 my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].renderPass)];
500 }
501 }
502 }
503 if (pipelineCache) {
504 std::lock_guard<std::mutex> lock(global_lock);
505 pipelineCache = (VkPipelineCache)my_device_data->unique_id_mapping[reinterpret_cast<uint64_t &>(pipelineCache)];
506 }
507
508 VkResult result = my_device_data->device_dispatch_table->CreateGraphicsPipelines(
509 device, pipelineCache, createInfoCount, (const VkGraphicsPipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines);
510 delete[] local_pCreateInfos;
Maciej Jesionowski42200702016-11-23 10:44:34 +0100511 {
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600512 uint64_t unique_id = 0;
513 std::lock_guard<std::mutex> lock(global_lock);
514 for (uint32_t i = 0; i < createInfoCount; ++i) {
Maciej Jesionowski42200702016-11-23 10:44:34 +0100515 if (pPipelines[i] != VK_NULL_HANDLE) {
516 unique_id = global_unique_id++;
517 my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pPipelines[i]);
518 pPipelines[i] = reinterpret_cast<VkPipeline &>(unique_id);
519 }
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600520 }
521 }
522 return result;
523}
524
525VKAPI_ATTR VkResult VKAPI_CALL CreateDebugReportCallbackEXT(VkInstance instance,
526 const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
527 const VkAllocationCallbacks *pAllocator,
528 VkDebugReportCallbackEXT *pMsgCallback) {
529 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
530 VkResult result =
531 instance_data->instance_dispatch_table->CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback);
532
533 if (VK_SUCCESS == result) {
534 result = layer_create_msg_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pMsgCallback);
535 }
536 return result;
537}
538
539VKAPI_ATTR void VKAPI_CALL DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback,
540 const VkAllocationCallbacks *pAllocator) {
541 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
542 instance_data->instance_dispatch_table->DestroyDebugReportCallbackEXT(instance, callback, pAllocator);
543 layer_destroy_msg_callback(instance_data->report_data, callback, pAllocator);
544}
545
546VKAPI_ATTR void VKAPI_CALL DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags,
547 VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location,
548 int32_t msgCode, const char *pLayerPrefix, const char *pMsg) {
549 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
550 instance_data->instance_dispatch_table->DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix,
551 pMsg);
552}
553
554VKAPI_ATTR VkResult VKAPI_CALL CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
555 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
556 layer_data *my_map_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
557 safe_VkSwapchainCreateInfoKHR *local_pCreateInfo = NULL;
558 if (pCreateInfo) {
559 std::lock_guard<std::mutex> lock(global_lock);
560 local_pCreateInfo = new safe_VkSwapchainCreateInfoKHR(pCreateInfo);
561 local_pCreateInfo->oldSwapchain =
562 (VkSwapchainKHR)my_map_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfo->oldSwapchain)];
563 // Need to pull surface mapping from the instance-level map
564 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(my_map_data->gpu), layer_data_map);
565 local_pCreateInfo->surface =
566 (VkSurfaceKHR)instance_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfo->surface)];
567 }
568
569 VkResult result = my_map_data->device_dispatch_table->CreateSwapchainKHR(
570 device, (const VkSwapchainCreateInfoKHR *)local_pCreateInfo, pAllocator, pSwapchain);
571 if (local_pCreateInfo) {
572 delete local_pCreateInfo;
573 }
574 if (VK_SUCCESS == result) {
575 std::lock_guard<std::mutex> lock(global_lock);
576 uint64_t unique_id = global_unique_id++;
577 my_map_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(*pSwapchain);
578 *pSwapchain = reinterpret_cast<VkSwapchainKHR &>(unique_id);
579 }
580 return result;
581}
582
583VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
584 VkImage *pSwapchainImages) {
585 layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
586 if (VK_NULL_HANDLE != swapchain) {
587 std::lock_guard<std::mutex> lock(global_lock);
588 swapchain = (VkSwapchainKHR)my_device_data->unique_id_mapping[reinterpret_cast<uint64_t &>(swapchain)];
589 }
590 VkResult result =
591 my_device_data->device_dispatch_table->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
592 // TODO : Need to add corresponding code to delete these images
593 if (VK_SUCCESS == result) {
594 if ((*pSwapchainImageCount > 0) && pSwapchainImages) {
595 uint64_t unique_id = 0;
596 std::lock_guard<std::mutex> lock(global_lock);
597 for (uint32_t i = 0; i < *pSwapchainImageCount; ++i) {
598 unique_id = global_unique_id++;
599 my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pSwapchainImages[i]);
600 pSwapchainImages[i] = reinterpret_cast<VkImage &>(unique_id);
601 }
602 }
603 }
604 return result;
605}
606
607#ifndef __ANDROID__
608VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
609 VkDisplayPropertiesKHR *pProperties) {
610 layer_data *my_map_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map);
611 safe_VkDisplayPropertiesKHR *local_pProperties = NULL;
612 {
613 std::lock_guard<std::mutex> lock(global_lock);
614 if (pProperties) {
615 local_pProperties = new safe_VkDisplayPropertiesKHR[*pPropertyCount];
616 for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
617 local_pProperties[idx0].initialize(&pProperties[idx0]);
618 if (pProperties[idx0].display) {
619 local_pProperties[idx0].display =
620 (VkDisplayKHR)my_map_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pProperties[idx0].display)];
621 }
622 }
623 }
624 }
625
626 VkResult result = my_map_data->instance_dispatch_table->GetPhysicalDeviceDisplayPropertiesKHR(
627 physicalDevice, pPropertyCount, (VkDisplayPropertiesKHR *)local_pProperties);
628 if (result == VK_SUCCESS && pProperties) {
629 for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
630 std::lock_guard<std::mutex> lock(global_lock);
631
632 uint64_t unique_id = global_unique_id++;
633 my_map_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(local_pProperties[idx0].display);
634 pProperties[idx0].display = reinterpret_cast<VkDisplayKHR &>(unique_id);
635 pProperties[idx0].displayName = local_pProperties[idx0].displayName;
636 pProperties[idx0].physicalDimensions = local_pProperties[idx0].physicalDimensions;
637 pProperties[idx0].physicalResolution = local_pProperties[idx0].physicalResolution;
638 pProperties[idx0].supportedTransforms = local_pProperties[idx0].supportedTransforms;
639 pProperties[idx0].planeReorderPossible = local_pProperties[idx0].planeReorderPossible;
640 pProperties[idx0].persistentContent = local_pProperties[idx0].persistentContent;
641 }
642 }
643 if (local_pProperties) {
644 delete[] local_pProperties;
645 }
646 return result;
647}
648
649VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex,
650 uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) {
651 layer_data *my_map_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map);
652 VkResult result = my_map_data->instance_dispatch_table->GetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex,
653 pDisplayCount, pDisplays);
654 if (VK_SUCCESS == result) {
655 if ((*pDisplayCount > 0) && pDisplays) {
656 std::lock_guard<std::mutex> lock(global_lock);
657 for (uint32_t i = 0; i < *pDisplayCount; i++) {
658 auto it = my_map_data->unique_id_mapping.find(reinterpret_cast<const uint64_t &>(pDisplays[i]));
659 assert(it != my_map_data->unique_id_mapping.end());
660 pDisplays[i] = reinterpret_cast<VkDisplayKHR &>(it->second);
661 }
662 }
663 }
664 return result;
665}
666
667VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
668 uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
669 layer_data *my_map_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map);
Mark Lobodzinskif0650ff2017-01-03 08:52:14 -0700670 VkDisplayModePropertiesKHR *local_pProperties = NULL;
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600671 {
672 std::lock_guard<std::mutex> lock(global_lock);
673 display = (VkDisplayKHR)my_map_data->unique_id_mapping[reinterpret_cast<uint64_t &>(display)];
674 if (pProperties) {
Mark Lobodzinskif0650ff2017-01-03 08:52:14 -0700675 local_pProperties = new VkDisplayModePropertiesKHR[*pPropertyCount];
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600676 }
677 }
678
679 VkResult result = my_map_data->instance_dispatch_table->GetDisplayModePropertiesKHR(
680 physicalDevice, display, pPropertyCount, (VkDisplayModePropertiesKHR *)local_pProperties);
681 if (result == VK_SUCCESS && pProperties) {
682 for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
683 std::lock_guard<std::mutex> lock(global_lock);
684
685 uint64_t unique_id = global_unique_id++;
686 my_map_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(local_pProperties[idx0].displayMode);
687 pProperties[idx0].displayMode = reinterpret_cast<VkDisplayModeKHR &>(unique_id);
688 pProperties[idx0].parameters.visibleRegion.width = local_pProperties[idx0].parameters.visibleRegion.width;
689 pProperties[idx0].parameters.visibleRegion.height = local_pProperties[idx0].parameters.visibleRegion.height;
690 pProperties[idx0].parameters.refreshRate = local_pProperties[idx0].parameters.refreshRate;
691 }
692 }
693 if (local_pProperties) {
694 delete[] local_pProperties;
695 }
696 return result;
697}
Norbert Nopper1dec9a52016-11-25 07:55:13 +0100698
699VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode,
700 uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
701 layer_data *dev_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map);
702 {
703 std::lock_guard<std::mutex> lock(global_lock);
704 auto it = dev_data->unique_id_mapping.find(reinterpret_cast<uint64_t &>(mode));
705 if (it == dev_data->unique_id_mapping.end()) {
706 uint64_t unique_id = global_unique_id++;
707 dev_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(mode);
708
709 mode = reinterpret_cast<VkDisplayModeKHR &>(unique_id);
710 } else {
711 mode = reinterpret_cast<VkDisplayModeKHR &>(it->second);
712 }
713 }
714 VkResult result =
715 dev_data->instance_dispatch_table->GetDisplayPlaneCapabilitiesKHR(physicalDevice, mode, planeIndex, pCapabilities);
716 return result;
717}
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600718#endif
719
720} // namespace unique_objects
721
722// vk_layer_logging.h expects these to be defined
723VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance,
724 const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
725 const VkAllocationCallbacks *pAllocator,
726 VkDebugReportCallbackEXT *pMsgCallback) {
727 return unique_objects::CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback);
728}
729
730VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback,
731 const VkAllocationCallbacks *pAllocator) {
732 unique_objects::DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator);
733}
734
735VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags,
736 VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location,
737 int32_t msgCode, const char *pLayerPrefix, const char *pMsg) {
738 unique_objects::DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg);
739}
740
741VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount,
742 VkExtensionProperties *pProperties) {
743 return unique_objects::EnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties);
744}
745
746VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount,
747 VkLayerProperties *pProperties) {
748 return unique_objects::EnumerateInstanceLayerProperties(pCount, pProperties);
749}
750
751VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
752 VkLayerProperties *pProperties) {
753 assert(physicalDevice == VK_NULL_HANDLE);
754 return unique_objects::EnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties);
755}
756
757VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) {
758 return unique_objects::GetDeviceProcAddr(dev, funcName);
759}
760
761VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) {
762 return unique_objects::GetInstanceProcAddr(instance, funcName);
763}
764
765VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
766 const char *pLayerName, uint32_t *pCount,
767 VkExtensionProperties *pProperties) {
768 assert(physicalDevice == VK_NULL_HANDLE);
769 return unique_objects::EnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties);
770}
Mark Young39389872017-01-19 21:10:49 -0700771
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700772VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance,
773 const char *funcName) {
Mark Young39389872017-01-19 21:10:49 -0700774 return unique_objects::GetPhysicalDeviceProcAddr(instance, funcName);
775}
776
777VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) {
778 assert(pVersionStruct != NULL);
779 assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT);
780
781 // Fill in the function pointers if our version is at least capable of having the structure contain them.
782 if (pVersionStruct->loaderLayerInterfaceVersion >= 2) {
783 pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr;
784 pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr;
785 pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr;
786 }
787
788 if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
789 unique_objects::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion;
790 } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
791 pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION;
792 }
793
794 return VK_SUCCESS;
795}