blob: f973ec56be09616c51b8770690b6615f0048c256 [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",
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700263 VK_LAYER_API_VERSION, // specVersion
264 1, // implementationVersion
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600265 "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 Lobodzinski64318ba2017-01-26 13:34:13 -0700272 if (!strcmp(name, procmap[i].name)) return procmap[i].pFunc;
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600273 }
Mark Young39389872017-01-19 21:10:49 -0700274 if (0 == strcmp(name, "vk_layerGetPhysicalDeviceProcAddr")) {
275 return (PFN_vkVoidFunction)GetPhysicalDeviceProcAddr;
276 }
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600277 return NULL;
278}
279
280VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) {
281 return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties);
282}
283
284VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
285 VkLayerProperties *pProperties) {
286 return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties);
287}
288
289VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount,
290 VkExtensionProperties *pProperties) {
291 if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName))
292 return util_GetExtensionProperties(0, NULL, pCount, pProperties);
293
294 return VK_ERROR_LAYER_NOT_PRESENT;
295}
296
297VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName,
298 uint32_t *pCount, VkExtensionProperties *pProperties) {
299 if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName))
300 return util_GetExtensionProperties(0, nullptr, pCount, pProperties);
301
302 assert(physicalDevice);
303
304 dispatch_key key = get_dispatch_key(physicalDevice);
305 layer_data *instance_data = get_my_data_ptr(key, layer_data_map);
306 return instance_data->instance_dispatch_table->EnumerateDeviceExtensionProperties(physicalDevice, NULL, pCount, pProperties);
307}
308
309VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) {
310 PFN_vkVoidFunction addr;
311 assert(device);
312 addr = layer_intercept_proc(funcName);
313 if (addr) {
314 return addr;
315 }
316
317 layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
318 VkLayerDispatchTable *disp_table = dev_data->device_dispatch_table;
319 if (disp_table->GetDeviceProcAddr == NULL) {
320 return NULL;
321 }
322 return disp_table->GetDeviceProcAddr(device, funcName);
323}
324
325VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) {
326 PFN_vkVoidFunction addr;
327
328 addr = layer_intercept_proc(funcName);
329 if (addr) {
330 return addr;
331 }
332 assert(instance);
333
334 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
335 addr = debug_report_get_instance_proc_addr(instance_data->report_data, funcName);
336 if (addr) {
337 return addr;
338 }
339
340 VkLayerInstanceDispatchTable *disp_table = instance_data->instance_dispatch_table;
341 if (disp_table->GetInstanceProcAddr == NULL) {
342 return NULL;
343 }
344 return disp_table->GetInstanceProcAddr(instance, funcName);
345}
346
Mark Young39389872017-01-19 21:10:49 -0700347VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) {
348 assert(instance);
349
350 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
351 VkLayerInstanceDispatchTable *disp_table = instance_data->instance_dispatch_table;
352 if (disp_table->GetPhysicalDeviceProcAddr == NULL) {
353 return NULL;
354 }
355 return disp_table->GetPhysicalDeviceProcAddr(instance, funcName);
356}
357
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600358VKAPI_ATTR VkResult VKAPI_CALL AllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
359 const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory) {
360 const VkMemoryAllocateInfo *input_allocate_info = pAllocateInfo;
361 std::unique_ptr<safe_VkMemoryAllocateInfo> safe_allocate_info;
Mark Lobodzinskid2443222016-10-07 14:13:38 -0600362 std::unique_ptr<safe_VkDedicatedAllocationMemoryAllocateInfoNV> safe_dedicated_allocate_info;
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600363 layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
364
365 if ((pAllocateInfo != nullptr) &&
366 ContainsExtStruct(pAllocateInfo, VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV)) {
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600367 // Assuming there is only one extension struct of this type in the list for now
368 safe_dedicated_allocate_info =
369 std::unique_ptr<safe_VkDedicatedAllocationMemoryAllocateInfoNV>(new safe_VkDedicatedAllocationMemoryAllocateInfoNV);
370 safe_allocate_info = std::unique_ptr<safe_VkMemoryAllocateInfo>(new safe_VkMemoryAllocateInfo(pAllocateInfo));
371 input_allocate_info = reinterpret_cast<const VkMemoryAllocateInfo *>(safe_allocate_info.get());
372
373 const GenericHeader *orig_pnext = reinterpret_cast<const GenericHeader *>(pAllocateInfo->pNext);
374 GenericHeader *input_pnext = reinterpret_cast<GenericHeader *>(safe_allocate_info.get());
375 while (orig_pnext != nullptr) {
376 if (orig_pnext->sType == VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV) {
377 safe_dedicated_allocate_info->initialize(
378 reinterpret_cast<const VkDedicatedAllocationMemoryAllocateInfoNV *>(orig_pnext));
379
380 std::unique_lock<std::mutex> lock(global_lock);
381
382 if (safe_dedicated_allocate_info->buffer != VK_NULL_HANDLE) {
383 uint64_t local_buffer = reinterpret_cast<uint64_t &>(safe_dedicated_allocate_info->buffer);
384 safe_dedicated_allocate_info->buffer =
385 reinterpret_cast<VkBuffer &>(device_data->unique_id_mapping[local_buffer]);
386 }
387
388 if (safe_dedicated_allocate_info->image != VK_NULL_HANDLE) {
389 uint64_t local_image = reinterpret_cast<uint64_t &>(safe_dedicated_allocate_info->image);
390 safe_dedicated_allocate_info->image = reinterpret_cast<VkImage &>(device_data->unique_id_mapping[local_image]);
391 }
392
393 lock.unlock();
394
395 input_pnext->pNext = reinterpret_cast<GenericHeader *>(safe_dedicated_allocate_info.get());
396 input_pnext = reinterpret_cast<GenericHeader *>(input_pnext->pNext);
397 } else {
398 // TODO: generic handling of pNext copies
399 }
400
401 orig_pnext = reinterpret_cast<const GenericHeader *>(orig_pnext->pNext);
402 }
403 }
404
405 VkResult result = device_data->device_dispatch_table->AllocateMemory(device, input_allocate_info, pAllocator, pMemory);
406
407 if (VK_SUCCESS == result) {
408 std::lock_guard<std::mutex> lock(global_lock);
409 uint64_t unique_id = global_unique_id++;
410 device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(*pMemory);
411 *pMemory = reinterpret_cast<VkDeviceMemory &>(unique_id);
412 }
413
414 return result;
415}
416
417VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
418 const VkComputePipelineCreateInfo *pCreateInfos,
419 const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) {
420 layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
421 safe_VkComputePipelineCreateInfo *local_pCreateInfos = NULL;
422 if (pCreateInfos) {
423 std::lock_guard<std::mutex> lock(global_lock);
424 local_pCreateInfos = new safe_VkComputePipelineCreateInfo[createInfoCount];
425 for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
426 local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]);
427 if (pCreateInfos[idx0].basePipelineHandle) {
428 local_pCreateInfos[idx0].basePipelineHandle =
429 (VkPipeline)my_device_data
430 ->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].basePipelineHandle)];
431 }
432 if (pCreateInfos[idx0].layout) {
433 local_pCreateInfos[idx0].layout =
434 (VkPipelineLayout)
435 my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].layout)];
436 }
437 if (pCreateInfos[idx0].stage.module) {
438 local_pCreateInfos[idx0].stage.module =
439 (VkShaderModule)
440 my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].stage.module)];
441 }
442 }
443 }
444 if (pipelineCache) {
445 std::lock_guard<std::mutex> lock(global_lock);
446 pipelineCache = (VkPipelineCache)my_device_data->unique_id_mapping[reinterpret_cast<uint64_t &>(pipelineCache)];
447 }
448
449 VkResult result = my_device_data->device_dispatch_table->CreateComputePipelines(
450 device, pipelineCache, createInfoCount, (const VkComputePipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines);
451 delete[] local_pCreateInfos;
Maciej Jesionowski42200702016-11-23 10:44:34 +0100452 {
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600453 uint64_t unique_id = 0;
454 std::lock_guard<std::mutex> lock(global_lock);
455 for (uint32_t i = 0; i < createInfoCount; ++i) {
Maciej Jesionowski42200702016-11-23 10:44:34 +0100456 if (pPipelines[i] != VK_NULL_HANDLE) {
457 unique_id = global_unique_id++;
458 my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pPipelines[i]);
459 pPipelines[i] = reinterpret_cast<VkPipeline &>(unique_id);
460 }
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600461 }
462 }
463 return result;
464}
465
466VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
467 const VkGraphicsPipelineCreateInfo *pCreateInfos,
468 const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) {
469 layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
470 safe_VkGraphicsPipelineCreateInfo *local_pCreateInfos = NULL;
471 if (pCreateInfos) {
472 local_pCreateInfos = new safe_VkGraphicsPipelineCreateInfo[createInfoCount];
473 std::lock_guard<std::mutex> lock(global_lock);
474 for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
475 local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]);
476 if (pCreateInfos[idx0].basePipelineHandle) {
477 local_pCreateInfos[idx0].basePipelineHandle =
478 (VkPipeline)my_device_data
479 ->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].basePipelineHandle)];
480 }
481 if (pCreateInfos[idx0].layout) {
482 local_pCreateInfos[idx0].layout =
483 (VkPipelineLayout)
484 my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].layout)];
485 }
486 if (pCreateInfos[idx0].pStages) {
487 for (uint32_t idx1 = 0; idx1 < pCreateInfos[idx0].stageCount; ++idx1) {
488 if (pCreateInfos[idx0].pStages[idx1].module) {
489 local_pCreateInfos[idx0].pStages[idx1].module =
490 (VkShaderModule)my_device_data
491 ->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].pStages[idx1].module)];
492 }
493 }
494 }
495 if (pCreateInfos[idx0].renderPass) {
496 local_pCreateInfos[idx0].renderPass =
497 (VkRenderPass)
498 my_device_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfos[idx0].renderPass)];
499 }
500 }
501 }
502 if (pipelineCache) {
503 std::lock_guard<std::mutex> lock(global_lock);
504 pipelineCache = (VkPipelineCache)my_device_data->unique_id_mapping[reinterpret_cast<uint64_t &>(pipelineCache)];
505 }
506
507 VkResult result = my_device_data->device_dispatch_table->CreateGraphicsPipelines(
508 device, pipelineCache, createInfoCount, (const VkGraphicsPipelineCreateInfo *)local_pCreateInfos, pAllocator, pPipelines);
509 delete[] local_pCreateInfos;
Maciej Jesionowski42200702016-11-23 10:44:34 +0100510 {
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600511 uint64_t unique_id = 0;
512 std::lock_guard<std::mutex> lock(global_lock);
513 for (uint32_t i = 0; i < createInfoCount; ++i) {
Maciej Jesionowski42200702016-11-23 10:44:34 +0100514 if (pPipelines[i] != VK_NULL_HANDLE) {
515 unique_id = global_unique_id++;
516 my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pPipelines[i]);
517 pPipelines[i] = reinterpret_cast<VkPipeline &>(unique_id);
518 }
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600519 }
520 }
521 return result;
522}
523
524VKAPI_ATTR VkResult VKAPI_CALL CreateDebugReportCallbackEXT(VkInstance instance,
525 const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
526 const VkAllocationCallbacks *pAllocator,
527 VkDebugReportCallbackEXT *pMsgCallback) {
528 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
529 VkResult result =
530 instance_data->instance_dispatch_table->CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback);
531
532 if (VK_SUCCESS == result) {
533 result = layer_create_msg_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pMsgCallback);
534 }
535 return result;
536}
537
538VKAPI_ATTR void VKAPI_CALL DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback,
539 const VkAllocationCallbacks *pAllocator) {
540 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
541 instance_data->instance_dispatch_table->DestroyDebugReportCallbackEXT(instance, callback, pAllocator);
542 layer_destroy_msg_callback(instance_data->report_data, callback, pAllocator);
543}
544
545VKAPI_ATTR void VKAPI_CALL DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags,
546 VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location,
547 int32_t msgCode, const char *pLayerPrefix, const char *pMsg) {
548 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
549 instance_data->instance_dispatch_table->DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix,
550 pMsg);
551}
552
553VKAPI_ATTR VkResult VKAPI_CALL CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
554 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
555 layer_data *my_map_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
556 safe_VkSwapchainCreateInfoKHR *local_pCreateInfo = NULL;
557 if (pCreateInfo) {
558 std::lock_guard<std::mutex> lock(global_lock);
559 local_pCreateInfo = new safe_VkSwapchainCreateInfoKHR(pCreateInfo);
560 local_pCreateInfo->oldSwapchain =
561 (VkSwapchainKHR)my_map_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfo->oldSwapchain)];
562 // Need to pull surface mapping from the instance-level map
563 layer_data *instance_data = get_my_data_ptr(get_dispatch_key(my_map_data->gpu), layer_data_map);
564 local_pCreateInfo->surface =
565 (VkSurfaceKHR)instance_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pCreateInfo->surface)];
566 }
567
568 VkResult result = my_map_data->device_dispatch_table->CreateSwapchainKHR(
569 device, (const VkSwapchainCreateInfoKHR *)local_pCreateInfo, pAllocator, pSwapchain);
570 if (local_pCreateInfo) {
571 delete local_pCreateInfo;
572 }
573 if (VK_SUCCESS == result) {
574 std::lock_guard<std::mutex> lock(global_lock);
575 uint64_t unique_id = global_unique_id++;
576 my_map_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(*pSwapchain);
577 *pSwapchain = reinterpret_cast<VkSwapchainKHR &>(unique_id);
578 }
579 return result;
580}
581
582VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
583 VkImage *pSwapchainImages) {
584 layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
585 if (VK_NULL_HANDLE != swapchain) {
586 std::lock_guard<std::mutex> lock(global_lock);
587 swapchain = (VkSwapchainKHR)my_device_data->unique_id_mapping[reinterpret_cast<uint64_t &>(swapchain)];
588 }
589 VkResult result =
590 my_device_data->device_dispatch_table->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
591 // TODO : Need to add corresponding code to delete these images
592 if (VK_SUCCESS == result) {
593 if ((*pSwapchainImageCount > 0) && pSwapchainImages) {
594 uint64_t unique_id = 0;
595 std::lock_guard<std::mutex> lock(global_lock);
596 for (uint32_t i = 0; i < *pSwapchainImageCount; ++i) {
597 unique_id = global_unique_id++;
598 my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pSwapchainImages[i]);
599 pSwapchainImages[i] = reinterpret_cast<VkImage &>(unique_id);
600 }
601 }
602 }
603 return result;
604}
605
606#ifndef __ANDROID__
607VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
608 VkDisplayPropertiesKHR *pProperties) {
609 layer_data *my_map_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map);
610 safe_VkDisplayPropertiesKHR *local_pProperties = NULL;
611 {
612 std::lock_guard<std::mutex> lock(global_lock);
613 if (pProperties) {
614 local_pProperties = new safe_VkDisplayPropertiesKHR[*pPropertyCount];
615 for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
616 local_pProperties[idx0].initialize(&pProperties[idx0]);
617 if (pProperties[idx0].display) {
618 local_pProperties[idx0].display =
619 (VkDisplayKHR)my_map_data->unique_id_mapping[reinterpret_cast<const uint64_t &>(pProperties[idx0].display)];
620 }
621 }
622 }
623 }
624
625 VkResult result = my_map_data->instance_dispatch_table->GetPhysicalDeviceDisplayPropertiesKHR(
626 physicalDevice, pPropertyCount, (VkDisplayPropertiesKHR *)local_pProperties);
627 if (result == VK_SUCCESS && pProperties) {
628 for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
629 std::lock_guard<std::mutex> lock(global_lock);
630
631 uint64_t unique_id = global_unique_id++;
632 my_map_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(local_pProperties[idx0].display);
633 pProperties[idx0].display = reinterpret_cast<VkDisplayKHR &>(unique_id);
634 pProperties[idx0].displayName = local_pProperties[idx0].displayName;
635 pProperties[idx0].physicalDimensions = local_pProperties[idx0].physicalDimensions;
636 pProperties[idx0].physicalResolution = local_pProperties[idx0].physicalResolution;
637 pProperties[idx0].supportedTransforms = local_pProperties[idx0].supportedTransforms;
638 pProperties[idx0].planeReorderPossible = local_pProperties[idx0].planeReorderPossible;
639 pProperties[idx0].persistentContent = local_pProperties[idx0].persistentContent;
640 }
641 }
642 if (local_pProperties) {
643 delete[] local_pProperties;
644 }
645 return result;
646}
647
648VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex,
649 uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) {
650 layer_data *my_map_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map);
651 VkResult result = my_map_data->instance_dispatch_table->GetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex,
652 pDisplayCount, pDisplays);
653 if (VK_SUCCESS == result) {
654 if ((*pDisplayCount > 0) && pDisplays) {
655 std::lock_guard<std::mutex> lock(global_lock);
656 for (uint32_t i = 0; i < *pDisplayCount; i++) {
657 auto it = my_map_data->unique_id_mapping.find(reinterpret_cast<const uint64_t &>(pDisplays[i]));
658 assert(it != my_map_data->unique_id_mapping.end());
659 pDisplays[i] = reinterpret_cast<VkDisplayKHR &>(it->second);
660 }
661 }
662 }
663 return result;
664}
665
666VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
667 uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
668 layer_data *my_map_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map);
Mark Lobodzinskif0650ff2017-01-03 08:52:14 -0700669 VkDisplayModePropertiesKHR *local_pProperties = NULL;
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600670 {
671 std::lock_guard<std::mutex> lock(global_lock);
672 display = (VkDisplayKHR)my_map_data->unique_id_mapping[reinterpret_cast<uint64_t &>(display)];
673 if (pProperties) {
Mark Lobodzinskif0650ff2017-01-03 08:52:14 -0700674 local_pProperties = new VkDisplayModePropertiesKHR[*pPropertyCount];
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600675 }
676 }
677
678 VkResult result = my_map_data->instance_dispatch_table->GetDisplayModePropertiesKHR(
679 physicalDevice, display, pPropertyCount, (VkDisplayModePropertiesKHR *)local_pProperties);
680 if (result == VK_SUCCESS && pProperties) {
681 for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
682 std::lock_guard<std::mutex> lock(global_lock);
683
684 uint64_t unique_id = global_unique_id++;
685 my_map_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(local_pProperties[idx0].displayMode);
686 pProperties[idx0].displayMode = reinterpret_cast<VkDisplayModeKHR &>(unique_id);
687 pProperties[idx0].parameters.visibleRegion.width = local_pProperties[idx0].parameters.visibleRegion.width;
688 pProperties[idx0].parameters.visibleRegion.height = local_pProperties[idx0].parameters.visibleRegion.height;
689 pProperties[idx0].parameters.refreshRate = local_pProperties[idx0].parameters.refreshRate;
690 }
691 }
692 if (local_pProperties) {
693 delete[] local_pProperties;
694 }
695 return result;
696}
Norbert Nopper1dec9a52016-11-25 07:55:13 +0100697
698VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode,
699 uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
700 layer_data *dev_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map);
701 {
702 std::lock_guard<std::mutex> lock(global_lock);
703 auto it = dev_data->unique_id_mapping.find(reinterpret_cast<uint64_t &>(mode));
704 if (it == dev_data->unique_id_mapping.end()) {
705 uint64_t unique_id = global_unique_id++;
706 dev_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(mode);
707
708 mode = reinterpret_cast<VkDisplayModeKHR &>(unique_id);
709 } else {
710 mode = reinterpret_cast<VkDisplayModeKHR &>(it->second);
711 }
712 }
713 VkResult result =
714 dev_data->instance_dispatch_table->GetDisplayPlaneCapabilitiesKHR(physicalDevice, mode, planeIndex, pCapabilities);
715 return result;
716}
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600717#endif
718
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700719} // namespace unique_objects
Mark Lobodzinskidc3bd852016-09-06 16:12:23 -0600720
721// vk_layer_logging.h expects these to be defined
722VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance,
723 const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
724 const VkAllocationCallbacks *pAllocator,
725 VkDebugReportCallbackEXT *pMsgCallback) {
726 return unique_objects::CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback);
727}
728
729VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback,
730 const VkAllocationCallbacks *pAllocator) {
731 unique_objects::DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator);
732}
733
734VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags,
735 VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location,
736 int32_t msgCode, const char *pLayerPrefix, const char *pMsg) {
737 unique_objects::DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg);
738}
739
740VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount,
741 VkExtensionProperties *pProperties) {
742 return unique_objects::EnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties);
743}
744
745VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount,
746 VkLayerProperties *pProperties) {
747 return unique_objects::EnumerateInstanceLayerProperties(pCount, pProperties);
748}
749
750VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
751 VkLayerProperties *pProperties) {
752 assert(physicalDevice == VK_NULL_HANDLE);
753 return unique_objects::EnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties);
754}
755
756VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) {
757 return unique_objects::GetDeviceProcAddr(dev, funcName);
758}
759
760VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) {
761 return unique_objects::GetInstanceProcAddr(instance, funcName);
762}
763
764VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
765 const char *pLayerName, uint32_t *pCount,
766 VkExtensionProperties *pProperties) {
767 assert(physicalDevice == VK_NULL_HANDLE);
768 return unique_objects::EnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties);
769}
Mark Young39389872017-01-19 21:10:49 -0700770
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700771VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance,
772 const char *funcName) {
Mark Young39389872017-01-19 21:10:49 -0700773 return unique_objects::GetPhysicalDeviceProcAddr(instance, funcName);
774}
775
776VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) {
777 assert(pVersionStruct != NULL);
778 assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT);
779
780 // Fill in the function pointers if our version is at least capable of having the structure contain them.
781 if (pVersionStruct->loaderLayerInterfaceVersion >= 2) {
782 pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr;
783 pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr;
784 pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr;
785 }
786
787 if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
788 unique_objects::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion;
789 } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
790 pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION;
791 }
792
793 return VK_SUCCESS;
794}