blob: 0b13b65c9adbb1458d15d343be0c123eed375b6f [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{
Courtney Goeltzenleuchter9f171942015-06-13 21:22:12 -0600149 dispatch_key key = get_dispatch_key(instance);
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500150 VkResult res = instance_dispatch_table(instance)->DestroyInstance(instance);
Courtney Goeltzenleuchter9f171942015-06-13 21:22:12 -0600151 destroy_instance_dispatch_table(key);
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500152 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;
Courtney Goeltzenleuchter9f171942015-06-13 21:22:12 -0600270 dispatch_key key = get_dispatch_key(device);
Jon Ashburn5a10d212015-06-01 10:02:09 -0600271 VkResult result = device_dispatch_table(device)->DestroyDevice(device);
Courtney Goeltzenleuchter9f171942015-06-13 21:22:12 -0600272 destroy_device_dispatch_table(key);
Jon Ashburn6f8cd632015-06-01 09:37:38 -0600273 tableDebugMarkerMap.erase(pDisp);
274 deviceExtMap.erase(pDisp);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600275 return result;
276}
277
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600278#define PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE 2
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600279static const VkExtensionProperties pcExts[PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE] = {
280 {
281 VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,
282 "ParamChecker",
283 0x10,
284 "Sample layer: ParamChecker",
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600285 },
286 {
287 VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,
288 "Validation",
289 0x10,
290 "Sample layer: ParamChecker",
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600291 }
Jon Ashburneb2728b2015-04-10 14:33:07 -0600292};
293
294VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo(
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600295 VkExtensionInfoType infoType,
296 uint32_t extensionIndex,
297 size_t* pDataSize,
298 void* pData)
Jon Ashburneb2728b2015-04-10 14:33:07 -0600299{
Jon Ashburneb2728b2015-04-10 14:33:07 -0600300 /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
Jon Ashburneb2728b2015-04-10 14:33:07 -0600301 uint32_t *count;
302
303 if (pDataSize == NULL)
304 return VK_ERROR_INVALID_POINTER;
305
306 switch (infoType) {
307 case VK_EXTENSION_INFO_TYPE_COUNT:
308 *pDataSize = sizeof(uint32_t);
309 if (pData == NULL)
310 return VK_SUCCESS;
311 count = (uint32_t *) pData;
312 *count = PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE;
313 break;
314 case VK_EXTENSION_INFO_TYPE_PROPERTIES:
315 *pDataSize = sizeof(VkExtensionProperties);
316 if (pData == NULL)
317 return VK_SUCCESS;
318 if (extensionIndex >= PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE)
319 return VK_ERROR_INVALID_VALUE;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600320 memcpy((VkExtensionProperties *) pData, &pcExts[extensionIndex], sizeof(VkExtensionProperties));
Jon Ashburneb2728b2015-04-10 14:33:07 -0600321 break;
322 default:
323 return VK_ERROR_INVALID_VALUE;
324 };
325
326 return VK_SUCCESS;
327}
328
Jeremy Hayescf469132015-04-17 10:36:53 -0600329VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo(
330 VkPhysicalDevice gpu,
331 VkExtensionInfoType infoType,
332 uint32_t extensionIndex,
333 size_t* pDataSize,
334 void* pData)
335{
Jon Ashburn6f8cd632015-06-01 09:37:38 -0600336 //TODO add debug_marker
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600337 /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
338 uint32_t *count;
339
340 if (pDataSize == NULL)
341 return VK_ERROR_INVALID_POINTER;
342
343 switch (infoType) {
344 case VK_EXTENSION_INFO_TYPE_COUNT:
345 *pDataSize = sizeof(uint32_t);
346 if (pData == NULL)
347 return VK_SUCCESS;
348 count = (uint32_t *) pData;
349 *count = PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE;
350 break;
351 case VK_EXTENSION_INFO_TYPE_PROPERTIES:
352 *pDataSize = sizeof(VkExtensionProperties);
353 if (pData == NULL)
354 return VK_SUCCESS;
355 if (extensionIndex >= PARAM_CHECKER_LAYER_EXT_ARRAY_SIZE)
356 return VK_ERROR_INVALID_VALUE;
357 memcpy((VkExtensionProperties *) pData, &pcExts[extensionIndex], sizeof(VkExtensionProperties));
358 break;
359 default:
360 return VK_ERROR_INVALID_VALUE;
361 };
362
363 return VK_SUCCESS;
Jeremy Hayescf469132015-04-17 10:36:53 -0600364}
365
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600366VK_LAYER_EXPORT VkResult VKAPI vkGetDeviceQueue(VkDevice device, uint32_t queueNodeIndex, uint32_t queueIndex, VkQueue* pQueue)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600367{
368
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500369 VkResult result = device_dispatch_table(device)->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600370 return result;
371}
372
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600373VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit(VkQueue queue, uint32_t cmdBufferCount, const VkCmdBuffer* pCmdBuffers, VkFence fence)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600374{
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500375 VkResult result = device_dispatch_table(queue)->QueueSubmit(queue, cmdBufferCount, pCmdBuffers, fence);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600376 return result;
377}
378
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600379VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitIdle(VkQueue queue)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600380{
381
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500382 VkResult result = device_dispatch_table(queue)->QueueWaitIdle(queue);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600383 return result;
384}
385
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600386VK_LAYER_EXPORT VkResult VKAPI vkDeviceWaitIdle(VkDevice device)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600387{
388
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500389 VkResult result = device_dispatch_table(device)->DeviceWaitIdle(device);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600390 return result;
391}
392
Tony Barbour8205d902015-04-16 15:59:00 -0600393VK_LAYER_EXPORT VkResult VKAPI vkAllocMemory(VkDevice device, const VkMemoryAllocInfo* pAllocInfo, VkDeviceMemory* pMem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600394{
395 char str[1024];
396 if (!pAllocInfo) {
397 sprintf(str, "Struct ptr parameter pAllocInfo to function AllocMemory is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600398 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600399 } else if (!vk_validate_vkmemoryallocinfo(pAllocInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600400 sprintf(str, "Parameter pAllocInfo to function AllocMemory contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600401 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600402 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500403 VkResult result = device_dispatch_table(device)->AllocMemory(device, pAllocInfo, pMem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600404 return result;
405}
406
Mike Stroyan230e6252015-04-17 12:36:38 -0600407VK_LAYER_EXPORT VkResult VKAPI vkFreeMemory(VkDevice device, VkDeviceMemory mem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600408{
409
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500410 VkResult result = device_dispatch_table(device)->FreeMemory(device, mem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600411 return result;
412}
413
Mike Stroyan230e6252015-04-17 12:36:38 -0600414VK_LAYER_EXPORT VkResult VKAPI vkSetMemoryPriority(VkDevice device, VkDeviceMemory mem, VkMemoryPriority priority)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600415{
416 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600417 if (!validate_VkMemoryPriority(priority)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600418 sprintf(str, "Parameter priority to function SetMemoryPriority has invalid value of %i.", (int)priority);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600419 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600420 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500421 VkResult result = device_dispatch_table(device)->SetMemoryPriority(device, mem, priority);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600422 return result;
423}
424
Mike Stroyan230e6252015-04-17 12:36:38 -0600425VK_LAYER_EXPORT VkResult VKAPI vkMapMemory(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkFlags flags, void** ppData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600426{
427
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500428 VkResult result = device_dispatch_table(device)->MapMemory(device, mem, offset, size, flags, ppData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600429 return result;
430}
431
Mike Stroyan230e6252015-04-17 12:36:38 -0600432VK_LAYER_EXPORT VkResult VKAPI vkUnmapMemory(VkDevice device, VkDeviceMemory mem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600433{
434
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500435 VkResult result = device_dispatch_table(device)->UnmapMemory(device, mem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600436 return result;
437}
438
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600439VK_LAYER_EXPORT VkResult VKAPI vkFlushMappedMemoryRanges(
440 VkDevice device,
441 uint32_t memRangeCount,
442 const VkMappedMemoryRange* pMemRanges)
Tony Barbour859ceab2015-04-16 19:23:13 -0600443{
444
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500445 VkResult result = device_dispatch_table(device)->FlushMappedMemoryRanges(device, memRangeCount, pMemRanges);
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600446 return result;
447}
448
449VK_LAYER_EXPORT VkResult VKAPI vkInvalidateMappedMemoryRanges(
450 VkDevice device,
451 uint32_t memRangeCount,
452 const VkMappedMemoryRange* pMemRanges)
453{
454
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500455 VkResult result = device_dispatch_table(device)->InvalidateMappedMemoryRanges(device, memRangeCount, pMemRanges);
Tony Barbour859ceab2015-04-16 19:23:13 -0600456 return result;
457}
458
Tony Barbour8205d902015-04-16 15:59:00 -0600459VK_LAYER_EXPORT VkResult VKAPI vkPinSystemMemory(VkDevice device, const void* pSysMem, size_t memSize, VkDeviceMemory* pMem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600460{
461
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500462 VkResult result = device_dispatch_table(device)->PinSystemMemory(device, pSysMem, memSize, pMem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600463 return result;
464}
465
Tony Barbour8205d902015-04-16 15:59:00 -0600466VK_LAYER_EXPORT VkResult VKAPI vkGetMultiDeviceCompatibility(VkPhysicalDevice gpu0, VkPhysicalDevice gpu1, VkPhysicalDeviceCompatibilityInfo* pInfo)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600467{
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600468
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500469 VkResult result = instance_dispatch_table(gpu0)->GetMultiDeviceCompatibility(gpu0, gpu1, pInfo);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600470 return result;
471}
472
Tony Barbour8205d902015-04-16 15:59:00 -0600473VK_LAYER_EXPORT VkResult VKAPI vkOpenSharedMemory(VkDevice device, const VkMemoryOpenInfo* pOpenInfo, VkDeviceMemory* pMem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600474{
475 char str[1024];
476 if (!pOpenInfo) {
477 sprintf(str, "Struct ptr parameter pOpenInfo to function OpenSharedMemory is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600478 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600479 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600480 else if (!vk_validate_vkmemoryopeninfo(pOpenInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600481 sprintf(str, "Parameter pOpenInfo to function OpenSharedMemory contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600482 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600483 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500484 VkResult result = device_dispatch_table(device)->OpenSharedMemory(device, pOpenInfo, pMem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600485 return result;
486}
487
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600488VK_LAYER_EXPORT VkResult VKAPI vkOpenSharedSemaphore(VkDevice device, const VkSemaphoreOpenInfo* pOpenInfo, VkSemaphore* pSemaphore)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600489{
490 char str[1024];
491 if (!pOpenInfo) {
492 sprintf(str, "Struct ptr parameter pOpenInfo to function OpenSharedSemaphore is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600493 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600494 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600495 else if (!vk_validate_vksemaphoreopeninfo(pOpenInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600496 sprintf(str, "Parameter pOpenInfo to function OpenSharedSemaphore contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600497 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600498 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500499 VkResult result = device_dispatch_table(device)->OpenSharedSemaphore(device, pOpenInfo, pSemaphore);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600500 return result;
501}
502
Tony Barbour8205d902015-04-16 15:59:00 -0600503VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerMemory(VkDevice device, const VkPeerMemoryOpenInfo* pOpenInfo, VkDeviceMemory* pMem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600504{
505 char str[1024];
506 if (!pOpenInfo) {
507 sprintf(str, "Struct ptr parameter pOpenInfo to function OpenPeerMemory is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600508 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600509 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600510 else if (!vk_validate_vkpeermemoryopeninfo(pOpenInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600511 sprintf(str, "Parameter pOpenInfo to function OpenPeerMemory contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600512 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600513 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500514 VkResult result = device_dispatch_table(device)->OpenPeerMemory(device, pOpenInfo, pMem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600515 return result;
516}
517
Tony Barbour8205d902015-04-16 15:59:00 -0600518VK_LAYER_EXPORT VkResult VKAPI vkOpenPeerImage(VkDevice device, const VkPeerImageOpenInfo* pOpenInfo, VkImage* pImage, VkDeviceMemory* pMem)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600519{
520 char str[1024];
521 if (!pOpenInfo) {
522 sprintf(str, "Struct ptr parameter pOpenInfo to function OpenPeerImage is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600523 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600524 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600525 else if (!vk_validate_vkpeerimageopeninfo(pOpenInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600526 sprintf(str, "Parameter pOpenInfo to function OpenPeerImage contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600527 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600528 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500529 VkResult result = device_dispatch_table(device)->OpenPeerImage(device, pOpenInfo, pImage, pMem);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600530 return result;
531}
532
Mike Stroyan230e6252015-04-17 12:36:38 -0600533VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType objType, VkObject object)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600534{
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500535 VkResult result = device_dispatch_table(device)->DestroyObject(device, objType, object);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600536 return result;
537}
538
Mike Stroyan230e6252015-04-17 12:36:38 -0600539VK_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 -0600540{
541 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600542 if (!validate_VkObjectInfoType(infoType)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600543 sprintf(str, "Parameter infoType to function GetObjectInfo has invalid value of %i.", (int)infoType);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600544 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600545 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500546 VkResult result = device_dispatch_table(device)->GetObjectInfo(device, objType, object, infoType, pDataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600547 return result;
548}
549
Mark Lobodzinski23182612015-05-29 09:32:35 -0500550VK_LAYER_EXPORT VkResult VKAPI vkBindObjectMemory(VkDevice device, VkObjectType objType, VkObject object, VkDeviceMemory mem, VkDeviceSize offset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600551{
552
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500553 VkResult result = device_dispatch_table(device)->BindObjectMemory(device, objType, object, mem, offset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600554 return result;
555}
556
Mark Lobodzinski23182612015-05-29 09:32:35 -0500557VK_LAYER_EXPORT VkResult VKAPI vkQueueBindSparseBufferMemory(VkQueue queue, VkBuffer buffer, VkDeviceSize rangeOffset, VkDeviceSize rangeSize, VkDeviceMemory mem, VkDeviceSize memOffset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600558{
559
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500560 VkResult result = device_dispatch_table(queue)->QueueBindSparseBufferMemory(queue, buffer, rangeOffset, rangeSize, mem, memOffset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600561 return result;
562}
563
Mark Lobodzinski23182612015-05-29 09:32:35 -0500564VK_LAYER_EXPORT VkResult VKAPI vkQueueBindSparseImageMemory(VkQueue queue, VkImage image, const VkImageMemoryBindInfo* pBindInfo, VkDeviceMemory mem, VkDeviceSize memOffset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600565{
566 char str[1024];
Jeremy Hayes47536532015-04-15 15:20:03 -0600567 if (!pBindInfo) {
Mark Lobodzinskifb9f5642015-05-11 17:21:15 -0500568 sprintf(str, "Struct ptr parameter pBindInfo to function QueueBindSparseImageMemory is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600569 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600570 }
Jeremy Hayes47536532015-04-15 15:20:03 -0600571 else if (!vk_validate_vkimagememorybindinfo(pBindInfo)) {
572 sprintf(str, "Parameter pBindInfo to function BindImageMemoryRange contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600573 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600574 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500575 VkResult result = device_dispatch_table(queue)->QueueBindSparseImageMemory(queue, image, pBindInfo, mem, memOffset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600576 return result;
577}
578
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600579VK_LAYER_EXPORT VkResult VKAPI vkCreateFence(VkDevice device, const VkFenceCreateInfo* pCreateInfo, VkFence* pFence)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600580{
581 char str[1024];
582 if (!pCreateInfo) {
583 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateFence is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600584 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600585 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600586 else if (!vk_validate_vkfencecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600587 sprintf(str, "Parameter pCreateInfo to function CreateFence contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600588 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600589 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500590 VkResult result = device_dispatch_table(device)->CreateFence(device, pCreateInfo, pFence);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600591 return result;
592}
593
Mike Stroyan230e6252015-04-17 12:36:38 -0600594VK_LAYER_EXPORT VkResult VKAPI vkGetFenceStatus(VkDevice device, VkFence fence)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600595{
596
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500597 VkResult result = device_dispatch_table(device)->GetFenceStatus(device, fence);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600598 return result;
599}
600
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600601VK_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 -0600602{
603
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500604 VkResult result = device_dispatch_table(device)->WaitForFences(device, fenceCount, pFences, waitAll, timeout);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600605 return result;
606}
607
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600608VK_LAYER_EXPORT VkResult VKAPI vkResetFences(VkDevice device, uint32_t fenceCount, VkFence* pFences)
Mark Lobodzinskiebe814d2015-04-07 16:07:57 -0500609{
610
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500611 VkResult result = device_dispatch_table(device)->ResetFences(device, fenceCount, pFences);
Mark Lobodzinskiebe814d2015-04-07 16:07:57 -0500612 return result;
613}
614
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600615VK_LAYER_EXPORT VkResult VKAPI vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, VkSemaphore* pSemaphore)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600616{
617 char str[1024];
618 if (!pCreateInfo) {
619 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateSemaphore is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600620 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600621 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600622 else if (!vk_validate_vksemaphorecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600623 sprintf(str, "Parameter pCreateInfo to function CreateSemaphore contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600624 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600625 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500626 VkResult result = device_dispatch_table(device)->CreateSemaphore(device, pCreateInfo, pSemaphore);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600627 return result;
628}
629
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600630VK_LAYER_EXPORT VkResult VKAPI vkQueueSignalSemaphore(VkQueue queue, VkSemaphore semaphore)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600631{
632
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500633 VkResult result = device_dispatch_table(queue)->QueueSignalSemaphore(queue, semaphore);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600634 return result;
635}
636
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600637VK_LAYER_EXPORT VkResult VKAPI vkQueueWaitSemaphore(VkQueue queue, VkSemaphore semaphore)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600638{
639
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500640 VkResult result = device_dispatch_table(queue)->QueueWaitSemaphore(queue, semaphore);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600641 return result;
642}
643
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600644VK_LAYER_EXPORT VkResult VKAPI vkCreateEvent(VkDevice device, const VkEventCreateInfo* pCreateInfo, VkEvent* pEvent)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600645{
646 char str[1024];
647 if (!pCreateInfo) {
648 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateEvent is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600649 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600650 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600651 else if (!vk_validate_vkeventcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600652 sprintf(str, "Parameter pCreateInfo to function CreateEvent contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600653 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600654 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500655 VkResult result = device_dispatch_table(device)->CreateEvent(device, pCreateInfo, pEvent);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600656 return result;
657}
658
Mike Stroyan230e6252015-04-17 12:36:38 -0600659VK_LAYER_EXPORT VkResult VKAPI vkGetEventStatus(VkDevice device, VkEvent event)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600660{
661
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500662 VkResult result = device_dispatch_table(device)->GetEventStatus(device, event);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600663 return result;
664}
665
Mike Stroyan230e6252015-04-17 12:36:38 -0600666VK_LAYER_EXPORT VkResult VKAPI vkSetEvent(VkDevice device, VkEvent event)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600667{
668
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500669 VkResult result = device_dispatch_table(device)->SetEvent(device, event);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600670 return result;
671}
672
Mike Stroyan230e6252015-04-17 12:36:38 -0600673VK_LAYER_EXPORT VkResult VKAPI vkResetEvent(VkDevice device, VkEvent event)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600674{
675
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500676 VkResult result = device_dispatch_table(device)->ResetEvent(device, event);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600677 return result;
678}
679
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600680VK_LAYER_EXPORT VkResult VKAPI vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, VkQueryPool* pQueryPool)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600681{
682 char str[1024];
683 if (!pCreateInfo) {
684 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateQueryPool is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600685 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600686 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600687 else if (!vk_validate_vkquerypoolcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600688 sprintf(str, "Parameter pCreateInfo to function CreateQueryPool contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600689 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600690 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500691 VkResult result = device_dispatch_table(device)->CreateQueryPool(device, pCreateInfo, pQueryPool);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600692 return result;
693}
694
Mike Stroyan230e6252015-04-17 12:36:38 -0600695VK_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 -0600696{
697
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500698 VkResult result = device_dispatch_table(device)->GetQueryPoolResults(device, queryPool, startQuery, queryCount, pDataSize, pData, flags);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600699 return result;
700}
701
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600702VK_LAYER_EXPORT VkResult VKAPI vkGetFormatInfo(VkDevice device, VkFormat format, VkFormatInfoType infoType, size_t* pDataSize, void* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600703{
704 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -0600705 if (!validate_VkFormat(format)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600706 sprintf(str, "Parameter format to function GetFormatInfo has invalid value of %i.", (int)format);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600707 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600708 }
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -0600709 if (!validate_VkFormatInfoType(infoType)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600710 sprintf(str, "Parameter infoType to function GetFormatInfo has invalid value of %i.", (int)infoType);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600711 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600712 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500713 VkResult result = device_dispatch_table(device)->GetFormatInfo(device, format, infoType, pDataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600714 return result;
715}
716
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600717VK_LAYER_EXPORT VkResult VKAPI vkCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, VkBuffer* pBuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600718{
719 char str[1024];
720 if (!pCreateInfo) {
721 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateBuffer is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600722 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600723 }
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600724 else if (!vk_validate_vkbuffercreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600725 sprintf(str, "Parameter pCreateInfo to function CreateBuffer contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600726 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600727 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500728 VkResult result = device_dispatch_table(device)->CreateBuffer(device, pCreateInfo, pBuffer);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600729 return result;
730}
731
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600732VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600733{
734 char str[1024];
735 if (!pCreateInfo) {
736 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateBufferView is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600737 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600738 }
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600739 else if (!vk_validate_vkbufferviewcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600740 sprintf(str, "Parameter pCreateInfo to function CreateBufferView contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600741 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600742 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500743 VkResult result = device_dispatch_table(device)->CreateBufferView(device, pCreateInfo, pView);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600744 return result;
745}
746
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600747void PreCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600748{
749 if(pCreateInfo == nullptr)
750 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600751 char const str[] = "vkCreateImage parameter, VkImageCreateInfo* pCreateInfo, is "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600752 "nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600753 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600754 return;
755 }
756
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600757 if(pCreateInfo->sType != VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600758 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600759 char const str[] = "vkCreateImage parameter, VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO "\
760 "pCreateInfo->sType, is not VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600761 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600762 return;
763 }
764
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600765 if (!validate_VkImageType(pCreateInfo->imageType))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600766 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600767 char const str[] = "vkCreateImage parameter, VkImageType pCreateInfo->imageType, is "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600768 "unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600769 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600770 return;
771 }
772
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -0600773 if (!validate_VkFormat(pCreateInfo->format))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600774 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600775 char const str[] = "vkCreateImage parameter, VkFormat pCreateInfo->format, is "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600776 "unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600777 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600778 return;
779 }
780
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600781 VkFormatProperties properties;
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600782 size_t size = sizeof(properties);
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500783 VkResult result = device_dispatch_table(device)->GetFormatInfo(device, pCreateInfo->format,
Tony Barbour8205d902015-04-16 15:59:00 -0600784 VK_FORMAT_INFO_TYPE_PROPERTIES, &size, &properties);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600785 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600786 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600787 char const str[] = "vkCreateImage parameter, VkFormat pCreateInfo->format, cannot be "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600788 "validated (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600789 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600790 return;
791 }
792
793 if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0))
794 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600795 char const str[] = "vkCreateImage parameter, VkFormat pCreateInfo->format, contains "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600796 "unsupported format (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600797 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600798 return;
799 }
800
801 // TODO: Can we check device-specific limits?
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600802 if (!vk_validate_vkextent3d(&pCreateInfo->extent))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600803 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600804 char const str[] = "vkCreateImage parameter, VkExtent3D pCreateInfo->extent, is invalid "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600805 "(precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600806 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600807 return;
808 }
809
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600810 if (!validate_VkImageTiling(pCreateInfo->tiling))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600811 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600812 char const str[] = "vkCreateImage parameter, VkImageTiling pCreateInfo->tiling, is "\
Jeremy Hayes6b7060b2015-04-07 09:49:05 -0600813 "unrecoginized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600814 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600815 return;
816 }
817}
818
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600819void PostCreateImage(VkResult result, VkImage* pImage)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600820{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600821 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600822 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600823 // TODO: Spit out VkResult value.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600824 char const str[] = "vkCreateImage failed (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600825 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600826 return;
827 }
828
829 if(pImage == nullptr)
830 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600831 char const str[] = "vkCreateImage parameter, VkImage* pImage, is nullptr (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600832 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600833 return;
834 }
835}
836
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600837VK_LAYER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, VkImage* pImage)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600838{
839 PreCreateImage(device, pCreateInfo);
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500840 VkResult result = device_dispatch_table(device)->CreateImage(device, pCreateInfo, pImage);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600841 PostCreateImage(result, pImage);
842 return result;
843}
844
Mike Stroyan230e6252015-04-17 12:36:38 -0600845VK_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 -0600846{
847 char str[1024];
848 if (!pSubresource) {
849 sprintf(str, "Struct ptr parameter pSubresource to function GetImageSubresourceInfo is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600850 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -0600851 } else if (!vk_validate_vkimagesubresource(pSubresource)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600852 sprintf(str, "Parameter pSubresource to function GetImageSubresourceInfo contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600853 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600854 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600855 if (!validate_VkSubresourceInfoType(infoType)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600856 sprintf(str, "Parameter infoType to function GetImageSubresourceInfo has invalid value of %i.", (int)infoType);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600857 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600858 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500859 VkResult result = device_dispatch_table(device)->GetImageSubresourceInfo(device, image, pSubresource, infoType, pDataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600860 return result;
861}
862
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600863VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600864{
865 char str[1024];
866 if (!pCreateInfo) {
867 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateImageView is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600868 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600869 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600870 else if (!vk_validate_vkimageviewcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600871 sprintf(str, "Parameter pCreateInfo to function CreateImageView contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600872 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600873 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500874 VkResult result = device_dispatch_table(device)->CreateImageView(device, pCreateInfo, pView);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600875 return result;
876}
877
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600878VK_LAYER_EXPORT VkResult VKAPI vkCreateColorAttachmentView(VkDevice device, const VkColorAttachmentViewCreateInfo* pCreateInfo, VkColorAttachmentView* pView)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600879{
880 char str[1024];
881 if (!pCreateInfo) {
882 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateColorAttachmentView is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600883 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600884 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600885 else if (!vk_validate_vkcolorattachmentviewcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600886 sprintf(str, "Parameter pCreateInfo to function CreateColorAttachmentView contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600887 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600888 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500889 VkResult result = device_dispatch_table(device)->CreateColorAttachmentView(device, pCreateInfo, pView);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600890 return result;
891}
892
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600893VK_LAYER_EXPORT VkResult VKAPI vkCreateDepthStencilView(VkDevice device, const VkDepthStencilViewCreateInfo* pCreateInfo, VkDepthStencilView* pView)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600894{
895 char str[1024];
896 if (!pCreateInfo) {
897 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDepthStencilView is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600898 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600899 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600900 else if (!vk_validate_vkdepthstencilviewcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600901 sprintf(str, "Parameter pCreateInfo to function CreateDepthStencilView contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600902 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600903 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500904 VkResult result = device_dispatch_table(device)->CreateDepthStencilView(device, pCreateInfo, pView);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600905 return result;
906}
907
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600908VK_LAYER_EXPORT VkResult VKAPI vkCreateShader(VkDevice device, const VkShaderCreateInfo* pCreateInfo, VkShader* pShader)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600909{
910 char str[1024];
911 if (!pCreateInfo) {
912 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateShader is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600913 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600914 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600915 else if (!vk_validate_vkshadercreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600916 sprintf(str, "Parameter pCreateInfo to function CreateShader contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600917 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600918 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500919 VkResult result = device_dispatch_table(device)->CreateShader(device, pCreateInfo, pShader);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600920 return result;
921}
922
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600923VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipeline(VkDevice device, const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600924{
925 char str[1024];
926 if (!pCreateInfo) {
927 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateGraphicsPipeline is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600928 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600929 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600930 else if (!vk_validate_vkgraphicspipelinecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600931 sprintf(str, "Parameter pCreateInfo to function CreateGraphicsPipeline contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600932 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600933 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500934 VkResult result = device_dispatch_table(device)->CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600935 return result;
936}
937
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600938VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative(VkDevice device, const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline basePipeline, VkPipeline* pPipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600939{
940 char str[1024];
941 if (!pCreateInfo) {
942 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateGraphicsPipelineDerivative is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600943 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600944 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600945 else if (!vk_validate_vkgraphicspipelinecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600946 sprintf(str, "Parameter pCreateInfo to function CreateGraphicsPipelineDerivative contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600947 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600948 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500949 VkResult result = device_dispatch_table(device)->CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600950 return result;
951}
952
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600953VK_LAYER_EXPORT VkResult VKAPI vkCreateComputePipeline(VkDevice device, const VkComputePipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600954{
955 char str[1024];
956 if (!pCreateInfo) {
957 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateComputePipeline is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600958 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600959 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600960 else if (!vk_validate_vkcomputepipelinecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600961 sprintf(str, "Parameter pCreateInfo to function CreateComputePipeline contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600962 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600963 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500964 VkResult result = device_dispatch_table(device)->CreateComputePipeline(device, pCreateInfo, pPipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600965 return result;
966}
967
Mike Stroyan230e6252015-04-17 12:36:38 -0600968VK_LAYER_EXPORT VkResult VKAPI vkStorePipeline(VkDevice device, VkPipeline pipeline, size_t* pDataSize, void* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600969{
970
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500971 VkResult result = device_dispatch_table(device)->StorePipeline(device, pipeline, pDataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600972 return result;
973}
974
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600975VK_LAYER_EXPORT VkResult VKAPI vkLoadPipeline(VkDevice device, size_t dataSize, const void* pData, VkPipeline* pPipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600976{
977
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500978 VkResult result = device_dispatch_table(device)->LoadPipeline(device, dataSize, pData, pPipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600979 return result;
980}
981
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600982VK_LAYER_EXPORT VkResult VKAPI vkLoadPipelineDerivative(VkDevice device, size_t dataSize, const void* pData, VkPipeline basePipeline, VkPipeline* pPipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600983{
984
Mark Lobodzinski3723c512015-05-26 10:58:40 -0500985 VkResult result = device_dispatch_table(device)->LoadPipelineDerivative(device, dataSize, pData, basePipeline, pPipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600986 return result;
987}
988
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600989VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600990{
991 char str[1024];
992 if (!pCreateInfo) {
993 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateSampler is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600994 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600995 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -0600996 else if (!vk_validate_vksamplercreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600997 sprintf(str, "Parameter pCreateInfo to function CreateSampler contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600998 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -0600999 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001000 VkResult result = device_dispatch_table(device)->CreateSampler(device, pCreateInfo, pSampler);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001001 return result;
1002}
1003
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001004VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayout* pSetLayout)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001005{
1006 char str[1024];
1007 if (!pCreateInfo) {
1008 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDescriptorSetLayout is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001009 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001010 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001011 else if (!vk_validate_vkdescriptorsetlayoutcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001012 sprintf(str, "Parameter pCreateInfo to function CreateDescriptorSetLayout contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001013 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001014 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001015 VkResult result = device_dispatch_table(device)->CreateDescriptorSetLayout(device, pCreateInfo, pSetLayout);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001016 return result;
1017}
1018
Mark Lobodzinski556f7212015-04-17 14:11:39 -05001019VK_LAYER_EXPORT VkResult VKAPI vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, VkPipelineLayout* pPipelineLayout)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001020{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001021 VkResult result = device_dispatch_table(device)->CreatePipelineLayout(device, pCreateInfo, pPipelineLayout);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001022 return result;
1023}
1024
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001025VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorPool(VkDevice device, VkDescriptorPoolUsage poolUsage, uint32_t maxSets, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001026{
1027 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001028 if (!validate_VkDescriptorPoolUsage(poolUsage)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001029 sprintf(str, "Parameter poolUsage to function CreateDescriptorPool has invalid value of %i.", (int)poolUsage);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001030 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001031 }
1032 if (!pCreateInfo) {
1033 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDescriptorPool is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001034 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001035 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001036 else if (!vk_validate_vkdescriptorpoolcreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001037 sprintf(str, "Parameter pCreateInfo to function CreateDescriptorPool contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001038 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001039 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001040 VkResult result = device_dispatch_table(device)->CreateDescriptorPool(device, poolUsage, maxSets, pCreateInfo, pDescriptorPool);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001041 return result;
1042}
1043
Mike Stroyan230e6252015-04-17 12:36:38 -06001044VK_LAYER_EXPORT VkResult VKAPI vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001045{
1046
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001047 VkResult result = device_dispatch_table(device)->ResetDescriptorPool(device, descriptorPool);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001048 return result;
1049}
1050
Mike Stroyan230e6252015-04-17 12:36:38 -06001051VK_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 -06001052{
1053 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001054 if (!validate_VkDescriptorSetUsage(setUsage)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001055 sprintf(str, "Parameter setUsage to function AllocDescriptorSets has invalid value of %i.", (int)setUsage);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001056 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001057 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001058 VkResult result = device_dispatch_table(device)->AllocDescriptorSets(device, descriptorPool, setUsage, count, pSetLayouts, pDescriptorSets, pCount);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001059 return result;
1060}
1061
Mike Stroyan230e6252015-04-17 12:36:38 -06001062VK_LAYER_EXPORT void VKAPI vkClearDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001063{
1064
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001065 device_dispatch_table(device)->ClearDescriptorSets(device, descriptorPool, count, pDescriptorSets);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001066}
1067
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +08001068VK_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 -06001069{
1070
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001071 return device_dispatch_table(device)->UpdateDescriptorSets(device, writeCount, pDescriptorWrites, copyCount, pDescriptorCopies);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001072}
1073
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001074VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, VkDynamicVpState* pState)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001075{
1076 char str[1024];
1077 if (!pCreateInfo) {
1078 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDynamicViewportState is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001079 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001080 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001081 else if (!vk_validate_vkdynamicvpstatecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001082 sprintf(str, "Parameter pCreateInfo to function CreateDynamicViewportState contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001083 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001084 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001085 VkResult result = device_dispatch_table(device)->CreateDynamicViewportState(device, pCreateInfo, pState);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001086 return result;
1087}
1088
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001089VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState(VkDevice device, const VkDynamicRsStateCreateInfo* pCreateInfo, VkDynamicRsState* pState)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001090{
1091 char str[1024];
1092 if (!pCreateInfo) {
1093 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDynamicRasterState is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001094 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001095 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001096 else if (!vk_validate_vkdynamicrsstatecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001097 sprintf(str, "Parameter pCreateInfo to function CreateDynamicRasterState contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001098 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001099 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001100 VkResult result = device_dispatch_table(device)->CreateDynamicRasterState(device, pCreateInfo, pState);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001101 return result;
1102}
1103
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001104VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState(VkDevice device, const VkDynamicCbStateCreateInfo* pCreateInfo, VkDynamicCbState* pState)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001105{
1106 char str[1024];
1107 if (!pCreateInfo) {
1108 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDynamicColorBlendState is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001109 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001110 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001111 else if (!vk_validate_vkdynamiccbstatecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001112 sprintf(str, "Parameter pCreateInfo to function CreateDynamicColorBlendState contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001113 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001114 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001115 VkResult result = device_dispatch_table(device)->CreateDynamicColorBlendState(device, pCreateInfo, pState);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001116 return result;
1117}
1118
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001119VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState(VkDevice device, const VkDynamicDsStateCreateInfo* pCreateInfo, VkDynamicDsState* pState)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001120{
1121 char str[1024];
1122 if (!pCreateInfo) {
1123 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateDynamicDepthStencilState is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001124 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001125 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001126 else if (!vk_validate_vkdynamicdsstatecreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001127 sprintf(str, "Parameter pCreateInfo to function CreateDynamicDepthStencilState contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001128 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001129 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001130 VkResult result = device_dispatch_table(device)->CreateDynamicDepthStencilState(device, pCreateInfo, pState);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001131 return result;
1132}
1133
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001134void PreCreateCommandBuffer(VkDevice device, const VkCmdBufferCreateInfo* pCreateInfo)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001135{
1136 if(device == nullptr)
1137 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001138 char const str[] = "vkCreateCommandBuffer parameter, VkDevice device, is "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001139 "nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001140 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001141 return;
1142 }
1143
1144 if(pCreateInfo == nullptr)
1145 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001146 char const str[] = "vkCreateCommandBuffer parameter, VkCmdBufferCreateInfo* pCreateInfo, is "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001147 "nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001148 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001149 return;
1150 }
1151
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001152 if(pCreateInfo->sType != VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001153 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001154 char const str[] = "vkCreateCommandBuffer parameter, VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO "\
1155 "pCreateInfo->sType, is not VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001156 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001157 return;
1158 }
1159}
1160
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001161void PostCreateCommandBuffer(VkResult result, VkCmdBuffer* pCmdBuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001162{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001163 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001164 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001165 // TODO: Spit out VkResult value.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001166 char const str[] = "vkCreateCommandBuffer failed (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001167 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001168 return;
1169 }
1170
1171 if(pCmdBuffer == nullptr)
1172 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001173 char const str[] = "vkCreateCommandBuffer parameter, VkCmdBuffer* pCmdBuffer, is nullptr (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001174 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001175 return;
1176 }
1177}
1178
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001179VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer(VkDevice device,
1180 const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001181{
1182 PreCreateCommandBuffer(device, pCreateInfo);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001183 VkResult result = device_dispatch_table(device)->CreateCommandBuffer(device, pCreateInfo, pCmdBuffer);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001184 PostCreateCommandBuffer(result, pCmdBuffer);
1185 return result;
1186}
1187
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001188VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001189{
1190 char str[1024];
1191 if (!pBeginInfo) {
1192 sprintf(str, "Struct ptr parameter pBeginInfo to function BeginCommandBuffer is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001193 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001194 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001195 else if (!vk_validate_vkcmdbufferbegininfo(pBeginInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001196 sprintf(str, "Parameter pBeginInfo to function BeginCommandBuffer contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001197 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001198 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001199 VkResult result = device_dispatch_table(cmdBuffer)->BeginCommandBuffer(cmdBuffer, pBeginInfo);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001200 return result;
1201}
1202
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001203VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer(VkCmdBuffer cmdBuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001204{
1205
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001206 VkResult result = device_dispatch_table(cmdBuffer)->EndCommandBuffer(cmdBuffer);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001207 return result;
1208}
1209
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001210VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCmdBuffer cmdBuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001211{
1212
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001213 VkResult result = device_dispatch_table(cmdBuffer)->ResetCommandBuffer(cmdBuffer);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001214 return result;
1215}
1216
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001217VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001218{
1219 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001220 if (!validate_VkPipelineBindPoint(pipelineBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001221 sprintf(str, "Parameter pipelineBindPoint to function CmdBindPipeline has invalid value of %i.", (int)pipelineBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001222 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001223 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001224 device_dispatch_table(cmdBuffer)->CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001225}
1226
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001227VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject(VkCmdBuffer cmdBuffer, VkStateBindPoint stateBindPoint, VkDynamicStateObject state)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001228{
1229 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001230 if (!validate_VkStateBindPoint(stateBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001231 sprintf(str, "Parameter stateBindPoint to function CmdBindDynamicStateObject has invalid value of %i.", (int)stateBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001232 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001233 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001234 device_dispatch_table(cmdBuffer)->CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001235}
1236
Cody Northrop1a01b1d2015-04-16 13:41:56 -06001237VK_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 -06001238{
1239 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001240 if (!validate_VkPipelineBindPoint(pipelineBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001241 sprintf(str, "Parameter pipelineBindPoint to function CmdBindDescriptorSets has invalid value of %i.", (int)pipelineBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001242 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001243 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001244 device_dispatch_table(cmdBuffer)->CmdBindDescriptorSets(cmdBuffer, pipelineBindPoint, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001245}
1246
Courtney Goeltzenleuchter46962942015-04-16 13:38:46 -06001247VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers(
1248 VkCmdBuffer cmdBuffer,
1249 uint32_t startBinding,
1250 uint32_t bindingCount,
1251 const VkBuffer* pBuffers,
Tony Barbour8205d902015-04-16 15:59:00 -06001252 const VkDeviceSize* pOffsets)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001253{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001254 device_dispatch_table(cmdBuffer)->CmdBindVertexBuffers(cmdBuffer, startBinding, bindingCount, pBuffers, pOffsets);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001255}
1256
Tony Barbour8205d902015-04-16 15:59:00 -06001257VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001258{
1259 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001260 if (!validate_VkIndexType(indexType)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001261 sprintf(str, "Parameter indexType to function CmdBindIndexBuffer has invalid value of %i.", (int)indexType);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001262 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001263 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001264 device_dispatch_table(cmdBuffer)->CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001265}
1266
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001267VK_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 -06001268{
1269
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001270 device_dispatch_table(cmdBuffer)->CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001271}
1272
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001273VK_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 -06001274{
1275
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001276 device_dispatch_table(cmdBuffer)->CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001277}
1278
Tony Barbour8205d902015-04-16 15:59:00 -06001279VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001280{
1281
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001282 device_dispatch_table(cmdBuffer)->CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001283}
1284
Tony Barbour8205d902015-04-16 15:59:00 -06001285VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001286{
1287
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001288 device_dispatch_table(cmdBuffer)->CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001289}
1290
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001291VK_LAYER_EXPORT void VKAPI vkCmdDispatch(VkCmdBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001292{
1293
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001294 device_dispatch_table(cmdBuffer)->CmdDispatch(cmdBuffer, x, y, z);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001295}
1296
Tony Barbour8205d902015-04-16 15:59:00 -06001297VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001298{
1299
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001300 device_dispatch_table(cmdBuffer)->CmdDispatchIndirect(cmdBuffer, buffer, offset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001301}
1302
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001303VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001304{
1305 char str[1024];
1306 uint32_t i;
1307 for (i = 0; i < regionCount; i++) {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001308 if (!vk_validate_vkbuffercopy(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001309 sprintf(str, "Parameter pRegions[%i] to function CmdCopyBuffer contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001310 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001311 }
1312 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001313 device_dispatch_table(cmdBuffer)->CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001314}
1315
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001316VK_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 -06001317{
1318 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001319 if (!validate_VkImageLayout(srcImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001320 sprintf(str, "Parameter srcImageLayout to function CmdCopyImage has invalid value of %i.", (int)srcImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001321 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001322 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001323 if (!validate_VkImageLayout(destImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001324 sprintf(str, "Parameter destImageLayout to function CmdCopyImage has invalid value of %i.", (int)destImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001325 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001326 }
1327 uint32_t i;
1328 for (i = 0; i < regionCount; i++) {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001329 if (!vk_validate_vkimagecopy(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001330 sprintf(str, "Parameter pRegions[%i] to function CmdCopyImage contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001331 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001332 }
1333 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001334 device_dispatch_table(cmdBuffer)->CmdCopyImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001335}
1336
Mark Lobodzinski20f68592015-05-22 14:43:25 -05001337VK_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 -06001338{
1339 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001340 if (!validate_VkImageLayout(srcImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001341 sprintf(str, "Parameter srcImageLayout to function CmdBlitImage has invalid value of %i.", (int)srcImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001342 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001343 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001344 if (!validate_VkImageLayout(destImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001345 sprintf(str, "Parameter destImageLayout to function CmdBlitImage has invalid value of %i.", (int)destImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001346 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001347 }
1348 uint32_t i;
1349 for (i = 0; i < regionCount; i++) {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001350 if (!vk_validate_vkimageblit(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001351 sprintf(str, "Parameter pRegions[%i] to function CmdBlitImage contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001352 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001353 }
1354 }
Mark Lobodzinski20f68592015-05-22 14:43:25 -05001355 //TODO: Add additional check for limitation from header rev 96.
1356 // VK_TEX_FILTER_NEAREST if the format that srcImage was created with is an integer-based format.
1357
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001358 device_dispatch_table(cmdBuffer)->CmdBlitImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions, filter);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001359}
1360
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001361VK_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 -06001362{
1363 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001364 if (!validate_VkImageLayout(destImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001365 sprintf(str, "Parameter destImageLayout to function CmdCopyBufferToImage has invalid value of %i.", (int)destImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001366 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001367 }
1368 uint32_t i;
1369 for (i = 0; i < regionCount; i++) {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001370 if (!vk_validate_vkbufferimagecopy(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001371 sprintf(str, "Parameter pRegions[%i] to function CmdCopyBufferToImage contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001372 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001373 }
1374 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001375 device_dispatch_table(cmdBuffer)->CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001376}
1377
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001378VK_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 -06001379{
1380 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001381 if (!validate_VkImageLayout(srcImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001382 sprintf(str, "Parameter srcImageLayout to function CmdCopyImageToBuffer has invalid value of %i.", (int)srcImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001383 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001384 }
1385 uint32_t i;
1386 for (i = 0; i < regionCount; i++) {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001387 if (!vk_validate_vkbufferimagecopy(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001388 sprintf(str, "Parameter pRegions[%i] to function CmdCopyImageToBuffer contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001389 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001390 }
1391 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001392 device_dispatch_table(cmdBuffer)->CmdCopyImageToBuffer(cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001393}
1394
Tony Barbour8205d902015-04-16 15:59:00 -06001395VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001396{
1397
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001398 device_dispatch_table(cmdBuffer)->CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001399}
1400
Tony Barbour8205d902015-04-16 15:59:00 -06001401VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001402{
1403
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001404 device_dispatch_table(cmdBuffer)->CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001405}
1406
Courtney Goeltzenleuchterda4a99e2015-04-23 17:49:22 -06001407VK_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 -06001408{
1409 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001410 if (!validate_VkImageLayout(imageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001411 sprintf(str, "Parameter imageLayout to function CmdClearColorImage has invalid value of %i.", (int)imageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001412 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001413 }
1414 uint32_t i;
1415 for (i = 0; i < rangeCount; i++) {
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001416 if (!vk_validate_vkimagesubresourcerange(&pRanges[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001417 sprintf(str, "Parameter pRanges[%i] to function CmdClearColorImage contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001418 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001419 }
1420 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001421 device_dispatch_table(cmdBuffer)->CmdClearColorImage(cmdBuffer, image, imageLayout, pColor, rangeCount, pRanges);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001422}
1423
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001424VK_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 -06001425{
1426 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001427 if (!validate_VkImageLayout(imageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001428 sprintf(str, "Parameter imageLayout to function CmdClearDepthStencil has invalid value of %i.", (int)imageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001429 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001430 }
1431 uint32_t i;
1432 for (i = 0; i < rangeCount; i++) {
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001433 if (!vk_validate_vkimagesubresourcerange(&pRanges[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001434 sprintf(str, "Parameter pRanges[%i] to function CmdClearDepthStencil contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001435 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001436 }
1437 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001438 device_dispatch_table(cmdBuffer)->CmdClearDepthStencil(cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001439}
1440
Tony Barbour11f74372015-04-13 15:02:52 -06001441VK_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 -06001442{
1443 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001444 if (!validate_VkImageLayout(srcImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001445 sprintf(str, "Parameter srcImageLayout to function CmdResolveImage has invalid value of %i.", (int)srcImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001446 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001447 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001448 if (!validate_VkImageLayout(destImageLayout)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001449 sprintf(str, "Parameter destImageLayout to function CmdResolveImage has invalid value of %i.", (int)destImageLayout);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001450 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001451 }
1452 uint32_t i;
Tony Barbour11f74372015-04-13 15:02:52 -06001453 for (i = 0; i < regionCount; i++) {
1454 if (!vk_validate_vkimageresolve(&pRegions[i])) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001455 sprintf(str, "Parameter pRects[%i] to function CmdResolveImage contains an invalid value.", i);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001456 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001457 }
1458 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001459 device_dispatch_table(cmdBuffer)->CmdResolveImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001460}
1461
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001462VK_LAYER_EXPORT void VKAPI vkCmdSetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001463{
1464 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001465 if (!validate_VkPipeEvent(pipeEvent)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001466 sprintf(str, "Parameter pipeEvent to function CmdSetEvent has invalid value of %i.", (int)pipeEvent);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001467 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001468 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001469 device_dispatch_table(cmdBuffer)->CmdSetEvent(cmdBuffer, event, pipeEvent);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001470}
1471
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001472VK_LAYER_EXPORT void VKAPI vkCmdResetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001473{
1474 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001475 if (!validate_VkPipeEvent(pipeEvent)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001476 sprintf(str, "Parameter pipeEvent to function CmdResetEvent has invalid value of %i.", (int)pipeEvent);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001477 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001478 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001479 device_dispatch_table(cmdBuffer)->CmdResetEvent(cmdBuffer, event, pipeEvent);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001480}
1481
Tony Barbour8205d902015-04-16 15:59:00 -06001482VK_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 -06001483{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001484 device_dispatch_table(cmdBuffer)->CmdWaitEvents(cmdBuffer, waitEvent, eventCount, pEvents, memBarrierCount, ppMemBarriers);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001485}
1486
Tony Barbour8205d902015-04-16 15:59:00 -06001487VK_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 -06001488{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001489 device_dispatch_table(cmdBuffer)->CmdPipelineBarrier(cmdBuffer, waitEvent, pipeEventCount, pPipeEvents, memBarrierCount, ppMemBarriers);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001490}
1491
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001492VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkFlags flags)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001493{
1494
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001495 device_dispatch_table(cmdBuffer)->CmdBeginQuery(cmdBuffer, queryPool, slot, flags);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001496}
1497
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001498VK_LAYER_EXPORT void VKAPI vkCmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001499{
1500
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001501 device_dispatch_table(cmdBuffer)->CmdEndQuery(cmdBuffer, queryPool, slot);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001502}
1503
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001504VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001505{
1506
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001507 device_dispatch_table(cmdBuffer)->CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001508}
1509
Tony Barbour8205d902015-04-16 15:59:00 -06001510VK_LAYER_EXPORT void VKAPI vkCmdWriteTimestamp(VkCmdBuffer cmdBuffer, VkTimestampType timestampType, VkBuffer destBuffer, VkDeviceSize destOffset)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001511{
1512 char str[1024];
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001513 if (!validate_VkTimestampType(timestampType)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001514 sprintf(str, "Parameter timestampType to function CmdWriteTimestamp has invalid value of %i.", (int)timestampType);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001515 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001516 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001517 device_dispatch_table(cmdBuffer)->CmdWriteTimestamp(cmdBuffer, timestampType, destBuffer, destOffset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001518}
1519
Jeremy Hayescf469132015-04-17 10:36:53 -06001520VK_LAYER_EXPORT void VKAPI vkCmdCopyQueryPoolResults(
1521 VkCmdBuffer cmdBuffer,
1522 VkQueryPool queryPool,
1523 uint32_t startQuery,
1524 uint32_t queryCount,
1525 VkBuffer destBuffer,
1526 VkDeviceSize destOffset,
1527 VkDeviceSize destStride,
1528 VkQueryResultFlags flags)
1529{
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001530 device_dispatch_table(cmdBuffer)->CmdCopyQueryPoolResults(cmdBuffer, queryPool, startQuery, queryCount, destBuffer, destOffset, destStride, flags);
Jeremy Hayescf469132015-04-17 10:36:53 -06001531}
1532
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001533VK_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 -06001534{
1535 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001536 if (!validate_VkPipelineBindPoint(pipelineBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001537 sprintf(str, "Parameter pipelineBindPoint to function CmdInitAtomicCounters has invalid value of %i.", (int)pipelineBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001538 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001539 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001540 device_dispatch_table(cmdBuffer)->CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001541}
1542
Tony Barbour8205d902015-04-16 15:59:00 -06001543VK_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 -06001544{
1545 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001546 if (!validate_VkPipelineBindPoint(pipelineBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001547 sprintf(str, "Parameter pipelineBindPoint to function CmdLoadAtomicCounters has invalid value of %i.", (int)pipelineBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001548 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001549 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001550 device_dispatch_table(cmdBuffer)->CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcBuffer, srcOffset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001551}
1552
Tony Barbour8205d902015-04-16 15:59:00 -06001553VK_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 -06001554{
1555 char str[1024];
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001556 if (!validate_VkPipelineBindPoint(pipelineBindPoint)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001557 sprintf(str, "Parameter pipelineBindPoint to function CmdSaveAtomicCounters has invalid value of %i.", (int)pipelineBindPoint);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001558 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001559 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001560 device_dispatch_table(cmdBuffer)->CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destBuffer, destOffset);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001561}
1562
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001563VK_LAYER_EXPORT VkResult VKAPI vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, VkFramebuffer* pFramebuffer)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001564{
1565 char str[1024];
1566 if (!pCreateInfo) {
1567 sprintf(str, "Struct ptr parameter pCreateInfo to function CreateFramebuffer is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001568 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001569 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001570 else if (!vk_validate_vkframebuffercreateinfo(pCreateInfo)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001571 sprintf(str, "Parameter pCreateInfo to function CreateFramebuffer contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001572 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001573 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001574 VkResult result = device_dispatch_table(device)->CreateFramebuffer(device, pCreateInfo, pFramebuffer);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001575 return result;
1576}
1577
1578
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001579void PreCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001580{
1581 if(pCreateInfo == nullptr)
1582 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001583 char const str[] = "vkCreateRenderPass parameter, VkRenderPassCreateInfo* pCreateInfo, is "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001584 "nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001585 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001586 return;
1587 }
1588
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001589 if(pCreateInfo->sType != VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001590 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001591 char const str[] = "vkCreateRenderPass parameter, VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO "\
1592 "pCreateInfo->sType, is not VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001593 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001594 return;
1595 }
1596
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001597 if(!vk_validate_vkrect(&pCreateInfo->renderArea))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001598 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001599 char const str[] = "vkCreateRenderPass parameter, VkRect pCreateInfo->renderArea, is invalid "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001600 "(precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001601 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001602 return;
1603 }
1604
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001605 if(!vk_validate_vkextent2d(&pCreateInfo->extent))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001606 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001607 char const str[] = "vkCreateRenderPass parameter, VkExtent2D pCreateInfo->extent, is invalid "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001608 "(precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001609 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001610 return;
1611 }
1612
1613 if(pCreateInfo->pColorFormats == nullptr)
1614 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001615 char const str[] = "vkCreateRenderPass parameter, VkFormat* pCreateInfo->pColorFormats, "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001616 "is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001617 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001618 return;
1619 }
1620
1621 for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
1622 {
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001623 if(!validate_VkFormat(pCreateInfo->pColorFormats[i]))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001624 {
1625 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001626 ss << "vkCreateRenderPass parameter, VkFormat pCreateInfo->pColorFormats[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001627 "], is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001628 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001629 continue;
1630 }
1631
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001632 VkFormatProperties properties;
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001633 size_t size = sizeof(properties);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001634 VkResult result = device_dispatch_table(device)->GetFormatInfo(device, pCreateInfo->pColorFormats[i],
Tony Barbour8205d902015-04-16 15:59:00 -06001635 VK_FORMAT_INFO_TYPE_PROPERTIES, &size, &properties);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001636 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001637 {
1638 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001639 ss << "vkCreateRenderPass parameter, VkFormat pCreateInfo->pColorFormats[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001640 "], cannot be validated (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001641 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001642 continue;
1643 }
1644
1645 if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0))
1646 {
1647 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001648 ss << "vkCreateRenderPass parameter, VkFormat pCreateInfo->pColorFormats[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001649 "], contains unsupported format (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001650 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001651 continue;
1652 }
1653
1654 }
1655
1656 if(pCreateInfo->pColorLayouts == nullptr)
1657 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001658 char const str[] = "vkCreateRenderPass parameter, VkImageLayout* pCreateInfo->pColorLayouts, "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001659 "is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001660 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001661 return;
1662 }
1663
1664 for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
1665 {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001666 if(!validate_VkImageLayout(pCreateInfo->pColorLayouts[i]))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001667 {
1668 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001669 ss << "vkCreateRenderPass parameter, VkImageLayout pCreateInfo->pColorLayouts[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001670 "], is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001671 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001672 continue;
1673 }
1674 }
1675
1676 if(pCreateInfo->pColorLoadOps == nullptr)
1677 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001678 char const str[] = "vkCreateRenderPass parameter, VkAttachmentLoadOp* pCreateInfo->pColorLoadOps, "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001679 "is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001680 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001681 return;
1682 }
1683
1684 for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
1685 {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001686 if(!validate_VkAttachmentLoadOp(pCreateInfo->pColorLoadOps[i]))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001687 {
1688 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001689 ss << "vkCreateRenderPass parameter, VkAttachmentLoadOp pCreateInfo->pColorLoadOps[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001690 "], is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001691 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001692 continue;
1693 }
1694 }
1695
1696 if(pCreateInfo->pColorStoreOps == nullptr)
1697 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001698 char const str[] = "vkCreateRenderPass parameter, VkAttachmentStoreOp* pCreateInfo->pColorStoreOps, "\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001699 "is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001700 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001701 return;
1702 }
1703
1704 for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
1705 {
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001706 if(!validate_VkAttachmentStoreOp(pCreateInfo->pColorStoreOps[i]))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001707 {
1708 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001709 ss << "vkCreateRenderPass parameter, VkAttachmentStoreOp pCreateInfo->pColorStoreOps[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001710 "], is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001711 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001712 continue;
1713 }
1714 }
1715
1716 if(pCreateInfo->pColorLoadClearValues == nullptr)
1717 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001718 char const str[] = "vkCreateRenderPass parameter, VkClearColor* pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001719 "pColorLoadClearValues, is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001720 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001721 return;
1722 }
Jeremy Hayes6b7060b2015-04-07 09:49:05 -06001723
1724 if(pCreateInfo->pColorStoreOps == nullptr)
1725 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001726 char const str[] = "vkCreateRenderPass parameter, VK_ATTACHMENT_STORE_OP* pCreateInfo->pColorStoreOps, "\
Jeremy Hayes9bafb9f2015-04-07 13:38:03 -06001727 "is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001728 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayes6b7060b2015-04-07 09:49:05 -06001729 return;
1730 }
1731
Jeremy Hayes6b7060b2015-04-07 09:49:05 -06001732 if(pCreateInfo->pColorLoadClearValues == nullptr)
1733 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001734 char const str[] = "vkCreateRenderPass parameter, VK_CLEAR_COLOR* pCreateInfo->"\
Jeremy Hayes9bafb9f2015-04-07 13:38:03 -06001735 "pColorLoadClearValues, is nullptr (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001736 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayes6b7060b2015-04-07 09:49:05 -06001737 return;
1738 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001739
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001740 for(uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; ++i)
1741 {
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001742 if(!vk_validate_vkclearcolor(&(pCreateInfo->pColorLoadClearValues[i])))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001743 {
1744 std::stringstream ss;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001745 ss << "vkCreateRenderPass parameter, VkClearColor pCreateInfo->pColorLoadClearValues[" << i <<
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001746 "], is invalid (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001747 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", ss.str().c_str());
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001748 continue;
1749 }
1750 }
1751
Courtney Goeltzenleuchter33318172015-04-10 17:06:20 -06001752 if(!validate_VkFormat(pCreateInfo->depthStencilFormat))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001753 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001754 char const str[] = "vkCreateRenderPass parameter, VkFormat pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001755 "depthStencilFormat, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001756 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001757 return;
1758 }
1759
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001760 VkFormatProperties properties;
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001761 size_t size = sizeof(properties);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001762 VkResult result = device_dispatch_table(device)->GetFormatInfo(device, pCreateInfo->depthStencilFormat,
Tony Barbour8205d902015-04-16 15:59:00 -06001763 VK_FORMAT_INFO_TYPE_PROPERTIES, &size, &properties);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001764 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001765 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001766 char const str[] = "vkCreateRenderPass parameter, VkFormat pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001767 "depthStencilFormat, cannot be validated (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001768 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001769 return;
1770 }
1771
1772 if((properties.linearTilingFeatures) == 0 && (properties.optimalTilingFeatures == 0))
1773 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001774 char const str[] = "vkCreateRenderPass parameter, VkFormat pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001775 "depthStencilFormat, contains unsupported format (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001776 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001777 return;
1778 }
1779
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001780 if(!validate_VkImageLayout(pCreateInfo->depthStencilLayout))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001781 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001782 char const str[] = "vkCreateRenderPass parameter, VkImageLayout pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001783 "depthStencilLayout, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001784 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001785 return;
1786 }
1787
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001788 if(!validate_VkAttachmentLoadOp(pCreateInfo->depthLoadOp))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001789 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001790 char const str[] = "vkCreateRenderPass parameter, VkAttachmentLoadOp pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001791 "depthLoadOp, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001792 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001793 return;
1794 }
1795
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001796 if(!validate_VkAttachmentStoreOp(pCreateInfo->depthStoreOp))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001797 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001798 char const str[] = "vkCreateRenderPass parameter, VkAttachmentStoreOp pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001799 "depthStoreOp, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001800 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001801 return;
1802 }
1803
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001804 if(!validate_VkAttachmentLoadOp(pCreateInfo->stencilLoadOp))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001805 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001806 char const str[] = "vkCreateRenderPass parameter, VkAttachmentLoadOp pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001807 "stencilLoadOp, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001808 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001809 return;
1810 }
1811
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001812 if(!validate_VkAttachmentStoreOp(pCreateInfo->stencilStoreOp))
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001813 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001814 char const str[] = "vkCreateRenderPass parameter, VkAttachmentStoreOp pCreateInfo->"\
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001815 "stencilStoreOp, is unrecognized (precondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001816 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001817 return;
1818 }
1819}
1820
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001821void PostCreateRenderPass(VkResult result, VkRenderPass* pRenderPass)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001822{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001823 if(result != VK_SUCCESS)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001824 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001825 // TODO: Spit out VkResult value.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001826 char const str[] = "vkCreateRenderPass failed (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001827 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001828 return;
1829 }
1830
1831 if(pRenderPass == nullptr)
1832 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001833 char const str[] = "vkCreateRenderPass parameter, VkRenderPass* pRenderPass, is nullptr (postcondition).";
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001834 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001835 return;
1836 }
1837}
1838
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001839VK_LAYER_EXPORT VkResult VKAPI vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001840{
1841 PreCreateRenderPass(device, pCreateInfo);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001842 VkResult result = device_dispatch_table(device)->CreateRenderPass(device, pCreateInfo, pRenderPass);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001843 PostCreateRenderPass(result, pRenderPass);
1844 return result;
1845}
1846
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001847VK_LAYER_EXPORT void VKAPI vkCmdBeginRenderPass(VkCmdBuffer cmdBuffer, const VkRenderPassBegin* pRenderPassBegin)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001848{
1849 char str[1024];
1850 if (!pRenderPassBegin) {
1851 sprintf(str, "Struct ptr parameter pRenderPassBegin to function CmdBeginRenderPass is NULL.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001852 layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001853 }
Courtney Goeltzenleuchterdfd1b2a2015-04-15 00:14:36 -06001854 else if (!vk_validate_vkrenderpassbegin(pRenderPassBegin)) {
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001855 sprintf(str, "Parameter pRenderPassBegin to function CmdBeginRenderPass contains an invalid value.");
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001856 layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001857 }
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001858 device_dispatch_table(cmdBuffer)->CmdBeginRenderPass(cmdBuffer, pRenderPassBegin);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001859}
1860
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001861VK_LAYER_EXPORT void VKAPI vkCmdEndRenderPass(VkCmdBuffer cmdBuffer, VkRenderPass renderPass)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001862{
1863
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001864 device_dispatch_table(cmdBuffer)->CmdEndRenderPass(cmdBuffer, renderPass);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001865}
1866
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -06001867VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback(
1868 VkInstance instance,
1869 VkFlags msgFlags,
1870 const PFN_vkDbgMsgCallback pfnMsgCallback,
1871 void* pUserData,
1872 VkDbgMsgCallback* pMsgCallback)
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001873{
Jon Ashburn5a10d212015-06-01 10:02:09 -06001874 VkLayerInstanceDispatchTable *pTable = instance_dispatch_table(instance);
Mark Lobodzinski3723c512015-05-26 10:58:40 -05001875 return layer_create_msg_callback(instance, pTable, msgFlags, pfnMsgCallback, pUserData, pMsgCallback);
Jeremy Hayesc6cfa572015-04-06 13:46:11 -06001876}
1877
Courtney Goeltzenleuchter09f85042015-06-01 14:45:27 -06001878VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback(
1879 VkInstance instance,
1880 VkDbgMsgCallback msgCallback)
1881{
Courtney Goeltzenleuchter9f171942015-06-13 21:22:12 -06001882 VkLayerInstanceDispatchTable *pTable = instance_dispatch_table(instance);
Courtney Goeltzenleuchter09f85042015-06-01 14:45:27 -06001883 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}