blob: 257ece7be2eacefe4c4eb6b2f97ee32c8435dc60 [file] [log] [blame]
Jon Ashburnd55a3942015-05-06 09:02:10 -06001/*
Jon Ashburnd55a3942015-05-06 09:02:10 -06002 *
Jon Ashburn23d36b12016-02-02 17:47:28 -07003 * Copyright (c) 2015-2016 The Khronos Group Inc.
4 * Copyright (c) 2015-2016 Valve Corporation
5 * Copyright (c) 2015-2016 LunarG, Inc.
Courtney Goeltzenleuchterf821dad2015-12-02 14:53:22 -07006 * Copyright (C) 2015 Google Inc.
Jon Ashburnd55a3942015-05-06 09:02:10 -06007 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -06008 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
Jon Ashburnd55a3942015-05-06 09:02:10 -060011 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -060012 * http://www.apache.org/licenses/LICENSE-2.0
Jon Ashburnd55a3942015-05-06 09:02:10 -060013 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -060014 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
Jon Ashburn23d36b12016-02-02 17:47:28 -070019 *
20 * Author: Courtney Goeltzenleuchter <courtney@lunarg.com>
Courtney Goeltzenleuchter05559522015-10-30 11:14:30 -060021 * Author: Jon Ashburn <jon@lunarg.com>
22 * Author: Tony Barbour <tony@LunarG.com>
Jon Ashburn23d36b12016-02-02 17:47:28 -070023 * Author: Chia-I Wu <olv@lunarg.com>
Jon Ashburnd55a3942015-05-06 09:02:10 -060024 */
Courtney Goeltzenleuchter7f5aafc2015-07-05 11:28:29 -060025#define _GNU_SOURCE
Jon Ashburn27cd5842015-05-12 17:26:48 -060026#include <stdlib.h>
27#include <string.h>
Jon Ashburnd55a3942015-05-06 09:02:10 -060028
Tobin Ehlisb835d1b2015-07-03 10:34:49 -060029#include "vk_loader_platform.h"
Jon Ashburnd55a3942015-05-06 09:02:10 -060030#include "loader.h"
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060031#include "debug_report.h"
Ian Elliott954fa342015-10-30 15:28:23 -060032#include "wsi.h"
Mark Lobodzinski317574e2016-08-29 14:21:14 -060033#include "extensions.h"
Jon Ashburn1530c342016-02-26 13:14:27 -070034#include "gpa_helper.h"
35#include "table_ops.h"
Jon Ashburnd55a3942015-05-06 09:02:10 -060036
Jon Ashburn1530c342016-02-26 13:14:27 -070037/* Trampoline entrypoints are in this file for core Vulkan commands */
38/**
39 * Get an instance level or global level entry point address.
40 * @param instance
41 * @param pName
42 * @return
43 * If instance == NULL returns a global level functions only
44 * If instance is valid returns a trampoline entry point for all dispatchable
45 * Vulkan
46 * functions both core and extensions.
47 */
48LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
49vkGetInstanceProcAddr(VkInstance instance, const char *pName) {
50
51 void *addr;
52
53 addr = globalGetProcAddr(pName);
54 if (instance == VK_NULL_HANDLE) {
55 // get entrypoint addresses that are global (no dispatchable object)
56
57 return addr;
58 } else {
59 // if a global entrypoint return NULL
60 if (addr)
61 return NULL;
62 }
63
64 struct loader_instance *ptr_instance = loader_get_instance(instance);
65 if (ptr_instance == NULL)
66 return NULL;
67 // Return trampoline code for non-global entrypoints including any
68 // extensions.
69 // Device extensions are returned if a layer or ICD supports the extension.
70 // Instance extensions are returned if the extension is enabled and the
Michael Jurka5c16c002016-12-19 16:31:43 +010071 // loader or someone else supports the extension
Jon Ashburn1530c342016-02-26 13:14:27 -070072 return trampolineGetProcAddr(ptr_instance, pName);
73}
74
75/**
76 * Get a device level or global level entry point address.
77 * @param device
78 * @param pName
79 * @return
80 * If device is valid, returns a device relative entry point for device level
81 * entry points both core and extensions.
82 * Device relative means call down the device chain.
83 */
84LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
85vkGetDeviceProcAddr(VkDevice device, const char *pName) {
86 void *addr;
87
88 /* for entrypoints that loader must handle (ie non-dispatchable or create
89 object)
90 make sure the loader entrypoint is returned */
91 addr = loader_non_passthrough_gdpa(pName);
92 if (addr) {
93 return addr;
94 }
95
96 /* Although CreateDevice is on device chain it's dispatchable object isn't
97 * a VkDevice or child of VkDevice so return NULL.
98 */
99 if (!strcmp(pName, "CreateDevice"))
100 return NULL;
101
102 /* return the dispatch table entrypoint for the fastest case */
103 const VkLayerDispatchTable *disp_table = *(VkLayerDispatchTable **)device;
104 if (disp_table == NULL)
105 return NULL;
106
107 addr = loader_lookup_device_dispatch_table(disp_table, pName);
108 if (addr)
109 return addr;
110
111 if (disp_table->GetDeviceProcAddr == NULL)
112 return NULL;
113 return disp_table->GetDeviceProcAddr(device, pName);
114}
115
116LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
117vkEnumerateInstanceExtensionProperties(const char *pLayerName,
118 uint32_t *pPropertyCount,
119 VkExtensionProperties *pProperties) {
120 struct loader_extension_list *global_ext_list = NULL;
121 struct loader_layer_list instance_layers;
Jon Ashburnb8726962016-04-08 15:03:35 -0600122 struct loader_extension_list local_ext_list;
Mark Young0153e0b2016-11-03 14:27:13 -0600123 struct loader_icd_tramp_list icd_tramp_list;
Jon Ashburn1530c342016-02-26 13:14:27 -0700124 uint32_t copy_size;
Mark Young0ad83132016-06-30 13:02:42 -0600125 VkResult res = VK_SUCCESS;
Jon Ashburn1530c342016-02-26 13:14:27 -0700126
127 tls_instance = NULL;
Jon Ashburnb8726962016-04-08 15:03:35 -0600128 memset(&local_ext_list, 0, sizeof(local_ext_list));
Jon Ashburn1530c342016-02-26 13:14:27 -0700129 memset(&instance_layers, 0, sizeof(instance_layers));
130 loader_platform_thread_once(&once_init, loader_initialize);
131
132 /* get layer libraries if needed */
133 if (pLayerName && strlen(pLayerName) != 0) {
Jeremy Hayes3e2bd5a2016-04-01 11:40:26 -0600134 if (vk_string_validate(MaxLoaderStringLength, pLayerName) !=
Jon Ashburn1530c342016-02-26 13:14:27 -0700135 VK_STRING_ERROR_NONE) {
Jon Ashburn1530c342016-02-26 13:14:27 -0700136 assert(VK_FALSE && "vkEnumerateInstanceExtensionProperties: "
137 "pLayerName is too long or is badly formed");
Mark Young0ad83132016-06-30 13:02:42 -0600138 res = VK_ERROR_EXTENSION_NOT_PRESENT;
139 goto out;
Jon Ashburn1530c342016-02-26 13:14:27 -0700140 }
Jeremy Hayes3e2bd5a2016-04-01 11:40:26 -0600141
Jon Ashburn491cd042016-05-16 14:01:18 -0600142 loader_layer_scan(NULL, &instance_layers);
Jon Ashburnb8726962016-04-08 15:03:35 -0600143 if (strcmp(pLayerName, std_validation_str) == 0) {
144 struct loader_layer_list local_list;
145 memset(&local_list, 0, sizeof(local_list));
146 for (uint32_t i = 0; i < sizeof(std_validation_names) /
147 sizeof(std_validation_names[0]);
148 i++) {
149 loader_find_layer_name_add_list(NULL, std_validation_names[i],
150 VK_LAYER_TYPE_INSTANCE_EXPLICIT,
151 &instance_layers, &local_list);
152 }
153 for (uint32_t i = 0; i < local_list.count; i++) {
154 struct loader_extension_list *ext_list =
Jon Ashburncc407a22016-04-15 09:25:03 -0600155 &local_list.list[i].instance_extension_list;
Jon Ashburnb8726962016-04-08 15:03:35 -0600156 loader_add_to_ext_list(NULL, &local_ext_list, ext_list->count,
157 ext_list->list);
158 }
Mark Youngd9ccdd32016-08-01 11:34:36 -0600159 loader_destroy_layer_list(NULL, NULL, &local_list);
Jon Ashburnb8726962016-04-08 15:03:35 -0600160 global_ext_list = &local_ext_list;
161
162 } else {
163 for (uint32_t i = 0; i < instance_layers.count; i++) {
164 struct loader_layer_properties *props =
165 &instance_layers.list[i];
166 if (strcmp(props->info.layerName, pLayerName) == 0) {
167 global_ext_list = &props->instance_extension_list;
168 break;
169 }
Jeremy Hayes3e2bd5a2016-04-01 11:40:26 -0600170 }
171 }
Jon Ashburn1530c342016-02-26 13:14:27 -0700172 } else {
173 /* Scan/discover all ICD libraries */
Mark Young0153e0b2016-11-03 14:27:13 -0600174 memset(&icd_tramp_list, 0, sizeof(struct loader_icd_tramp_list));
175 res = loader_icd_scan(NULL, &icd_tramp_list);
Mark Young0ad83132016-06-30 13:02:42 -0600176 if (VK_SUCCESS != res) {
177 goto out;
178 }
Jon Ashburn1530c342016-02-26 13:14:27 -0700179 /* get extensions from all ICD's, merge so no duplicates */
Mark Young0153e0b2016-11-03 14:27:13 -0600180 res = loader_get_icd_loader_instance_extensions(NULL, &icd_tramp_list,
Mark Young3a587792016-08-19 15:25:08 -0600181 &local_ext_list);
182 if (VK_SUCCESS != res) {
183 goto out;
184 }
Mark Young0153e0b2016-11-03 14:27:13 -0600185 loader_scanned_icd_clear(NULL, &icd_tramp_list);
Jeremy Hayes3e2bd5a2016-04-01 11:40:26 -0600186
187 // Append implicit layers.
Jon Ashburn491cd042016-05-16 14:01:18 -0600188 loader_implicit_layer_scan(NULL, &instance_layers);
Jeremy Hayes3e2bd5a2016-04-01 11:40:26 -0600189 for (uint32_t i = 0; i < instance_layers.count; i++) {
Jon Ashburncc407a22016-04-15 09:25:03 -0600190 struct loader_extension_list *ext_list =
191 &instance_layers.list[i].instance_extension_list;
192 loader_add_to_ext_list(NULL, &local_ext_list, ext_list->count,
193 ext_list->list);
Jeremy Hayes3e2bd5a2016-04-01 11:40:26 -0600194 }
195
Jon Ashburnb8726962016-04-08 15:03:35 -0600196 global_ext_list = &local_ext_list;
Jon Ashburn1530c342016-02-26 13:14:27 -0700197 }
198
199 if (global_ext_list == NULL) {
Mark Young0ad83132016-06-30 13:02:42 -0600200 res = VK_ERROR_LAYER_NOT_PRESENT;
201 goto out;
Jon Ashburn1530c342016-02-26 13:14:27 -0700202 }
203
204 if (pProperties == NULL) {
205 *pPropertyCount = global_ext_list->count;
Mark Young0ad83132016-06-30 13:02:42 -0600206 goto out;
Jon Ashburn1530c342016-02-26 13:14:27 -0700207 }
208
209 copy_size = *pPropertyCount < global_ext_list->count
210 ? *pPropertyCount
211 : global_ext_list->count;
212 for (uint32_t i = 0; i < copy_size; i++) {
213 memcpy(&pProperties[i], &global_ext_list->list[i],
214 sizeof(VkExtensionProperties));
215 }
216 *pPropertyCount = copy_size;
Jon Ashburn1530c342016-02-26 13:14:27 -0700217
218 if (copy_size < global_ext_list->count) {
Mark Young0ad83132016-06-30 13:02:42 -0600219 res = VK_INCOMPLETE;
220 goto out;
Jon Ashburn1530c342016-02-26 13:14:27 -0700221 }
222
Mark Young0ad83132016-06-30 13:02:42 -0600223out:
Mark Young6267ae62017-01-12 12:27:19 -0700224
Mark Young0153e0b2016-11-03 14:27:13 -0600225 loader_destroy_generic_list(NULL,
226 (struct loader_generic_list *)&local_ext_list);
davidhubbard36831082016-07-27 17:59:58 -0700227 loader_delete_layer_properties(NULL, &instance_layers);
Mark Young0ad83132016-06-30 13:02:42 -0600228 return res;
Jon Ashburn1530c342016-02-26 13:14:27 -0700229}
230
Mark Young0153e0b2016-11-03 14:27:13 -0600231LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(
232 uint32_t *pPropertyCount, VkLayerProperties *pProperties) {
Jon Ashburn1530c342016-02-26 13:14:27 -0700233
234 struct loader_layer_list instance_layer_list;
235 tls_instance = NULL;
236
237 loader_platform_thread_once(&once_init, loader_initialize);
238
239 uint32_t copy_size;
240
241 /* get layer libraries */
242 memset(&instance_layer_list, 0, sizeof(instance_layer_list));
Jon Ashburn491cd042016-05-16 14:01:18 -0600243 loader_layer_scan(NULL, &instance_layer_list);
Jon Ashburn1530c342016-02-26 13:14:27 -0700244
245 if (pProperties == NULL) {
246 *pPropertyCount = instance_layer_list.count;
Mark Young0ad83132016-06-30 13:02:42 -0600247 loader_destroy_layer_list(NULL, NULL, &instance_layer_list);
Jon Ashburn1530c342016-02-26 13:14:27 -0700248 return VK_SUCCESS;
249 }
250
251 copy_size = (*pPropertyCount < instance_layer_list.count)
252 ? *pPropertyCount
253 : instance_layer_list.count;
254 for (uint32_t i = 0; i < copy_size; i++) {
255 memcpy(&pProperties[i], &instance_layer_list.list[i].info,
256 sizeof(VkLayerProperties));
257 }
258
259 *pPropertyCount = copy_size;
Jon Ashburn1530c342016-02-26 13:14:27 -0700260
261 if (copy_size < instance_layer_list.count) {
Jeremy Hayese852f132016-07-06 12:02:03 -0600262 loader_destroy_layer_list(NULL, NULL, &instance_layer_list);
Jon Ashburn1530c342016-02-26 13:14:27 -0700263 return VK_INCOMPLETE;
264 }
265
Jeremy Hayese852f132016-07-06 12:02:03 -0600266 loader_destroy_layer_list(NULL, NULL, &instance_layer_list);
267
Jon Ashburn1530c342016-02-26 13:14:27 -0700268 return VK_SUCCESS;
269}
270
Mark Young0ad83132016-06-30 13:02:42 -0600271LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
272 const VkInstanceCreateInfo *pCreateInfo,
273 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) {
Jon Ashburn27cd5842015-05-12 17:26:48 -0600274 struct loader_instance *ptr_instance = NULL;
Jon Ashburne5b9bba2016-01-18 12:20:03 -0700275 VkInstance created_instance = VK_NULL_HANDLE;
Mark Young0ad83132016-06-30 13:02:42 -0600276 bool loaderLocked = false;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600277 VkResult res = VK_ERROR_INITIALIZATION_FAILED;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600278
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600279 loader_platform_thread_once(&once_init, loader_initialize);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600280
Mark Young0ad83132016-06-30 13:02:42 -0600281#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
282 {
283#else
284 if (pAllocator) {
285 ptr_instance = (struct loader_instance *)pAllocator->pfnAllocation(
286 pAllocator->pUserData, sizeof(struct loader_instance),
287 sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Courtney Goeltzenleuchter81095102015-07-06 09:08:37 -0600288 } else {
Jon Ashburnf9af1d32016-01-25 14:51:47 -0700289#endif
Mark Young0ad83132016-06-30 13:02:42 -0600290 ptr_instance =
291 (struct loader_instance *)malloc(sizeof(struct loader_instance));
292 }
293
294 VkInstanceCreateInfo ici = *pCreateInfo;
295
Jon Ashburn27cd5842015-05-12 17:26:48 -0600296 if (ptr_instance == NULL) {
Mark Young0ad83132016-06-30 13:02:42 -0600297 res = VK_ERROR_OUT_OF_HOST_MEMORY;
298 goto out;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600299 }
Courtney Goeltzenleuchter81095102015-07-06 09:08:37 -0600300
Jon Ashburn87d6aa92015-08-28 15:19:27 -0600301 tls_instance = ptr_instance;
Courtney Goeltzenleuchter81095102015-07-06 09:08:37 -0600302 loader_platform_thread_lock_mutex(&loader_lock);
Mark Young0ad83132016-06-30 13:02:42 -0600303 loaderLocked = true;
Jon Ashburnb82c1852015-08-11 14:49:54 -0600304 memset(ptr_instance, 0, sizeof(struct loader_instance));
Chia-I Wuf7458c52015-10-26 21:10:41 +0800305 if (pAllocator) {
306 ptr_instance->alloc_callbacks = *pAllocator;
Courtney Goeltzenleuchter7f5aafc2015-07-05 11:28:29 -0600307 }
308
Courtney Goeltzenleuchter45cde5d2015-12-03 13:45:51 -0700309 /*
Ian Elliottad6300f2016-03-31 10:48:19 -0600310 * Look for one or more debug report create info structures
311 * and setup a callback(s) for each one found.
Courtney Goeltzenleuchter45cde5d2015-12-03 13:45:51 -0700312 */
Ian Elliottad6300f2016-03-31 10:48:19 -0600313 ptr_instance->num_tmp_callbacks = 0;
314 ptr_instance->tmp_dbg_create_infos = NULL;
315 ptr_instance->tmp_callbacks = NULL;
Jon Ashburncc407a22016-04-15 09:25:03 -0600316 if (util_CopyDebugReportCreateInfos(pCreateInfo->pNext, pAllocator,
Ian Elliottad6300f2016-03-31 10:48:19 -0600317 &ptr_instance->num_tmp_callbacks,
318 &ptr_instance->tmp_dbg_create_infos,
319 &ptr_instance->tmp_callbacks)) {
320 // One or more were found, but allocation failed. Therefore, clean up
321 // and fail this function:
Mark Young0ad83132016-06-30 13:02:42 -0600322 res = VK_ERROR_OUT_OF_HOST_MEMORY;
323 goto out;
Ian Elliottad6300f2016-03-31 10:48:19 -0600324 } else if (ptr_instance->num_tmp_callbacks > 0) {
325 // Setup the temporary callback(s) here to catch early issues:
Jon Ashburncc407a22016-04-15 09:25:03 -0600326 if (util_CreateDebugReportCallbacks(ptr_instance, pAllocator,
Ian Elliottad6300f2016-03-31 10:48:19 -0600327 ptr_instance->num_tmp_callbacks,
328 ptr_instance->tmp_dbg_create_infos,
329 ptr_instance->tmp_callbacks)) {
330 // Failure of setting up one or more of the callback. Therefore,
331 // clean up and fail this function:
Mark Young0ad83132016-06-30 13:02:42 -0600332 res = VK_ERROR_OUT_OF_HOST_MEMORY;
333 goto out;
Courtney Goeltzenleuchter82887272015-12-02 15:29:33 -0700334 }
335 }
336
Jon Ashburn3d002332015-08-20 16:35:30 -0600337 /* Due to implicit layers need to get layer list even if
Jon Ashburnf19916e2016-01-11 13:12:43 -0700338 * enabledLayerCount == 0 and VK_INSTANCE_LAYERS is unset. For now always
Jon Ashburn491cd042016-05-16 14:01:18 -0600339 * get layer list via loader_layer_scan(). */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700340 memset(&ptr_instance->instance_layer_list, 0,
341 sizeof(ptr_instance->instance_layer_list));
Jon Ashburn491cd042016-05-16 14:01:18 -0600342 loader_layer_scan(ptr_instance, &ptr_instance->instance_layer_list);
Jon Ashburn3d002332015-08-20 16:35:30 -0600343
344 /* validate the app requested layers to be enabled */
Jon Ashburnf19916e2016-01-11 13:12:43 -0700345 if (pCreateInfo->enabledLayerCount > 0) {
Jon Ashburnf2b4e382016-02-10 20:50:19 -0700346 res =
347 loader_validate_layers(ptr_instance, pCreateInfo->enabledLayerCount,
348 pCreateInfo->ppEnabledLayerNames,
349 &ptr_instance->instance_layer_list);
Jon Ashburn3d002332015-08-20 16:35:30 -0600350 if (res != VK_SUCCESS) {
Mark Young0ad83132016-06-30 13:02:42 -0600351 goto out;
Jon Ashburn3d002332015-08-20 16:35:30 -0600352 }
353 }
354
Jon Ashburn86a527a2016-02-10 20:59:26 -0700355 /* convert any meta layers to the actual layers makes a copy of layer name*/
Mark Young0ad83132016-06-30 13:02:42 -0600356 VkResult layerErr = loader_expand_layer_names(
Jon Ashburn86a527a2016-02-10 20:59:26 -0700357 ptr_instance, std_validation_str,
358 sizeof(std_validation_names) / sizeof(std_validation_names[0]),
Jon Ashburncc407a22016-04-15 09:25:03 -0600359 std_validation_names, &ici.enabledLayerCount, &ici.ppEnabledLayerNames);
Mark Young0ad83132016-06-30 13:02:42 -0600360 if (VK_SUCCESS != layerErr) {
361 res = layerErr;
362 goto out;
363 }
Jon Ashburn86a527a2016-02-10 20:59:26 -0700364
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600365 /* Scan/discover all ICD libraries */
Mark Young0153e0b2016-11-03 14:27:13 -0600366 memset(&ptr_instance->icd_tramp_list, 0,
367 sizeof(ptr_instance->icd_tramp_list));
368 res = loader_icd_scan(ptr_instance, &ptr_instance->icd_tramp_list);
Mark Young0ad83132016-06-30 13:02:42 -0600369 if (res != VK_SUCCESS) {
370 goto out;
371 }
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600372
Jon Ashburneacfa3a2015-08-14 12:51:47 -0600373 /* get extensions from all ICD's, merge so no duplicates, then validate */
Mark Young3a587792016-08-19 15:25:08 -0600374 res = loader_get_icd_loader_instance_extensions(
Mark Young0153e0b2016-11-03 14:27:13 -0600375 ptr_instance, &ptr_instance->icd_tramp_list, &ptr_instance->ext_list);
Mark Young3a587792016-08-19 15:25:08 -0600376 if (res != VK_SUCCESS) {
377 goto out;
378 }
Jon Ashburn23d36b12016-02-02 17:47:28 -0700379 res = loader_validate_instance_extensions(
Jon Ashburnf2b4e382016-02-10 20:50:19 -0700380 ptr_instance, &ptr_instance->ext_list,
Chris Forbesbd9de052016-04-06 20:49:02 +1200381 &ptr_instance->instance_layer_list, &ici);
Jon Ashburneacfa3a2015-08-14 12:51:47 -0600382 if (res != VK_SUCCESS) {
Mark Young0ad83132016-06-30 13:02:42 -0600383 goto out;
Jon Ashburneacfa3a2015-08-14 12:51:47 -0600384 }
385
Mark Young0ad83132016-06-30 13:02:42 -0600386 ptr_instance->disp = loader_instance_heap_alloc(
387 ptr_instance, sizeof(VkLayerInstanceDispatchTable),
388 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Courtney Goeltzenleuchter81095102015-07-06 09:08:37 -0600389 if (ptr_instance->disp == NULL) {
Mark Youngb6399312017-01-10 14:22:15 -0700390 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
391 "vkCreateInstance: Failed to allocate Instance dispatch"
392 " table.");
Mark Young0ad83132016-06-30 13:02:42 -0600393 res = VK_ERROR_OUT_OF_HOST_MEMORY;
394 goto out;
Courtney Goeltzenleuchter81095102015-07-06 09:08:37 -0600395 }
396 memcpy(ptr_instance->disp, &instance_disp, sizeof(instance_disp));
397 ptr_instance->next = loader.instances;
398 loader.instances = ptr_instance;
399
Jon Ashburnb82c1852015-08-11 14:49:54 -0600400 /* activate any layers on instance chain */
Chris Forbesbd9de052016-04-06 20:49:02 +1200401 res = loader_enable_instance_layers(ptr_instance, &ici,
Jon Ashburne39a4f82015-08-28 13:38:21 -0600402 &ptr_instance->instance_layer_list);
Courtney Goeltzenleuchter81095102015-07-06 09:08:37 -0600403 if (res != VK_SUCCESS) {
Mark Young0ad83132016-06-30 13:02:42 -0600404 goto out;
Courtney Goeltzenleuchter81095102015-07-06 09:08:37 -0600405 }
Jon Ashburn07daee72015-05-21 18:13:33 -0600406
Jon Ashburn23d36b12016-02-02 17:47:28 -0700407 created_instance = (VkInstance)ptr_instance;
Chris Forbesbd9de052016-04-06 20:49:02 +1200408 res = loader_create_instance_chain(&ici, pAllocator, ptr_instance,
Jon Ashburn6e0a2132016-02-03 12:37:30 -0700409 &created_instance);
Jon Ashburneed0c002015-05-21 17:42:17 -0600410
Jon Ashburne46cf7c2016-01-14 13:51:55 -0700411 if (res == VK_SUCCESS) {
Chris Forbesbd9de052016-04-06 20:49:02 +1200412 wsi_create_instance(ptr_instance, &ici);
413 debug_report_create_instance(ptr_instance, &ici);
Mark Lobodzinski317574e2016-08-29 14:21:14 -0600414 extensions_create_instance(ptr_instance, &ici);
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700415
Jon Ashburne5b9bba2016-01-18 12:20:03 -0700416 *pInstance = created_instance;
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700417
Jon Ashburne46cf7c2016-01-14 13:51:55 -0700418 /*
419 * Finally have the layers in place and everyone has seen
420 * the CreateInstance command go by. This allows the layer's
421 * GetInstanceProcAddr functions to return valid extension functions
422 * if enabled.
423 */
424 loader_activate_instance_layer_extensions(ptr_instance, *pInstance);
425 }
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700426
Mark Young0ad83132016-06-30 13:02:42 -0600427out:
428
429 if (NULL != ptr_instance) {
430 if (res != VK_SUCCESS) {
431 if (NULL != ptr_instance->next) {
432 loader.instances = ptr_instance->next;
433 }
434 if (NULL != ptr_instance->disp) {
435 loader_instance_heap_free(ptr_instance, ptr_instance->disp);
436 }
437 if (ptr_instance->num_tmp_callbacks > 0) {
438 util_DestroyDebugReportCallbacks(
439 ptr_instance, pAllocator, ptr_instance->num_tmp_callbacks,
440 ptr_instance->tmp_callbacks);
441 util_FreeDebugReportCreateInfos(
442 pAllocator, ptr_instance->tmp_dbg_create_infos,
443 ptr_instance->tmp_callbacks);
444 }
445
446 loader_deactivate_layers(ptr_instance, NULL,
447 &ptr_instance->activated_layer_list);
448
449 loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo,
450 &ici);
451 loader_delete_layer_properties(ptr_instance,
452 &ptr_instance->instance_layer_list);
Mark Young0153e0b2016-11-03 14:27:13 -0600453 loader_scanned_icd_clear(ptr_instance,
454 &ptr_instance->icd_tramp_list);
Mark Young0ad83132016-06-30 13:02:42 -0600455 loader_destroy_generic_list(
456 ptr_instance,
457 (struct loader_generic_list *)&ptr_instance->ext_list);
458
459 loader_instance_heap_free(ptr_instance, ptr_instance);
460 } else {
461 /* Remove temporary debug_report callback */
462 util_DestroyDebugReportCallbacks(ptr_instance, pAllocator,
463 ptr_instance->num_tmp_callbacks,
464 ptr_instance->tmp_callbacks);
465 loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo,
466 &ici);
467 }
468
469 if (loaderLocked) {
470 loader_platform_thread_unlock_mutex(&loader_lock);
471 }
472 }
473
Jon Ashburn27cd5842015-05-12 17:26:48 -0600474 return res;
475}
476
Mark Young0ad83132016-06-30 13:02:42 -0600477LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(
478 VkInstance instance, const VkAllocationCallbacks *pAllocator) {
Jon Ashburn27cd5842015-05-12 17:26:48 -0600479 const VkLayerInstanceDispatchTable *disp;
Jon Ashburne0e64572015-09-30 12:56:42 -0600480 struct loader_instance *ptr_instance = NULL;
Ian Elliott3b354cf2016-03-25 08:43:01 -0600481 bool callback_setup = false;
482
Jeremy Hayesd8726c22016-04-21 13:19:41 -0600483 if (instance == VK_NULL_HANDLE) {
484 return;
485 }
486
Jon Ashburn27cd5842015-05-12 17:26:48 -0600487 disp = loader_get_instance_dispatch(instance);
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600488
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600489 loader_platform_thread_lock_mutex(&loader_lock);
490
Jon Ashburne0e64572015-09-30 12:56:42 -0600491 ptr_instance = loader_get_instance(instance);
Ian Elliott3b354cf2016-03-25 08:43:01 -0600492
Mark Young0ad83132016-06-30 13:02:42 -0600493 if (pAllocator) {
494 ptr_instance->alloc_callbacks = *pAllocator;
495 }
496
Ian Elliottad6300f2016-03-31 10:48:19 -0600497 if (ptr_instance->num_tmp_callbacks > 0) {
498 // Setup the temporary callback(s) here to catch cleanup issues:
Jon Ashburncc407a22016-04-15 09:25:03 -0600499 if (!util_CreateDebugReportCallbacks(ptr_instance, pAllocator,
500 ptr_instance->num_tmp_callbacks,
501 ptr_instance->tmp_dbg_create_infos,
502 ptr_instance->tmp_callbacks)) {
Ian Elliott3b354cf2016-03-25 08:43:01 -0600503 callback_setup = true;
504 }
505 }
506
Chia-I Wuf7458c52015-10-26 21:10:41 +0800507 disp->DestroyInstance(instance, pAllocator);
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600508
Mark Young0ad83132016-06-30 13:02:42 -0600509 loader_deactivate_layers(ptr_instance, NULL,
510 &ptr_instance->activated_layer_list);
Mark Young0153e0b2016-11-03 14:27:13 -0600511 if (ptr_instance->phys_devs_tramp) {
Lenny Komowb9f70c32016-12-19 17:11:40 -0700512 for (uint32_t i = 0; i < ptr_instance->phys_dev_count_tramp; i++) {
513 loader_instance_heap_free(ptr_instance,
514 ptr_instance->phys_devs_tramp[i]);
515 }
Mark Young0153e0b2016-11-03 14:27:13 -0600516 loader_instance_heap_free(ptr_instance, ptr_instance->phys_devs_tramp);
Mark Young0ad83132016-06-30 13:02:42 -0600517 }
Ian Elliott3b354cf2016-03-25 08:43:01 -0600518 if (callback_setup) {
Jon Ashburncc407a22016-04-15 09:25:03 -0600519 util_DestroyDebugReportCallbacks(ptr_instance, pAllocator,
Ian Elliottad6300f2016-03-31 10:48:19 -0600520 ptr_instance->num_tmp_callbacks,
521 ptr_instance->tmp_callbacks);
522 util_FreeDebugReportCreateInfos(pAllocator,
523 ptr_instance->tmp_dbg_create_infos,
524 ptr_instance->tmp_callbacks);
Ian Elliott3b354cf2016-03-25 08:43:01 -0600525 }
Mark Young0ad83132016-06-30 13:02:42 -0600526 loader_instance_heap_free(ptr_instance, ptr_instance->disp);
527 loader_instance_heap_free(ptr_instance, ptr_instance);
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600528 loader_platform_thread_unlock_mutex(&loader_lock);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600529}
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600530
Jon Ashburn23d36b12016-02-02 17:47:28 -0700531LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
532vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
533 VkPhysicalDevice *pPhysicalDevices) {
Jon Ashburn27cd5842015-05-12 17:26:48 -0600534 const VkLayerInstanceDispatchTable *disp;
Mark Youngd8382d72016-12-23 16:59:58 -0700535 VkResult res = VK_SUCCESS;
Mark Young6267ae62017-01-12 12:27:19 -0700536 uint32_t count, i;
537 struct loader_instance *inst;
538 disp = loader_get_instance_dispatch(instance);
Mark Youngd8382d72016-12-23 16:59:58 -0700539
Mark Young6267ae62017-01-12 12:27:19 -0700540 loader_platform_thread_lock_mutex(&loader_lock);
541
542 inst = loader_get_instance(instance);
Mark Youngd8382d72016-12-23 16:59:58 -0700543 if (NULL == inst) {
544 res = VK_ERROR_INITIALIZATION_FAILED;
545 goto out;
546 }
547
Mark Young6267ae62017-01-12 12:27:19 -0700548 if (pPhysicalDevices == NULL) {
549 // Call down. At the lower levels, this will setup the terminator
550 // structures in the loader.
551 res = disp->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount,
552 pPhysicalDevices);
553 if (VK_SUCCESS != res) {
554 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
555 "vkEnumeratePhysicalDevices: Failed in dispatch call"
556 " used to determine number of available GPUs");
Lenny Komowb9f70c32016-12-19 17:11:40 -0700557 }
Jon Ashburn014438f2016-03-01 19:51:07 -0700558
Mark Young6267ae62017-01-12 12:27:19 -0700559 // Goto out, even on success since we don't need to fill in the rest.
560 goto out;
561 }
562
563 VkResult setup_res = setupLoaderTrampPhysDevs(instance);
564 if (setup_res != VK_SUCCESS && setup_res != VK_INCOMPLETE) {
565 res = setup_res;
566 goto out;
567 }
568
569 // Wrap the PhysDev object for loader usage, return wrapped objects
570 if (inst->total_gpu_count > *pPhysicalDeviceCount) {
571 loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
572 "vkEnumeratePhysicalDevices: Trimming device count down"
573 " by application request from %d to %d physical devices",
574 inst->total_gpu_count, *pPhysicalDeviceCount);
575 count = *pPhysicalDeviceCount;
576 res = VK_INCOMPLETE;
577 } else {
578 count = inst->total_gpu_count;
579 *pPhysicalDeviceCount = count;
580 }
581
582 for (i = 0; i < count; i++) {
583 pPhysicalDevices[i] = (VkPhysicalDevice)inst->phys_devs_tramp[i];
Jon Ashburn014438f2016-03-01 19:51:07 -0700584 }
Lenny Komowb9f70c32016-12-19 17:11:40 -0700585
Lenny Komowa5e01122016-12-22 15:29:43 -0700586out:
Mark Youngd8382d72016-12-23 16:59:58 -0700587
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600588 loader_platform_thread_unlock_mutex(&loader_lock);
589 return res;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600590}
591
Mark Young0153e0b2016-11-03 14:27:13 -0600592LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(
593 VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures *pFeatures) {
Jon Ashburn754864f2015-07-23 18:49:07 -0600594 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn014438f2016-03-01 19:51:07 -0700595 VkPhysicalDevice unwrapped_phys_dev =
596 loader_unwrap_physical_device(physicalDevice);
597 disp = loader_get_instance_dispatch(physicalDevice);
598 disp->GetPhysicalDeviceFeatures(unwrapped_phys_dev, pFeatures);
Jon Ashburn754864f2015-07-23 18:49:07 -0600599}
600
Mark Young0153e0b2016-11-03 14:27:13 -0600601LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(
602 VkPhysicalDevice physicalDevice, VkFormat format,
603 VkFormatProperties *pFormatInfo) {
Jon Ashburn754864f2015-07-23 18:49:07 -0600604 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn014438f2016-03-01 19:51:07 -0700605 VkPhysicalDevice unwrapped_pd =
606 loader_unwrap_physical_device(physicalDevice);
607 disp = loader_get_instance_dispatch(physicalDevice);
608 disp->GetPhysicalDeviceFormatProperties(unwrapped_pd, format, pFormatInfo);
Jon Ashburn754864f2015-07-23 18:49:07 -0600609}
610
Jon Ashburn23d36b12016-02-02 17:47:28 -0700611LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
612vkGetPhysicalDeviceImageFormatProperties(
613 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
614 VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
615 VkImageFormatProperties *pImageFormatProperties) {
Jon Ashburn754864f2015-07-23 18:49:07 -0600616 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn014438f2016-03-01 19:51:07 -0700617 VkPhysicalDevice unwrapped_phys_dev =
618 loader_unwrap_physical_device(physicalDevice);
Jon Ashburn754864f2015-07-23 18:49:07 -0600619 disp = loader_get_instance_dispatch(physicalDevice);
Jon Ashburn23d36b12016-02-02 17:47:28 -0700620 return disp->GetPhysicalDeviceImageFormatProperties(
Jon Ashburn014438f2016-03-01 19:51:07 -0700621 unwrapped_phys_dev, format, type, tiling, usage, flags,
Jon Ashburn23d36b12016-02-02 17:47:28 -0700622 pImageFormatProperties);
Jon Ashburn754864f2015-07-23 18:49:07 -0600623}
624
Mark Young0153e0b2016-11-03 14:27:13 -0600625LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(
626 VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties) {
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600627 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn014438f2016-03-01 19:51:07 -0700628 VkPhysicalDevice unwrapped_phys_dev =
629 loader_unwrap_physical_device(physicalDevice);
630 disp = loader_get_instance_dispatch(physicalDevice);
631 disp->GetPhysicalDeviceProperties(unwrapped_phys_dev, pProperties);
Tony Barbour59a47322015-06-24 16:06:58 -0600632}
633
Jon Ashburn23d36b12016-02-02 17:47:28 -0700634LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
635vkGetPhysicalDeviceQueueFamilyProperties(
Jon Ashburn014438f2016-03-01 19:51:07 -0700636 VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount,
Jon Ashburn23d36b12016-02-02 17:47:28 -0700637 VkQueueFamilyProperties *pQueueProperties) {
Tony Barbour59a47322015-06-24 16:06:58 -0600638 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn014438f2016-03-01 19:51:07 -0700639 VkPhysicalDevice unwrapped_phys_dev =
640 loader_unwrap_physical_device(physicalDevice);
641 disp = loader_get_instance_dispatch(physicalDevice);
642 disp->GetPhysicalDeviceQueueFamilyProperties(
643 unwrapped_phys_dev, pQueueFamilyPropertyCount, pQueueProperties);
Tony Barbour59a47322015-06-24 16:06:58 -0600644}
645
Chia-I Wu9ab61502015-11-06 06:42:02 +0800646LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(
Jon Ashburn014438f2016-03-01 19:51:07 -0700647 VkPhysicalDevice physicalDevice,
648 VkPhysicalDeviceMemoryProperties *pMemoryProperties) {
Tony Barbour59a47322015-06-24 16:06:58 -0600649 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn014438f2016-03-01 19:51:07 -0700650 VkPhysicalDevice unwrapped_phys_dev =
651 loader_unwrap_physical_device(physicalDevice);
652 disp = loader_get_instance_dispatch(physicalDevice);
653 disp->GetPhysicalDeviceMemoryProperties(unwrapped_phys_dev,
654 pMemoryProperties);
Jon Ashburnd55a3942015-05-06 09:02:10 -0600655}
656
Mark Young0ad83132016-06-30 13:02:42 -0600657LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(
658 VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
659 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) {
Jon Ashburnd55a3942015-05-06 09:02:10 -0600660 VkResult res;
Mark Young0ad83132016-06-30 13:02:42 -0600661 struct loader_physical_device_tramp *phys_dev = NULL;
662 struct loader_device *dev = NULL;
663 struct loader_instance *inst = NULL;
Jon Ashburn1530c342016-02-26 13:14:27 -0700664
665 assert(pCreateInfo->queueCreateInfoCount >= 1);
Jon Ashburnd55a3942015-05-06 09:02:10 -0600666
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600667 loader_platform_thread_lock_mutex(&loader_lock);
Courtney Goeltzenleuchterca173b82015-06-25 18:01:43 -0600668
Jon Ashburn787eb252016-03-24 15:49:57 -0600669 phys_dev = (struct loader_physical_device_tramp *)physicalDevice;
Piers Daniell295fe402016-03-29 11:51:11 -0600670 inst = (struct loader_instance *)phys_dev->this_instance;
Jon Ashburn1530c342016-02-26 13:14:27 -0700671
Jon Ashburn014438f2016-03-01 19:51:07 -0700672 /* Get the physical device (ICD) extensions */
673 struct loader_extension_list icd_exts;
Mark Young0ad83132016-06-30 13:02:42 -0600674 icd_exts.list = NULL;
Mark Young3a587792016-08-19 15:25:08 -0600675 res =
676 loader_init_generic_list(inst, (struct loader_generic_list *)&icd_exts,
677 sizeof(VkExtensionProperties));
678 if (VK_SUCCESS != res) {
Mark Youngb6399312017-01-10 14:22:15 -0700679 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
680 "vkCreateDevice: Failed to create ICD extension list");
Mark Young0ad83132016-06-30 13:02:42 -0600681 goto out;
Jon Ashburn014438f2016-03-01 19:51:07 -0700682 }
Jon Ashburn1530c342016-02-26 13:14:27 -0700683
Jon Ashburn014438f2016-03-01 19:51:07 -0700684 res = loader_add_device_extensions(
Jon Ashburncc407a22016-04-15 09:25:03 -0600685 inst, inst->disp->EnumerateDeviceExtensionProperties,
686 phys_dev->phys_dev, "Unknown", &icd_exts);
Jon Ashburn014438f2016-03-01 19:51:07 -0700687 if (res != VK_SUCCESS) {
Mark Youngb6399312017-01-10 14:22:15 -0700688 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
689 "vkCreateDevice: Failed to add extensions to list");
Mark Young0ad83132016-06-30 13:02:42 -0600690 goto out;
Jon Ashburn1530c342016-02-26 13:14:27 -0700691 }
692
Jon Ashburn1530c342016-02-26 13:14:27 -0700693 /* make sure requested extensions to be enabled are supported */
Mark Young0ad83132016-06-30 13:02:42 -0600694 res = loader_validate_device_extensions(
695 phys_dev, &inst->activated_layer_list, &icd_exts, pCreateInfo);
Jon Ashburn1530c342016-02-26 13:14:27 -0700696 if (res != VK_SUCCESS) {
Mark Youngb6399312017-01-10 14:22:15 -0700697 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
698 "vkCreateDevice: Failed to validate extensions in list");
Mark Young0ad83132016-06-30 13:02:42 -0600699 goto out;
Jon Ashburn1530c342016-02-26 13:14:27 -0700700 }
701
Mark Young0ad83132016-06-30 13:02:42 -0600702 dev = loader_create_logical_device(inst, pAllocator);
Jon Ashburn1530c342016-02-26 13:14:27 -0700703 if (dev == NULL) {
Mark Young0ad83132016-06-30 13:02:42 -0600704 res = VK_ERROR_OUT_OF_HOST_MEMORY;
705 goto out;
Jon Ashburn1530c342016-02-26 13:14:27 -0700706 }
707
Jon Ashburn491cd042016-05-16 14:01:18 -0600708 /* copy the instance layer list into the device */
709 dev->activated_layer_list.capacity = inst->activated_layer_list.capacity;
710 dev->activated_layer_list.count = inst->activated_layer_list.count;
Mark Young0ad83132016-06-30 13:02:42 -0600711 dev->activated_layer_list.list =
712 loader_device_heap_alloc(dev, inst->activated_layer_list.capacity,
713 VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
Jon Ashburn491cd042016-05-16 14:01:18 -0600714 if (dev->activated_layer_list.list == NULL) {
Mark Youngb6399312017-01-10 14:22:15 -0700715 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
716 "vkCreateDevice: Failed to allocate activated layer"
717 "list of size %d.",
718 inst->activated_layer_list.capacity);
Mark Young0ad83132016-06-30 13:02:42 -0600719 res = VK_ERROR_OUT_OF_HOST_MEMORY;
720 goto out;
Jon Ashburn1530c342016-02-26 13:14:27 -0700721 }
Jon Ashburn491cd042016-05-16 14:01:18 -0600722 memcpy(dev->activated_layer_list.list, inst->activated_layer_list.list,
Mark Young0ad83132016-06-30 13:02:42 -0600723 sizeof(*dev->activated_layer_list.list) *
724 dev->activated_layer_list.count);
Jon Ashburn1530c342016-02-26 13:14:27 -0700725
Mark Young0ad83132016-06-30 13:02:42 -0600726 res = loader_create_device_chain(phys_dev, pCreateInfo, pAllocator, inst,
727 dev);
Jon Ashburn1530c342016-02-26 13:14:27 -0700728 if (res != VK_SUCCESS) {
Mark Youngb6399312017-01-10 14:22:15 -0700729 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
730 "vkCreateDevice: Failed to create device chain.");
Mark Young0ad83132016-06-30 13:02:42 -0600731 goto out;
Jon Ashburn1530c342016-02-26 13:14:27 -0700732 }
733
Mark Young65cb3662016-11-07 13:27:02 -0700734 *pDevice = dev->chain_device;
Jon Ashburn1530c342016-02-26 13:14:27 -0700735
Mark Younga7c51fd2016-09-16 10:18:42 -0600736 // Initialize any device extension dispatch entry's from the instance list
Jon Ashburn1530c342016-02-26 13:14:27 -0700737 loader_init_dispatch_dev_ext(inst, dev);
738
Mark Younga7c51fd2016-09-16 10:18:42 -0600739 // Initialize WSI device extensions as part of core dispatch since loader
740 // has dedicated trampoline code for these*/
Jon Ashburn1530c342016-02-26 13:14:27 -0700741 loader_init_device_extension_dispatch_table(
742 &dev->loader_dispatch,
Mark Younga7c51fd2016-09-16 10:18:42 -0600743 dev->loader_dispatch.core_dispatch.GetDeviceProcAddr, *pDevice);
744
Mark Young0ad83132016-06-30 13:02:42 -0600745out:
746
747 // Failure cleanup
748 if (VK_SUCCESS != res) {
749 if (NULL != dev) {
750 loader_destroy_logical_device(inst, dev, pAllocator);
751 }
752 }
753
754 if (NULL != icd_exts.list) {
755 loader_destroy_generic_list(inst,
756 (struct loader_generic_list *)&icd_exts);
757 }
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600758 loader_platform_thread_unlock_mutex(&loader_lock);
Jon Ashburnd55a3942015-05-06 09:02:10 -0600759 return res;
760}
761
Jon Ashburn23d36b12016-02-02 17:47:28 -0700762LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
763vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) {
Jon Ashburnd55a3942015-05-06 09:02:10 -0600764 const VkLayerDispatchTable *disp;
Jon Ashburne39a4f82015-08-28 13:38:21 -0600765 struct loader_device *dev;
Andrzej Kotlowskib168b1a2016-02-03 09:41:53 +0100766
Jeremy Hayesd8726c22016-04-21 13:19:41 -0600767 if (device == VK_NULL_HANDLE) {
768 return;
769 }
770
Andrzej Kotlowskib168b1a2016-02-03 09:41:53 +0100771 loader_platform_thread_lock_mutex(&loader_lock);
772
Mark Young0153e0b2016-11-03 14:27:13 -0600773 struct loader_icd_term *icd_term =
774 loader_get_icd_and_device(device, &dev, NULL);
775 const struct loader_instance *inst = icd_term->this_instance;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600776 disp = loader_get_dispatch(device);
777
Chia-I Wuf7458c52015-10-26 21:10:41 +0800778 disp->DestroyDevice(device, pAllocator);
Mark Young65cb3662016-11-07 13:27:02 -0700779 dev->chain_device = NULL;
Mark Young65cb3662016-11-07 13:27:02 -0700780 dev->icd_device = NULL;
Mark Young95ed4952016-11-14 15:03:34 -0700781 loader_remove_logical_device(inst, icd_term, dev, pAllocator);
Jon Ashburn781a7ae2015-11-19 15:43:26 -0700782
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600783 loader_platform_thread_unlock_mutex(&loader_lock);
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600784}
785
Jon Ashburn23d36b12016-02-02 17:47:28 -0700786LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
787vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
788 const char *pLayerName,
789 uint32_t *pPropertyCount,
790 VkExtensionProperties *pProperties) {
Jon Ashburndc5d9202016-02-29 13:00:51 -0700791 VkResult res = VK_SUCCESS;
Jon Ashburn787eb252016-03-24 15:49:57 -0600792 struct loader_physical_device_tramp *phys_dev;
793 phys_dev = (struct loader_physical_device_tramp *)physicalDevice;
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600794
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600795 loader_platform_thread_lock_mutex(&loader_lock);
Jon Ashburn00eb6c02015-11-02 17:40:01 -0700796
797 /* If pLayerName == NULL, then querying ICD extensions, pass this call
798 down the instance chain which will terminate in the ICD. This allows
799 layers to filter the extensions coming back up the chain.
800 If pLayerName != NULL then get layer extensions from manifest file. */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700801 if (pLayerName == NULL || strlen(pLayerName) == 0) {
Jon Ashburn00eb6c02015-11-02 17:40:01 -0700802 const VkLayerInstanceDispatchTable *disp;
803
804 disp = loader_get_instance_dispatch(physicalDevice);
Jon Ashburn23d36b12016-02-02 17:47:28 -0700805 res = disp->EnumerateDeviceExtensionProperties(
Jon Ashburn014438f2016-03-01 19:51:07 -0700806 phys_dev->phys_dev, NULL, pPropertyCount, pProperties);
Jon Ashburn00eb6c02015-11-02 17:40:01 -0700807 } else {
Jon Ashburn014438f2016-03-01 19:51:07 -0700808
Jon Ashburndc5d9202016-02-29 13:00:51 -0700809 uint32_t count;
810 uint32_t copy_size;
Piers Daniell295fe402016-03-29 11:51:11 -0600811 const struct loader_instance *inst = phys_dev->this_instance;
Jon Ashburnb8726962016-04-08 15:03:35 -0600812 struct loader_device_extension_list *dev_ext_list = NULL;
813 struct loader_device_extension_list local_ext_list;
814 memset(&local_ext_list, 0, sizeof(local_ext_list));
Jon Ashburndc5d9202016-02-29 13:00:51 -0700815 if (vk_string_validate(MaxLoaderStringLength, pLayerName) ==
Jon Ashburn014438f2016-03-01 19:51:07 -0700816 VK_STRING_ERROR_NONE) {
Jon Ashburnb8726962016-04-08 15:03:35 -0600817 if (strcmp(pLayerName, std_validation_str) == 0) {
818 struct loader_layer_list local_list;
819 memset(&local_list, 0, sizeof(local_list));
820 for (uint32_t i = 0; i < sizeof(std_validation_names) /
821 sizeof(std_validation_names[0]);
822 i++) {
Jon Ashburncc407a22016-04-15 09:25:03 -0600823 loader_find_layer_name_add_list(
824 NULL, std_validation_names[i],
Mark Young0153e0b2016-11-03 14:27:13 -0600825 VK_LAYER_TYPE_INSTANCE_EXPLICIT,
826 &inst->instance_layer_list, &local_list);
Jon Ashburnb8726962016-04-08 15:03:35 -0600827 }
828 for (uint32_t i = 0; i < local_list.count; i++) {
829 struct loader_device_extension_list *ext_list =
Jon Ashburncc407a22016-04-15 09:25:03 -0600830 &local_list.list[i].device_extension_list;
Jon Ashburnb8726962016-04-08 15:03:35 -0600831 for (uint32_t j = 0; j < ext_list->count; j++) {
832 loader_add_to_dev_ext_list(NULL, &local_ext_list,
833 &ext_list->list[j].props, 0,
834 NULL);
835 }
836 }
837 dev_ext_list = &local_ext_list;
Jon Ashburndc5d9202016-02-29 13:00:51 -0700838
Jon Ashburnb8726962016-04-08 15:03:35 -0600839 } else {
Jon Ashburn491cd042016-05-16 14:01:18 -0600840 for (uint32_t i = 0; i < inst->instance_layer_list.count; i++) {
Jon Ashburnb8726962016-04-08 15:03:35 -0600841 struct loader_layer_properties *props =
Jon Ashburn491cd042016-05-16 14:01:18 -0600842 &inst->instance_layer_list.list[i];
Jon Ashburnb8726962016-04-08 15:03:35 -0600843 if (strcmp(props->info.layerName, pLayerName) == 0) {
844 dev_ext_list = &props->device_extension_list;
845 }
Jon Ashburndc5d9202016-02-29 13:00:51 -0700846 }
847 }
Jon Ashburnb8726962016-04-08 15:03:35 -0600848
Jon Ashburndc5d9202016-02-29 13:00:51 -0700849 count = (dev_ext_list == NULL) ? 0 : dev_ext_list->count;
850 if (pProperties == NULL) {
851 *pPropertyCount = count;
Jon Ashburncc407a22016-04-15 09:25:03 -0600852 loader_destroy_generic_list(
853 inst, (struct loader_generic_list *)&local_ext_list);
Jon Ashburndc5d9202016-02-29 13:00:51 -0700854 loader_platform_thread_unlock_mutex(&loader_lock);
855 return VK_SUCCESS;
856 }
857
858 copy_size = *pPropertyCount < count ? *pPropertyCount : count;
859 for (uint32_t i = 0; i < copy_size; i++) {
860 memcpy(&pProperties[i], &dev_ext_list->list[i].props,
Jon Ashburn014438f2016-03-01 19:51:07 -0700861 sizeof(VkExtensionProperties));
Jon Ashburndc5d9202016-02-29 13:00:51 -0700862 }
863 *pPropertyCount = copy_size;
864
Jon Ashburncc407a22016-04-15 09:25:03 -0600865 loader_destroy_generic_list(
866 inst, (struct loader_generic_list *)&local_ext_list);
Jon Ashburndc5d9202016-02-29 13:00:51 -0700867 if (copy_size < count) {
868 loader_platform_thread_unlock_mutex(&loader_lock);
869 return VK_INCOMPLETE;
870 }
871 } else {
Jon Ashburn014438f2016-03-01 19:51:07 -0700872 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
873 "vkEnumerateDeviceExtensionProperties: pLayerName "
874 "is too long or is badly formed");
875 loader_platform_thread_unlock_mutex(&loader_lock);
Jon Ashburndc5d9202016-02-29 13:00:51 -0700876 return VK_ERROR_EXTENSION_NOT_PRESENT;
877 }
Jon Ashburn00eb6c02015-11-02 17:40:01 -0700878 }
879
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600880 loader_platform_thread_unlock_mutex(&loader_lock);
Tony Barbour59a47322015-06-24 16:06:58 -0600881 return res;
882}
883
Jon Ashburn23d36b12016-02-02 17:47:28 -0700884LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
885vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice,
886 uint32_t *pPropertyCount,
887 VkLayerProperties *pProperties) {
Jon Ashburndc5d9202016-02-29 13:00:51 -0700888 uint32_t copy_size;
Jon Ashburn787eb252016-03-24 15:49:57 -0600889 struct loader_physical_device_tramp *phys_dev;
Jon Ashburn491cd042016-05-16 14:01:18 -0600890 struct loader_layer_list *enabled_layers, layers_list;
891 uint32_t std_val_count = sizeof(std_validation_names) /
892 sizeof(std_validation_names[0]);
893 memset(&layers_list, 0, sizeof(layers_list));
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600894 loader_platform_thread_lock_mutex(&loader_lock);
Jon Ashburn00eb6c02015-11-02 17:40:01 -0700895
896 /* Don't dispatch this call down the instance chain, want all device layers
897 enumerated and instance chain may not contain all device layers */
Jon Ashburn491cd042016-05-16 14:01:18 -0600898 // TODO re-evaluate the above statement we maybe able to start calling
899 // down the chain
Jon Ashburndc5d9202016-02-29 13:00:51 -0700900
Jon Ashburn787eb252016-03-24 15:49:57 -0600901 phys_dev = (struct loader_physical_device_tramp *)physicalDevice;
Piers Daniell295fe402016-03-29 11:51:11 -0600902 const struct loader_instance *inst = phys_dev->this_instance;
Jon Ashburndc5d9202016-02-29 13:00:51 -0700903
Jon Ashburn491cd042016-05-16 14:01:18 -0600904 uint32_t count = inst->activated_layer_list.count;
905 if (inst->activated_layers_are_std_val)
906 count = count - std_val_count + 1;
Jon Ashburndc5d9202016-02-29 13:00:51 -0700907 if (pProperties == NULL) {
908 *pPropertyCount = count;
909 loader_platform_thread_unlock_mutex(&loader_lock);
910 return VK_SUCCESS;
911 }
Jon Ashburn491cd042016-05-16 14:01:18 -0600912 /* make sure to enumerate standard_validation if that is what was used
913 at the instance layer enablement */
914 if (inst->activated_layers_are_std_val) {
915 enabled_layers = &layers_list;
916 enabled_layers->count = count;
917 enabled_layers->capacity = enabled_layers->count *
918 sizeof(struct loader_layer_properties);
Mark Young0ad83132016-06-30 13:02:42 -0600919 enabled_layers->list = loader_instance_heap_alloc(inst, enabled_layers->capacity,
Jon Ashburn491cd042016-05-16 14:01:18 -0600920 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Mark Youngb6399312017-01-10 14:22:15 -0700921 if (!enabled_layers->list) {
922 loader_log(
923 inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
924 "vkEnumerateDeviceLayerProperties: Failed to allocate enabled"
925 "layer list of size %d",
926 enabled_layers->capacity);
Jon Ashburn491cd042016-05-16 14:01:18 -0600927 return VK_ERROR_OUT_OF_HOST_MEMORY;
Mark Youngb6399312017-01-10 14:22:15 -0700928 }
Jon Ashburn491cd042016-05-16 14:01:18 -0600929
930 uint32_t j = 0;
931 for (uint32_t i = 0; i < inst->activated_layer_list.count; j++) {
932
933 if (loader_find_layer_name_array(
934 inst->activated_layer_list.list[i].info.layerName,
935 std_val_count, std_validation_names)) {
936 struct loader_layer_properties props;
937 loader_init_std_validation_props(&props);
Mark Young0ad83132016-06-30 13:02:42 -0600938 VkResult err = loader_copy_layer_properties(inst,
939 &enabled_layers->list[j],
940 &props);
941 if (err != VK_SUCCESS) {
942 return err;
943 }
Jon Ashburn491cd042016-05-16 14:01:18 -0600944 i += std_val_count;
945 }
946 else {
Mark Young0ad83132016-06-30 13:02:42 -0600947 VkResult err = loader_copy_layer_properties(inst,
948 &enabled_layers->list[j],
949 &inst->activated_layer_list.list[i++]);
950 if (err != VK_SUCCESS) {
951 return err;
952 }
Jon Ashburn491cd042016-05-16 14:01:18 -0600953 }
954 }
955 }
956 else {
957 enabled_layers = (struct loader_layer_list *) &inst->activated_layer_list;
958 }
959
Jon Ashburndc5d9202016-02-29 13:00:51 -0700960
961 copy_size = (*pPropertyCount < count) ? *pPropertyCount : count;
962 for (uint32_t i = 0; i < copy_size; i++) {
Jon Ashburn491cd042016-05-16 14:01:18 -0600963 memcpy(&pProperties[i], &(enabled_layers->list[i].info),
Jon Ashburndc5d9202016-02-29 13:00:51 -0700964 sizeof(VkLayerProperties));
965 }
966 *pPropertyCount = copy_size;
967
Mark Young0ad83132016-06-30 13:02:42 -0600968 if (inst->activated_layers_are_std_val) {
Jon Ashburn491cd042016-05-16 14:01:18 -0600969 loader_delete_layer_properties(inst, enabled_layers);
Mark Young0ad83132016-06-30 13:02:42 -0600970 }
Jon Ashburndc5d9202016-02-29 13:00:51 -0700971 if (copy_size < count) {
972 loader_platform_thread_unlock_mutex(&loader_lock);
973 return VK_INCOMPLETE;
974 }
975
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600976 loader_platform_thread_unlock_mutex(&loader_lock);
Jon Ashburndc5d9202016-02-29 13:00:51 -0700977 return VK_SUCCESS;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600978}
979
Jon Ashburn23d36b12016-02-02 17:47:28 -0700980LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
981vkGetDeviceQueue(VkDevice device, uint32_t queueNodeIndex, uint32_t queueIndex,
982 VkQueue *pQueue) {
Jon Ashburnd55a3942015-05-06 09:02:10 -0600983 const VkLayerDispatchTable *disp;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600984
985 disp = loader_get_dispatch(device);
986
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600987 disp->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue);
988 loader_set_dispatch(*pQueue, disp);
Jon Ashburnd55a3942015-05-06 09:02:10 -0600989}
990
Jon Ashburn23d36b12016-02-02 17:47:28 -0700991LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
992vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits,
993 VkFence fence) {
Jon Ashburnd55a3942015-05-06 09:02:10 -0600994 const VkLayerDispatchTable *disp;
995
996 disp = loader_get_dispatch(queue);
997
Chia-I Wu40cf0ae2015-10-26 17:20:32 +0800998 return disp->QueueSubmit(queue, submitCount, pSubmits, fence);
Jon Ashburnd55a3942015-05-06 09:02:10 -0600999}
1000
Jon Ashburn23d36b12016-02-02 17:47:28 -07001001LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle(VkQueue queue) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001002 const VkLayerDispatchTable *disp;
1003
1004 disp = loader_get_dispatch(queue);
1005
1006 return disp->QueueWaitIdle(queue);
1007}
1008
Jon Ashburn23d36b12016-02-02 17:47:28 -07001009LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(VkDevice device) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001010 const VkLayerDispatchTable *disp;
1011
1012 disp = loader_get_dispatch(device);
1013
1014 return disp->DeviceWaitIdle(device);
1015}
1016
Jon Ashburn23d36b12016-02-02 17:47:28 -07001017LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1018vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
1019 const VkAllocationCallbacks *pAllocator,
1020 VkDeviceMemory *pMemory) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001021 const VkLayerDispatchTable *disp;
1022
1023 disp = loader_get_dispatch(device);
1024
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001025 return disp->AllocateMemory(device, pAllocateInfo, pAllocator, pMemory);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001026}
1027
Jon Ashburn23d36b12016-02-02 17:47:28 -07001028LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1029vkFreeMemory(VkDevice device, VkDeviceMemory mem,
1030 const VkAllocationCallbacks *pAllocator) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001031 const VkLayerDispatchTable *disp;
1032
1033 disp = loader_get_dispatch(device);
1034
Chia-I Wuf7458c52015-10-26 21:10:41 +08001035 disp->FreeMemory(device, mem, pAllocator);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001036}
1037
Jon Ashburn23d36b12016-02-02 17:47:28 -07001038LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1039vkMapMemory(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset,
1040 VkDeviceSize size, VkFlags flags, void **ppData) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001041 const VkLayerDispatchTable *disp;
1042
1043 disp = loader_get_dispatch(device);
1044
1045 return disp->MapMemory(device, mem, offset, size, flags, ppData);
1046}
1047
Jon Ashburn23d36b12016-02-02 17:47:28 -07001048LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1049vkUnmapMemory(VkDevice device, VkDeviceMemory mem) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001050 const VkLayerDispatchTable *disp;
1051
1052 disp = loader_get_dispatch(device);
1053
Mark Lobodzinski2141f652015-09-07 13:59:43 -06001054 disp->UnmapMemory(device, mem);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001055}
1056
Jon Ashburn23d36b12016-02-02 17:47:28 -07001057LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1058vkFlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount,
1059 const VkMappedMemoryRange *pMemoryRanges) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001060 const VkLayerDispatchTable *disp;
1061
1062 disp = loader_get_dispatch(device);
1063
Jon Ashburn23d36b12016-02-02 17:47:28 -07001064 return disp->FlushMappedMemoryRanges(device, memoryRangeCount,
1065 pMemoryRanges);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001066}
1067
Jon Ashburn23d36b12016-02-02 17:47:28 -07001068LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1069vkInvalidateMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount,
1070 const VkMappedMemoryRange *pMemoryRanges) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001071 const VkLayerDispatchTable *disp;
1072
1073 disp = loader_get_dispatch(device);
1074
Jon Ashburn23d36b12016-02-02 17:47:28 -07001075 return disp->InvalidateMappedMemoryRanges(device, memoryRangeCount,
1076 pMemoryRanges);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001077}
1078
Jon Ashburn23d36b12016-02-02 17:47:28 -07001079LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1080vkGetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory,
1081 VkDeviceSize *pCommittedMemoryInBytes) {
Courtney Goeltzenleuchterfb71f222015-07-09 21:57:28 -06001082 const VkLayerDispatchTable *disp;
1083
1084 disp = loader_get_dispatch(device);
1085
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -06001086 disp->GetDeviceMemoryCommitment(device, memory, pCommittedMemoryInBytes);
Courtney Goeltzenleuchterfb71f222015-07-09 21:57:28 -06001087}
1088
Jon Ashburn23d36b12016-02-02 17:47:28 -07001089LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1090vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem,
1091 VkDeviceSize offset) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001092 const VkLayerDispatchTable *disp;
1093
Mark Lobodzinski942b1722015-05-11 17:21:15 -05001094 disp = loader_get_dispatch(device);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001095
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001096 return disp->BindBufferMemory(device, buffer, mem, offset);
1097}
1098
Jon Ashburn23d36b12016-02-02 17:47:28 -07001099LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1100vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem,
1101 VkDeviceSize offset) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001102 const VkLayerDispatchTable *disp;
1103
1104 disp = loader_get_dispatch(device);
1105
1106 return disp->BindImageMemory(device, image, mem, offset);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001107}
1108
Jon Ashburn23d36b12016-02-02 17:47:28 -07001109LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1110vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer,
1111 VkMemoryRequirements *pMemoryRequirements) {
Jon Ashburn754864f2015-07-23 18:49:07 -06001112 const VkLayerDispatchTable *disp;
1113
1114 disp = loader_get_dispatch(device);
1115
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -06001116 disp->GetBufferMemoryRequirements(device, buffer, pMemoryRequirements);
Jon Ashburn754864f2015-07-23 18:49:07 -06001117}
1118
Jon Ashburn23d36b12016-02-02 17:47:28 -07001119LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1120vkGetImageMemoryRequirements(VkDevice device, VkImage image,
1121 VkMemoryRequirements *pMemoryRequirements) {
Jon Ashburn754864f2015-07-23 18:49:07 -06001122 const VkLayerDispatchTable *disp;
1123
1124 disp = loader_get_dispatch(device);
1125
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -06001126 disp->GetImageMemoryRequirements(device, image, pMemoryRequirements);
Jon Ashburn754864f2015-07-23 18:49:07 -06001127}
1128
Jon Ashburn23d36b12016-02-02 17:47:28 -07001129LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements(
1130 VkDevice device, VkImage image, uint32_t *pSparseMemoryRequirementCount,
1131 VkSparseImageMemoryRequirements *pSparseMemoryRequirements) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001132 const VkLayerDispatchTable *disp;
1133
Mark Lobodzinski16e8bef2015-07-03 15:58:09 -06001134 disp = loader_get_dispatch(device);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001135
Jon Ashburn23d36b12016-02-02 17:47:28 -07001136 disp->GetImageSparseMemoryRequirements(device, image,
1137 pSparseMemoryRequirementCount,
1138 pSparseMemoryRequirements);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001139}
1140
Jon Ashburn23d36b12016-02-02 17:47:28 -07001141LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1142vkGetPhysicalDeviceSparseImageFormatProperties(
1143 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
1144 VkSampleCountFlagBits samples, VkImageUsageFlags usage,
1145 VkImageTiling tiling, uint32_t *pPropertyCount,
1146 VkSparseImageFormatProperties *pProperties) {
Mark Lobodzinski16e8bef2015-07-03 15:58:09 -06001147 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn014438f2016-03-01 19:51:07 -07001148 VkPhysicalDevice unwrapped_phys_dev =
1149 loader_unwrap_physical_device(physicalDevice);
Mark Lobodzinski16e8bef2015-07-03 15:58:09 -06001150 disp = loader_get_instance_dispatch(physicalDevice);
1151
Jon Ashburn23d36b12016-02-02 17:47:28 -07001152 disp->GetPhysicalDeviceSparseImageFormatProperties(
Jon Ashburn014438f2016-03-01 19:51:07 -07001153 unwrapped_phys_dev, format, type, samples, usage, tiling,
1154 pPropertyCount, pProperties);
Mark Lobodzinski16e8bef2015-07-03 15:58:09 -06001155}
1156
Jon Ashburn23d36b12016-02-02 17:47:28 -07001157LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1158vkQueueBindSparse(VkQueue queue, uint32_t bindInfoCount,
1159 const VkBindSparseInfo *pBindInfo, VkFence fence) {
Mark Lobodzinski16e8bef2015-07-03 15:58:09 -06001160 const VkLayerDispatchTable *disp;
1161
1162 disp = loader_get_dispatch(queue);
1163
Chia-I Wu1ff4c3d2015-10-26 16:55:27 +08001164 return disp->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001165}
1166
Jon Ashburn23d36b12016-02-02 17:47:28 -07001167LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1168vkCreateFence(VkDevice device, const VkFenceCreateInfo *pCreateInfo,
1169 const VkAllocationCallbacks *pAllocator, VkFence *pFence) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001170 const VkLayerDispatchTable *disp;
1171
1172 disp = loader_get_dispatch(device);
1173
Chia-I Wuf7458c52015-10-26 21:10:41 +08001174 return disp->CreateFence(device, pCreateInfo, pAllocator, pFence);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001175}
1176
Jon Ashburn23d36b12016-02-02 17:47:28 -07001177LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1178vkDestroyFence(VkDevice device, VkFence fence,
1179 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001180 const VkLayerDispatchTable *disp;
1181
1182 disp = loader_get_dispatch(device);
1183
Chia-I Wuf7458c52015-10-26 21:10:41 +08001184 disp->DestroyFence(device, fence, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001185}
1186
Jon Ashburn23d36b12016-02-02 17:47:28 -07001187LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1188vkResetFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001189 const VkLayerDispatchTable *disp;
1190
1191 disp = loader_get_dispatch(device);
1192
1193 return disp->ResetFences(device, fenceCount, pFences);
1194}
1195
Jon Ashburn23d36b12016-02-02 17:47:28 -07001196LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1197vkGetFenceStatus(VkDevice device, VkFence fence) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001198 const VkLayerDispatchTable *disp;
1199
1200 disp = loader_get_dispatch(device);
1201
1202 return disp->GetFenceStatus(device, fence);
1203}
1204
Jon Ashburn23d36b12016-02-02 17:47:28 -07001205LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1206vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences,
1207 VkBool32 waitAll, uint64_t timeout) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001208 const VkLayerDispatchTable *disp;
1209
1210 disp = loader_get_dispatch(device);
1211
1212 return disp->WaitForFences(device, fenceCount, pFences, waitAll, timeout);
1213}
1214
Jon Ashburn23d36b12016-02-02 17:47:28 -07001215LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1216vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo,
1217 const VkAllocationCallbacks *pAllocator,
1218 VkSemaphore *pSemaphore) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001219 const VkLayerDispatchTable *disp;
1220
1221 disp = loader_get_dispatch(device);
1222
Chia-I Wuf7458c52015-10-26 21:10:41 +08001223 return disp->CreateSemaphore(device, pCreateInfo, pAllocator, pSemaphore);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001224}
1225
Jon Ashburn23d36b12016-02-02 17:47:28 -07001226LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1227vkDestroySemaphore(VkDevice device, VkSemaphore semaphore,
1228 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001229 const VkLayerDispatchTable *disp;
1230
1231 disp = loader_get_dispatch(device);
1232
Chia-I Wuf7458c52015-10-26 21:10:41 +08001233 disp->DestroySemaphore(device, semaphore, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001234}
1235
Jon Ashburn23d36b12016-02-02 17:47:28 -07001236LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1237vkCreateEvent(VkDevice device, const VkEventCreateInfo *pCreateInfo,
1238 const VkAllocationCallbacks *pAllocator, VkEvent *pEvent) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001239 const VkLayerDispatchTable *disp;
1240
1241 disp = loader_get_dispatch(device);
1242
Chia-I Wuf7458c52015-10-26 21:10:41 +08001243 return disp->CreateEvent(device, pCreateInfo, pAllocator, pEvent);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001244}
1245
Jon Ashburn23d36b12016-02-02 17:47:28 -07001246LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1247vkDestroyEvent(VkDevice device, VkEvent event,
1248 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001249 const VkLayerDispatchTable *disp;
1250
1251 disp = loader_get_dispatch(device);
1252
Chia-I Wuf7458c52015-10-26 21:10:41 +08001253 disp->DestroyEvent(device, event, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001254}
1255
Jon Ashburn23d36b12016-02-02 17:47:28 -07001256LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1257vkGetEventStatus(VkDevice device, VkEvent event) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001258 const VkLayerDispatchTable *disp;
1259
1260 disp = loader_get_dispatch(device);
1261
1262 return disp->GetEventStatus(device, event);
1263}
1264
Jon Ashburn23d36b12016-02-02 17:47:28 -07001265LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1266vkSetEvent(VkDevice device, VkEvent event) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001267 const VkLayerDispatchTable *disp;
1268
1269 disp = loader_get_dispatch(device);
1270
1271 return disp->SetEvent(device, event);
1272}
1273
Jon Ashburn23d36b12016-02-02 17:47:28 -07001274LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1275vkResetEvent(VkDevice device, VkEvent event) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001276 const VkLayerDispatchTable *disp;
1277
1278 disp = loader_get_dispatch(device);
1279
1280 return disp->ResetEvent(device, event);
1281}
1282
Jon Ashburn23d36b12016-02-02 17:47:28 -07001283LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1284vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
1285 const VkAllocationCallbacks *pAllocator,
1286 VkQueryPool *pQueryPool) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001287 const VkLayerDispatchTable *disp;
1288
1289 disp = loader_get_dispatch(device);
1290
Chia-I Wuf7458c52015-10-26 21:10:41 +08001291 return disp->CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001292}
1293
Jon Ashburn23d36b12016-02-02 17:47:28 -07001294LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1295vkDestroyQueryPool(VkDevice device, VkQueryPool queryPool,
1296 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001297 const VkLayerDispatchTable *disp;
1298
1299 disp = loader_get_dispatch(device);
1300
Chia-I Wuf7458c52015-10-26 21:10:41 +08001301 disp->DestroyQueryPool(device, queryPool, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001302}
1303
Jon Ashburn23d36b12016-02-02 17:47:28 -07001304LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1305vkGetQueryPoolResults(VkDevice device, VkQueryPool queryPool,
1306 uint32_t firstQuery, uint32_t queryCount, size_t dataSize,
1307 void *pData, VkDeviceSize stride,
1308 VkQueryResultFlags flags) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001309 const VkLayerDispatchTable *disp;
1310
1311 disp = loader_get_dispatch(device);
1312
Jon Ashburn23d36b12016-02-02 17:47:28 -07001313 return disp->GetQueryPoolResults(device, queryPool, firstQuery, queryCount,
1314 dataSize, pData, stride, flags);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001315}
1316
Jon Ashburn23d36b12016-02-02 17:47:28 -07001317LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1318vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
1319 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001320 const VkLayerDispatchTable *disp;
1321
1322 disp = loader_get_dispatch(device);
1323
Chia-I Wuf7458c52015-10-26 21:10:41 +08001324 return disp->CreateBuffer(device, pCreateInfo, pAllocator, pBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001325}
1326
Jon Ashburn23d36b12016-02-02 17:47:28 -07001327LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1328vkDestroyBuffer(VkDevice device, VkBuffer buffer,
1329 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001330 const VkLayerDispatchTable *disp;
1331
1332 disp = loader_get_dispatch(device);
1333
Chia-I Wuf7458c52015-10-26 21:10:41 +08001334 disp->DestroyBuffer(device, buffer, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001335}
1336
Jon Ashburn23d36b12016-02-02 17:47:28 -07001337LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1338vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo,
1339 const VkAllocationCallbacks *pAllocator,
1340 VkBufferView *pView) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001341 const VkLayerDispatchTable *disp;
1342
1343 disp = loader_get_dispatch(device);
1344
Chia-I Wuf7458c52015-10-26 21:10:41 +08001345 return disp->CreateBufferView(device, pCreateInfo, pAllocator, pView);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001346}
1347
Jon Ashburn23d36b12016-02-02 17:47:28 -07001348LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1349vkDestroyBufferView(VkDevice device, VkBufferView bufferView,
1350 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001351 const VkLayerDispatchTable *disp;
1352
1353 disp = loader_get_dispatch(device);
1354
Chia-I Wuf7458c52015-10-26 21:10:41 +08001355 disp->DestroyBufferView(device, bufferView, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001356}
1357
Jon Ashburn23d36b12016-02-02 17:47:28 -07001358LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1359vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
1360 const VkAllocationCallbacks *pAllocator, VkImage *pImage) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001361 const VkLayerDispatchTable *disp;
1362
1363 disp = loader_get_dispatch(device);
1364
Chia-I Wuf7458c52015-10-26 21:10:41 +08001365 return disp->CreateImage(device, pCreateInfo, pAllocator, pImage);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001366}
1367
Jon Ashburn23d36b12016-02-02 17:47:28 -07001368LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1369vkDestroyImage(VkDevice device, VkImage image,
1370 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001371 const VkLayerDispatchTable *disp;
1372
1373 disp = loader_get_dispatch(device);
1374
Chia-I Wuf7458c52015-10-26 21:10:41 +08001375 disp->DestroyImage(device, image, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001376}
1377
Jon Ashburn23d36b12016-02-02 17:47:28 -07001378LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1379vkGetImageSubresourceLayout(VkDevice device, VkImage image,
1380 const VkImageSubresource *pSubresource,
1381 VkSubresourceLayout *pLayout) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001382 const VkLayerDispatchTable *disp;
1383
1384 disp = loader_get_dispatch(device);
1385
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -06001386 disp->GetImageSubresourceLayout(device, image, pSubresource, pLayout);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001387}
1388
Jon Ashburn23d36b12016-02-02 17:47:28 -07001389LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1390vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1391 const VkAllocationCallbacks *pAllocator, VkImageView *pView) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001392 const VkLayerDispatchTable *disp;
1393
1394 disp = loader_get_dispatch(device);
1395
Chia-I Wuf7458c52015-10-26 21:10:41 +08001396 return disp->CreateImageView(device, pCreateInfo, pAllocator, pView);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001397}
1398
Jon Ashburn23d36b12016-02-02 17:47:28 -07001399LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1400vkDestroyImageView(VkDevice device, VkImageView imageView,
1401 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001402 const VkLayerDispatchTable *disp;
1403
1404 disp = loader_get_dispatch(device);
1405
Chia-I Wuf7458c52015-10-26 21:10:41 +08001406 disp->DestroyImageView(device, imageView, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001407}
1408
Jon Ashburn23d36b12016-02-02 17:47:28 -07001409LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1410vkCreateShaderModule(VkDevice device,
1411 const VkShaderModuleCreateInfo *pCreateInfo,
1412 const VkAllocationCallbacks *pAllocator,
1413 VkShaderModule *pShader) {
Courtney Goeltzenleuchter2d2cb682015-06-24 18:24:19 -06001414 const VkLayerDispatchTable *disp;
1415
1416 disp = loader_get_dispatch(device);
1417
Chia-I Wuf7458c52015-10-26 21:10:41 +08001418 return disp->CreateShaderModule(device, pCreateInfo, pAllocator, pShader);
Courtney Goeltzenleuchter2d2cb682015-06-24 18:24:19 -06001419}
1420
Jon Ashburn23d36b12016-02-02 17:47:28 -07001421LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1422vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule,
1423 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001424 const VkLayerDispatchTable *disp;
1425
1426 disp = loader_get_dispatch(device);
1427
Chia-I Wuf7458c52015-10-26 21:10:41 +08001428 disp->DestroyShaderModule(device, shaderModule, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001429}
1430
Jon Ashburn23d36b12016-02-02 17:47:28 -07001431LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1432vkCreatePipelineCache(VkDevice device,
1433 const VkPipelineCacheCreateInfo *pCreateInfo,
1434 const VkAllocationCallbacks *pAllocator,
1435 VkPipelineCache *pPipelineCache) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001436 const VkLayerDispatchTable *disp;
1437
1438 disp = loader_get_dispatch(device);
1439
Jon Ashburn23d36b12016-02-02 17:47:28 -07001440 return disp->CreatePipelineCache(device, pCreateInfo, pAllocator,
1441 pPipelineCache);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001442}
1443
Jon Ashburn23d36b12016-02-02 17:47:28 -07001444LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1445vkDestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache,
1446 const VkAllocationCallbacks *pAllocator) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001447 const VkLayerDispatchTable *disp;
1448
1449 disp = loader_get_dispatch(device);
1450
Chia-I Wuf7458c52015-10-26 21:10:41 +08001451 disp->DestroyPipelineCache(device, pipelineCache, pAllocator);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001452}
1453
Jon Ashburn23d36b12016-02-02 17:47:28 -07001454LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1455vkGetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache,
1456 size_t *pDataSize, void *pData) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001457 const VkLayerDispatchTable *disp;
1458
1459 disp = loader_get_dispatch(device);
1460
Chia-I Wub16facd2015-10-26 19:17:06 +08001461 return disp->GetPipelineCacheData(device, pipelineCache, pDataSize, pData);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001462}
1463
Jon Ashburn23d36b12016-02-02 17:47:28 -07001464LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1465vkMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
1466 uint32_t srcCacheCount,
1467 const VkPipelineCache *pSrcCaches) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001468 const VkLayerDispatchTable *disp;
1469
1470 disp = loader_get_dispatch(device);
1471
Jon Ashburn23d36b12016-02-02 17:47:28 -07001472 return disp->MergePipelineCaches(device, dstCache, srcCacheCount,
1473 pSrcCaches);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001474}
1475
Jon Ashburn23d36b12016-02-02 17:47:28 -07001476LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1477vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1478 uint32_t createInfoCount,
1479 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1480 const VkAllocationCallbacks *pAllocator,
1481 VkPipeline *pPipelines) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001482 const VkLayerDispatchTable *disp;
1483
1484 disp = loader_get_dispatch(device);
1485
Jon Ashburn23d36b12016-02-02 17:47:28 -07001486 return disp->CreateGraphicsPipelines(device, pipelineCache, createInfoCount,
1487 pCreateInfos, pAllocator, pPipelines);
Jon Ashburnc669cc62015-07-09 15:02:25 -06001488}
1489
Jon Ashburn23d36b12016-02-02 17:47:28 -07001490LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1491vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
1492 uint32_t createInfoCount,
1493 const VkComputePipelineCreateInfo *pCreateInfos,
1494 const VkAllocationCallbacks *pAllocator,
1495 VkPipeline *pPipelines) {
Jon Ashburnc669cc62015-07-09 15:02:25 -06001496 const VkLayerDispatchTable *disp;
1497
1498 disp = loader_get_dispatch(device);
1499
Jon Ashburn23d36b12016-02-02 17:47:28 -07001500 return disp->CreateComputePipelines(device, pipelineCache, createInfoCount,
1501 pCreateInfos, pAllocator, pPipelines);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001502}
1503
Jon Ashburn23d36b12016-02-02 17:47:28 -07001504LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1505vkDestroyPipeline(VkDevice device, VkPipeline pipeline,
1506 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001507 const VkLayerDispatchTable *disp;
1508
1509 disp = loader_get_dispatch(device);
1510
Chia-I Wuf7458c52015-10-26 21:10:41 +08001511 disp->DestroyPipeline(device, pipeline, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001512}
1513
Jon Ashburn23d36b12016-02-02 17:47:28 -07001514LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1515vkCreatePipelineLayout(VkDevice device,
1516 const VkPipelineLayoutCreateInfo *pCreateInfo,
1517 const VkAllocationCallbacks *pAllocator,
1518 VkPipelineLayout *pPipelineLayout) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001519 const VkLayerDispatchTable *disp;
1520
1521 disp = loader_get_dispatch(device);
1522
Jon Ashburn23d36b12016-02-02 17:47:28 -07001523 return disp->CreatePipelineLayout(device, pCreateInfo, pAllocator,
1524 pPipelineLayout);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001525}
1526
Jon Ashburn23d36b12016-02-02 17:47:28 -07001527LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1528vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout,
1529 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001530 const VkLayerDispatchTable *disp;
1531
1532 disp = loader_get_dispatch(device);
1533
Chia-I Wuf7458c52015-10-26 21:10:41 +08001534 disp->DestroyPipelineLayout(device, pipelineLayout, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001535}
1536
Jon Ashburn23d36b12016-02-02 17:47:28 -07001537LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1538vkCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
1539 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001540 const VkLayerDispatchTable *disp;
1541
1542 disp = loader_get_dispatch(device);
1543
Chia-I Wuf7458c52015-10-26 21:10:41 +08001544 return disp->CreateSampler(device, pCreateInfo, pAllocator, pSampler);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001545}
1546
Jon Ashburn23d36b12016-02-02 17:47:28 -07001547LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1548vkDestroySampler(VkDevice device, VkSampler sampler,
1549 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001550 const VkLayerDispatchTable *disp;
1551
1552 disp = loader_get_dispatch(device);
1553
Chia-I Wuf7458c52015-10-26 21:10:41 +08001554 disp->DestroySampler(device, sampler, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001555}
1556
Jon Ashburn23d36b12016-02-02 17:47:28 -07001557LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1558vkCreateDescriptorSetLayout(VkDevice device,
1559 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
1560 const VkAllocationCallbacks *pAllocator,
1561 VkDescriptorSetLayout *pSetLayout) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001562 const VkLayerDispatchTable *disp;
1563
1564 disp = loader_get_dispatch(device);
1565
Jon Ashburn23d36b12016-02-02 17:47:28 -07001566 return disp->CreateDescriptorSetLayout(device, pCreateInfo, pAllocator,
1567 pSetLayout);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001568}
1569
Jon Ashburn23d36b12016-02-02 17:47:28 -07001570LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1571vkDestroyDescriptorSetLayout(VkDevice device,
1572 VkDescriptorSetLayout descriptorSetLayout,
1573 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001574 const VkLayerDispatchTable *disp;
1575
1576 disp = loader_get_dispatch(device);
1577
Chia-I Wuf7458c52015-10-26 21:10:41 +08001578 disp->DestroyDescriptorSetLayout(device, descriptorSetLayout, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001579}
1580
Jon Ashburn23d36b12016-02-02 17:47:28 -07001581LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1582vkCreateDescriptorPool(VkDevice device,
1583 const VkDescriptorPoolCreateInfo *pCreateInfo,
1584 const VkAllocationCallbacks *pAllocator,
1585 VkDescriptorPool *pDescriptorPool) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001586 const VkLayerDispatchTable *disp;
1587
1588 disp = loader_get_dispatch(device);
1589
Jon Ashburn23d36b12016-02-02 17:47:28 -07001590 return disp->CreateDescriptorPool(device, pCreateInfo, pAllocator,
1591 pDescriptorPool);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001592}
1593
Jon Ashburn23d36b12016-02-02 17:47:28 -07001594LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1595vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool,
1596 const VkAllocationCallbacks *pAllocator) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001597 const VkLayerDispatchTable *disp;
1598
1599 disp = loader_get_dispatch(device);
1600
Chia-I Wuf7458c52015-10-26 21:10:41 +08001601 disp->DestroyDescriptorPool(device, descriptorPool, pAllocator);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001602}
1603
Jon Ashburn23d36b12016-02-02 17:47:28 -07001604LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1605vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool,
1606 VkDescriptorPoolResetFlags flags) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001607 const VkLayerDispatchTable *disp;
1608
1609 disp = loader_get_dispatch(device);
1610
Courtney Goeltzenleuchterbee18a92015-10-23 14:21:05 -06001611 return disp->ResetDescriptorPool(device, descriptorPool, flags);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001612}
1613
Jon Ashburn23d36b12016-02-02 17:47:28 -07001614LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1615vkAllocateDescriptorSets(VkDevice device,
1616 const VkDescriptorSetAllocateInfo *pAllocateInfo,
1617 VkDescriptorSet *pDescriptorSets) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001618 const VkLayerDispatchTable *disp;
1619
1620 disp = loader_get_dispatch(device);
1621
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001622 return disp->AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001623}
1624
Jon Ashburn23d36b12016-02-02 17:47:28 -07001625LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1626vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
1627 uint32_t descriptorSetCount,
1628 const VkDescriptorSet *pDescriptorSets) {
Tony Barbour34ec6922015-07-10 10:50:45 -06001629 const VkLayerDispatchTable *disp;
1630
1631 disp = loader_get_dispatch(device);
1632
Jon Ashburn23d36b12016-02-02 17:47:28 -07001633 return disp->FreeDescriptorSets(device, descriptorPool, descriptorSetCount,
1634 pDescriptorSets);
Tony Barbour34ec6922015-07-10 10:50:45 -06001635}
1636
Jon Ashburn23d36b12016-02-02 17:47:28 -07001637LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1638vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
1639 const VkWriteDescriptorSet *pDescriptorWrites,
1640 uint32_t descriptorCopyCount,
1641 const VkCopyDescriptorSet *pDescriptorCopies) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001642 const VkLayerDispatchTable *disp;
1643
1644 disp = loader_get_dispatch(device);
1645
Jon Ashburn23d36b12016-02-02 17:47:28 -07001646 disp->UpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites,
1647 descriptorCopyCount, pDescriptorCopies);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001648}
1649
Jon Ashburn23d36b12016-02-02 17:47:28 -07001650LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1651vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
1652 const VkAllocationCallbacks *pAllocator,
1653 VkFramebuffer *pFramebuffer) {
Jon Ashburn754864f2015-07-23 18:49:07 -06001654 const VkLayerDispatchTable *disp;
1655
1656 disp = loader_get_dispatch(device);
1657
Jon Ashburn23d36b12016-02-02 17:47:28 -07001658 return disp->CreateFramebuffer(device, pCreateInfo, pAllocator,
1659 pFramebuffer);
Jon Ashburn754864f2015-07-23 18:49:07 -06001660}
1661
Jon Ashburn23d36b12016-02-02 17:47:28 -07001662LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1663vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer,
1664 const VkAllocationCallbacks *pAllocator) {
Jon Ashburn754864f2015-07-23 18:49:07 -06001665 const VkLayerDispatchTable *disp;
1666
1667 disp = loader_get_dispatch(device);
1668
Chia-I Wuf7458c52015-10-26 21:10:41 +08001669 disp->DestroyFramebuffer(device, framebuffer, pAllocator);
Jon Ashburn754864f2015-07-23 18:49:07 -06001670}
1671
Jon Ashburn23d36b12016-02-02 17:47:28 -07001672LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1673vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
1674 const VkAllocationCallbacks *pAllocator,
1675 VkRenderPass *pRenderPass) {
Jon Ashburn754864f2015-07-23 18:49:07 -06001676 const VkLayerDispatchTable *disp;
1677
1678 disp = loader_get_dispatch(device);
1679
Chia-I Wuf7458c52015-10-26 21:10:41 +08001680 return disp->CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass);
Jon Ashburn754864f2015-07-23 18:49:07 -06001681}
1682
Jon Ashburn23d36b12016-02-02 17:47:28 -07001683LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1684vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
1685 const VkAllocationCallbacks *pAllocator) {
Jon Ashburn754864f2015-07-23 18:49:07 -06001686 const VkLayerDispatchTable *disp;
1687
1688 disp = loader_get_dispatch(device);
1689
Chia-I Wuf7458c52015-10-26 21:10:41 +08001690 disp->DestroyRenderPass(device, renderPass, pAllocator);
Jon Ashburn754864f2015-07-23 18:49:07 -06001691}
1692
Jon Ashburn23d36b12016-02-02 17:47:28 -07001693LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1694vkGetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass,
1695 VkExtent2D *pGranularity) {
Jon Ashburn754864f2015-07-23 18:49:07 -06001696 const VkLayerDispatchTable *disp;
1697
1698 disp = loader_get_dispatch(device);
1699
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -06001700 disp->GetRenderAreaGranularity(device, renderPass, pGranularity);
Jon Ashburn754864f2015-07-23 18:49:07 -06001701}
1702
Jon Ashburn23d36b12016-02-02 17:47:28 -07001703LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1704vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo,
1705 const VkAllocationCallbacks *pAllocator,
1706 VkCommandPool *pCommandPool) {
Cody Northrope62183e2015-07-09 18:08:05 -06001707 const VkLayerDispatchTable *disp;
1708
1709 disp = loader_get_dispatch(device);
1710
Jon Ashburn23d36b12016-02-02 17:47:28 -07001711 return disp->CreateCommandPool(device, pCreateInfo, pAllocator,
1712 pCommandPool);
Cody Northrope62183e2015-07-09 18:08:05 -06001713}
1714
Jon Ashburn23d36b12016-02-02 17:47:28 -07001715LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1716vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
1717 const VkAllocationCallbacks *pAllocator) {
Cody Northrope62183e2015-07-09 18:08:05 -06001718 const VkLayerDispatchTable *disp;
1719
1720 disp = loader_get_dispatch(device);
1721
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001722 disp->DestroyCommandPool(device, commandPool, pAllocator);
Cody Northrope62183e2015-07-09 18:08:05 -06001723}
1724
Jon Ashburn23d36b12016-02-02 17:47:28 -07001725LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1726vkResetCommandPool(VkDevice device, VkCommandPool commandPool,
1727 VkCommandPoolResetFlags flags) {
Cody Northrope62183e2015-07-09 18:08:05 -06001728 const VkLayerDispatchTable *disp;
1729
1730 disp = loader_get_dispatch(device);
1731
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001732 return disp->ResetCommandPool(device, commandPool, flags);
Cody Northrope62183e2015-07-09 18:08:05 -06001733}
1734
Jon Ashburn23d36b12016-02-02 17:47:28 -07001735LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1736vkAllocateCommandBuffers(VkDevice device,
1737 const VkCommandBufferAllocateInfo *pAllocateInfo,
1738 VkCommandBuffer *pCommandBuffers) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001739 const VkLayerDispatchTable *disp;
1740 VkResult res;
1741
1742 disp = loader_get_dispatch(device);
1743
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001744 res = disp->AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001745 if (res == VK_SUCCESS) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001746 for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) {
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001747 if (pCommandBuffers[i]) {
1748 loader_init_dispatch(pCommandBuffers[i], disp);
Courtney Goeltzenleuchterbee18a92015-10-23 14:21:05 -06001749 }
1750 }
Jon Ashburnd55a3942015-05-06 09:02:10 -06001751 }
1752
1753 return res;
1754}
1755
Jon Ashburn23d36b12016-02-02 17:47:28 -07001756LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1757vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
1758 uint32_t commandBufferCount,
1759 const VkCommandBuffer *pCommandBuffers) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001760 const VkLayerDispatchTable *disp;
1761
1762 disp = loader_get_dispatch(device);
1763
Jon Ashburn23d36b12016-02-02 17:47:28 -07001764 disp->FreeCommandBuffers(device, commandPool, commandBufferCount,
1765 pCommandBuffers);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001766}
1767
Jon Ashburn23d36b12016-02-02 17:47:28 -07001768LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1769vkBeginCommandBuffer(VkCommandBuffer commandBuffer,
1770 const VkCommandBufferBeginInfo *pBeginInfo) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001771 const VkLayerDispatchTable *disp;
1772
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001773 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001774
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001775 return disp->BeginCommandBuffer(commandBuffer, pBeginInfo);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001776}
1777
Jon Ashburn23d36b12016-02-02 17:47:28 -07001778LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1779vkEndCommandBuffer(VkCommandBuffer commandBuffer) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001780 const VkLayerDispatchTable *disp;
1781
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001782 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001783
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001784 return disp->EndCommandBuffer(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001785}
1786
Jon Ashburn23d36b12016-02-02 17:47:28 -07001787LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1788vkResetCommandBuffer(VkCommandBuffer commandBuffer,
1789 VkCommandBufferResetFlags flags) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001790 const VkLayerDispatchTable *disp;
1791
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001792 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001793
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001794 return disp->ResetCommandBuffer(commandBuffer, flags);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001795}
1796
Jon Ashburn23d36b12016-02-02 17:47:28 -07001797LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1798vkCmdBindPipeline(VkCommandBuffer commandBuffer,
1799 VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001800 const VkLayerDispatchTable *disp;
1801
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001802 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001803
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001804 disp->CmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001805}
1806
Jon Ashburn23d36b12016-02-02 17:47:28 -07001807LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1808vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
1809 uint32_t viewportCount, const VkViewport *pViewports) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001810 const VkLayerDispatchTable *disp;
1811
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001812 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001813
Jon Ashburn23d36b12016-02-02 17:47:28 -07001814 disp->CmdSetViewport(commandBuffer, firstViewport, viewportCount,
1815 pViewports);
Courtney Goeltzenleuchter078f8172015-09-21 11:44:06 -06001816}
1817
Jon Ashburn23d36b12016-02-02 17:47:28 -07001818LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1819vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
1820 uint32_t scissorCount, const VkRect2D *pScissors) {
Courtney Goeltzenleuchter078f8172015-09-21 11:44:06 -06001821 const VkLayerDispatchTable *disp;
1822
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001823 disp = loader_get_dispatch(commandBuffer);
Courtney Goeltzenleuchter078f8172015-09-21 11:44:06 -06001824
Jon Ashburn19d3bf12015-12-30 14:06:55 -07001825 disp->CmdSetScissor(commandBuffer, firstScissor, scissorCount, pScissors);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001826}
1827
Jon Ashburn23d36b12016-02-02 17:47:28 -07001828LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1829vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001830 const VkLayerDispatchTable *disp;
1831
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001832 disp = loader_get_dispatch(commandBuffer);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001833
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001834 disp->CmdSetLineWidth(commandBuffer, lineWidth);
Cody Northrop12365112015-08-17 11:10:49 -06001835}
1836
Jon Ashburn23d36b12016-02-02 17:47:28 -07001837LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1838vkCmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor,
1839 float depthBiasClamp, float depthBiasSlopeFactor) {
Cody Northrop12365112015-08-17 11:10:49 -06001840 const VkLayerDispatchTable *disp;
1841
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001842 disp = loader_get_dispatch(commandBuffer);
Cody Northrop12365112015-08-17 11:10:49 -06001843
Jon Ashburn23d36b12016-02-02 17:47:28 -07001844 disp->CmdSetDepthBias(commandBuffer, depthBiasConstantFactor,
1845 depthBiasClamp, depthBiasSlopeFactor);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001846}
1847
Jon Ashburn23d36b12016-02-02 17:47:28 -07001848LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1849vkCmdSetBlendConstants(VkCommandBuffer commandBuffer,
1850 const float blendConstants[4]) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001851 const VkLayerDispatchTable *disp;
1852
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001853 disp = loader_get_dispatch(commandBuffer);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001854
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001855 disp->CmdSetBlendConstants(commandBuffer, blendConstants);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001856}
1857
Jon Ashburn23d36b12016-02-02 17:47:28 -07001858LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1859vkCmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds,
1860 float maxDepthBounds) {
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001861 const VkLayerDispatchTable *disp;
1862
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001863 disp = loader_get_dispatch(commandBuffer);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06001864
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001865 disp->CmdSetDepthBounds(commandBuffer, minDepthBounds, maxDepthBounds);
Cody Northrop82485a82015-08-18 15:21:16 -06001866}
1867
Jon Ashburn23d36b12016-02-02 17:47:28 -07001868LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1869vkCmdSetStencilCompareMask(VkCommandBuffer commandBuffer,
1870 VkStencilFaceFlags faceMask, uint32_t compareMask) {
Cody Northrop82485a82015-08-18 15:21:16 -06001871 const VkLayerDispatchTable *disp;
1872
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001873 disp = loader_get_dispatch(commandBuffer);
Cody Northrop82485a82015-08-18 15:21:16 -06001874
Chia-I Wu1b99bb22015-10-27 19:25:11 +08001875 disp->CmdSetStencilCompareMask(commandBuffer, faceMask, compareMask);
Courtney Goeltzenleuchter49c73082015-09-17 15:06:17 -06001876}
1877
Jon Ashburn23d36b12016-02-02 17:47:28 -07001878LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1879vkCmdSetStencilWriteMask(VkCommandBuffer commandBuffer,
1880 VkStencilFaceFlags faceMask, uint32_t writeMask) {
Courtney Goeltzenleuchter49c73082015-09-17 15:06:17 -06001881 const VkLayerDispatchTable *disp;
1882
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001883 disp = loader_get_dispatch(commandBuffer);
Courtney Goeltzenleuchter49c73082015-09-17 15:06:17 -06001884
Chia-I Wu1b99bb22015-10-27 19:25:11 +08001885 disp->CmdSetStencilWriteMask(commandBuffer, faceMask, writeMask);
Courtney Goeltzenleuchter49c73082015-09-17 15:06:17 -06001886}
1887
Jon Ashburn23d36b12016-02-02 17:47:28 -07001888LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1889vkCmdSetStencilReference(VkCommandBuffer commandBuffer,
1890 VkStencilFaceFlags faceMask, uint32_t reference) {
Courtney Goeltzenleuchter49c73082015-09-17 15:06:17 -06001891 const VkLayerDispatchTable *disp;
1892
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001893 disp = loader_get_dispatch(commandBuffer);
Courtney Goeltzenleuchter49c73082015-09-17 15:06:17 -06001894
Chia-I Wu1b99bb22015-10-27 19:25:11 +08001895 disp->CmdSetStencilReference(commandBuffer, faceMask, reference);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001896}
1897
Jon Ashburn23d36b12016-02-02 17:47:28 -07001898LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets(
1899 VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint,
1900 VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount,
1901 const VkDescriptorSet *pDescriptorSets, uint32_t dynamicOffsetCount,
1902 const uint32_t *pDynamicOffsets) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001903 const VkLayerDispatchTable *disp;
1904
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001905 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001906
Jon Ashburn23d36b12016-02-02 17:47:28 -07001907 disp->CmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout,
1908 firstSet, descriptorSetCount, pDescriptorSets,
1909 dynamicOffsetCount, pDynamicOffsets);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001910}
1911
Jon Ashburn23d36b12016-02-02 17:47:28 -07001912LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1913vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
1914 VkDeviceSize offset, VkIndexType indexType) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001915 const VkLayerDispatchTable *disp;
1916
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001917 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001918
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001919 disp->CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001920}
1921
Jon Ashburn23d36b12016-02-02 17:47:28 -07001922LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1923vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
1924 uint32_t bindingCount, const VkBuffer *pBuffers,
1925 const VkDeviceSize *pOffsets) {
Jon Ashburn754864f2015-07-23 18:49:07 -06001926 const VkLayerDispatchTable *disp;
1927
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001928 disp = loader_get_dispatch(commandBuffer);
Jon Ashburn754864f2015-07-23 18:49:07 -06001929
Jon Ashburn23d36b12016-02-02 17:47:28 -07001930 disp->CmdBindVertexBuffers(commandBuffer, firstBinding, bindingCount,
1931 pBuffers, pOffsets);
Jon Ashburn754864f2015-07-23 18:49:07 -06001932}
1933
Jon Ashburn23d36b12016-02-02 17:47:28 -07001934LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1935vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount,
1936 uint32_t instanceCount, uint32_t firstVertex,
1937 uint32_t firstInstance) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001938 const VkLayerDispatchTable *disp;
1939
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001940 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001941
Jon Ashburn23d36b12016-02-02 17:47:28 -07001942 disp->CmdDraw(commandBuffer, vertexCount, instanceCount, firstVertex,
1943 firstInstance);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001944}
1945
Jon Ashburn23d36b12016-02-02 17:47:28 -07001946LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1947vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount,
1948 uint32_t instanceCount, uint32_t firstIndex,
1949 int32_t vertexOffset, uint32_t firstInstance) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001950 const VkLayerDispatchTable *disp;
1951
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001952 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001953
Jon Ashburn23d36b12016-02-02 17:47:28 -07001954 disp->CmdDrawIndexed(commandBuffer, indexCount, instanceCount, firstIndex,
1955 vertexOffset, firstInstance);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001956}
1957
Jon Ashburn23d36b12016-02-02 17:47:28 -07001958LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1959vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
1960 VkDeviceSize offset, uint32_t drawCount, uint32_t stride) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001961 const VkLayerDispatchTable *disp;
1962
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001963 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001964
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001965 disp->CmdDrawIndirect(commandBuffer, buffer, offset, drawCount, stride);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001966}
1967
Jon Ashburn23d36b12016-02-02 17:47:28 -07001968LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1969vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
1970 VkDeviceSize offset, uint32_t drawCount,
1971 uint32_t stride) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001972 const VkLayerDispatchTable *disp;
1973
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001974 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001975
Jon Ashburn23d36b12016-02-02 17:47:28 -07001976 disp->CmdDrawIndexedIndirect(commandBuffer, buffer, offset, drawCount,
1977 stride);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001978}
1979
Jon Ashburn23d36b12016-02-02 17:47:28 -07001980LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1981vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y,
1982 uint32_t z) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001983 const VkLayerDispatchTable *disp;
1984
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001985 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001986
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001987 disp->CmdDispatch(commandBuffer, x, y, z);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001988}
1989
Jon Ashburn23d36b12016-02-02 17:47:28 -07001990LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
1991vkCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
1992 VkDeviceSize offset) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06001993 const VkLayerDispatchTable *disp;
1994
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001995 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001996
Chia-I Wu3432a0c2015-10-27 18:04:07 +08001997 disp->CmdDispatchIndirect(commandBuffer, buffer, offset);
Jon Ashburnd55a3942015-05-06 09:02:10 -06001998}
1999
Jon Ashburn23d36b12016-02-02 17:47:28 -07002000LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2001vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
2002 VkBuffer dstBuffer, uint32_t regionCount,
2003 const VkBufferCopy *pRegions) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002004 const VkLayerDispatchTable *disp;
2005
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002006 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002007
Jon Ashburn23d36b12016-02-02 17:47:28 -07002008 disp->CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount,
2009 pRegions);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002010}
2011
Jon Ashburn23d36b12016-02-02 17:47:28 -07002012LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2013vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2014 VkImageLayout srcImageLayout, VkImage dstImage,
2015 VkImageLayout dstImageLayout, uint32_t regionCount,
2016 const VkImageCopy *pRegions) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002017 const VkLayerDispatchTable *disp;
2018
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002019 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002020
Jon Ashburn23d36b12016-02-02 17:47:28 -07002021 disp->CmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage,
2022 dstImageLayout, regionCount, pRegions);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002023}
2024
Jon Ashburn23d36b12016-02-02 17:47:28 -07002025LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2026vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2027 VkImageLayout srcImageLayout, VkImage dstImage,
2028 VkImageLayout dstImageLayout, uint32_t regionCount,
2029 const VkImageBlit *pRegions, VkFilter filter) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002030 const VkLayerDispatchTable *disp;
2031
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002032 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002033
Jon Ashburn23d36b12016-02-02 17:47:28 -07002034 disp->CmdBlitImage(commandBuffer, srcImage, srcImageLayout, dstImage,
2035 dstImageLayout, regionCount, pRegions, filter);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002036}
2037
Jon Ashburn23d36b12016-02-02 17:47:28 -07002038LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2039vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
2040 VkImage dstImage, VkImageLayout dstImageLayout,
2041 uint32_t regionCount,
2042 const VkBufferImageCopy *pRegions) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002043 const VkLayerDispatchTable *disp;
2044
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002045 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002046
Jon Ashburn23d36b12016-02-02 17:47:28 -07002047 disp->CmdCopyBufferToImage(commandBuffer, srcBuffer, dstImage,
2048 dstImageLayout, regionCount, pRegions);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002049}
2050
Jon Ashburn23d36b12016-02-02 17:47:28 -07002051LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2052vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
2053 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
2054 uint32_t regionCount,
2055 const VkBufferImageCopy *pRegions) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002056 const VkLayerDispatchTable *disp;
2057
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002058 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002059
Jon Ashburn23d36b12016-02-02 17:47:28 -07002060 disp->CmdCopyImageToBuffer(commandBuffer, srcImage, srcImageLayout,
2061 dstBuffer, regionCount, pRegions);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002062}
2063
Jon Ashburn23d36b12016-02-02 17:47:28 -07002064LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2065vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
2066 VkDeviceSize dstOffset, VkDeviceSize dataSize,
Karl Schultzee344492016-07-11 15:09:57 -06002067 const void *pData) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002068 const VkLayerDispatchTable *disp;
2069
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002070 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002071
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002072 disp->CmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002073}
2074
Jon Ashburn23d36b12016-02-02 17:47:28 -07002075LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2076vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
2077 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002078 const VkLayerDispatchTable *disp;
2079
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002080 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002081
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002082 disp->CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002083}
2084
Jon Ashburn23d36b12016-02-02 17:47:28 -07002085LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2086vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
2087 VkImageLayout imageLayout, const VkClearColorValue *pColor,
2088 uint32_t rangeCount,
2089 const VkImageSubresourceRange *pRanges) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002090 const VkLayerDispatchTable *disp;
2091
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002092 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002093
Jon Ashburn23d36b12016-02-02 17:47:28 -07002094 disp->CmdClearColorImage(commandBuffer, image, imageLayout, pColor,
2095 rangeCount, pRanges);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002096}
2097
Jon Ashburn23d36b12016-02-02 17:47:28 -07002098LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2099vkCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image,
2100 VkImageLayout imageLayout,
2101 const VkClearDepthStencilValue *pDepthStencil,
2102 uint32_t rangeCount,
2103 const VkImageSubresourceRange *pRanges) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002104 const VkLayerDispatchTable *disp;
2105
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002106 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002107
Jon Ashburn23d36b12016-02-02 17:47:28 -07002108 disp->CmdClearDepthStencilImage(commandBuffer, image, imageLayout,
2109 pDepthStencil, rangeCount, pRanges);
Chris Forbesd9be82b2015-06-22 17:21:59 +12002110}
2111
Jon Ashburn23d36b12016-02-02 17:47:28 -07002112LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2113vkCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
2114 const VkClearAttachment *pAttachments, uint32_t rectCount,
2115 const VkClearRect *pRects) {
Chris Forbesd9be82b2015-06-22 17:21:59 +12002116 const VkLayerDispatchTable *disp;
2117
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002118 disp = loader_get_dispatch(commandBuffer);
Chris Forbesd9be82b2015-06-22 17:21:59 +12002119
Jon Ashburn23d36b12016-02-02 17:47:28 -07002120 disp->CmdClearAttachments(commandBuffer, attachmentCount, pAttachments,
2121 rectCount, pRects);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002122}
2123
Jon Ashburn23d36b12016-02-02 17:47:28 -07002124LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2125vkCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2126 VkImageLayout srcImageLayout, VkImage dstImage,
2127 VkImageLayout dstImageLayout, uint32_t regionCount,
2128 const VkImageResolve *pRegions) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002129 const VkLayerDispatchTable *disp;
2130
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002131 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002132
Jon Ashburn23d36b12016-02-02 17:47:28 -07002133 disp->CmdResolveImage(commandBuffer, srcImage, srcImageLayout, dstImage,
2134 dstImageLayout, regionCount, pRegions);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002135}
2136
Jon Ashburn23d36b12016-02-02 17:47:28 -07002137LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2138vkCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event,
2139 VkPipelineStageFlags stageMask) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002140 const VkLayerDispatchTable *disp;
2141
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002142 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002143
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002144 disp->CmdSetEvent(commandBuffer, event, stageMask);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002145}
2146
Jon Ashburn23d36b12016-02-02 17:47:28 -07002147LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2148vkCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event,
2149 VkPipelineStageFlags stageMask) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002150 const VkLayerDispatchTable *disp;
2151
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002152 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002153
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002154 disp->CmdResetEvent(commandBuffer, event, stageMask);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002155}
2156
Jon Ashburn23d36b12016-02-02 17:47:28 -07002157LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2158vkCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount,
2159 const VkEvent *pEvents, VkPipelineStageFlags sourceStageMask,
2160 VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount,
2161 const VkMemoryBarrier *pMemoryBarriers,
2162 uint32_t bufferMemoryBarrierCount,
2163 const VkBufferMemoryBarrier *pBufferMemoryBarriers,
2164 uint32_t imageMemoryBarrierCount,
2165 const VkImageMemoryBarrier *pImageMemoryBarriers) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002166 const VkLayerDispatchTable *disp;
2167
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002168 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002169
Jon Ashburnf19916e2016-01-11 13:12:43 -07002170 disp->CmdWaitEvents(commandBuffer, eventCount, pEvents, sourceStageMask,
2171 dstStageMask, memoryBarrierCount, pMemoryBarriers,
2172 bufferMemoryBarrierCount, pBufferMemoryBarriers,
2173 imageMemoryBarrierCount, pImageMemoryBarriers);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002174}
2175
Jon Ashburnf19916e2016-01-11 13:12:43 -07002176LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier(
Jon Ashburn23d36b12016-02-02 17:47:28 -07002177 VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask,
2178 VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags,
2179 uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers,
2180 uint32_t bufferMemoryBarrierCount,
2181 const VkBufferMemoryBarrier *pBufferMemoryBarriers,
2182 uint32_t imageMemoryBarrierCount,
2183 const VkImageMemoryBarrier *pImageMemoryBarriers) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002184 const VkLayerDispatchTable *disp;
2185
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002186 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002187
Jon Ashburn23d36b12016-02-02 17:47:28 -07002188 disp->CmdPipelineBarrier(
2189 commandBuffer, srcStageMask, dstStageMask, dependencyFlags,
2190 memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount,
2191 pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002192}
2193
Jon Ashburn23d36b12016-02-02 17:47:28 -07002194LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2195vkCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool,
2196 uint32_t slot, VkFlags flags) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002197 const VkLayerDispatchTable *disp;
2198
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002199 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002200
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002201 disp->CmdBeginQuery(commandBuffer, queryPool, slot, flags);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002202}
2203
Jon Ashburn23d36b12016-02-02 17:47:28 -07002204LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2205vkCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool,
2206 uint32_t slot) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002207 const VkLayerDispatchTable *disp;
2208
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002209 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002210
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002211 disp->CmdEndQuery(commandBuffer, queryPool, slot);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002212}
2213
Jon Ashburn23d36b12016-02-02 17:47:28 -07002214LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2215vkCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool,
2216 uint32_t firstQuery, uint32_t queryCount) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002217 const VkLayerDispatchTable *disp;
2218
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002219 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002220
Jon Ashburn19d3bf12015-12-30 14:06:55 -07002221 disp->CmdResetQueryPool(commandBuffer, queryPool, firstQuery, queryCount);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002222}
2223
Jon Ashburn23d36b12016-02-02 17:47:28 -07002224LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2225vkCmdWriteTimestamp(VkCommandBuffer commandBuffer,
2226 VkPipelineStageFlagBits pipelineStage,
2227 VkQueryPool queryPool, uint32_t slot) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002228 const VkLayerDispatchTable *disp;
2229
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002230 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002231
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002232 disp->CmdWriteTimestamp(commandBuffer, pipelineStage, queryPool, slot);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002233}
2234
Jon Ashburn23d36b12016-02-02 17:47:28 -07002235LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2236vkCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool,
2237 uint32_t firstQuery, uint32_t queryCount,
2238 VkBuffer dstBuffer, VkDeviceSize dstOffset,
2239 VkDeviceSize stride, VkFlags flags) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002240 const VkLayerDispatchTable *disp;
2241
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002242 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002243
Jon Ashburn23d36b12016-02-02 17:47:28 -07002244 disp->CmdCopyQueryPoolResults(commandBuffer, queryPool, firstQuery,
2245 queryCount, dstBuffer, dstOffset, stride,
2246 flags);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002247}
2248
Jon Ashburn23d36b12016-02-02 17:47:28 -07002249LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2250vkCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
2251 VkShaderStageFlags stageFlags, uint32_t offset,
2252 uint32_t size, const void *pValues) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002253 const VkLayerDispatchTable *disp;
2254
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002255 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002256
Jon Ashburn23d36b12016-02-02 17:47:28 -07002257 disp->CmdPushConstants(commandBuffer, layout, stageFlags, offset, size,
2258 pValues);
Tony Barbour1d2cd3f2015-07-03 10:33:54 -06002259}
2260
Jon Ashburn23d36b12016-02-02 17:47:28 -07002261LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2262vkCmdBeginRenderPass(VkCommandBuffer commandBuffer,
2263 const VkRenderPassBeginInfo *pRenderPassBegin,
2264 VkSubpassContents contents) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002265 const VkLayerDispatchTable *disp;
2266
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002267 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002268
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002269 disp->CmdBeginRenderPass(commandBuffer, pRenderPassBegin, contents);
Chia-I Wu08accc62015-07-07 11:50:03 +08002270}
2271
Jon Ashburn23d36b12016-02-02 17:47:28 -07002272LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2273vkCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) {
Chia-I Wu08accc62015-07-07 11:50:03 +08002274 const VkLayerDispatchTable *disp;
2275
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002276 disp = loader_get_dispatch(commandBuffer);
Chia-I Wu08accc62015-07-07 11:50:03 +08002277
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002278 disp->CmdNextSubpass(commandBuffer, contents);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002279}
2280
Jon Ashburn23d36b12016-02-02 17:47:28 -07002281LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2282vkCmdEndRenderPass(VkCommandBuffer commandBuffer) {
Jon Ashburnd55a3942015-05-06 09:02:10 -06002283 const VkLayerDispatchTable *disp;
2284
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002285 disp = loader_get_dispatch(commandBuffer);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002286
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002287 disp->CmdEndRenderPass(commandBuffer);
Chia-I Wu0b50a1c2015-06-26 15:34:39 +08002288}
2289
Jon Ashburn23d36b12016-02-02 17:47:28 -07002290LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
2291vkCmdExecuteCommands(VkCommandBuffer commandBuffer,
2292 uint32_t commandBuffersCount,
2293 const VkCommandBuffer *pCommandBuffers) {
Chia-I Wu0b50a1c2015-06-26 15:34:39 +08002294 const VkLayerDispatchTable *disp;
2295
Chia-I Wu3432a0c2015-10-27 18:04:07 +08002296 disp = loader_get_dispatch(commandBuffer);
Chia-I Wu0b50a1c2015-06-26 15:34:39 +08002297
Jon Ashburn23d36b12016-02-02 17:47:28 -07002298 disp->CmdExecuteCommands(commandBuffer, commandBuffersCount,
2299 pCommandBuffers);
Jon Ashburnd55a3942015-05-06 09:02:10 -06002300}