forked from KhronosGroup/Vulkan-Loader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
trampoline.c
3284 lines (2800 loc) · 174 KB
/
trampoline.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
*
* Copyright (c) 2015-2023 The Khronos Group Inc.
* Copyright (c) 2015-2023 Valve Corporation
* Copyright (c) 2015-2023 LunarG, Inc.
* Copyright (C) 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Courtney Goeltzenleuchter <[email protected]>
* Author: Jon Ashburn <[email protected]>
* Author: Tony Barbour <[email protected]>
* Author: Chia-I Wu <[email protected]>
* Author: Charles Giessen <[email protected]>
*/
#include <stdlib.h>
#include <string.h>
#include "allocation.h"
#include "debug_utils.h"
#include "gpa_helper.h"
#include "loader.h"
#include "log.h"
#include "settings.h"
#include "vk_loader_extensions.h"
#include "vk_loader_platform.h"
#include "wsi.h"
// Trampoline entrypoints are in this file for core Vulkan commands
/* vkGetInstanceProcAddr: Get global level or instance level entrypoint addresses.
* @param instance
* @param pName
* @return
* If pName is a global level entrypoint:
* If instance == NULL || instance is invalid || (instance is valid && instance.minor_version <= 2):
* return global level functions
* Else:
* return NULL
* Else:
* If instance is valid:
* return a trampoline entry point for all dispatchable Vulkan functions both core and extensions.
* Else:
* return NULL
*
* Note:
* Vulkan header updated 1.2.193 changed the behavior of vkGetInstanceProcAddr for global entrypoints. They used to always be
* returned regardless of the value of the instance parameter. The spec was amended in this version to only allow querying global
* level entrypoints with a NULL instance. However, as to not break old applications, the new behavior is only applied if the
* instance passed in is both valid and minor version is greater than 1.2, which was when this change in behavior occurred. Only
* instances with a newer version will get the new behavior.
*/
LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName) {
// Always should be able to get vkGetInstanceProcAddr if queried, regardless of the value of instance
if (!strcmp(pName, "vkGetInstanceProcAddr")) return (PFN_vkVoidFunction)vkGetInstanceProcAddr;
// Get entrypoint addresses that are global (no dispatchable object)
void *addr = globalGetProcAddr(pName);
if (addr != VK_NULL_HANDLE) {
// Always can get a global entrypoint from vkGetInstanceProcAddr with a NULL instance handle
if (instance == VK_NULL_HANDLE) {
return addr;
} else {
// New behavior only returns a global entrypoint if the instance handle is NULL.
// Old behavior is to return a global entrypoint regardless of the value of the instance handle.
// Use new behavior if: The instance is valid and the minor version of the instance is greater than 1.2, which
// was when the new behavior was added. (eg, it is enforced in the next minor version of vulkan, which will be 1.3)
// First check if instance is valid - loader_get_instance() returns NULL if it isn't.
struct loader_instance *ptr_instance = loader_get_instance(instance);
if (ptr_instance != NULL &&
loader_check_version_meets_required(loader_combine_version(1, 3, 0), ptr_instance->app_api_version)) {
// New behavior
return NULL;
} else {
// Old behavior
return addr;
}
}
} else {
// All other functions require a valid instance handle to get
if (instance == VK_NULL_HANDLE) {
return NULL;
}
struct loader_instance *ptr_instance = loader_get_instance(instance);
// If we've gotten here and the pointer is NULL, it's invalid
if (ptr_instance == NULL) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkGetInstanceProcAddr: Invalid instance [VUID-vkGetInstanceProcAddr-instance-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
// Return trampoline code for non-global entrypoints including any extensions.
// Device extensions are returned if a layer or ICD supports the extension.
// Instance extensions are returned if the extension is enabled and the
// loader or someone else supports the extension
return trampoline_get_proc_addr(ptr_instance, pName);
}
}
// Get a device level or global level entry point address.
// @param device
// @param pName
// @return
// If device is valid, returns a device relative entry point for device level
// entry points both core and extensions.
// Device relative means call down the device chain.
LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *pName) {
void *addr;
// For entrypoints that loader must handle (ie non-dispatchable or create object)
// make sure the loader entrypoint is returned
addr = loader_non_passthrough_gdpa(pName);
if (addr) {
return addr;
}
// Although CreateDevice is on device chain it's dispatchable object isn't
// a VkDevice or child of VkDevice so return NULL.
if (!strcmp(pName, "CreateDevice")) return NULL;
// Return the dispatch table entrypoint for the fastest case
const VkLayerDispatchTable *disp_table = *(VkLayerDispatchTable **)device;
if (disp_table == NULL) return NULL;
addr = loader_lookup_device_dispatch_table(disp_table, pName);
if (addr) return addr;
if (disp_table->GetDeviceProcAddr == NULL) return NULL;
return disp_table->GetDeviceProcAddr(device, pName);
}
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName,
uint32_t *pPropertyCount,
VkExtensionProperties *pProperties) {
LOADER_PLATFORM_THREAD_ONCE(&once_init, loader_initialize);
update_global_loader_settings();
// We know we need to call at least the terminator
VkResult res = VK_SUCCESS;
VkEnumerateInstanceExtensionPropertiesChain chain_tail = {
.header =
{
.type = VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES,
.version = VK_CURRENT_CHAIN_VERSION,
.size = sizeof(chain_tail),
},
.pfnNextLayer = &terminator_EnumerateInstanceExtensionProperties,
.pNextLink = NULL,
};
VkEnumerateInstanceExtensionPropertiesChain *chain_head = &chain_tail;
// Get the implicit layers
struct loader_layer_list layers = {0};
loader_platform_dl_handle *libs = NULL;
size_t lib_count = 0;
memset(&layers, 0, sizeof(layers));
res = loader_scan_for_implicit_layers(NULL, &layers);
if (VK_SUCCESS != res) {
return res;
}
res = loader_init_library_list(&layers, &libs);
if (VK_SUCCESS != res) {
return res;
}
// Prepend layers onto the chain if they implement this entry point
for (uint32_t i = 0; i < layers.count; ++i) {
// Skip this layer if it doesn't expose the entry-point
if (NULL == layers.list[i].pre_instance_functions.enumerate_instance_extension_properties) {
continue;
}
loader_platform_dl_handle layer_lib = loader_platform_open_library(layers.list[i].lib_name);
if (layer_lib == NULL) {
loader_log(NULL, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
"%s: Unable to load implicit layer library \"%s\"", __FUNCTION__, layers.list[i].lib_name);
continue;
}
libs[lib_count++] = layer_lib;
void *pfn = loader_platform_get_proc_address(layer_lib,
layers.list[i].pre_instance_functions.enumerate_instance_extension_properties);
if (pfn == NULL) {
loader_log(NULL, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
"%s: Unable to resolve symbol \"%s\" in implicit layer library \"%s\"", __FUNCTION__,
layers.list[i].pre_instance_functions.enumerate_instance_extension_properties, layers.list[i].lib_name);
continue;
}
VkEnumerateInstanceExtensionPropertiesChain *chain_link =
loader_alloc(NULL, sizeof(VkEnumerateInstanceExtensionPropertiesChain), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
if (chain_link == NULL) {
res = VK_ERROR_OUT_OF_HOST_MEMORY;
break;
}
memset(chain_link, 0, sizeof(VkEnumerateInstanceLayerPropertiesChain));
chain_link->header.type = VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES;
chain_link->header.version = VK_CURRENT_CHAIN_VERSION;
chain_link->header.size = sizeof(*chain_link);
chain_link->pfnNextLayer = pfn;
chain_link->pNextLink = chain_head;
chain_head = chain_link;
}
// Call down the chain
if (res == VK_SUCCESS) {
res = chain_head->pfnNextLayer(chain_head->pNextLink, pLayerName, pPropertyCount, pProperties);
}
// Free up the layers
loader_delete_layer_list_and_properties(NULL, &layers);
// Tear down the chain
while (chain_head != &chain_tail) {
VkEnumerateInstanceExtensionPropertiesChain *holder = chain_head;
chain_head = (VkEnumerateInstanceExtensionPropertiesChain *)chain_head->pNextLink;
loader_free(NULL, holder);
}
// Close the dl handles
for (size_t i = 0; i < lib_count; ++i) {
loader_platform_close_library(libs[i]);
}
loader_free(NULL, libs);
return res;
}
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount,
VkLayerProperties *pProperties) {
LOADER_PLATFORM_THREAD_ONCE(&once_init, loader_initialize);
update_global_loader_settings();
// We know we need to call at least the terminator
VkResult res = VK_SUCCESS;
VkEnumerateInstanceLayerPropertiesChain chain_tail = {
.header =
{
.type = VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES,
.version = VK_CURRENT_CHAIN_VERSION,
.size = sizeof(chain_tail),
},
.pfnNextLayer = &terminator_EnumerateInstanceLayerProperties,
.pNextLink = NULL,
};
VkEnumerateInstanceLayerPropertiesChain *chain_head = &chain_tail;
// Get the implicit layers
struct loader_layer_list layers;
loader_platform_dl_handle *libs = NULL;
size_t lib_count = 0;
memset(&layers, 0, sizeof(layers));
res = loader_scan_for_implicit_layers(NULL, &layers);
if (VK_SUCCESS != res) {
return res;
}
res = loader_init_library_list(&layers, &libs);
if (VK_SUCCESS != res) {
return res;
}
// Prepend layers onto the chain if they implement this entry point
for (uint32_t i = 0; i < layers.count; ++i) {
// Skip this layer if it doesn't expose the entry-point
if (NULL == layers.list[i].pre_instance_functions.enumerate_instance_layer_properties) {
continue;
}
loader_platform_dl_handle layer_lib = loader_platform_open_library(layers.list[i].lib_name);
if (layer_lib == NULL) {
loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "%s: Unable to load implicit layer library \"%s\"", __FUNCTION__,
layers.list[i].lib_name);
continue;
}
libs[lib_count++] = layer_lib;
void *pfn =
loader_platform_get_proc_address(layer_lib, layers.list[i].pre_instance_functions.enumerate_instance_layer_properties);
if (pfn == NULL) {
loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "%s: Unable to resolve symbol \"%s\" in implicit layer library \"%s\"",
__FUNCTION__, layers.list[i].pre_instance_functions.enumerate_instance_layer_properties,
layers.list[i].lib_name);
continue;
}
VkEnumerateInstanceLayerPropertiesChain *chain_link =
loader_alloc(NULL, sizeof(VkEnumerateInstanceLayerPropertiesChain), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
if (chain_link == NULL) {
res = VK_ERROR_OUT_OF_HOST_MEMORY;
break;
}
memset(chain_link, 0, sizeof(VkEnumerateInstanceLayerPropertiesChain));
chain_link->header.type = VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES;
chain_link->header.version = VK_CURRENT_CHAIN_VERSION;
chain_link->header.size = sizeof(*chain_link);
chain_link->pfnNextLayer = pfn;
chain_link->pNextLink = chain_head;
chain_head = chain_link;
}
// Call down the chain
if (res == VK_SUCCESS) {
res = chain_head->pfnNextLayer(chain_head->pNextLink, pPropertyCount, pProperties);
}
// Free up the layers
loader_delete_layer_list_and_properties(NULL, &layers);
// Tear down the chain
while (chain_head != &chain_tail) {
VkEnumerateInstanceLayerPropertiesChain *holder = chain_head;
chain_head = (VkEnumerateInstanceLayerPropertiesChain *)chain_head->pNextLink;
loader_free(NULL, holder);
}
// Close the dl handles
for (size_t i = 0; i < lib_count; ++i) {
loader_platform_close_library(libs[i]);
}
loader_free(NULL, libs);
return res;
}
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion(uint32_t *pApiVersion) {
LOADER_PLATFORM_THREAD_ONCE(&once_init, loader_initialize);
update_global_loader_settings();
if (NULL == pApiVersion) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkEnumerateInstanceVersion: \'pApiVersion\' must not be NULL "
"(VUID-vkEnumerateInstanceVersion-pApiVersion-parameter");
// NOTE: This seems silly, but it's the only allowable failure
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
// We know we need to call at least the terminator
VkResult res = VK_SUCCESS;
VkEnumerateInstanceVersionChain chain_tail = {
.header =
{
.type = VK_CHAIN_TYPE_ENUMERATE_INSTANCE_VERSION,
.version = VK_CURRENT_CHAIN_VERSION,
.size = sizeof(chain_tail),
},
.pfnNextLayer = &terminator_EnumerateInstanceVersion,
.pNextLink = NULL,
};
VkEnumerateInstanceVersionChain *chain_head = &chain_tail;
// Get the implicit layers
struct loader_layer_list layers;
loader_platform_dl_handle *libs = NULL;
size_t lib_count = 0;
memset(&layers, 0, sizeof(layers));
res = loader_scan_for_implicit_layers(NULL, &layers);
if (VK_SUCCESS != res) {
return res;
}
res = loader_init_library_list(&layers, &libs);
if (VK_SUCCESS != res) {
return res;
}
// Prepend layers onto the chain if they implement this entry point
for (uint32_t i = 0; i < layers.count; ++i) {
// Skip this layer if it doesn't expose the entry-point
if (NULL == layers.list[i].pre_instance_functions.enumerate_instance_version) {
continue;
}
loader_platform_dl_handle layer_lib = loader_platform_open_library(layers.list[i].lib_name);
if (layer_lib == NULL) {
loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "%s: Unable to load implicit layer library \"%s\"", __FUNCTION__,
layers.list[i].lib_name);
continue;
}
libs[lib_count++] = layer_lib;
void *pfn = loader_platform_get_proc_address(layer_lib, layers.list[i].pre_instance_functions.enumerate_instance_version);
if (pfn == NULL) {
loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "%s: Unable to resolve symbol \"%s\" in implicit layer library \"%s\"",
__FUNCTION__, layers.list[i].pre_instance_functions.enumerate_instance_version, layers.list[i].lib_name);
continue;
}
VkEnumerateInstanceVersionChain *chain_link =
loader_alloc(NULL, sizeof(VkEnumerateInstanceVersionChain), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
if (chain_link == NULL) {
res = VK_ERROR_OUT_OF_HOST_MEMORY;
break;
}
memset(chain_link, 0, sizeof(VkEnumerateInstanceLayerPropertiesChain));
chain_link->header.type = VK_CHAIN_TYPE_ENUMERATE_INSTANCE_VERSION;
chain_link->header.version = VK_CURRENT_CHAIN_VERSION;
chain_link->header.size = sizeof(*chain_link);
chain_link->pfnNextLayer = pfn;
chain_link->pNextLink = chain_head;
chain_head = chain_link;
}
// Call down the chain
if (res == VK_SUCCESS) {
res = chain_head->pfnNextLayer(chain_head->pNextLink, pApiVersion);
}
// Free up the layers
loader_delete_layer_list_and_properties(NULL, &layers);
// Tear down the chain
while (chain_head != &chain_tail) {
VkEnumerateInstanceVersionChain *holder = chain_head;
chain_head = (VkEnumerateInstanceVersionChain *)chain_head->pNextLink;
loader_free(NULL, holder);
}
// Close the dl handles
for (size_t i = 0; i < lib_count; ++i) {
loader_platform_close_library(libs[i]);
}
loader_free(NULL, libs);
return res;
}
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) {
struct loader_instance *ptr_instance = NULL;
VkInstance created_instance = VK_NULL_HANDLE;
VkResult res = VK_ERROR_INITIALIZATION_FAILED;
VkInstanceCreateInfo ici = *pCreateInfo;
LOADER_PLATFORM_THREAD_ONCE(&once_init, loader_initialize);
if (pCreateInfo == NULL) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkCreateInstance: \'pCreateInfo\' is NULL (VUID-vkCreateInstance-pCreateInfo-parameter)");
goto out;
}
if (pInstance == NULL) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkCreateInstance \'pInstance\' not valid (VUID-vkCreateInstance-pInstance-parameter)");
goto out;
}
ptr_instance =
(struct loader_instance *)loader_calloc(pAllocator, sizeof(struct loader_instance), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (ptr_instance == NULL) {
res = VK_ERROR_OUT_OF_HOST_MEMORY;
goto out;
}
loader_platform_thread_lock_mutex(&loader_lock);
if (pAllocator) {
ptr_instance->alloc_callbacks = *pAllocator;
}
ptr_instance->magic = LOADER_MAGIC_NUMBER;
// Save the application version
if (NULL == pCreateInfo->pApplicationInfo || 0 == pCreateInfo->pApplicationInfo->apiVersion) {
ptr_instance->app_api_version = LOADER_VERSION_1_0_0;
} else {
ptr_instance->app_api_version = loader_make_version(pCreateInfo->pApplicationInfo->apiVersion);
}
// Look for one or more VK_EXT_debug_report or VK_EXT_debug_utils create info structures
// and setup a callback(s) for each one found.
// Handle cases of VK_EXT_debug_utils
// Setup the temporary messenger(s) here to catch early issues:
res = util_CreateDebugUtilsMessengers(ptr_instance, pCreateInfo->pNext, pAllocator);
if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
// Failure of setting up one or more of the messenger.
goto out;
}
// Handle cases of VK_EXT_debug_report
// Setup the temporary callback(s) here to catch early issues:
res = util_CreateDebugReportCallbacks(ptr_instance, pCreateInfo->pNext, pAllocator);
if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
// Failure of setting up one or more of the callback.
goto out;
}
VkResult settings_file_res = get_loader_settings(ptr_instance, &ptr_instance->settings);
if (settings_file_res == VK_ERROR_OUT_OF_HOST_MEMORY) {
res = settings_file_res;
goto out;
}
if (ptr_instance->settings.settings_active) {
log_settings(ptr_instance, &ptr_instance->settings);
}
// Check the VkInstanceCreateInfoFlags wether to allow the portability enumeration flag
if ((pCreateInfo->flags & VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR) == 1) {
// Make sure the extension has been enabled
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) == 0) {
ptr_instance->portability_enumeration_enabled = true;
loader_log(ptr_instance, VULKAN_LOADER_INFO_BIT, 0,
"Portability enumeration bit was set, enumerating portability drivers.");
}
}
}
// Make sure the application provided API version has 0 for its variant
if (NULL != pCreateInfo->pApplicationInfo) {
uint32_t variant_version = VK_API_VERSION_VARIANT(pCreateInfo->pApplicationInfo->apiVersion);
if (0 != variant_version) {
loader_log(ptr_instance, VULKAN_LOADER_WARN_BIT, 0,
"vkCreateInstance: The API Variant specified in pCreateInfo->pApplicationInfo.apiVersion is %d instead of "
"the expected value of 0.",
variant_version);
}
}
// Due to implicit layers need to get layer list even if
// enabledLayerCount == 0 and VK_INSTANCE_LAYERS is unset. For now always
// get layer list via loader_scan_for_layers().
memset(&ptr_instance->instance_layer_list, 0, sizeof(ptr_instance->instance_layer_list));
res = loader_scan_for_layers(ptr_instance, &ptr_instance->instance_layer_list);
if (VK_SUCCESS != res) {
goto out;
}
// Validate the app requested layers to be enabled
if (pCreateInfo->enabledLayerCount > 0) {
res = loader_validate_layers(ptr_instance, pCreateInfo->enabledLayerCount, pCreateInfo->ppEnabledLayerNames,
&ptr_instance->instance_layer_list);
if (res != VK_SUCCESS) {
goto out;
}
}
// Scan/discover all System and Environment Variable ICD libraries
bool skipped_portability_drivers = false;
res = loader_icd_scan(ptr_instance, &ptr_instance->icd_tramp_list, pCreateInfo, &skipped_portability_drivers);
if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
goto out;
}
if (ptr_instance->icd_tramp_list.count == 0) {
// No drivers found
if (skipped_portability_drivers) {
loader_log(
ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
"vkCreateInstance: Found drivers that contain devices which support the portability subset, but the "
"portability enumeration bit was not set! Applications that wish to enumerate portability drivers must set the "
"VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo flags and "
"enable the VK_KHR_portability_enumeration instance extension.");
}
loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0, "vkCreateInstance: Found no drivers!");
res = VK_ERROR_INCOMPATIBLE_DRIVER;
goto out;
}
// Get extensions from all ICD's, merge so no duplicates, then validate
res = loader_get_icd_loader_instance_extensions(ptr_instance, &ptr_instance->icd_tramp_list, &ptr_instance->ext_list);
if (res != VK_SUCCESS) {
goto out;
}
res = loader_validate_instance_extensions(ptr_instance, &ptr_instance->ext_list, &ptr_instance->instance_layer_list, &ici);
if (res != VK_SUCCESS) {
goto out;
}
ptr_instance->disp = loader_instance_heap_alloc(ptr_instance, sizeof(struct loader_instance_dispatch_table),
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (ptr_instance->disp == NULL) {
loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT, 0,
"vkCreateInstance: Failed to allocate Loader's full Instance dispatch table.");
res = VK_ERROR_OUT_OF_HOST_MEMORY;
goto out;
}
memcpy(&ptr_instance->disp->layer_inst_disp, &instance_disp, sizeof(instance_disp));
loader_platform_thread_lock_mutex(&loader_global_instance_list_lock);
ptr_instance->next = loader.instances;
loader.instances = ptr_instance;
loader_platform_thread_unlock_mutex(&loader_global_instance_list_lock);
// Activate any layers on instance chain
res = loader_enable_instance_layers(ptr_instance, &ici, &ptr_instance->instance_layer_list);
if (res != VK_SUCCESS) {
goto out;
}
created_instance = (VkInstance)ptr_instance;
res = loader_create_instance_chain(&ici, pAllocator, ptr_instance, &created_instance);
if (VK_SUCCESS == res) {
// Check for enabled extensions here to setup the loader structures so the loader knows what extensions
// it needs to worry about.
// We do it in the terminator and again above the layers here since we may think different extensions
// are enabled than what's down in the terminator.
// This is why we don't clear inside of these function calls.
// The clearing should actually be handled by the overall memset of the pInstance structure above.
wsi_create_instance(ptr_instance, &ici);
check_for_enabled_debug_extensions(ptr_instance, &ici);
extensions_create_instance(ptr_instance, &ici);
*pInstance = (VkInstance)ptr_instance;
// Finally have the layers in place and everyone has seen
// the CreateInstance command go by. This allows the layer's
// GetInstanceProcAddr functions to return valid extension functions
// if enabled.
loader_activate_instance_layer_extensions(ptr_instance, created_instance);
ptr_instance->instance_finished_creation = true;
} else if (VK_ERROR_EXTENSION_NOT_PRESENT == res && !ptr_instance->create_terminator_invalid_extension) {
loader_log(ptr_instance, VULKAN_LOADER_WARN_BIT, 0,
"vkCreateInstance: Layer returning invalid extension error not triggered by ICD/Loader (Policy #LLP_LAYER_17).");
}
out:
if (NULL != ptr_instance) {
if (res != VK_SUCCESS) {
loader_platform_thread_lock_mutex(&loader_global_instance_list_lock);
// error path, should clean everything up
if (loader.instances == ptr_instance) {
loader.instances = ptr_instance->next;
}
loader_platform_thread_unlock_mutex(&loader_global_instance_list_lock);
free_loader_settings(ptr_instance, &ptr_instance->settings);
loader_instance_heap_free(ptr_instance, ptr_instance->disp);
// Remove any created VK_EXT_debug_report or VK_EXT_debug_utils items
destroy_debug_callbacks_chain(ptr_instance, pAllocator);
loader_destroy_pointer_layer_list(ptr_instance, &ptr_instance->expanded_activated_layer_list);
loader_destroy_pointer_layer_list(ptr_instance, &ptr_instance->app_activated_layer_list);
loader_delete_layer_list_and_properties(ptr_instance, &ptr_instance->instance_layer_list);
loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_tramp_list);
loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&ptr_instance->ext_list);
// Free any icd_terms that were created.
// If an OOM occurs from a layer, terminator_CreateInstance won't be reached where this kind of
// cleanup normally occurs
struct loader_icd_term *icd_term = NULL;
while (NULL != ptr_instance->icd_terms) {
icd_term = ptr_instance->icd_terms;
// Call destroy Instance on each driver in case we successfully called down the chain but failed on
// our way back out of it.
if (icd_term->instance) {
icd_term->dispatch.DestroyInstance(icd_term->instance, pAllocator);
}
icd_term->instance = VK_NULL_HANDLE;
ptr_instance->icd_terms = icd_term->next;
loader_icd_destroy(ptr_instance, icd_term, pAllocator);
}
free_string_list(ptr_instance, &ptr_instance->enabled_layer_names);
loader_instance_heap_free(ptr_instance, ptr_instance);
} else {
// success path, swap out created debug callbacks out so they aren't used until instance destruction
ptr_instance->InstanceCreationDeletionDebugFunctionHead = ptr_instance->DbgFunctionHead;
ptr_instance->DbgFunctionHead = NULL;
}
// Only unlock when ptr_instance isn't NULL, as if it is, the above code didn't make it to when loader_lock was locked.
loader_platform_thread_unlock_mutex(&loader_lock);
}
return res;
}
LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
const VkLayerInstanceDispatchTable *disp;
struct loader_instance *ptr_instance = NULL;
if (instance == VK_NULL_HANDLE) {
return;
}
loader_platform_thread_lock_mutex(&loader_lock);
ptr_instance = loader_get_instance(instance);
if (ptr_instance == NULL) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkDestroyInstance: Invalid instance [VUID-vkDestroyInstance-instance-parameter]");
loader_platform_thread_unlock_mutex(&loader_lock);
abort(); /* Intentionally fail so user can correct issue. */
}
if (pAllocator) {
ptr_instance->alloc_callbacks = *pAllocator;
}
// Remove any callbacks that weren't cleaned up by the application
destroy_debug_callbacks_chain(ptr_instance, pAllocator);
// Swap in the debug callbacks created during instance creation
ptr_instance->DbgFunctionHead = ptr_instance->InstanceCreationDeletionDebugFunctionHead;
ptr_instance->InstanceCreationDeletionDebugFunctionHead = NULL;
disp = loader_get_instance_layer_dispatch(instance);
disp->DestroyInstance(ptr_instance->instance, pAllocator);
free_loader_settings(ptr_instance, &ptr_instance->settings);
loader_destroy_pointer_layer_list(ptr_instance, &ptr_instance->expanded_activated_layer_list);
loader_destroy_pointer_layer_list(ptr_instance, &ptr_instance->app_activated_layer_list);
loader_delete_layer_list_and_properties(ptr_instance, &ptr_instance->instance_layer_list);
free_string_list(ptr_instance, &ptr_instance->enabled_layer_names);
if (ptr_instance->phys_devs_tramp) {
for (uint32_t i = 0; i < ptr_instance->phys_dev_count_tramp; i++) {
loader_instance_heap_free(ptr_instance, ptr_instance->phys_devs_tramp[i]);
}
loader_instance_heap_free(ptr_instance, ptr_instance->phys_devs_tramp);
}
// Destroy the debug callbacks created during instance creation
destroy_debug_callbacks_chain(ptr_instance, pAllocator);
loader_instance_heap_free(ptr_instance, ptr_instance->disp);
loader_instance_heap_free(ptr_instance, ptr_instance);
loader_platform_thread_unlock_mutex(&loader_lock);
// Unload preloaded layers, so if vkEnumerateInstanceExtensionProperties or vkCreateInstance is called again, the ICD's are
// up to date
loader_unload_preloaded_icds();
}
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
VkPhysicalDevice *pPhysicalDevices) {
VkResult res = VK_SUCCESS;
struct loader_instance *inst;
loader_platform_thread_lock_mutex(&loader_lock);
inst = loader_get_instance(instance);
if (NULL == inst) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkEnumeratePhysicalDevices: Invalid instance [VUID-vkEnumeratePhysicalDevices-instance-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
if (NULL == pPhysicalDeviceCount) {
loader_log(inst, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkEnumeratePhysicalDevices: Received NULL pointer for physical device count return value. "
"[VUID-vkEnumeratePhysicalDevices-pPhysicalDeviceCount-parameter]");
res = VK_ERROR_INITIALIZATION_FAILED;
goto out;
}
// Call down the chain to get the physical device info
res = inst->disp->layer_inst_disp.EnumeratePhysicalDevices(inst->instance, pPhysicalDeviceCount, pPhysicalDevices);
if (NULL != pPhysicalDevices && (VK_SUCCESS == res || VK_INCOMPLETE == res)) {
// Wrap the PhysDev object for loader usage, return wrapped objects
VkResult update_res = setup_loader_tramp_phys_devs(inst, *pPhysicalDeviceCount, pPhysicalDevices);
if (VK_SUCCESS != update_res) {
res = update_res;
}
}
out:
loader_platform_thread_unlock_mutex(&loader_lock);
return res;
}
LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice,
VkPhysicalDeviceFeatures *pFeatures) {
const VkLayerInstanceDispatchTable *disp;
VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
if (VK_NULL_HANDLE == unwrapped_phys_dev) {
loader_log(
NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkGetPhysicalDeviceFeatures: Invalid physicalDevice [VUID-vkGetPhysicalDeviceFeatures-physicalDevice-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
disp = loader_get_instance_layer_dispatch(physicalDevice);
disp->GetPhysicalDeviceFeatures(unwrapped_phys_dev, pFeatures);
}
LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format,
VkFormatProperties *pFormatInfo) {
const VkLayerInstanceDispatchTable *disp;
VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
if (VK_NULL_HANDLE == unwrapped_phys_dev) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkGetPhysicalDeviceFormatProperties: Invalid physicalDevice "
"[VUID-vkGetPhysicalDeviceFormatProperties-physicalDevice-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
disp = loader_get_instance_layer_dispatch(physicalDevice);
disp->GetPhysicalDeviceFormatProperties(unwrapped_phys_dev, format, pFormatInfo);
}
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(
VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) {
const VkLayerInstanceDispatchTable *disp;
VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
if (VK_NULL_HANDLE == unwrapped_phys_dev) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkGetPhysicalDeviceImageFormatProperties: Invalid physicalDevice "
"[VUID-vkGetPhysicalDeviceImageFormatProperties-physicalDevice-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
disp = loader_get_instance_layer_dispatch(physicalDevice);
return disp->GetPhysicalDeviceImageFormatProperties(unwrapped_phys_dev, format, type, tiling, usage, flags,
pImageFormatProperties);
}
LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
VkPhysicalDeviceProperties *pProperties) {
const VkLayerInstanceDispatchTable *disp;
VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
if (VK_NULL_HANDLE == unwrapped_phys_dev) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkGetPhysicalDeviceProperties: Invalid physicalDevice "
"[VUID-vkGetPhysicalDeviceProperties-physicalDevice-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
disp = loader_get_instance_layer_dispatch(physicalDevice);
disp->GetPhysicalDeviceProperties(unwrapped_phys_dev, pProperties);
}
LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice,
uint32_t *pQueueFamilyPropertyCount,
VkQueueFamilyProperties *pQueueProperties) {
const VkLayerInstanceDispatchTable *disp;
VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
if (VK_NULL_HANDLE == unwrapped_phys_dev) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkGetPhysicalDeviceQueueFamilyProperties: Invalid physicalDevice "
"[VUID-vkGetPhysicalDeviceQueueFamilyProperties-physicalDevice-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
disp = loader_get_instance_layer_dispatch(physicalDevice);
disp->GetPhysicalDeviceQueueFamilyProperties(unwrapped_phys_dev, pQueueFamilyPropertyCount, pQueueProperties);
}
LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice,
VkPhysicalDeviceMemoryProperties *pMemoryProperties) {
const VkLayerInstanceDispatchTable *disp;
VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
if (VK_NULL_HANDLE == unwrapped_phys_dev) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkGetPhysicalDeviceMemoryProperties: Invalid physicalDevice "
"[VUID-vkGetPhysicalDeviceMemoryProperties-physicalDevice-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
disp = loader_get_instance_layer_dispatch(physicalDevice);
disp->GetPhysicalDeviceMemoryProperties(unwrapped_phys_dev, pMemoryProperties);
}
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) {
if (VK_NULL_HANDLE == loader_unwrap_physical_device(physicalDevice)) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkCreateDevice: Invalid physicalDevice [VUID-vkCreateDevice-physicalDevice-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
loader_platform_thread_lock_mutex(&loader_lock);
VkResult res = loader_layer_create_device(NULL, physicalDevice, pCreateInfo, pAllocator, pDevice, NULL, NULL);
loader_platform_thread_unlock_mutex(&loader_lock);
return res;
}
LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) {
const VkLayerDispatchTable *disp;
if (device == VK_NULL_HANDLE) {
return;
}
disp = loader_get_dispatch(device);
if (NULL == disp) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkDestroyDevice: Invalid device [VUID-vkDestroyDevice-device-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
loader_platform_thread_lock_mutex(&loader_lock);
loader_layer_destroy_device(device, pAllocator, disp->DestroyDevice);
loader_platform_thread_unlock_mutex(&loader_lock);
}
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
const char *pLayerName, uint32_t *pPropertyCount,
VkExtensionProperties *pProperties) {
VkResult res = VK_SUCCESS;
struct loader_physical_device_tramp *phys_dev;
const VkLayerInstanceDispatchTable *disp;
phys_dev = (struct loader_physical_device_tramp *)physicalDevice;
if (VK_NULL_HANDLE == physicalDevice || PHYS_TRAMP_MAGIC_NUMBER != phys_dev->magic) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkEnumerateDeviceExtensionProperties: Invalid physicalDevice "
"[VUID-vkEnumerateDeviceExtensionProperties-physicalDevice-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
loader_platform_thread_lock_mutex(&loader_lock);
// always pass this call down the instance chain which will terminate
// in the ICD. This allows layers to filter the extensions coming back
// up the chain. In the terminator we look up layer extensions from the
// manifest file if it wasn't provided by the layer itself.
disp = loader_get_instance_layer_dispatch(physicalDevice);
res = disp->EnumerateDeviceExtensionProperties(phys_dev->phys_dev, pLayerName, pPropertyCount, pProperties);
loader_platform_thread_unlock_mutex(&loader_lock);
return res;
}
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice,
uint32_t *pPropertyCount,
VkLayerProperties *pProperties) {
uint32_t copy_size;
struct loader_physical_device_tramp *phys_dev;
loader_platform_thread_lock_mutex(&loader_lock);
// Don't dispatch this call down the instance chain, want all device layers
// enumerated and instance chain may not contain all device layers
// TODO re-evaluate the above statement we maybe able to start calling
// down the chain
phys_dev = (struct loader_physical_device_tramp *)physicalDevice;
if (VK_NULL_HANDLE == physicalDevice || PHYS_TRAMP_MAGIC_NUMBER != phys_dev->magic) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkEnumerateDeviceLayerProperties: Invalid physicalDevice "
"[VUID-vkEnumerateDeviceLayerProperties-physicalDevice-parameter]");
loader_platform_thread_unlock_mutex(&loader_lock);
abort(); /* Intentionally fail so user can correct issue. */
}
const struct loader_instance *inst = phys_dev->this_instance;
uint32_t count = inst->app_activated_layer_list.count;
if (count == 0 || pProperties == NULL) {
*pPropertyCount = count;
loader_platform_thread_unlock_mutex(&loader_lock);
return VK_SUCCESS;
}
copy_size = (*pPropertyCount < count) ? *pPropertyCount : count;
for (uint32_t i = 0; i < copy_size; i++) {
memcpy(&pProperties[i], &(inst->app_activated_layer_list.list[i]->info), sizeof(VkLayerProperties));
}
*pPropertyCount = copy_size;
if (copy_size < count) {
loader_platform_thread_unlock_mutex(&loader_lock);
return VK_INCOMPLETE;
}
loader_platform_thread_unlock_mutex(&loader_lock);
return VK_SUCCESS;
}
LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueNodeIndex, uint32_t queueIndex,
VkQueue *pQueue) {
const VkLayerDispatchTable *disp = loader_get_dispatch(device);
if (NULL == disp) {
loader_log(NULL, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
"vkGetDeviceQueue: Invalid device [VUID-vkGetDeviceQueue-device-parameter]");
abort(); /* Intentionally fail so user can correct issue. */
}
disp->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue);
if (pQueue != NULL && *pQueue != NULL) {
loader_set_dispatch(*pQueue, disp);
}
}
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits,
VkFence fence) {