blob: c1a6fef5d1f249de6e41a87ddf7cb3c9e1db1890 [file] [log] [blame]
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06003 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28
29#include <iostream>
30#include <string>
31#include <sstream>
Mark Lobodzinski3723c512015-05-26 10:58:40 -050032#include <unordered_map>
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060033
34#include "loader_platform.h"
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060035#include "vkLayer.h"
Jon Ashburnf0615e22015-05-25 14:11:37 -060036#include "vk_debug_marker_layer.h"
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060037#include "layers_config.h"
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060038#include "vk_enum_validate_helper.h"
39#include "vk_struct_validate_helper.h"
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060040//The following is #included again to catch certain OS-specific functions being used:
41#include "loader_platform.h"
42
43#include "layers_msg.h"
Jon Ashburn6f8cd632015-06-01 09:37:38 -060044#include "layers_debug_marker_table.h"
Jon Ashburn5a10d212015-06-01 10:02:09 -060045#include "layers_table.h"
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060046
Jon Ashburnd9564002015-05-07 10:27:37 -060047static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);
Jon Ashburn6f8cd632015-06-01 09:37:38 -060048struct devExts {
49 bool debug_marker_enabled;
50};
Jon Ashburn6f8cd632015-06-01 09:37:38 -060051static std::unordered_map<void *, struct devExts> deviceExtMap;
Mark Lobodzinski3723c512015-05-26 10:58:40 -050052
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060053
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060054#include "vk_dispatch_table_helper.h"
Jon Ashburnd9564002015-05-07 10:27:37 -060055
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060056static void initParamChecker(void)
57{
58
59 const char *strOpt;
60 // initialize ParamChecker options
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060061 getLayerOptionEnum("ParamCheckerReportLevel", (uint32_t *) &g_reportFlags);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060062 g_actionIsDefault = getLayerOptionEnum("ParamCheckerDebugAction", (uint32_t *) &g_debugAction);
63
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060064 if (g_debugAction & VK_DBG_LAYER_ACTION_LOG_MSG)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060065 {
66 strOpt = getLayerOption("ParamCheckerLogFilename");
67 if (strOpt)
68 {
69 g_logFile = fopen(strOpt, "w");
70 }
71 if (g_logFile == NULL)
72 g_logFile = stdout;
73 }
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060074}
75
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060076void PreCreateInstance(const VkApplicationInfo* pAppInfo, const VkAllocCallbacks* pAllocCb)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060077{
78 if(pAppInfo == nullptr)
79 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060080 char const str[] = "vkCreateInstance parameter, VkApplicationInfo* pAppInfo, is "\
Mike Stroyan0ae32252015-04-06 15:24:46 -060081 "nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060082 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060083 return;
84 }
85
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060086 if(pAppInfo->sType != VK_STRUCTURE_TYPE_APPLICATION_INFO)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060087 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060088 char const str[] = "vkCreateInstance parameter, VK_STRUCTURE_TYPE_APPLICATION_INFO "\
89 "pAppInfo->sType, is not VK_STRUCTURE_TYPE_APPLICATION_INFO (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060090 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060091 return;
92 }
93
94 // TODO: What else can validated in pAppInfo?
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060095 // TODO: VK_API_VERSION validation.
Jeremy Hayesc6cfa572015-04-06 13:46:11 -060096
97 // It's okay if pAllocCb is a nullptr.
98 if(pAllocCb != nullptr)
99 {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600100 if(!vk_validate_vkalloccallbacks(pAllocCb))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600101 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600102 char const str[] = "vkCreateInstance parameter, VkAllocCallbacks* pAllocCb, "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600103 "contains an invalid value (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600104 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600105 return;
106 }
107 }
108}
109
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600110void PostCreateInstance(VkResult result, const VkInstanceCreateInfo *pCreateInfo, VkInstance* pInstance)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600111{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600112 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600113 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600114 // TODO: Spit out VkResult value.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600115 char const str[] = "vkCreateInstance failed (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600116 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600117 return;
118 }
119
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600120 enable_debug_report(pCreateInfo->extensionCount, pCreateInfo->pEnabledExtensions);
121
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600122 if(pInstance == nullptr)
123 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600124 char const str[] = "vkCreateInstance parameter, VkInstance* pInstance, is nullptr "\
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600125 "(postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600126 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600127 return;
128 }
Courtney Goeltzenleuchterf4a2eba2015-06-08 14:58:39 -0600129
130 VkLayerInstanceDispatchTable *pTable = instance_dispatch_table(*pInstance);
131 debug_report_init_instance_extension_dispatch_table(
132 pTable,
133 pTable->GetInstanceProcAddr,
134 *pInstance);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600135}
136
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600137VK_LAYER_EXPORT VkResult VKAPI vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600138{
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600139 loader_platform_thread_once(&initOnce, initParamChecker);
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600140
Jon Ashburn29669a42015-04-04 14:52:07 -0600141 PreCreateInstance(pCreateInfo->pAppInfo, pCreateInfo->pAllocCb);
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500142 VkResult result = instance_dispatch_table(*pInstance)->CreateInstance(pCreateInfo, pInstance);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600143 PostCreateInstance(result, pCreateInfo, pInstance);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600144 return result;
145}
146
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600147VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600148{
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500149 VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance;
150 VkResult res = instance_dispatch_table(instance)->DestroyInstance(instance);
151 tableInstanceMap.erase(pDisp);
152 return res;
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600153}
154
Tony Barbour8205d902015-04-16 15:59:00 -0600155VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceInfo(VkPhysicalDevice gpu, VkPhysicalDeviceInfoType infoType, size_t* pDataSize, void* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600156{
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600157 char str[1024];
Tony Barbour8205d902015-04-16 15:59:00 -0600158 if (!validate_VkPhysicalDeviceInfoType(infoType)) {
159 sprintf(str, "Parameter infoType to function GetPhysicalDeviceInfo has invalid value of %i.", (int)infoType);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600160 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600161 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500162 VkResult result = instance_dispatch_table(gpu)->GetPhysicalDeviceInfo(gpu, infoType, pDataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600163 return result;
164}
165
Tony Barbour8205d902015-04-16 15:59:00 -0600166void PreCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600167{
168 if(gpu == nullptr)
169 {
Tony Barbour8205d902015-04-16 15:59:00 -0600170 char const str[] = "vkCreateDevice parameter, VkPhysicalDevice gpu, is nullptr "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600171 "(precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600172 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600173 return;
174 }
175
176 if(pCreateInfo == nullptr)
177 {
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600178 char const str[] = "vkCreateDevice parameter, VkDeviceCreateInfo* pCreateInfo, is "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600179 "nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600180 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600181 return;
182 }
183
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600184 if(pCreateInfo->sType != VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600185 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600186 char const str[] = "vkCreateDevice parameter, VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO "\
187 "pCreateInfo->sType, is not VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600188 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600189 return;
190 }
191
192 if(pCreateInfo->queueRecordCount == 0)
193 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600194 char const str[] = "vkCreateDevice parameter, uint32_t pCreateInfo->queueRecordCount, is "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600195 "zero (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600196 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600197 return;
198 }
199
200 if(pCreateInfo->pRequestedQueues == nullptr)
201 {
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600202 char const str[] = "vkCreateDevice parameter, VkDeviceQueueCreateInfo* pCreateInfo->pRequestedQueues, is "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600203 "nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600204 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600205 return;
206 }
207
208 for(uint32_t i = 0; i < pCreateInfo->queueRecordCount; ++i)
209 {
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600210 if(!vk_validate_vkdevicequeuecreateinfo(&(pCreateInfo->pRequestedQueues[i])))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600211 {
212 std::stringstream ss;
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600213 ss << "vkCreateDevice parameter, VkDeviceQueueCreateInfo pCreateInfo->pRequestedQueues[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600214 "], is invalid (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600215 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600216 continue;
217 }
218 }
219
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600220}
221
Jon Ashburnf0615e22015-05-25 14:11:37 -0600222static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device)
223{
224 uint32_t i, ext_idx;
Jon Ashburn6f8cd632015-06-01 09:37:38 -0600225 VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
226 deviceExtMap[pDisp].debug_marker_enabled = false;
Jon Ashburnf0615e22015-05-25 14:11:37 -0600227 for (i = 0; i < pCreateInfo->extensionCount; i++) {
228 if (strcmp(pCreateInfo->pEnabledExtensions[i].name, DEBUG_MARKER_EXTENSION_NAME) == 0) {
Jon Ashburn6f8cd632015-06-01 09:37:38 -0600229 /* Found a matching extension name, mark it enabled and init dispatch table*/
230 initDebugMarkerTable(device);
231 deviceExtMap[pDisp].debug_marker_enabled = true;
232
Jon Ashburnf0615e22015-05-25 14:11:37 -0600233 }
234
235 }
236}
237
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600238void PostCreateDevice(VkResult result, const VkDeviceCreateInfo *pCreateInfo, VkDevice* pDevice)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600239{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600240 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600241 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600242 // TODO: Spit out VkResult value.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600243 char const str[] = "vkCreateDevice failed (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600244 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600245 return;
246 }
247
248 if(pDevice == nullptr)
249 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600250 char const str[] = "vkCreateDevice parameter, VkDevice* pDevice, is nullptr (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600251 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600252 return;
253 }
Jon Ashburn6f8cd632015-06-01 09:37:38 -0600254 VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) *pDevice;
255 enable_debug_report(pCreateInfo->extensionCount, pCreateInfo->pEnabledExtensions);
256 createDeviceRegisterExtensions(pCreateInfo, *pDevice);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600257}
258
Tony Barbour8205d902015-04-16 15:59:00 -0600259VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600260{
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600261 PreCreateDevice(gpu, pCreateInfo);
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500262 VkResult result = instance_dispatch_table(gpu)->CreateDevice(gpu, pCreateInfo, pDevice);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600263 PostCreateDevice(result, pCreateInfo, pDevice);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600264 return result;
265}
266
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600267VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600268{
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500269 VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
Jon Ashburn5a10d212015-06-01 10:02:09 -0600270 VkResult result = device_dispatch_table(device)->DestroyDevice(device);
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500271 tableMap.erase(pDisp);
Jon Ashburn6f8cd632015-06-01 09:37:38 -0600272 tableDebugMarkerMap.erase(pDisp);
273 deviceExtMap.erase(pDisp);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600274 return result;
275}
276
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600277#define PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE 2
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600278static const VkExtensionProperties pcExts[PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE] = {
279 {
280 VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,
281 "ParamChecker",
282 0x10,
283 "Sample layer: ParamChecker",
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600284 },
285 {
286 VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,
287 "Validation",
288 0x10,
289 "Sample layer: ParamChecker",
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600290 }
Jon Ashburneb2728b2015-04-10 14:33:07 -0600291};
292
293VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo(
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600294 VkExtensionInfoType infoType,
295 uint32_t extensionIndex,
296 size_t* pDataSize,
297 void* pData)
Jon Ashburneb2728b2015-04-10 14:33:07 -0600298{
Jon Ashburneb2728b2015-04-10 14:33:07 -0600299 /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
Jon Ashburneb2728b2015-04-10 14:33:07 -0600300 uint32_t *count;
301
302 if (pDataSize == NULL)
303 return VK_ERROR_INVALID_POINTER;
304
305 switch (infoType) {
306 case VK_EXTENSION_INFO_TYPE_COUNT:
307 *pDataSize = sizeof(uint32_t);
308 if (pData == NULL)
309 return VK_SUCCESS;
310 count = (uint32_t *) pData;
311 *count = PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE;
312 break;
313 case VK_EXTENSION_INFO_TYPE_PROPERTIES:
314 *pDataSize = sizeof(VkExtensionProperties);
315 if (pData == NULL)
316 return VK_SUCCESS;
317 if (extensionIndex >= PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE)
318 return VK_ERROR_INVALID_VALUE;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600319 memcpy((VkExtensionProperties *) pData, &pcExts[extensionIndex], sizeof(VkExtensionProperties));
Jon Ashburneb2728b2015-04-10 14:33:07 -0600320 break;
321 default:
322 return VK_ERROR_INVALID_VALUE;
323 };
324
325 return VK_SUCCESS;
326}
327
Jeremy Hayescf469132015-04-17 10:36:53 -0600328VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo(
329 VkPhysicalDevice gpu,
330 VkExtensionInfoType infoType,
331 uint32_t extensionIndex,
332 size_t* pDataSize,
333 void* pData)
334{
Jon Ashburn6f8cd632015-06-01 09:37:38 -0600335 //TODO add debug_marker
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600336 /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
337 uint32_t *count;
338
339 if (pDataSize == NULL)
340 return VK_ERROR_INVALID_POINTER;
341
342 switch (infoType) {
343 case VK_EXTENSION_INFO_TYPE_COUNT:
344 *pDataSize = sizeof(uint32_t);
345 if (pData == NULL)
346 return VK_SUCCESS;
347 count = (uint32_t *) pData;
348 *count = PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE;
349 break;
350 case VK_EXTENSION_INFO_TYPE_PROPERTIES:
351 *pDataSize = sizeof(VkExtensionProperties);
352 if (pData == NULL)
353 return VK_SUCCESS;
354 if (extensionIndex >= PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE)
355 return VK_ERROR_INVALID_VALUE;
356 memcpy((VkExtensionProperties *) pData, &pcExts[extensionIndex], sizeof(VkExtensionProperties));
357 break;
358 default:
359 return VK_ERROR_INVALID_VALUE;
360 };
361
362 return VK_SUCCESS;
Jeremy Hayescf469132015-04-17 10:36:53 -0600363}
364
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600365VK_LAYER_EXPORT VkResult VKAPI vkGetDeviceQueue(VkDevice device, uint32_t queueNodeIndex, uint32_t queueIndex, VkQueue* pQueue)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600366{
367
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500368 VkResult result = device_dispatch_table(device)->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600369 return result;
370}
371
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600372VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit(VkQueue queue, uint32_t cmdBufferCount, const VkCmdBuffer* pCmdBuffers, VkFence fence)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600373{
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500374 VkResult result = device_dispatch_table(queue)->QueueSubmit(queue, cmdBufferCount, pCmdBuffers, fence);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600375 return result;
376}
377
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600378VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitIdle(VkQueue queue)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600379{
380
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500381 VkResult result = device_dispatch_table(queue)->QueueWaitIdle(queue);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600382 return result;
383}
384
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600385VK_LAYER_EXPORT VkResult VKAPI vkDeviceWaitIdle(VkDevice device)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600386{
387
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500388 VkResult result = device_dispatch_table(device)->DeviceWaitIdle(device);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600389 return result;
390}
391
Tony Barbour8205d902015-04-16 15:59:00 -0600392VK_LAYER_EXPORT VkResult VKAPI vkAllocMemory(VkDevice device, const VkMemoryAllocInfo* pAllocInfo, VkDeviceMemory* pMem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600393{
394 char str[1024];
395 if (!pAllocInfo) {
396 sprintf(str, "Struct ptr parameter pAllocInfo to function AllocMemory is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600397 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600398 } else if (!vk_validate_vkmemoryallocinfo(pAllocInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600399 sprintf(str, "Parameter pAllocInfo to function AllocMemory contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600400 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600401 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500402 VkResult result = device_dispatch_table(device)->AllocMemory(device, pAllocInfo, pMem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600403 return result;
404}
405
Mike Stroyan230e6252015-04-17 12:36:38 -0600406VK_LAYER_EXPORT VkResult VKAPI vkFreeMemory(VkDevice device, VkDeviceMemory mem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600407{
408
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500409 VkResult result = device_dispatch_table(device)->FreeMemory(device, mem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600410 return result;
411}
412
Mike Stroyan230e6252015-04-17 12:36:38 -0600413VK_LAYER_EXPORT VkResult VKAPI vkSetMemoryPriority(VkDevice device, VkDeviceMemory mem, VkMemoryPriority priority)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600414{
415 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600416 if (!validate_VkMemoryPriority(priority)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600417 sprintf(str, "Parameter priority to function SetMemoryPriority has invalid value of %i.", (int)priority);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600418 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600419 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500420 VkResult result = device_dispatch_table(device)->SetMemoryPriority(device, mem, priority);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600421 return result;
422}
423
Mike Stroyan230e6252015-04-17 12:36:38 -0600424VK_LAYER_EXPORT VkResult VKAPI vkMapMemory(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkFlags flags, void** ppData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600425{
426
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500427 VkResult result = device_dispatch_table(device)->MapMemory(device, mem, offset, size, flags, ppData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600428 return result;
429}
430
Mike Stroyan230e6252015-04-17 12:36:38 -0600431VK_LAYER_EXPORT VkResult VKAPI vkUnmapMemory(VkDevice device, VkDeviceMemory mem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600432{
433
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500434 VkResult result = device_dispatch_table(device)->UnmapMemory(device, mem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600435 return result;
436}
437
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600438VK_LAYER_EXPORT VkResult VKAPI vkFlushMappedMemoryRanges(
439 VkDevice device,
440 uint32_t memRangeCount,
441 const VkMappedMemoryRange* pMemRanges)
Tony Barbour859ceab2015-04-16 19:23:13 -0600442{
443
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500444 VkResult result = device_dispatch_table(device)->FlushMappedMemoryRanges(device, memRangeCount, pMemRanges);
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600445 return result;
446}
447
448VK_LAYER_EXPORT VkResult VKAPI vkInvalidateMappedMemoryRanges(
449 VkDevice device,
450 uint32_t memRangeCount,
451 const VkMappedMemoryRange* pMemRanges)
452{
453
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500454 VkResult result = device_dispatch_table(device)->InvalidateMappedMemoryRanges(device, memRangeCount, pMemRanges);
Tony Barbour859ceab2015-04-16 19:23:13 -0600455 return result;
456}
457
Tony Barbour8205d902015-04-16 15:59:00 -0600458VK_LAYER_EXPORT VkResult VKAPI vkPinSystemMemory(VkDevice device, const void* pSysMem, size_t memSize, VkDeviceMemory* pMem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600459{
460
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500461 VkResult result = device_dispatch_table(device)->PinSystemMemory(device, pSysMem, memSize, pMem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600462 return result;
463}
464
Tony Barbour8205d902015-04-16 15:59:00 -0600465VK_LAYER_EXPORT VkResult VKAPI vkGetMultiDeviceCompatibility(VkPhysicalDevice gpu0, VkPhysicalDevice gpu1, VkPhysicalDeviceCompatibilityInfo* pInfo)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600466{
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600467
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500468 VkResult result = instance_dispatch_table(gpu0)->GetMultiDeviceCompatibility(gpu0, gpu1, pInfo);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600469 return result;
470}
471
Tony Barbour8205d902015-04-16 15:59:00 -0600472VK_LAYER_EXPORT VkResult VKAPI vkOpenSharedMemory(VkDevice device, const VkMemoryOpenInfo* pOpenInfo, VkDeviceMemory* pMem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600473{
474 char str[1024];
475 if (!pOpenInfo) {
476 sprintf(str, "Struct ptr parameter pOpenInfo to function OpenSharedMemory is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600477 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600478 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600479 else if (!vk_validate_vkmemoryopeninfo(pOpenInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600480 sprintf(str, "Parameter pOpenInfo to function OpenSharedMemory contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600481 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600482 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500483 VkResult result = device_dispatch_table(device)->OpenSharedMemory(device, pOpenInfo, pMem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600484 return result;
485}
486
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600487VK_LAYER_EXPORT VkResult VKAPI vkOpenSharedSemaphore(VkDevice device, const VkSemaphoreOpenInfo* pOpenInfo, VkSemaphore* pSemaphore)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600488{
489 char str[1024];
490 if (!pOpenInfo) {
491 sprintf(str, "Struct ptr parameter pOpenInfo to function OpenSharedSemaphore is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600492 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600493 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600494 else if (!vk_validate_vksemaphoreopeninfo(pOpenInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600495 sprintf(str, "Parameter pOpenInfo to function OpenSharedSemaphore contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600496 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600497 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500498 VkResult result = device_dispatch_table(device)->OpenSharedSemaphore(device, pOpenInfo, pSemaphore);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600499 return result;
500}
501
Tony Barbour8205d902015-04-16 15:59:00 -0600502VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerMemory(VkDevice device, const VkPeerMemoryOpenInfo* pOpenInfo, VkDeviceMemory* pMem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600503{
504 char str[1024];
505 if (!pOpenInfo) {
506 sprintf(str, "Struct ptr parameter pOpenInfo to function OpenPeerMemory is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600507 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600508 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600509 else if (!vk_validate_vkpeermemoryopeninfo(pOpenInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600510 sprintf(str, "Parameter pOpenInfo to function OpenPeerMemory contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600511 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600512 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500513 VkResult result = device_dispatch_table(device)->OpenPeerMemory(device, pOpenInfo, pMem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600514 return result;
515}
516
Tony Barbour8205d902015-04-16 15:59:00 -0600517VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerImage(VkDevice device, const VkPeerImageOpenInfo* pOpenInfo, VkImage* pImage, VkDeviceMemory* pMem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600518{
519 char str[1024];
520 if (!pOpenInfo) {
521 sprintf(str, "Struct ptr parameter pOpenInfo to function OpenPeerImage is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600522 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600523 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600524 else if (!vk_validate_vkpeerimageopeninfo(pOpenInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600525 sprintf(str, "Parameter pOpenInfo to function OpenPeerImage contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600526 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600527 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500528 VkResult result = device_dispatch_table(device)->OpenPeerImage(device, pOpenInfo, pImage, pMem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600529 return result;
530}
531
Mike Stroyan230e6252015-04-17 12:36:38 -0600532VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType objType, VkObject object)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600533{
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500534 VkResult result = device_dispatch_table(device)->DestroyObject(device, objType, object);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600535 return result;
536}
537
Mike Stroyan230e6252015-04-17 12:36:38 -0600538VK_LAYER_EXPORT VkResult VKAPI vkGetObjectInfo(VkDevice device, VkObjectType objType, VkObject object, VkObjectInfoType infoType, size_t* pDataSize, void* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600539{
540 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600541 if (!validate_VkObjectInfoType(infoType)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600542 sprintf(str, "Parameter infoType to function GetObjectInfo has invalid value of %i.", (int)infoType);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600543 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600544 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500545 VkResult result = device_dispatch_table(device)->GetObjectInfo(device, objType, object, infoType, pDataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600546 return result;
547}
548
Mark Lobodzinski23182612015-05-29 09:32:35 -0500549VK_LAYER_EXPORT VkResult VKAPI vkBindObjectMemory(VkDevice device, VkObjectType objType, VkObject object, VkDeviceMemory mem, VkDeviceSize offset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600550{
551
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500552 VkResult result = device_dispatch_table(device)->BindObjectMemory(device, objType, object, mem, offset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600553 return result;
554}
555
Mark Lobodzinski23182612015-05-29 09:32:35 -0500556VK_LAYER_EXPORT VkResult VKAPI vkQueueBindSparseBufferMemory(VkQueue queue, VkBuffer buffer, VkDeviceSize rangeOffset, VkDeviceSize rangeSize, VkDeviceMemory mem, VkDeviceSize memOffset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600557{
558
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500559 VkResult result = device_dispatch_table(queue)->QueueBindSparseBufferMemory(queue, buffer, rangeOffset, rangeSize, mem, memOffset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600560 return result;
561}
562
Mark Lobodzinski23182612015-05-29 09:32:35 -0500563VK_LAYER_EXPORT VkResult VKAPI vkQueueBindSparseImageMemory(VkQueue queue, VkImage image, const VkImageMemoryBindInfo* pBindInfo, VkDeviceMemory mem, VkDeviceSize memOffset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600564{
565 char str[1024];
Jeremy Hayes47536532015-04-15 15:20:03 -0600566 if (!pBindInfo) {
Mark Lobodzinskifb9f5642015-05-11 17:21:15 -0500567 sprintf(str, "Struct ptr parameter pBindInfo to function QueueBindSparseImageMemory is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600568 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600569 }
Jeremy Hayes47536532015-04-15 15:20:03 -0600570 else if (!vk_validate_vkimagememorybindinfo(pBindInfo)) {
571 sprintf(str, "Parameter pBindInfo to function BindImageMemoryRange contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600572 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600573 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500574 VkResult result = device_dispatch_table(queue)->QueueBindSparseImageMemory(queue, image, pBindInfo, mem, memOffset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600575 return result;
576}
577
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600578VK_LAYER_EXPORT VkResult VKAPI vkCreateFence(VkDevice device, const VkFenceCreateInfo* pCreateInfo, VkFence* pFence)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600579{
580 char str[1024];
581 if (!pCreateInfo) {
582 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateFence is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600583 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600584 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600585 else if (!vk_validate_vkfencecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600586 sprintf(str, "Parameter pCreateInfo to function CreateFence contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600587 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600588 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500589 VkResult result = device_dispatch_table(device)->CreateFence(device, pCreateInfo, pFence);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600590 return result;
591}
592
Mike Stroyan230e6252015-04-17 12:36:38 -0600593VK_LAYER_EXPORT VkResult VKAPI vkGetFenceStatus(VkDevice device, VkFence fence)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600594{
595
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500596 VkResult result = device_dispatch_table(device)->GetFenceStatus(device, fence);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600597 return result;
598}
599
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600600VK_LAYER_EXPORT VkResult VKAPI vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, bool32_t waitAll, uint64_t timeout)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600601{
602
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500603 VkResult result = device_dispatch_table(device)->WaitForFences(device, fenceCount, pFences, waitAll, timeout);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600604 return result;
605}
606
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600607VK_LAYER_EXPORT VkResult VKAPI vkResetFences(VkDevice device, uint32_t fenceCount, VkFence* pFences)
Mark Lobodzinskiebe814d2015-04-07 16:07:57 -0500608{
609
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500610 VkResult result = device_dispatch_table(device)->ResetFences(device, fenceCount, pFences);
Mark Lobodzinskiebe814d2015-04-07 16:07:57 -0500611 return result;
612}
613
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600614VK_LAYER_EXPORT VkResult VKAPI vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, VkSemaphore* pSemaphore)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600615{
616 char str[1024];
617 if (!pCreateInfo) {
618 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateSemaphore is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600619 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600620 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600621 else if (!vk_validate_vksemaphorecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600622 sprintf(str, "Parameter pCreateInfo to function CreateSemaphore contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600623 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600624 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500625 VkResult result = device_dispatch_table(device)->CreateSemaphore(device, pCreateInfo, pSemaphore);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600626 return result;
627}
628
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600629VK_LAYER_EXPORT VkResult VKAPI vkQueueSignalSemaphore(VkQueue queue, VkSemaphore semaphore)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600630{
631
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500632 VkResult result = device_dispatch_table(queue)->QueueSignalSemaphore(queue, semaphore);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600633 return result;
634}
635
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600636VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitSemaphore(VkQueue queue, VkSemaphore semaphore)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600637{
638
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500639 VkResult result = device_dispatch_table(queue)->QueueWaitSemaphore(queue, semaphore);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600640 return result;
641}
642
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600643VK_LAYER_EXPORT VkResult VKAPI vkCreateEvent(VkDevice device, const VkEventCreateInfo* pCreateInfo, VkEvent* pEvent)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600644{
645 char str[1024];
646 if (!pCreateInfo) {
647 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateEvent is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600648 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600649 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600650 else if (!vk_validate_vkeventcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600651 sprintf(str, "Parameter pCreateInfo to function CreateEvent contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600652 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600653 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500654 VkResult result = device_dispatch_table(device)->CreateEvent(device, pCreateInfo, pEvent);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600655 return result;
656}
657
Mike Stroyan230e6252015-04-17 12:36:38 -0600658VK_LAYER_EXPORT VkResult VKAPI vkGetEventStatus(VkDevice device, VkEvent event)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600659{
660
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500661 VkResult result = device_dispatch_table(device)->GetEventStatus(device, event);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600662 return result;
663}
664
Mike Stroyan230e6252015-04-17 12:36:38 -0600665VK_LAYER_EXPORT VkResult VKAPI vkSetEvent(VkDevice device, VkEvent event)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600666{
667
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500668 VkResult result = device_dispatch_table(device)->SetEvent(device, event);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600669 return result;
670}
671
Mike Stroyan230e6252015-04-17 12:36:38 -0600672VK_LAYER_EXPORT VkResult VKAPI vkResetEvent(VkDevice device, VkEvent event)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600673{
674
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500675 VkResult result = device_dispatch_table(device)->ResetEvent(device, event);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600676 return result;
677}
678
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600679VK_LAYER_EXPORT VkResult VKAPI vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, VkQueryPool* pQueryPool)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600680{
681 char str[1024];
682 if (!pCreateInfo) {
683 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateQueryPool is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600684 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600685 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600686 else if (!vk_validate_vkquerypoolcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600687 sprintf(str, "Parameter pCreateInfo to function CreateQueryPool contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600688 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600689 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500690 VkResult result = device_dispatch_table(device)->CreateQueryPool(device, pCreateInfo, pQueryPool);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600691 return result;
692}
693
Mike Stroyan230e6252015-04-17 12:36:38 -0600694VK_LAYER_EXPORT VkResult VKAPI vkGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, size_t* pDataSize, void* pData, VkQueryResultFlags flags)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600695{
696
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500697 VkResult result = device_dispatch_table(device)->GetQueryPoolResults(device, queryPool, startQuery, queryCount, pDataSize, pData, flags);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600698 return result;
699}
700
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600701VK_LAYER_EXPORT VkResult VKAPI vkGetFormatInfo(VkDevice device, VkFormat format, VkFormatInfoType infoType, size_t* pDataSize, void* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600702{
703 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -0600704 if (!validate_VkFormat(format)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600705 sprintf(str, "Parameter format to function GetFormatInfo has invalid value of %i.", (int)format);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600706 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600707 }
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -0600708 if (!validate_VkFormatInfoType(infoType)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600709 sprintf(str, "Parameter infoType to function GetFormatInfo has invalid value of %i.", (int)infoType);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600710 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600711 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500712 VkResult result = device_dispatch_table(device)->GetFormatInfo(device, format, infoType, pDataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600713 return result;
714}
715
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600716VK_LAYER_EXPORT VkResult VKAPI vkCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, VkBuffer* pBuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600717{
718 char str[1024];
719 if (!pCreateInfo) {
720 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateBuffer is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600721 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600722 }
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600723 else if (!vk_validate_vkbuffercreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600724 sprintf(str, "Parameter pCreateInfo to function CreateBuffer contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600725 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600726 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500727 VkResult result = device_dispatch_table(device)->CreateBuffer(device, pCreateInfo, pBuffer);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600728 return result;
729}
730
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600731VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600732{
733 char str[1024];
734 if (!pCreateInfo) {
735 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateBufferView is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600736 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600737 }
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600738 else if (!vk_validate_vkbufferviewcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600739 sprintf(str, "Parameter pCreateInfo to function CreateBufferView contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600740 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600741 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500742 VkResult result = device_dispatch_table(device)->CreateBufferView(device, pCreateInfo, pView);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600743 return result;
744}
745
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600746void PreCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600747{
748 if(pCreateInfo == nullptr)
749 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600750 char const str[] = "vkCreateImage parameter, VkImageCreateInfo* pCreateInfo, is "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600751 "nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600752 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600753 return;
754 }
755
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600756 if(pCreateInfo->sType != VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600757 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600758 char const str[] = "vkCreateImage parameter, VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO "\
759 "pCreateInfo->sType, is not VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600760 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600761 return;
762 }
763
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600764 if (!validate_VkImageType(pCreateInfo->imageType))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600765 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600766 char const str[] = "vkCreateImage parameter, VkImageType pCreateInfo->imageType, is "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600767 "unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600768 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600769 return;
770 }
771
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -0600772 if (!validate_VkFormat(pCreateInfo->format))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600773 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600774 char const str[] = "vkCreateImage parameter, VkFormat pCreateInfo->format, is "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600775 "unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600776 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600777 return;
778 }
779
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600780 VkFormatProperties properties;
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600781 size_t size = sizeof(properties);
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500782 VkResult result = device_dispatch_table(device)->GetFormatInfo(device, pCreateInfo->format,
Tony Barbour8205d902015-04-16 15:59:00 -0600783 VK_FORMAT_INFO_TYPE_PROPERTIES, &size, &properties);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600784 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600785 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600786 char const str[] = "vkCreateImage parameter, VkFormat pCreateInfo->format, cannot be "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600787 "validated (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600788 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600789 return;
790 }
791
792 if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0))
793 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600794 char const str[] = "vkCreateImage parameter, VkFormat pCreateInfo->format, contains "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600795 "unsupported format (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600796 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600797 return;
798 }
799
800 // TODO: Can we check device-specific limits?
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600801 if (!vk_validate_vkextent3d(&pCreateInfo->extent))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600802 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600803 char const str[] = "vkCreateImage parameter, VkExtent3D pCreateInfo->extent, is invalid "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600804 "(precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600805 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600806 return;
807 }
808
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600809 if (!validate_VkImageTiling(pCreateInfo->tiling))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600810 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600811 char const str[] = "vkCreateImage parameter, VkImageTiling pCreateInfo->tiling, is "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600812 "unrecoginized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600813 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600814 return;
815 }
816}
817
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600818void PostCreateImage(VkResult result, VkImage* pImage)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600819{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600820 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600821 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600822 // TODO: Spit out VkResult value.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600823 char const str[] = "vkCreateImage failed (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600824 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600825 return;
826 }
827
828 if(pImage == nullptr)
829 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600830 char const str[] = "vkCreateImage parameter, VkImage* pImage, is nullptr (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600831 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600832 return;
833 }
834}
835
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600836VK_LAYER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, VkImage* pImage)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600837{
838 PreCreateImage(device, pCreateInfo);
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500839 VkResult result = device_dispatch_table(device)->CreateImage(device, pCreateInfo, pImage);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600840 PostCreateImage(result, pImage);
841 return result;
842}
843
Mike Stroyan230e6252015-04-17 12:36:38 -0600844VK_LAYER_EXPORT VkResult VKAPI vkGetImageSubresourceInfo(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceInfoType infoType, size_t* pDataSize, void* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600845{
846 char str[1024];
847 if (!pSubresource) {
848 sprintf(str, "Struct ptr parameter pSubresource to function GetImageSubresourceInfo is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600849 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -0600850 } else if (!vk_validate_vkimagesubresource(pSubresource)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600851 sprintf(str, "Parameter pSubresource to function GetImageSubresourceInfo contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600852 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600853 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600854 if (!validate_VkSubresourceInfoType(infoType)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600855 sprintf(str, "Parameter infoType to function GetImageSubresourceInfo has invalid value of %i.", (int)infoType);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600856 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600857 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500858 VkResult result = device_dispatch_table(device)->GetImageSubresourceInfo(device, image, pSubresource, infoType, pDataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600859 return result;
860}
861
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600862VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600863{
864 char str[1024];
865 if (!pCreateInfo) {
866 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateImageView is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600867 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600868 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600869 else if (!vk_validate_vkimageviewcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600870 sprintf(str, "Parameter pCreateInfo to function CreateImageView contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600871 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600872 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500873 VkResult result = device_dispatch_table(device)->CreateImageView(device, pCreateInfo, pView);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600874 return result;
875}
876
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600877VK_LAYER_EXPORT VkResult VKAPI vkCreateColorAttachmentView(VkDevice device, const VkColorAttachmentViewCreateInfo* pCreateInfo, VkColorAttachmentView* pView)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600878{
879 char str[1024];
880 if (!pCreateInfo) {
881 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateColorAttachmentView is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600882 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600883 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600884 else if (!vk_validate_vkcolorattachmentviewcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600885 sprintf(str, "Parameter pCreateInfo to function CreateColorAttachmentView contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600886 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600887 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500888 VkResult result = device_dispatch_table(device)->CreateColorAttachmentView(device, pCreateInfo, pView);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600889 return result;
890}
891
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600892VK_LAYER_EXPORT VkResult VKAPI vkCreateDepthStencilView(VkDevice device, const VkDepthStencilViewCreateInfo* pCreateInfo, VkDepthStencilView* pView)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600893{
894 char str[1024];
895 if (!pCreateInfo) {
896 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDepthStencilView is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600897 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600898 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600899 else if (!vk_validate_vkdepthstencilviewcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600900 sprintf(str, "Parameter pCreateInfo to function CreateDepthStencilView contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600901 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600902 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500903 VkResult result = device_dispatch_table(device)->CreateDepthStencilView(device, pCreateInfo, pView);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600904 return result;
905}
906
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600907VK_LAYER_EXPORT VkResult VKAPI vkCreateShader(VkDevice device, const VkShaderCreateInfo* pCreateInfo, VkShader* pShader)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600908{
909 char str[1024];
910 if (!pCreateInfo) {
911 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateShader is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600912 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600913 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600914 else if (!vk_validate_vkshadercreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600915 sprintf(str, "Parameter pCreateInfo to function CreateShader contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600916 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600917 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500918 VkResult result = device_dispatch_table(device)->CreateShader(device, pCreateInfo, pShader);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600919 return result;
920}
921
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600922VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipeline(VkDevice device, const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600923{
924 char str[1024];
925 if (!pCreateInfo) {
926 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateGraphicsPipeline is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600927 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600928 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600929 else if (!vk_validate_vkgraphicspipelinecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600930 sprintf(str, "Parameter pCreateInfo to function CreateGraphicsPipeline contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600931 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600932 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500933 VkResult result = device_dispatch_table(device)->CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600934 return result;
935}
936
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600937VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative(VkDevice device, const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline basePipeline, VkPipeline* pPipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600938{
939 char str[1024];
940 if (!pCreateInfo) {
941 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateGraphicsPipelineDerivative is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600942 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600943 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600944 else if (!vk_validate_vkgraphicspipelinecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600945 sprintf(str, "Parameter pCreateInfo to function CreateGraphicsPipelineDerivative contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600946 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600947 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500948 VkResult result = device_dispatch_table(device)->CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600949 return result;
950}
951
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600952VK_LAYER_EXPORT VkResult VKAPI vkCreateComputePipeline(VkDevice device, const VkComputePipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600953{
954 char str[1024];
955 if (!pCreateInfo) {
956 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateComputePipeline is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600957 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600958 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600959 else if (!vk_validate_vkcomputepipelinecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600960 sprintf(str, "Parameter pCreateInfo to function CreateComputePipeline contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600961 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600962 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500963 VkResult result = device_dispatch_table(device)->CreateComputePipeline(device, pCreateInfo, pPipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600964 return result;
965}
966
Mike Stroyan230e6252015-04-17 12:36:38 -0600967VK_LAYER_EXPORT VkResult VKAPI vkStorePipeline(VkDevice device, VkPipeline pipeline, size_t* pDataSize, void* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600968{
969
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500970 VkResult result = device_dispatch_table(device)->StorePipeline(device, pipeline, pDataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600971 return result;
972}
973
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600974VK_LAYER_EXPORT VkResult VKAPI vkLoadPipeline(VkDevice device, size_t dataSize, const void* pData, VkPipeline* pPipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600975{
976
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500977 VkResult result = device_dispatch_table(device)->LoadPipeline(device, dataSize, pData, pPipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600978 return result;
979}
980
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600981VK_LAYER_EXPORT VkResult VKAPI vkLoadPipelineDerivative(VkDevice device, size_t dataSize, const void* pData, VkPipeline basePipeline, VkPipeline* pPipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600982{
983
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500984 VkResult result = device_dispatch_table(device)->LoadPipelineDerivative(device, dataSize, pData, basePipeline, pPipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600985 return result;
986}
987
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600988VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600989{
990 char str[1024];
991 if (!pCreateInfo) {
992 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateSampler is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600993 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600994 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600995 else if (!vk_validate_vksamplercreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600996 sprintf(str, "Parameter pCreateInfo to function CreateSampler contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600997 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600998 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500999 VkResult result = device_dispatch_table(device)->CreateSampler(device, pCreateInfo, pSampler);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001000 return result;
1001}
1002
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001003VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayout* pSetLayout)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001004{
1005 char str[1024];
1006 if (!pCreateInfo) {
1007 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDescriptorSetLayout is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001008 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001009 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001010 else if (!vk_validate_vkdescriptorsetlayoutcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001011 sprintf(str, "Parameter pCreateInfo to function CreateDescriptorSetLayout contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001012 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001013 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001014 VkResult result = device_dispatch_table(device)->CreateDescriptorSetLayout(device, pCreateInfo, pSetLayout);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001015 return result;
1016}
1017
Mark Lobodzinski556f7212015-04-17 14:11:39 -05001018VK_LAYER_EXPORT VkResult VKAPI vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, VkPipelineLayout* pPipelineLayout)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001019{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001020 VkResult result = device_dispatch_table(device)->CreatePipelineLayout(device, pCreateInfo, pPipelineLayout);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001021 return result;
1022}
1023
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001024VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorPool(VkDevice device, VkDescriptorPoolUsage poolUsage, uint32_t maxSets, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001025{
1026 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001027 if (!validate_VkDescriptorPoolUsage(poolUsage)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001028 sprintf(str, "Parameter poolUsage to function CreateDescriptorPool has invalid value of %i.", (int)poolUsage);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001029 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001030 }
1031 if (!pCreateInfo) {
1032 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDescriptorPool is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001033 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001034 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001035 else if (!vk_validate_vkdescriptorpoolcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001036 sprintf(str, "Parameter pCreateInfo to function CreateDescriptorPool contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001037 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001038 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001039 VkResult result = device_dispatch_table(device)->CreateDescriptorPool(device, poolUsage, maxSets, pCreateInfo, pDescriptorPool);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001040 return result;
1041}
1042
Mike Stroyan230e6252015-04-17 12:36:38 -06001043VK_LAYER_EXPORT VkResult VKAPI vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001044{
1045
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001046 VkResult result = device_dispatch_table(device)->ResetDescriptorPool(device, descriptorPool);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001047 return result;
1048}
1049
Mike Stroyan230e6252015-04-17 12:36:38 -06001050VK_LAYER_EXPORT VkResult VKAPI vkAllocDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSetUsage setUsage, uint32_t count, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets, uint32_t* pCount)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001051{
1052 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001053 if (!validate_VkDescriptorSetUsage(setUsage)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001054 sprintf(str, "Parameter setUsage to function AllocDescriptorSets has invalid value of %i.", (int)setUsage);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001055 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001056 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001057 VkResult result = device_dispatch_table(device)->AllocDescriptorSets(device, descriptorPool, setUsage, count, pSetLayouts, pDescriptorSets, pCount);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001058 return result;
1059}
1060
Mike Stroyan230e6252015-04-17 12:36:38 -06001061VK_LAYER_EXPORT void VKAPI vkClearDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001062{
1063
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001064 device_dispatch_table(device)->ClearDescriptorSets(device, descriptorPool, count, pDescriptorSets);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001065}
1066
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +08001067VK_LAYER_EXPORT VkResult VKAPI vkUpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001068{
1069
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001070 return device_dispatch_table(device)->UpdateDescriptorSets(device, writeCount, pDescriptorWrites, copyCount, pDescriptorCopies);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001071}
1072
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001073VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, VkDynamicVpState* pState)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001074{
1075 char str[1024];
1076 if (!pCreateInfo) {
1077 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDynamicViewportState is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001078 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001079 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001080 else if (!vk_validate_vkdynamicvpstatecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001081 sprintf(str, "Parameter pCreateInfo to function CreateDynamicViewportState contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001082 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001083 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001084 VkResult result = device_dispatch_table(device)->CreateDynamicViewportState(device, pCreateInfo, pState);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001085 return result;
1086}
1087
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001088VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState(VkDevice device, const VkDynamicRsStateCreateInfo* pCreateInfo, VkDynamicRsState* pState)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001089{
1090 char str[1024];
1091 if (!pCreateInfo) {
1092 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDynamicRasterState is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001093 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001094 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001095 else if (!vk_validate_vkdynamicrsstatecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001096 sprintf(str, "Parameter pCreateInfo to function CreateDynamicRasterState contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001097 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001098 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001099 VkResult result = device_dispatch_table(device)->CreateDynamicRasterState(device, pCreateInfo, pState);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001100 return result;
1101}
1102
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001103VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState(VkDevice device, const VkDynamicCbStateCreateInfo* pCreateInfo, VkDynamicCbState* pState)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001104{
1105 char str[1024];
1106 if (!pCreateInfo) {
1107 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDynamicColorBlendState is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001108 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001109 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001110 else if (!vk_validate_vkdynamiccbstatecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001111 sprintf(str, "Parameter pCreateInfo to function CreateDynamicColorBlendState contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001112 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001113 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001114 VkResult result = device_dispatch_table(device)->CreateDynamicColorBlendState(device, pCreateInfo, pState);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001115 return result;
1116}
1117
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001118VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState(VkDevice device, const VkDynamicDsStateCreateInfo* pCreateInfo, VkDynamicDsState* pState)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001119{
1120 char str[1024];
1121 if (!pCreateInfo) {
1122 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDynamicDepthStencilState is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001123 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001124 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001125 else if (!vk_validate_vkdynamicdsstatecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001126 sprintf(str, "Parameter pCreateInfo to function CreateDynamicDepthStencilState contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001127 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001128 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001129 VkResult result = device_dispatch_table(device)->CreateDynamicDepthStencilState(device, pCreateInfo, pState);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001130 return result;
1131}
1132
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001133void PreCreateCommandBuffer(VkDevice device, const VkCmdBufferCreateInfo* pCreateInfo)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001134{
1135 if(device == nullptr)
1136 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001137 char const str[] = "vkCreateCommandBuffer parameter, VkDevice device, is "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001138 "nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001139 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001140 return;
1141 }
1142
1143 if(pCreateInfo == nullptr)
1144 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001145 char const str[] = "vkCreateCommandBuffer parameter, VkCmdBufferCreateInfo* pCreateInfo, is "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001146 "nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001147 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001148 return;
1149 }
1150
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001151 if(pCreateInfo->sType != VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001152 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001153 char const str[] = "vkCreateCommandBuffer parameter, VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO "\
1154 "pCreateInfo->sType, is not VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001155 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001156 return;
1157 }
1158}
1159
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001160void PostCreateCommandBuffer(VkResult result, VkCmdBuffer* pCmdBuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001161{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001162 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001163 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001164 // TODO: Spit out VkResult value.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001165 char const str[] = "vkCreateCommandBuffer failed (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001166 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001167 return;
1168 }
1169
1170 if(pCmdBuffer == nullptr)
1171 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001172 char const str[] = "vkCreateCommandBuffer parameter, VkCmdBuffer* pCmdBuffer, is nullptr (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001173 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001174 return;
1175 }
1176}
1177
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001178VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer(VkDevice device,
1179 const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001180{
1181 PreCreateCommandBuffer(device, pCreateInfo);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001182 VkResult result = device_dispatch_table(device)->CreateCommandBuffer(device, pCreateInfo, pCmdBuffer);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001183 PostCreateCommandBuffer(result, pCmdBuffer);
1184 return result;
1185}
1186
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001187VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001188{
1189 char str[1024];
1190 if (!pBeginInfo) {
1191 sprintf(str, "Struct ptr parameter pBeginInfo to function BeginCommandBuffer is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001192 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001193 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001194 else if (!vk_validate_vkcmdbufferbegininfo(pBeginInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001195 sprintf(str, "Parameter pBeginInfo to function BeginCommandBuffer contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001196 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001197 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001198 VkResult result = device_dispatch_table(cmdBuffer)->BeginCommandBuffer(cmdBuffer, pBeginInfo);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001199 return result;
1200}
1201
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001202VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer(VkCmdBuffer cmdBuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001203{
1204
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001205 VkResult result = device_dispatch_table(cmdBuffer)->EndCommandBuffer(cmdBuffer);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001206 return result;
1207}
1208
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001209VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCmdBuffer cmdBuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001210{
1211
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001212 VkResult result = device_dispatch_table(cmdBuffer)->ResetCommandBuffer(cmdBuffer);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001213 return result;
1214}
1215
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001216VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001217{
1218 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001219 if (!validate_VkPipelineBindPoint(pipelineBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001220 sprintf(str, "Parameter pipelineBindPoint to function CmdBindPipeline has invalid value of %i.", (int)pipelineBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001221 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001222 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001223 device_dispatch_table(cmdBuffer)->CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001224}
1225
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001226VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject(VkCmdBuffer cmdBuffer, VkStateBindPoint stateBindPoint, VkDynamicStateObject state)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001227{
1228 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001229 if (!validate_VkStateBindPoint(stateBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001230 sprintf(str, "Parameter stateBindPoint to function CmdBindDynamicStateObject has invalid value of %i.", (int)stateBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001231 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001232 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001233 device_dispatch_table(cmdBuffer)->CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001234}
1235
Cody Northrop1a01b1d2015-04-16 13:41:56 -06001236VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001237{
1238 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001239 if (!validate_VkPipelineBindPoint(pipelineBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001240 sprintf(str, "Parameter pipelineBindPoint to function CmdBindDescriptorSets has invalid value of %i.", (int)pipelineBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001241 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001242 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001243 device_dispatch_table(cmdBuffer)->CmdBindDescriptorSets(cmdBuffer, pipelineBindPoint, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001244}
1245
Courtney Goeltzenleuchter46962942015-04-16 13:38:46 -06001246VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers(
1247 VkCmdBuffer cmdBuffer,
1248 uint32_t startBinding,
1249 uint32_t bindingCount,
1250 const VkBuffer* pBuffers,
Tony Barbour8205d902015-04-16 15:59:00 -06001251 const VkDeviceSize* pOffsets)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001252{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001253 device_dispatch_table(cmdBuffer)->CmdBindVertexBuffers(cmdBuffer, startBinding, bindingCount, pBuffers, pOffsets);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001254}
1255
Tony Barbour8205d902015-04-16 15:59:00 -06001256VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001257{
1258 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001259 if (!validate_VkIndexType(indexType)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001260 sprintf(str, "Parameter indexType to function CmdBindIndexBuffer has invalid value of %i.", (int)indexType);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001261 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001262 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001263 device_dispatch_table(cmdBuffer)->CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001264}
1265
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001266VK_LAYER_EXPORT void VKAPI vkCmdDraw(VkCmdBuffer cmdBuffer, uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001267{
1268
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001269 device_dispatch_table(cmdBuffer)->CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001270}
1271
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001272VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexed(VkCmdBuffer cmdBuffer, uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001273{
1274
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001275 device_dispatch_table(cmdBuffer)->CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001276}
1277
Tony Barbour8205d902015-04-16 15:59:00 -06001278VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001279{
1280
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001281 device_dispatch_table(cmdBuffer)->CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001282}
1283
Tony Barbour8205d902015-04-16 15:59:00 -06001284VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001285{
1286
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001287 device_dispatch_table(cmdBuffer)->CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001288}
1289
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001290VK_LAYER_EXPORT void VKAPI vkCmdDispatch(VkCmdBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001291{
1292
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001293 device_dispatch_table(cmdBuffer)->CmdDispatch(cmdBuffer, x, y, z);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001294}
1295
Tony Barbour8205d902015-04-16 15:59:00 -06001296VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001297{
1298
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001299 device_dispatch_table(cmdBuffer)->CmdDispatchIndirect(cmdBuffer, buffer, offset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001300}
1301
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001302VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001303{
1304 char str[1024];
1305 uint32_t i;
1306 for (i = 0; i < regionCount; i++) {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001307 if (!vk_validate_vkbuffercopy(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001308 sprintf(str, "Parameter pRegions[%i] to function CmdCopyBuffer contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001309 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001310 }
1311 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001312 device_dispatch_table(cmdBuffer)->CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001313}
1314
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001315VK_LAYER_EXPORT void VKAPI vkCmdCopyImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageCopy* pRegions)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001316{
1317 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001318 if (!validate_VkImageLayout(srcImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001319 sprintf(str, "Parameter srcImageLayout to function CmdCopyImage has invalid value of %i.", (int)srcImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001320 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001321 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001322 if (!validate_VkImageLayout(destImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001323 sprintf(str, "Parameter destImageLayout to function CmdCopyImage has invalid value of %i.", (int)destImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001324 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001325 }
1326 uint32_t i;
1327 for (i = 0; i < regionCount; i++) {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001328 if (!vk_validate_vkimagecopy(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001329 sprintf(str, "Parameter pRegions[%i] to function CmdCopyImage contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001330 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001331 }
1332 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001333 device_dispatch_table(cmdBuffer)->CmdCopyImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001334}
1335
Mark Lobodzinski20f68592015-05-22 14:43:25 -05001336VK_LAYER_EXPORT void VKAPI vkCmdBlitImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkTexFilter filter)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001337{
1338 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001339 if (!validate_VkImageLayout(srcImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001340 sprintf(str, "Parameter srcImageLayout to function CmdBlitImage has invalid value of %i.", (int)srcImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001341 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001342 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001343 if (!validate_VkImageLayout(destImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001344 sprintf(str, "Parameter destImageLayout to function CmdBlitImage has invalid value of %i.", (int)destImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001345 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001346 }
1347 uint32_t i;
1348 for (i = 0; i < regionCount; i++) {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001349 if (!vk_validate_vkimageblit(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001350 sprintf(str, "Parameter pRegions[%i] to function CmdBlitImage contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001351 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001352 }
1353 }
Mark Lobodzinski20f68592015-05-22 14:43:25 -05001354 //TODO: Add additional check for limitation from header rev 96.
1355 // VK_TEX_FILTER_NEAREST if the format that srcImage was created with is an integer-based format.
1356
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001357 device_dispatch_table(cmdBuffer)->CmdBlitImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions, filter);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001358}
1359
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001360VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001361{
1362 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001363 if (!validate_VkImageLayout(destImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001364 sprintf(str, "Parameter destImageLayout to function CmdCopyBufferToImage has invalid value of %i.", (int)destImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001365 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001366 }
1367 uint32_t i;
1368 for (i = 0; i < regionCount; i++) {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001369 if (!vk_validate_vkbufferimagecopy(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001370 sprintf(str, "Parameter pRegions[%i] to function CmdCopyBufferToImage contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001371 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001372 }
1373 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001374 device_dispatch_table(cmdBuffer)->CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001375}
1376
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001377VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer destBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001378{
1379 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001380 if (!validate_VkImageLayout(srcImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001381 sprintf(str, "Parameter srcImageLayout to function CmdCopyImageToBuffer has invalid value of %i.", (int)srcImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001382 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001383 }
1384 uint32_t i;
1385 for (i = 0; i < regionCount; i++) {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001386 if (!vk_validate_vkbufferimagecopy(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001387 sprintf(str, "Parameter pRegions[%i] to function CmdCopyImageToBuffer contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001388 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001389 }
1390 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001391 device_dispatch_table(cmdBuffer)->CmdCopyImageToBuffer(cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001392}
1393
Tony Barbour8205d902015-04-16 15:59:00 -06001394VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001395{
1396
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001397 device_dispatch_table(cmdBuffer)->CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001398}
1399
Tony Barbour8205d902015-04-16 15:59:00 -06001400VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001401{
1402
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001403 device_dispatch_table(cmdBuffer)->CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001404}
1405
Courtney Goeltzenleuchterda4a99e2015-04-23 17:49:22 -06001406VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColor* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001407{
1408 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001409 if (!validate_VkImageLayout(imageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001410 sprintf(str, "Parameter imageLayout to function CmdClearColorImage has invalid value of %i.", (int)imageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001411 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001412 }
1413 uint32_t i;
1414 for (i = 0; i < rangeCount; i++) {
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001415 if (!vk_validate_vkimagesubresourcerange(&pRanges[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001416 sprintf(str, "Parameter pRanges[%i] to function CmdClearColorImage contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001417 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001418 }
1419 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001420 device_dispatch_table(cmdBuffer)->CmdClearColorImage(cmdBuffer, image, imageLayout, pColor, rangeCount, pRanges);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001421}
1422
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001423VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencil(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, float depth, uint32_t stencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001424{
1425 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001426 if (!validate_VkImageLayout(imageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001427 sprintf(str, "Parameter imageLayout to function CmdClearDepthStencil has invalid value of %i.", (int)imageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001428 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001429 }
1430 uint32_t i;
1431 for (i = 0; i < rangeCount; i++) {
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001432 if (!vk_validate_vkimagesubresourcerange(&pRanges[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001433 sprintf(str, "Parameter pRanges[%i] to function CmdClearDepthStencil contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001434 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001435 }
1436 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001437 device_dispatch_table(cmdBuffer)->CmdClearDepthStencil(cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001438}
1439
Tony Barbour11f74372015-04-13 15:02:52 -06001440VK_LAYER_EXPORT void VKAPI vkCmdResolveImage(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001441{
1442 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001443 if (!validate_VkImageLayout(srcImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001444 sprintf(str, "Parameter srcImageLayout to function CmdResolveImage has invalid value of %i.", (int)srcImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001445 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001446 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001447 if (!validate_VkImageLayout(destImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001448 sprintf(str, "Parameter destImageLayout to function CmdResolveImage has invalid value of %i.", (int)destImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001449 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001450 }
1451 uint32_t i;
Tony Barbour11f74372015-04-13 15:02:52 -06001452 for (i = 0; i < regionCount; i++) {
1453 if (!vk_validate_vkimageresolve(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001454 sprintf(str, "Parameter pRects[%i] to function CmdResolveImage contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001455 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001456 }
1457 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001458 device_dispatch_table(cmdBuffer)->CmdResolveImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001459}
1460
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001461VK_LAYER_EXPORT void VKAPI vkCmdSetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001462{
1463 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001464 if (!validate_VkPipeEvent(pipeEvent)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001465 sprintf(str, "Parameter pipeEvent to function CmdSetEvent has invalid value of %i.", (int)pipeEvent);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001466 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001467 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001468 device_dispatch_table(cmdBuffer)->CmdSetEvent(cmdBuffer, event, pipeEvent);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001469}
1470
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001471VK_LAYER_EXPORT void VKAPI vkCmdResetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001472{
1473 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001474 if (!validate_VkPipeEvent(pipeEvent)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001475 sprintf(str, "Parameter pipeEvent to function CmdResetEvent has invalid value of %i.", (int)pipeEvent);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001476 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001477 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001478 device_dispatch_table(cmdBuffer)->CmdResetEvent(cmdBuffer, event, pipeEvent);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001479}
1480
Tony Barbour8205d902015-04-16 15:59:00 -06001481VK_LAYER_EXPORT void VKAPI vkCmdWaitEvents(VkCmdBuffer cmdBuffer, VkWaitEvent waitEvent, uint32_t eventCount, const VkEvent* pEvents, uint32_t memBarrierCount, const void** ppMemBarriers)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001482{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001483 device_dispatch_table(cmdBuffer)->CmdWaitEvents(cmdBuffer, waitEvent, eventCount, pEvents, memBarrierCount, ppMemBarriers);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001484}
1485
Tony Barbour8205d902015-04-16 15:59:00 -06001486VK_LAYER_EXPORT void VKAPI vkCmdPipelineBarrier(VkCmdBuffer cmdBuffer, VkWaitEvent waitEvent, uint32_t pipeEventCount, const VkPipeEvent* pPipeEvents, uint32_t memBarrierCount, const void** ppMemBarriers)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001487{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001488 device_dispatch_table(cmdBuffer)->CmdPipelineBarrier(cmdBuffer, waitEvent, pipeEventCount, pPipeEvents, memBarrierCount, ppMemBarriers);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001489}
1490
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001491VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkFlags flags)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001492{
1493
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001494 device_dispatch_table(cmdBuffer)->CmdBeginQuery(cmdBuffer, queryPool, slot, flags);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001495}
1496
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001497VK_LAYER_EXPORT void VKAPI vkCmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001498{
1499
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001500 device_dispatch_table(cmdBuffer)->CmdEndQuery(cmdBuffer, queryPool, slot);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001501}
1502
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001503VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001504{
1505
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001506 device_dispatch_table(cmdBuffer)->CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001507}
1508
Tony Barbour8205d902015-04-16 15:59:00 -06001509VK_LAYER_EXPORT void VKAPI vkCmdWriteTimestamp(VkCmdBuffer cmdBuffer, VkTimestampType timestampType, VkBuffer destBuffer, VkDeviceSize destOffset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001510{
1511 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001512 if (!validate_VkTimestampType(timestampType)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001513 sprintf(str, "Parameter timestampType to function CmdWriteTimestamp has invalid value of %i.", (int)timestampType);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001514 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001515 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001516 device_dispatch_table(cmdBuffer)->CmdWriteTimestamp(cmdBuffer, timestampType, destBuffer, destOffset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001517}
1518
Jeremy Hayescf469132015-04-17 10:36:53 -06001519VK_LAYER_EXPORT void VKAPI vkCmdCopyQueryPoolResults(
1520 VkCmdBuffer cmdBuffer,
1521 VkQueryPool queryPool,
1522 uint32_t startQuery,
1523 uint32_t queryCount,
1524 VkBuffer destBuffer,
1525 VkDeviceSize destOffset,
1526 VkDeviceSize destStride,
1527 VkQueryResultFlags flags)
1528{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001529 device_dispatch_table(cmdBuffer)->CmdCopyQueryPoolResults(cmdBuffer, queryPool, startQuery, queryCount, destBuffer, destOffset, destStride, flags);
Jeremy Hayescf469132015-04-17 10:36:53 -06001530}
1531
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001532VK_LAYER_EXPORT void VKAPI vkCmdInitAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, const uint32_t* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001533{
1534 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001535 if (!validate_VkPipelineBindPoint(pipelineBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001536 sprintf(str, "Parameter pipelineBindPoint to function CmdInitAtomicCounters has invalid value of %i.", (int)pipelineBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001537 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001538 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001539 device_dispatch_table(cmdBuffer)->CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001540}
1541
Tony Barbour8205d902015-04-16 15:59:00 -06001542VK_LAYER_EXPORT void VKAPI vkCmdLoadAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer srcBuffer, VkDeviceSize srcOffset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001543{
1544 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001545 if (!validate_VkPipelineBindPoint(pipelineBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001546 sprintf(str, "Parameter pipelineBindPoint to function CmdLoadAtomicCounters has invalid value of %i.", (int)pipelineBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001547 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001548 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001549 device_dispatch_table(cmdBuffer)->CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcBuffer, srcOffset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001550}
1551
Tony Barbour8205d902015-04-16 15:59:00 -06001552VK_LAYER_EXPORT void VKAPI vkCmdSaveAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer destBuffer, VkDeviceSize destOffset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001553{
1554 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001555 if (!validate_VkPipelineBindPoint(pipelineBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001556 sprintf(str, "Parameter pipelineBindPoint to function CmdSaveAtomicCounters has invalid value of %i.", (int)pipelineBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001557 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001558 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001559 device_dispatch_table(cmdBuffer)->CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destBuffer, destOffset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001560}
1561
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001562VK_LAYER_EXPORT VkResult VKAPI vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, VkFramebuffer* pFramebuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001563{
1564 char str[1024];
1565 if (!pCreateInfo) {
1566 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateFramebuffer is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001567 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001568 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001569 else if (!vk_validate_vkframebuffercreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001570 sprintf(str, "Parameter pCreateInfo to function CreateFramebuffer contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001571 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001572 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001573 VkResult result = device_dispatch_table(device)->CreateFramebuffer(device, pCreateInfo, pFramebuffer);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001574 return result;
1575}
1576
1577
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001578void PreCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001579{
1580 if(pCreateInfo == nullptr)
1581 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001582 char const str[] = "vkCreateRenderPass parameter, VkRenderPassCreateInfo* pCreateInfo, is "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001583 "nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001584 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001585 return;
1586 }
1587
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001588 if(pCreateInfo->sType != VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001589 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001590 char const str[] = "vkCreateRenderPass parameter, VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO "\
1591 "pCreateInfo->sType, is not VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001592 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001593 return;
1594 }
1595
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001596 if(!vk_validate_vkrect(&pCreateInfo->renderArea))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001597 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001598 char const str[] = "vkCreateRenderPass parameter, VkRect pCreateInfo->renderArea, is invalid "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001599 "(precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001600 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001601 return;
1602 }
1603
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001604 if(!vk_validate_vkextent2d(&pCreateInfo->extent))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001605 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001606 char const str[] = "vkCreateRenderPass parameter, VkExtent2D pCreateInfo->extent, is invalid "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001607 "(precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001608 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001609 return;
1610 }
1611
1612 if(pCreateInfo->pColorFormats == nullptr)
1613 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001614 char const str[] = "vkCreateRenderPass parameter, VkFormat* pCreateInfo->pColorFormats, "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001615 "is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001616 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001617 return;
1618 }
1619
1620 for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
1621 {
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001622 if(!validate_VkFormat(pCreateInfo->pColorFormats[i]))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001623 {
1624 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001625 ss << "vkCreateRenderPass parameter, VkFormat pCreateInfo->pColorFormats[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001626 "], is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001627 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001628 continue;
1629 }
1630
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001631 VkFormatProperties properties;
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001632 size_t size = sizeof(properties);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001633 VkResult result = device_dispatch_table(device)->GetFormatInfo(device, pCreateInfo->pColorFormats[i],
Tony Barbour8205d902015-04-16 15:59:00 -06001634 VK_FORMAT_INFO_TYPE_PROPERTIES, &size, &properties);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001635 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001636 {
1637 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001638 ss << "vkCreateRenderPass parameter, VkFormat pCreateInfo->pColorFormats[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001639 "], cannot be validated (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001640 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001641 continue;
1642 }
1643
1644 if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0))
1645 {
1646 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001647 ss << "vkCreateRenderPass parameter, VkFormat pCreateInfo->pColorFormats[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001648 "], contains unsupported format (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001649 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001650 continue;
1651 }
1652
1653 }
1654
1655 if(pCreateInfo->pColorLayouts == nullptr)
1656 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001657 char const str[] = "vkCreateRenderPass parameter, VkImageLayout* pCreateInfo->pColorLayouts, "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001658 "is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001659 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001660 return;
1661 }
1662
1663 for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
1664 {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001665 if(!validate_VkImageLayout(pCreateInfo->pColorLayouts[i]))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001666 {
1667 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001668 ss << "vkCreateRenderPass parameter, VkImageLayout pCreateInfo->pColorLayouts[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001669 "], is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001670 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001671 continue;
1672 }
1673 }
1674
1675 if(pCreateInfo->pColorLoadOps == nullptr)
1676 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001677 char const str[] = "vkCreateRenderPass parameter, VkAttachmentLoadOp* pCreateInfo->pColorLoadOps, "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001678 "is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001679 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001680 return;
1681 }
1682
1683 for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
1684 {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001685 if(!validate_VkAttachmentLoadOp(pCreateInfo->pColorLoadOps[i]))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001686 {
1687 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001688 ss << "vkCreateRenderPass parameter, VkAttachmentLoadOp pCreateInfo->pColorLoadOps[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001689 "], is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001690 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001691 continue;
1692 }
1693 }
1694
1695 if(pCreateInfo->pColorStoreOps == nullptr)
1696 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001697 char const str[] = "vkCreateRenderPass parameter, VkAttachmentStoreOp* pCreateInfo->pColorStoreOps, "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001698 "is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001699 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001700 return;
1701 }
1702
1703 for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
1704 {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001705 if(!validate_VkAttachmentStoreOp(pCreateInfo->pColorStoreOps[i]))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001706 {
1707 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001708 ss << "vkCreateRenderPass parameter, VkAttachmentStoreOp pCreateInfo->pColorStoreOps[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001709 "], is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001710 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001711 continue;
1712 }
1713 }
1714
1715 if(pCreateInfo->pColorLoadClearValues == nullptr)
1716 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001717 char const str[] = "vkCreateRenderPass parameter, VkClearColor* pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001718 "pColorLoadClearValues, is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001719 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001720 return;
1721 }
Jeremy Hayes6b7060b2015-04-07 09:49:05 -06001722
1723 if(pCreateInfo->pColorStoreOps == nullptr)
1724 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001725 char const str[] = "vkCreateRenderPass parameter, VK_ATTACHMENT_STORE_OP* pCreateInfo->pColorStoreOps, "\
Jeremy Hayes9bafb9f2015-04-07 13:38:03 -06001726 "is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001727 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayes6b7060b2015-04-07 09:49:05 -06001728 return;
1729 }
1730
Jeremy Hayes6b7060b2015-04-07 09:49:05 -06001731 if(pCreateInfo->pColorLoadClearValues == nullptr)
1732 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001733 char const str[] = "vkCreateRenderPass parameter, VK_CLEAR_COLOR* pCreateInfo->"\
Jeremy Hayes9bafb9f2015-04-07 13:38:03 -06001734 "pColorLoadClearValues, is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001735 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayes6b7060b2015-04-07 09:49:05 -06001736 return;
1737 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001738
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001739 for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
1740 {
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001741 if(!vk_validate_vkclearcolor(&(pCreateInfo->pColorLoadClearValues[i])))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001742 {
1743 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001744 ss << "vkCreateRenderPass parameter, VkClearColor pCreateInfo->pColorLoadClearValues[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001745 "], is invalid (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001746 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001747 continue;
1748 }
1749 }
1750
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001751 if(!validate_VkFormat(pCreateInfo->depthStencilFormat))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001752 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001753 char const str[] = "vkCreateRenderPass parameter, VkFormat pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001754 "depthStencilFormat, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001755 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001756 return;
1757 }
1758
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001759 VkFormatProperties properties;
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001760 size_t size = sizeof(properties);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001761 VkResult result = device_dispatch_table(device)->GetFormatInfo(device, pCreateInfo->depthStencilFormat,
Tony Barbour8205d902015-04-16 15:59:00 -06001762 VK_FORMAT_INFO_TYPE_PROPERTIES, &size, &properties);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001763 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001764 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001765 char const str[] = "vkCreateRenderPass parameter, VkFormat pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001766 "depthStencilFormat, cannot be validated (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001767 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001768 return;
1769 }
1770
1771 if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0))
1772 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001773 char const str[] = "vkCreateRenderPass parameter, VkFormat pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001774 "depthStencilFormat, contains unsupported format (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001775 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001776 return;
1777 }
1778
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001779 if(!validate_VkImageLayout(pCreateInfo->depthStencilLayout))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001780 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001781 char const str[] = "vkCreateRenderPass parameter, VkImageLayout pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001782 "depthStencilLayout, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001783 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001784 return;
1785 }
1786
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001787 if(!validate_VkAttachmentLoadOp(pCreateInfo->depthLoadOp))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001788 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001789 char const str[] = "vkCreateRenderPass parameter, VkAttachmentLoadOp pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001790 "depthLoadOp, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001791 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001792 return;
1793 }
1794
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001795 if(!validate_VkAttachmentStoreOp(pCreateInfo->depthStoreOp))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001796 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001797 char const str[] = "vkCreateRenderPass parameter, VkAttachmentStoreOp pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001798 "depthStoreOp, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001799 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001800 return;
1801 }
1802
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001803 if(!validate_VkAttachmentLoadOp(pCreateInfo->stencilLoadOp))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001804 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001805 char const str[] = "vkCreateRenderPass parameter, VkAttachmentLoadOp pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001806 "stencilLoadOp, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001807 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001808 return;
1809 }
1810
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001811 if(!validate_VkAttachmentStoreOp(pCreateInfo->stencilStoreOp))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001812 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001813 char const str[] = "vkCreateRenderPass parameter, VkAttachmentStoreOp pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001814 "stencilStoreOp, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001815 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001816 return;
1817 }
1818}
1819
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001820void PostCreateRenderPass(VkResult result, VkRenderPass* pRenderPass)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001821{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001822 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001823 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001824 // TODO: Spit out VkResult value.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001825 char const str[] = "vkCreateRenderPass failed (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001826 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001827 return;
1828 }
1829
1830 if(pRenderPass == nullptr)
1831 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001832 char const str[] = "vkCreateRenderPass parameter, VkRenderPass* pRenderPass, is nullptr (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001833 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001834 return;
1835 }
1836}
1837
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001838VK_LAYER_EXPORT VkResult VKAPI vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001839{
1840 PreCreateRenderPass(device, pCreateInfo);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001841 VkResult result = device_dispatch_table(device)->CreateRenderPass(device, pCreateInfo, pRenderPass);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001842 PostCreateRenderPass(result, pRenderPass);
1843 return result;
1844}
1845
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001846VK_LAYER_EXPORT void VKAPI vkCmdBeginRenderPass(VkCmdBuffer cmdBuffer, const VkRenderPassBegin* pRenderPassBegin)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001847{
1848 char str[1024];
1849 if (!pRenderPassBegin) {
1850 sprintf(str, "Struct ptr parameter pRenderPassBegin to function CmdBeginRenderPass is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001851 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001852 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001853 else if (!vk_validate_vkrenderpassbegin(pRenderPassBegin)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001854 sprintf(str, "Parameter pRenderPassBegin to function CmdBeginRenderPass contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001855 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001856 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001857 device_dispatch_table(cmdBuffer)->CmdBeginRenderPass(cmdBuffer, pRenderPassBegin);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001858}
1859
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001860VK_LAYER_EXPORT void VKAPI vkCmdEndRenderPass(VkCmdBuffer cmdBuffer, VkRenderPass renderPass)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001861{
1862
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001863 device_dispatch_table(cmdBuffer)->CmdEndRenderPass(cmdBuffer, renderPass);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001864}
1865
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001866VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback(
1867 VkInstance instance,
1868 VkFlags msgFlags,
1869 const PFN_vkDbgMsgCallback pfnMsgCallback,
1870 void* pUserData,
1871 VkDbgMsgCallback* pMsgCallback)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001872{
Jon Ashburn5a10d212015-06-01 10:02:09 -06001873 VkLayerInstanceDispatchTable *pTable = instance_dispatch_table(instance);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001874 return layer_create_msg_callback(instance, pTable, msgFlags, pfnMsgCallback, pUserData, pMsgCallback);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001875}
1876
Courtney Goeltzenleuchter09f85042015-06-01 14:45:27 -06001877VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback(
1878 VkInstance instance,
1879 VkDbgMsgCallback msgCallback)
1880{
1881 VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance;
1882 VkLayerInstanceDispatchTable *pTable = tableInstanceMap[pDisp];
1883 return layer_destroy_msg_callback(instance, pTable, msgCallback);
1884}
1885
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001886VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerBegin(VkCmdBuffer cmdBuffer, const char* pMarker)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001887{
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001888 VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
1889 if (!deviceExtMap[pDisp].debug_marker_enabled) {
Jon Ashburnf0615e22015-05-25 14:11:37 -06001890 char const str[] = "Attempt to use CmdDbgMarkerBegin but extension disabled!";
1891 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001892 return;
Jon Ashburnf0615e22015-05-25 14:11:37 -06001893 }
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001894 debug_marker_dispatch_table(cmdBuffer)->CmdDbgMarkerBegin(cmdBuffer, pMarker);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001895}
1896
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001897VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerEnd(VkCmdBuffer cmdBuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001898{
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001899 VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
1900 if (!deviceExtMap[pDisp].debug_marker_enabled) {
Jon Ashburnf0615e22015-05-25 14:11:37 -06001901 char const str[] = "Attempt to use CmdDbgMarkerEnd but extension disabled!";
1902 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001903 return;
Jon Ashburnf0615e22015-05-25 14:11:37 -06001904 }
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001905 debug_marker_dispatch_table(cmdBuffer)->CmdDbgMarkerEnd(cmdBuffer);
Jon Ashburnf0615e22015-05-25 14:11:37 -06001906}
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001907
Jon Ashburnf0615e22015-05-25 14:11:37 -06001908VkResult VKAPI vkDbgSetObjectTag(VkDevice device, VkObjectType objType, VkObject object, size_t tagSize, const void* pTag)
1909{
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001910 VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
1911 if (!deviceExtMap[pDisp].debug_marker_enabled) {
Jon Ashburnf0615e22015-05-25 14:11:37 -06001912 char const str[] = "Attempt to use DbgSetObjectTag but extension disabled!";
1913 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001914 return VK_ERROR_UNAVAILABLE;
Jon Ashburnf0615e22015-05-25 14:11:37 -06001915 }
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001916 debug_marker_dispatch_table(device)->DbgSetObjectTag(device, objType, object, tagSize, pTag);
Jon Ashburnf0615e22015-05-25 14:11:37 -06001917}
1918
1919VkResult VKAPI vkDbgSetObjectName(VkDevice device, VkObjectType objType, VkObject object, size_t nameSize, const char* pName)
1920{
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001921 VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
1922 if (!deviceExtMap[pDisp].debug_marker_enabled) {
Jon Ashburnf0615e22015-05-25 14:11:37 -06001923 char const str[] = "Attempt to use DbgSetObjectName but extension disabled!";
1924 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001925 return VK_ERROR_UNAVAILABLE;
Jon Ashburnf0615e22015-05-25 14:11:37 -06001926 }
Jon Ashburn6f8cd632015-06-01 09:37:38 -06001927 debug_marker_dispatch_table(device)->DbgSetObjectName(device, objType, object, nameSize, pName);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001928}
1929
Chia-I Wu5b66aa52015-04-16 22:02:10 +08001930VK_LAYER_EXPORT VkResult VKAPI vkGetDisplayInfoWSI(VkDisplayWSI display, VkDisplayInfoTypeWSI infoType, size_t* pDataSize, void* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001931{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001932 VkResult result = instance_dispatch_table(display)->GetDisplayInfoWSI(display, infoType, pDataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001933 return result;
1934}
1935
Chia-I Wu5b66aa52015-04-16 22:02:10 +08001936VK_LAYER_EXPORT VkResult VKAPI vkCreateSwapChainWSI(VkDevice device, const VkSwapChainCreateInfoWSI* pCreateInfo, VkSwapChainWSI* pSwapChain)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001937{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001938 VkResult result = device_dispatch_table(device)->CreateSwapChainWSI(device, pCreateInfo, pSwapChain);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001939 return result;
1940}
1941
Chia-I Wu5b66aa52015-04-16 22:02:10 +08001942VK_LAYER_EXPORT VkResult VKAPI vkDestroySwapChainWSI(VkSwapChainWSI swapChain)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001943{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001944 VkResult result = device_dispatch_table(swapChain)->DestroySwapChainWSI(swapChain);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001945 return result;
1946}
1947
Chia-I Wu5b66aa52015-04-16 22:02:10 +08001948VK_LAYER_EXPORT VkResult VKAPI vkGetSwapChainInfoWSI(VkSwapChainWSI swapChain, VkSwapChainInfoTypeWSI infoType, size_t* pDataSize, void* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001949{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001950 VkResult result = device_dispatch_table(swapChain)->GetSwapChainInfoWSI(swapChain, infoType, pDataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001951 return result;
1952}
1953
Chia-I Wu5b66aa52015-04-16 22:02:10 +08001954VK_LAYER_EXPORT VkResult VKAPI vkQueuePresentWSI(VkQueue queue, const VkPresentInfoWSI* pPresentInfo)
1955{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001956 VkResult result = device_dispatch_table(queue)->QueuePresentWSI(queue, pPresentInfo);
Chia-I Wu5b66aa52015-04-16 22:02:10 +08001957 return result;
1958}
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001959
Jon Ashburn79b78ac2015-05-05 14:22:52 -06001960static inline void* layer_intercept_proc(const char *name)
1961{
1962 if (!name || name[0] != 'v' || name[1] != 'k')
1963 return NULL;
1964
1965 name += 2;
Jon Ashburn79b78ac2015-05-05 14:22:52 -06001966 if (!strcmp(name, "DestroyDevice"))
1967 return (void*) vkDestroyDevice;
Jon Ashburn79b78ac2015-05-05 14:22:52 -06001968 if (!strcmp(name, "GetDeviceQueue"))
1969 return (void*) vkGetDeviceQueue;
1970 if (!strcmp(name, "QueueSubmit"))
1971 return (void*) vkQueueSubmit;
1972 if (!strcmp(name, "QueueWaitIdle"))
1973 return (void*) vkQueueWaitIdle;
1974 if (!strcmp(name, "DeviceWaitIdle"))
1975 return (void*) vkDeviceWaitIdle;
1976 if (!strcmp(name, "AllocMemory"))
1977 return (void*) vkAllocMemory;
1978 if (!strcmp(name, "FreeMemory"))
1979 return (void*) vkFreeMemory;
1980 if (!strcmp(name, "SetMemoryPriority"))
1981 return (void*) vkSetMemoryPriority;
1982 if (!strcmp(name, "MapMemory"))
1983 return (void*) vkMapMemory;
1984 if (!strcmp(name, "UnmapMemory"))
1985 return (void*) vkUnmapMemory;
1986 if (!strcmp(name, "FlushMappedMemoryRanges"))
1987 return (void*) vkFlushMappedMemoryRanges;
1988 if (!strcmp(name, "InvalidateMappedMemoryRanges"))
1989 return (void*) vkInvalidateMappedMemoryRanges;
1990 if (!strcmp(name, "PinSystemMemory"))
1991 return (void*) vkPinSystemMemory;
Jon Ashburn79b78ac2015-05-05 14:22:52 -06001992 if (!strcmp(name, "OpenSharedMemory"))
1993 return (void*) vkOpenSharedMemory;
1994 if (!strcmp(name, "OpenSharedSemaphore"))
1995 return (void*) vkOpenSharedSemaphore;
1996 if (!strcmp(name, "OpenPeerMemory"))
1997 return (void*) vkOpenPeerMemory;
1998 if (!strcmp(name, "OpenPeerImage"))
1999 return (void*) vkOpenPeerImage;
2000 if (!strcmp(name, "DestroyObject"))
2001 return (void*) vkDestroyObject;
2002 if (!strcmp(name, "GetObjectInfo"))
2003 return (void*) vkGetObjectInfo;
2004 if (!strcmp(name, "CreateFence"))
2005 return (void*) vkCreateFence;
2006 if (!strcmp(name, "ResetFences"))
2007 return (void*) vkResetFences;
2008 if (!strcmp(name, "GetFenceStatus"))
2009 return (void*) vkGetFenceStatus;
2010 if (!strcmp(name, "WaitForFences"))
2011 return (void*) vkWaitForFences;
2012 if (!strcmp(name, "CreateSemaphore"))
2013 return (void*) vkCreateSemaphore;
2014 if (!strcmp(name, "QueueSignalSemaphore"))
2015 return (void*) vkQueueSignalSemaphore;
2016 if (!strcmp(name, "QueueWaitSemaphore"))
2017 return (void*) vkQueueWaitSemaphore;
2018 if (!strcmp(name, "CreateEvent"))
2019 return (void*) vkCreateEvent;
2020 if (!strcmp(name, "GetEventStatus"))
2021 return (void*) vkGetEventStatus;
2022 if (!strcmp(name, "SetEvent"))
2023 return (void*) vkSetEvent;
2024 if (!strcmp(name, "ResetEvent"))
2025 return (void*) vkResetEvent;
2026 if (!strcmp(name, "CreateQueryPool"))
2027 return (void*) vkCreateQueryPool;
2028 if (!strcmp(name, "GetQueryPoolResults"))
2029 return (void*) vkGetQueryPoolResults;
2030 if (!strcmp(name, "GetFormatInfo"))
2031 return (void*) vkGetFormatInfo;
2032 if (!strcmp(name, "CreateBuffer"))
2033 return (void*) vkCreateBuffer;
2034 if (!strcmp(name, "CreateBufferView"))
2035 return (void*) vkCreateBufferView;
2036 if (!strcmp(name, "CreateImage"))
2037 return (void*) vkCreateImage;
2038 if (!strcmp(name, "GetImageSubresourceInfo"))
2039 return (void*) vkGetImageSubresourceInfo;
2040 if (!strcmp(name, "CreateImageView"))
2041 return (void*) vkCreateImageView;
2042 if (!strcmp(name, "CreateColorAttachmentView"))
2043 return (void*) vkCreateColorAttachmentView;
2044 if (!strcmp(name, "CreateDepthStencilView"))
2045 return (void*) vkCreateDepthStencilView;
2046 if (!strcmp(name, "CreateShader"))
2047 return (void*) vkCreateShader;
2048 if (!strcmp(name, "CreateGraphicsPipeline"))
2049 return (void*) vkCreateGraphicsPipeline;
2050 if (!strcmp(name, "CreateGraphicsPipelineDerivative"))
2051 return (void*) vkCreateGraphicsPipelineDerivative;
2052 if (!strcmp(name, "CreateComputePipeline"))
2053 return (void*) vkCreateComputePipeline;
2054 if (!strcmp(name, "StorePipeline"))
2055 return (void*) vkStorePipeline;
2056 if (!strcmp(name, "LoadPipeline"))
2057 return (void*) vkLoadPipeline;
2058 if (!strcmp(name, "LoadPipelineDerivative"))
2059 return (void*) vkLoadPipelineDerivative;
2060 if (!strcmp(name, "CreatePipelineLayout"))
2061 return (void*) vkCreatePipelineLayout;
2062 if (!strcmp(name, "CreateSampler"))
2063 return (void*) vkCreateSampler;
2064 if (!strcmp(name, "CreateDescriptorSetLayout"))
2065 return (void*) vkCreateDescriptorSetLayout;
2066 if (!strcmp(name, "CreateDescriptorPool"))
2067 return (void*) vkCreateDescriptorPool;
2068 if (!strcmp(name, "ResetDescriptorPool"))
2069 return (void*) vkResetDescriptorPool;
2070 if (!strcmp(name, "AllocDescriptorSets"))
2071 return (void*) vkAllocDescriptorSets;
2072 if (!strcmp(name, "ClearDescriptorSets"))
2073 return (void*) vkClearDescriptorSets;
2074 if (!strcmp(name, "CreateDynamicViewportState"))
2075 return (void*) vkCreateDynamicViewportState;
2076 if (!strcmp(name, "CreateDynamicRasterState"))
2077 return (void*) vkCreateDynamicRasterState;
2078 if (!strcmp(name, "CreateDynamicColorBlendState"))
2079 return (void*) vkCreateDynamicColorBlendState;
2080 if (!strcmp(name, "CreateDynamicDepthStencilState"))
2081 return (void*) vkCreateDynamicDepthStencilState;
2082 if (!strcmp(name, "CreateCommandBuffer"))
2083 return (void*) vkCreateCommandBuffer;
2084 if (!strcmp(name, "BeginCommandBuffer"))
2085 return (void*) vkBeginCommandBuffer;
2086 if (!strcmp(name, "EndCommandBuffer"))
2087 return (void*) vkEndCommandBuffer;
2088 if (!strcmp(name, "ResetCommandBuffer"))
2089 return (void*) vkResetCommandBuffer;
2090 if (!strcmp(name, "CmdBindPipeline"))
2091 return (void*) vkCmdBindPipeline;
2092 if (!strcmp(name, "CmdBindDynamicStateObject"))
2093 return (void*) vkCmdBindDynamicStateObject;
2094 if (!strcmp(name, "CmdBindDescriptorSets"))
2095 return (void*) vkCmdBindDescriptorSets;
2096 if (!strcmp(name, "CmdBindVertexBuffers"))
2097 return (void*) vkCmdBindVertexBuffers;
2098 if (!strcmp(name, "CmdBindIndexBuffer"))
2099 return (void*) vkCmdBindIndexBuffer;
2100 if (!strcmp(name, "CmdDraw"))
2101 return (void*) vkCmdDraw;
2102 if (!strcmp(name, "CmdDrawIndexed"))
2103 return (void*) vkCmdDrawIndexed;
2104 if (!strcmp(name, "CmdDrawIndirect"))
2105 return (void*) vkCmdDrawIndirect;
2106 if (!strcmp(name, "CmdDrawIndexedIndirect"))
2107 return (void*) vkCmdDrawIndexedIndirect;
2108 if (!strcmp(name, "CmdDispatch"))
2109 return (void*) vkCmdDispatch;
2110 if (!strcmp(name, "CmdDispatchIndirect"))
2111 return (void*) vkCmdDispatchIndirect;
2112 if (!strcmp(name, "CmdCopyBuffer"))
2113 return (void*) vkCmdCopyBuffer;
2114 if (!strcmp(name, "CmdCopyImage"))
2115 return (void*) vkCmdCopyImage;
2116 if (!strcmp(name, "CmdBlitImage"))
2117 return (void*) vkCmdBlitImage;
2118 if (!strcmp(name, "CmdCopyBufferToImage"))
2119 return (void*) vkCmdCopyBufferToImage;
2120 if (!strcmp(name, "CmdCopyImageToBuffer"))
2121 return (void*) vkCmdCopyImageToBuffer;
2122 if (!strcmp(name, "CmdUpdateBuffer"))
2123 return (void*) vkCmdUpdateBuffer;
2124 if (!strcmp(name, "CmdFillBuffer"))
2125 return (void*) vkCmdFillBuffer;
2126 if (!strcmp(name, "CmdClearColorImage"))
2127 return (void*) vkCmdClearColorImage;
2128 if (!strcmp(name, "CmdClearDepthStencil"))
2129 return (void*) vkCmdClearDepthStencil;
2130 if (!strcmp(name, "CmdResolveImage"))
2131 return (void*) vkCmdResolveImage;
2132 if (!strcmp(name, "CmdSetEvent"))
2133 return (void*) vkCmdSetEvent;
2134 if (!strcmp(name, "CmdResetEvent"))
2135 return (void*) vkCmdResetEvent;
2136 if (!strcmp(name, "CmdWaitEvents"))
2137 return (void*) vkCmdWaitEvents;
2138 if (!strcmp(name, "CmdPipelineBarrier"))
2139 return (void*) vkCmdPipelineBarrier;
2140 if (!strcmp(name, "CmdBeginQuery"))
2141 return (void*) vkCmdBeginQuery;
2142 if (!strcmp(name, "CmdEndQuery"))
2143 return (void*) vkCmdEndQuery;
2144 if (!strcmp(name, "CmdResetQueryPool"))
2145 return (void*) vkCmdResetQueryPool;
2146 if (!strcmp(name, "CmdWriteTimestamp"))
2147 return (void*) vkCmdWriteTimestamp;
2148 if (!strcmp(name, "CmdCopyQueryPoolResults"))
2149 return (void*) vkCmdCopyQueryPoolResults;
2150 if (!strcmp(name, "CmdInitAtomicCounters"))
2151 return (void*) vkCmdInitAtomicCounters;
2152 if (!strcmp(name, "CmdLoadAtomicCounters"))
2153 return (void*) vkCmdLoadAtomicCounters;
2154 if (!strcmp(name, "CmdSaveAtomicCounters"))
2155 return (void*) vkCmdSaveAtomicCounters;
2156 if (!strcmp(name, "CreateFramebuffer"))
2157 return (void*) vkCreateFramebuffer;
2158 if (!strcmp(name, "CreateRenderPass"))
2159 return (void*) vkCreateRenderPass;
2160 if (!strcmp(name, "CmdBeginRenderPass"))
2161 return (void*) vkCmdBeginRenderPass;
2162 if (!strcmp(name, "CmdEndRenderPass"))
2163 return (void*) vkCmdEndRenderPass;
Jon Ashburn79b78ac2015-05-05 14:22:52 -06002164 if (!strcmp(name, "GetDisplayInfoWSI"))
2165 return (void*) vkGetDisplayInfoWSI;
2166 if (!strcmp(name, "CreateSwapChainWSI"))
2167 return (void*) vkCreateSwapChainWSI;
2168 if (!strcmp(name, "DestroySwapChainWSI"))
2169 return (void*) vkDestroySwapChainWSI;
2170 if (!strcmp(name, "GetSwapChainInfoWSI"))
2171 return (void*) vkGetSwapChainInfoWSI;
2172 if (!strcmp(name, "QueuePresentWSI"))
2173 return (void*) vkQueuePresentWSI;
2174
2175 return NULL;
2176}
2177
2178static inline void* layer_intercept_instance_proc(const char *name)
2179{
2180 if (!name || name[0] != 'v' || name[1] != 'k')
2181 return NULL;
2182
2183 name += 2;
Jon Ashburn79b78ac2015-05-05 14:22:52 -06002184 if (!strcmp(name, "CreateInstance"))
2185 return (void*) vkCreateInstance;
2186 if (!strcmp(name, "DestroyInstance"))
2187 return (void*) vkDestroyInstance;
2188 if (!strcmp(name, "GetPhysicalDeviceInfo"))
2189 return (void*) vkGetPhysicalDeviceInfo;
Jon Ashburn79b78ac2015-05-05 14:22:52 -06002190 if (!strcmp(name, "CreateDevice"))
2191 return (void*) vkCreateDevice;
2192 if (!strcmp(name, "GetGlobalExtensionInfo"))
2193 return (void*) vkGetGlobalExtensionInfo;
2194 if (!strcmp(name, "GetPhysicalDeviceExtensionInfo"))
2195 return (void*) vkGetPhysicalDeviceExtensionInfo;
Jon Ashburn79b78ac2015-05-05 14:22:52 -06002196 if (!strcmp(name, "GetMultiDeviceCompatibility"))
2197 return (void*) vkGetMultiDeviceCompatibility;
Jon Ashburn79b78ac2015-05-05 14:22:52 -06002198
2199 return NULL;
2200}
2201
Jon Ashburn1245cec2015-05-18 13:20:15 -06002202VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr(VkDevice device, const char* funcName)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06002203{
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06002204 void* addr;
Mark Lobodzinski3723c512015-05-26 10:58:40 -05002205 if (device == NULL) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06002206 return NULL;
Mark Lobodzinski3723c512015-05-26 10:58:40 -05002207 }
2208
Jon Ashburnd9564002015-05-07 10:27:37 -06002209 loader_platform_thread_once(&initOnce, initParamChecker);
Jon Ashburn4f2575f2015-05-28 16:25:02 -06002210
2211 /* loader uses this to force layer initialization; device object is wrapped */
2212 if (!strcmp(funcName, "vkGetDeviceProcAddr")) {
2213 initDeviceTable((const VkBaseLayerObject *) device);
2214 return (void*) vkGetDeviceProcAddr;
2215 }
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06002216
2217 addr = layer_intercept_proc(funcName);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05002218 if (addr) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06002219 return addr;
Mark Lobodzinski3723c512015-05-26 10:58:40 -05002220 }
Jon Ashburn6f8cd632015-06-01 09:37:38 -06002221
2222 VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
2223 if (!deviceExtMap[pDisp].debug_marker_enabled)
2224 {
2225 if (!strcmp(funcName, "CmdDbgMarkerBegin"))
2226 return (void*) vkCmdDbgMarkerBegin;
2227 if (!strcmp(funcName, "CmdDbgMarkerEnd"))
2228 return (void*) vkCmdDbgMarkerEnd;
2229 if (!strcmp(funcName, "DbgSetObjectTag"))
2230 return (void*) vkDbgSetObjectTag;
2231 if (!strcmp(funcName, "DbgSetObjectName"))
2232 return (void*) vkDbgSetObjectName;
2233 }
2234 {
Jon Ashburn5a10d212015-06-01 10:02:09 -06002235 VkLayerDispatchTable* pTable = device_dispatch_table(device);
Jon Ashburn4f2575f2015-05-28 16:25:02 -06002236 if (pTable->GetDeviceProcAddr == NULL)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06002237 return NULL;
Jon Ashburn4f2575f2015-05-28 16:25:02 -06002238 return pTable->GetDeviceProcAddr(device, funcName);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06002239 }
2240}
2241
Mark Lobodzinski3723c512015-05-26 10:58:40 -05002242VK_LAYER_EXPORT void* VKAPI vkGetInstanceProcAddr(VkInstance instance, const char* funcName)
Jon Ashburn79b78ac2015-05-05 14:22:52 -06002243{
Courtney Goeltzenleuchter09f85042015-06-01 14:45:27 -06002244 void *fptr;
Jon Ashburn79b78ac2015-05-05 14:22:52 -06002245 void* addr;
Mark Lobodzinski3723c512015-05-26 10:58:40 -05002246 if (instance == NULL) {
Jon Ashburn79b78ac2015-05-05 14:22:52 -06002247 return NULL;
Mark Lobodzinski3723c512015-05-26 10:58:40 -05002248 }
2249
Jon Ashburnd9564002015-05-07 10:27:37 -06002250 loader_platform_thread_once(&initOnce, initParamChecker);
Jon Ashburn4f2575f2015-05-28 16:25:02 -06002251
2252 /* loader uses this to force layer initialization; instance object is wrapped */
2253 if (!strcmp(funcName, "vkGetInstanceProcAddr")) {
2254 initInstanceTable((const VkBaseLayerObject *) instance);
2255 return (void*) vkGetInstanceProcAddr;
2256 }
Jon Ashburn79b78ac2015-05-05 14:22:52 -06002257
2258 addr = layer_intercept_instance_proc(funcName);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05002259 if (addr) {
Jon Ashburn79b78ac2015-05-05 14:22:52 -06002260 return addr;
Mark Lobodzinski3723c512015-05-26 10:58:40 -05002261 }
Courtney Goeltzenleuchter09f85042015-06-01 14:45:27 -06002262
2263 fptr = msg_callback_get_proc_addr(funcName);
2264 if (fptr)
2265 return fptr;
2266
Jon Ashburn5a10d212015-06-01 10:02:09 -06002267 VkLayerInstanceDispatchTable* pTable = instance_dispatch_table(instance);
2268 if (pTable->GetInstanceProcAddr == NULL)
2269 return NULL;
2270 return pTable->GetInstanceProcAddr(instance, funcName);
Jon Ashburn79b78ac2015-05-05 14:22:52 -06002271}