blob: c8f5a100bfdd2e1bdd5bba7f51dd03adad72ea61 [file] [log] [blame]
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001/* Copyright (c) 2015-2017 The Khronos Group Inc.
2 * Copyright (c) 2015-2017 Valve Corporation
3 * Copyright (c) 2015-2017 LunarG, Inc.
4 * Copyright (C) 2015-2017 Google Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
19 */
20
21#define NOMINMAX
22
23#include <limits.h>
24#include <math.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <inttypes.h>
29
30#include <iostream>
31#include <string>
32#include <sstream>
33#include <unordered_map>
34#include <unordered_set>
35#include <vector>
36#include <mutex>
37
38#include "vk_loader_platform.h"
39#include "vulkan/vk_layer.h"
40#include "vk_layer_config.h"
41#include "vk_dispatch_table_helper.h"
42
43#include "vk_layer_table.h"
44#include "vk_layer_data.h"
45#include "vk_layer_logging.h"
46#include "vk_layer_extension_utils.h"
47#include "vk_layer_utils.h"
48
49#include "parameter_name.h"
50#include "parameter_validation.h"
51
52// TODO: remove on NDK update (r15 will probably have proper STL impl)
53#ifdef __ANDROID__
54namespace std {
55
56template <typename T>
57std::string to_string(T var) {
58 std::ostringstream ss;
59 ss << var;
60 return ss.str();
61}
62} // namespace std
63#endif
64
65namespace parameter_validation {
66
67extern bool parameter_validation_vkCreateInstance(VkInstance instance, const VkInstanceCreateInfo *pCreateInfo,
68 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance);
69extern bool parameter_validation_vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator);
70extern bool parameter_validation_vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
71 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
72extern bool parameter_validation_vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator);
73extern bool parameter_validation_vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
74 const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool);
75extern bool parameter_validation_vkCreateDebugReportCallbackEXT(VkInstance instance,
76 const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
77 const VkAllocationCallbacks *pAllocator,
78 VkDebugReportCallbackEXT *pMsgCallback);
79extern bool parameter_validation_vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback,
80 const VkAllocationCallbacks *pAllocator);
81extern bool parameter_validation_vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo,
82 const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool);
83
84// TODO : This can be much smarter, using separate locks for separate global data
85std::mutex global_lock;
86
87static uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION;
88std::unordered_map<void *, layer_data *> layer_data_map;
89std::unordered_map<void *, instance_layer_data *> instance_layer_data_map;
90
91void InitializeManualParameterValidationFunctionPointers(void);
92
93static void init_parameter_validation(instance_layer_data *instance_data, const VkAllocationCallbacks *pAllocator) {
94 layer_debug_actions(instance_data->report_data, instance_data->logging_callback, pAllocator, "lunarg_parameter_validation");
95}
96
97static const VkExtensionProperties instance_extensions[] = {{VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}};
98
99static const VkLayerProperties global_layer = {
100 "VK_LAYER_LUNARG_parameter_validation", VK_LAYER_API_VERSION, 1, "LunarG Validation Layer",
101};
102
103static const int MaxParamCheckerStringLength = 256;
104
105static bool validate_string(debug_report_data *report_data, const char *apiName, const ParameterName &stringName,
106 const char *validateString) {
107 assert(apiName != nullptr);
108 assert(validateString != nullptr);
109
110 bool skip = false;
111
112 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
113
114 if (result == VK_STRING_ERROR_NONE) {
115 return skip;
116 } else if (result & VK_STRING_ERROR_LENGTH) {
117 skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
118 INVALID_USAGE, LayerName, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
119 MaxParamCheckerStringLength);
120 } else if (result & VK_STRING_ERROR_BAD_DATA) {
121 skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
122 INVALID_USAGE, LayerName, "%s: string %s contains invalid characters or is badly formed", apiName,
123 stringName.get_name().c_str());
124 }
125 return skip;
126}
127
128static bool ValidateDeviceQueueFamily(layer_data *device_data, uint32_t queue_family, const char *cmd_name,
129 const char *parameter_name, int32_t error_code, bool optional = false,
130 const char *vu_note = nullptr) {
131 bool skip = false;
132
133 if (!vu_note) vu_note = validation_error_map[error_code];
134 if (!optional && queue_family == VK_QUEUE_FAMILY_IGNORED) {
135 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
136 HandleToUint64(device_data->device), __LINE__, error_code, LayerName,
137 "%s: %s is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family index value. %s",
138 cmd_name, parameter_name, vu_note);
139 } else if (device_data->queueFamilyIndexMap.find(queue_family) == device_data->queueFamilyIndexMap.end()) {
140 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
141 HandleToUint64(device_data->device), __LINE__, error_code, LayerName,
142 "%s: %s (= %" PRIu32
143 ") is not one of the queue families given via VkDeviceQueueCreateInfo structures when "
144 "the device was created. %s",
145 cmd_name, parameter_name, queue_family, vu_note);
146 }
147
148 return skip;
149}
150
151static bool ValidateQueueFamilies(layer_data *device_data, uint32_t queue_family_count, const uint32_t *queue_families,
152 const char *cmd_name, const char *array_parameter_name, int32_t unique_error_code,
153 int32_t valid_error_code, bool optional = false, const char *unique_vu_note = nullptr,
154 const char *valid_vu_note = nullptr) {
155 bool skip = false;
156 if (!unique_vu_note) unique_vu_note = validation_error_map[unique_error_code];
157 if (!valid_vu_note) valid_vu_note = validation_error_map[valid_error_code];
158 if (queue_families) {
159 std::unordered_set<uint32_t> set;
160 for (uint32_t i = 0; i < queue_family_count; ++i) {
161 std::string parameter_name = std::string(array_parameter_name) + "[" + std::to_string(i) + "]";
162
163 if (set.count(queue_families[i])) {
164 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
165 HandleToUint64(device_data->device), __LINE__, VALIDATION_ERROR_056002e8, LayerName,
166 "%s: %s (=%" PRIu32 ") is not unique within %s array. %s", cmd_name, parameter_name.c_str(),
167 queue_families[i], array_parameter_name, unique_vu_note);
168 } else {
169 set.insert(queue_families[i]);
170 skip |= ValidateDeviceQueueFamily(device_data, queue_families[i], cmd_name, parameter_name.c_str(),
171 valid_error_code, optional, valid_vu_note);
172 }
173 }
174 }
175 return skip;
176}
177
178VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
179 VkInstance *pInstance) {
180 VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
181
182 VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
183 assert(chain_info != nullptr);
184 assert(chain_info->u.pLayerInfo != nullptr);
185
186 PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
187 PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance");
188 if (fpCreateInstance == NULL) {
189 return VK_ERROR_INITIALIZATION_FAILED;
190 }
191
192 // Advance the link info for the next element on the chain
193 chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
194
195 result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
196
197 if (result == VK_SUCCESS) {
198 InitializeManualParameterValidationFunctionPointers();
199 auto my_instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), instance_layer_data_map);
200 assert(my_instance_data != nullptr);
201
202 layer_init_instance_dispatch_table(*pInstance, &my_instance_data->dispatch_table, fpGetInstanceProcAddr);
203 my_instance_data->instance = *pInstance;
204 my_instance_data->report_data =
205 debug_report_create_instance(&my_instance_data->dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount,
206 pCreateInfo->ppEnabledExtensionNames);
207
208 // Look for one or more debug report create info structures
209 // and setup a callback(s) for each one found.
210 if (!layer_copy_tmp_callbacks(pCreateInfo->pNext, &my_instance_data->num_tmp_callbacks,
211 &my_instance_data->tmp_dbg_create_infos, &my_instance_data->tmp_callbacks)) {
212 if (my_instance_data->num_tmp_callbacks > 0) {
213 // Setup the temporary callback(s) here to catch early issues:
214 if (layer_enable_tmp_callbacks(my_instance_data->report_data, my_instance_data->num_tmp_callbacks,
215 my_instance_data->tmp_dbg_create_infos, my_instance_data->tmp_callbacks)) {
216 // Failure of setting up one or more of the callback.
217 // Therefore, clean up and don't use those callbacks:
218 layer_free_tmp_callbacks(my_instance_data->tmp_dbg_create_infos, my_instance_data->tmp_callbacks);
219 my_instance_data->num_tmp_callbacks = 0;
220 }
221 }
222 }
223
224 init_parameter_validation(my_instance_data, pAllocator);
225 my_instance_data->extensions.InitFromInstanceCreateInfo(pCreateInfo);
226
227 // Ordinarily we'd check these before calling down the chain, but none of the layer support is in place until now, if we
228 // survive we can report the issue now.
229 parameter_validation_vkCreateInstance(*pInstance, pCreateInfo, pAllocator, pInstance);
230
231 if (pCreateInfo->pApplicationInfo) {
232 if (pCreateInfo->pApplicationInfo->pApplicationName) {
233 validate_string(my_instance_data->report_data, "vkCreateInstance",
234 "pCreateInfo->VkApplicationInfo->pApplicationName",
235 pCreateInfo->pApplicationInfo->pApplicationName);
236 }
237
238 if (pCreateInfo->pApplicationInfo->pEngineName) {
239 validate_string(my_instance_data->report_data, "vkCreateInstance", "pCreateInfo->VkApplicationInfo->pEngineName",
240 pCreateInfo->pApplicationInfo->pEngineName);
241 }
242 }
243
244 // Disable the tmp callbacks:
245 if (my_instance_data->num_tmp_callbacks > 0) {
246 layer_disable_tmp_callbacks(my_instance_data->report_data, my_instance_data->num_tmp_callbacks,
247 my_instance_data->tmp_callbacks);
248 }
249 }
250
251 return result;
252}
253
254VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
255 // Grab the key before the instance is destroyed.
256 dispatch_key key = get_dispatch_key(instance);
257 bool skip = false;
258 auto instance_data = GetLayerDataPtr(key, instance_layer_data_map);
259
260 // Enable the temporary callback(s) here to catch vkDestroyInstance issues:
261 bool callback_setup = false;
262 if (instance_data->num_tmp_callbacks > 0) {
263 if (!layer_enable_tmp_callbacks(instance_data->report_data, instance_data->num_tmp_callbacks,
264 instance_data->tmp_dbg_create_infos, instance_data->tmp_callbacks)) {
265 callback_setup = true;
266 }
267 }
268
269 skip |= parameter_validation_vkDestroyInstance(instance, pAllocator);
270
271 // Disable and cleanup the temporary callback(s):
272 if (callback_setup) {
273 layer_disable_tmp_callbacks(instance_data->report_data, instance_data->num_tmp_callbacks, instance_data->tmp_callbacks);
274 }
275 if (instance_data->num_tmp_callbacks > 0) {
276 layer_free_tmp_callbacks(instance_data->tmp_dbg_create_infos, instance_data->tmp_callbacks);
277 instance_data->num_tmp_callbacks = 0;
278 }
279
280 if (!skip) {
281 instance_data->dispatch_table.DestroyInstance(instance, pAllocator);
282
283 // Clean up logging callback, if any
284 while (instance_data->logging_callback.size() > 0) {
285 VkDebugReportCallbackEXT callback = instance_data->logging_callback.back();
286 layer_destroy_msg_callback(instance_data->report_data, callback, pAllocator);
287 instance_data->logging_callback.pop_back();
288 }
289
290 layer_debug_report_destroy_instance(instance_data->report_data);
291 }
292
293 FreeLayerDataPtr(key, instance_layer_data_map);
294}
295
296VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance,
297 const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
298 const VkAllocationCallbacks *pAllocator,
299 VkDebugReportCallbackEXT *pMsgCallback) {
300 bool skip = parameter_validation_vkCreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback);
301 if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
302
303 auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
304 VkResult result = instance_data->dispatch_table.CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback);
305 if (result == VK_SUCCESS) {
306 result = layer_create_msg_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pMsgCallback);
307 }
308 return result;
309}
310
311VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback,
312 const VkAllocationCallbacks *pAllocator) {
313 bool skip = parameter_validation_vkDestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator);
314 if (!skip) {
315 auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
316 instance_data->dispatch_table.DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator);
317 layer_destroy_msg_callback(instance_data->report_data, msgCallback, pAllocator);
318 }
319}
320
321static bool ValidateDeviceCreateInfo(instance_layer_data *instance_data, VkPhysicalDevice physicalDevice,
322 const VkDeviceCreateInfo *pCreateInfo) {
323 bool skip = false;
324
325 if ((pCreateInfo->enabledLayerCount > 0) && (pCreateInfo->ppEnabledLayerNames != NULL)) {
326 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
327 skip |= validate_string(instance_data->report_data, "vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
328 pCreateInfo->ppEnabledLayerNames[i]);
329 }
330 }
331
332 bool maint1 = false;
333 bool negative_viewport = false;
334
335 if ((pCreateInfo->enabledExtensionCount > 0) && (pCreateInfo->ppEnabledExtensionNames != NULL)) {
336 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
337 skip |= validate_string(instance_data->report_data, "vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
338 pCreateInfo->ppEnabledExtensionNames[i]);
339 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MAINTENANCE1_EXTENSION_NAME) == 0) maint1 = true;
340 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME) == 0)
341 negative_viewport = true;
342 }
343 }
344
345 if (maint1 && negative_viewport) {
346 skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
347 __LINE__, VALIDATION_ERROR_056002ec, LayerName,
348 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
349 "VK_AMD_negative_viewport_height. %s",
350 validation_error_map[VALIDATION_ERROR_056002ec]);
351 }
352
353 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
354 // Check for get_physical_device_properties2 struct
355 struct std_header {
356 VkStructureType sType;
357 const void *pNext;
358 };
359 std_header *cur_pnext = (std_header *)pCreateInfo->pNext;
360 while (cur_pnext) {
361 if (VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR == cur_pnext->sType) {
362 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
363 skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
364 0, __LINE__, INVALID_USAGE, LayerName,
365 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
366 "pCreateInfo->pEnabledFeatures is non-NULL.");
367 break;
368 }
369 cur_pnext = (std_header *)cur_pnext->pNext;
370 }
371 }
372 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
373 // Check for get_physical_device_properties2 struct
374 struct std_header {
375 VkStructureType sType;
376 const void *pNext;
377 };
378 std_header *cur_pnext = (std_header *)pCreateInfo->pNext;
379 while (cur_pnext) {
380 if (VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR == cur_pnext->sType) {
381 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
382 skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
383 0, __LINE__, INVALID_USAGE, LayerName,
384 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
385 "pCreateInfo->pEnabledFeatures is non-NULL.");
386 break;
387 }
388 cur_pnext = (std_header *)cur_pnext->pNext;
389 }
390 }
391
392 // Validate pCreateInfo->pQueueCreateInfos
393 if (pCreateInfo->pQueueCreateInfos) {
394 std::unordered_set<uint32_t> set;
395
396 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
397 const uint32_t requested_queue_family = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex;
398 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
399 skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
400 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__,
401 VALIDATION_ERROR_06c002fa, LayerName,
402 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
403 "].queueFamilyIndex is "
404 "VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family index value. %s",
405 i, validation_error_map[VALIDATION_ERROR_06c002fa]);
406 } else if (set.count(requested_queue_family)) {
407 skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
408 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__,
409 VALIDATION_ERROR_056002e8, LayerName,
410 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
411 ") is "
412 "not unique within pCreateInfo->pQueueCreateInfos array. %s",
413 i, requested_queue_family, validation_error_map[VALIDATION_ERROR_056002e8]);
414 } else {
415 set.insert(requested_queue_family);
416 }
417
418 if (pCreateInfo->pQueueCreateInfos[i].pQueuePriorities != nullptr) {
419 for (uint32_t j = 0; j < pCreateInfo->pQueueCreateInfos[i].queueCount; ++j) {
420 const float queue_priority = pCreateInfo->pQueueCreateInfos[i].pQueuePriorities[j];
421 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
422 skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
423 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__,
424 VALIDATION_ERROR_06c002fe, LayerName,
425 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
426 "] (=%f) is not between 0 and 1 (inclusive). %s",
427 i, j, queue_priority, validation_error_map[VALIDATION_ERROR_06c002fe]);
428 }
429 }
430 }
431 }
432 }
433
434 return skip;
435}
436
437VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
438 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) {
439 // NOTE: Don't validate physicalDevice or any dispatchable object as the first parameter. We couldn't get here if it was wrong!
440
441 VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
442 bool skip = false;
443 auto my_instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
444 assert(my_instance_data != nullptr);
445 std::unique_lock<std::mutex> lock(global_lock);
446
447 skip |= parameter_validation_vkCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);
448
449 if (pCreateInfo != NULL) skip |= ValidateDeviceCreateInfo(my_instance_data, physicalDevice, pCreateInfo);
450
451 if (!skip) {
452 VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
453 assert(chain_info != nullptr);
454 assert(chain_info->u.pLayerInfo != nullptr);
455
456 PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
457 PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;
458 PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(my_instance_data->instance, "vkCreateDevice");
459 if (fpCreateDevice == NULL) {
460 return VK_ERROR_INITIALIZATION_FAILED;
461 }
462
463 // Advance the link info for the next element on the chain
464 chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
465
466 lock.unlock();
467
468 result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);
469
470 lock.lock();
471
472 validate_result(my_instance_data->report_data, "vkCreateDevice", {}, result);
473
474 if (result == VK_SUCCESS) {
475 layer_data *my_device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
476 assert(my_device_data != nullptr);
477
478 my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice);
479 layer_init_device_dispatch_table(*pDevice, &my_device_data->dispatch_table, fpGetDeviceProcAddr);
480
481 my_device_data->extensions.InitFromDeviceCreateInfo(&my_instance_data->extensions, pCreateInfo);
482
483 // Store createdevice data
484 if ((pCreateInfo != nullptr) && (pCreateInfo->pQueueCreateInfos != nullptr)) {
485 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
486 my_device_data->queueFamilyIndexMap.insert(std::make_pair(pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex,
487 pCreateInfo->pQueueCreateInfos[i].queueCount));
488 }
489 }
490
491 // Query and save physical device limits for this device
492 VkPhysicalDeviceProperties device_properties = {};
493 my_instance_data->dispatch_table.GetPhysicalDeviceProperties(physicalDevice, &device_properties);
494 memcpy(&my_device_data->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
495 my_device_data->physical_device = physicalDevice;
496 my_device_data->device = *pDevice;
497
498 // Save app-enabled features in this device's layer_data structure
499 if (pCreateInfo->pEnabledFeatures) {
500 my_device_data->physical_device_features = *pCreateInfo->pEnabledFeatures;
501 } else {
502 memset(&my_device_data->physical_device_features, 0, sizeof(VkPhysicalDeviceFeatures));
503 }
504 }
505 }
506
507 return result;
508}
509
510VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) {
511 dispatch_key key = get_dispatch_key(device);
512 bool skip = false;
513 layer_data *device_data = GetLayerDataPtr(key, layer_data_map);
514 {
515 std::unique_lock<std::mutex> lock(global_lock);
516 skip |= parameter_validation_vkDestroyDevice(device, pAllocator);
517 }
518
519 if (!skip) {
520 layer_debug_report_destroy_device(device);
521 device_data->dispatch_table.DestroyDevice(device, pAllocator);
522 }
523 FreeLayerDataPtr(key, layer_data_map);
524}
525
526extern bool (*manual_vkGetDeviceQueue)(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue);
527bool pv_vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) {
528 bool skip = false;
529 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
530
531 skip |=
532 ValidateDeviceQueueFamily(device_data, queueFamilyIndex, "vkGetDeviceQueue", "queueFamilyIndex", VALIDATION_ERROR_29600300);
533 const auto &queue_data = device_data->queueFamilyIndexMap.find(queueFamilyIndex);
534 if (queue_data != device_data->queueFamilyIndexMap.end() && queue_data->second <= queueIndex) {
535 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
536 HandleToUint64(device), __LINE__, VALIDATION_ERROR_29600302, LayerName,
537 "vkGetDeviceQueue: queueIndex (=%" PRIu32
538 ") is not less than the number of queues requested from "
539 "queueFamilyIndex (=%" PRIu32 ") when the device was created (i.e. is not less than %" PRIu32 "). %s",
540 queueIndex, queueFamilyIndex, queue_data->second, validation_error_map[VALIDATION_ERROR_29600302]);
541 }
542 return skip;
543}
544
545VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo,
546 const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool) {
547 layer_data *local_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
548 bool skip = false;
549 VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
550 std::unique_lock<std::mutex> lock(global_lock);
551
552 skip |= ValidateDeviceQueueFamily(local_data, pCreateInfo->queueFamilyIndex, "vkCreateCommandPool",
553 "pCreateInfo->queueFamilyIndex", VALIDATION_ERROR_02c0004e);
554
555 skip |= parameter_validation_vkCreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool);
556
557 lock.unlock();
558 if (!skip) {
559 result = local_data->dispatch_table.CreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool);
560 }
561 return result;
562}
563
564VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
565 const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool) {
566 VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
567 bool skip = false;
568 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
569
570 skip |= parameter_validation_vkCreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool);
571
572 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
573 if (pCreateInfo != nullptr) {
574 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
575 // VkQueryPipelineStatisticFlagBits values
576 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
577 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
578 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
579 __LINE__, VALIDATION_ERROR_11c00630, LayerName,
580 "vkCreateQueryPool(): if pCreateInfo->queryType is "
581 "VK_QUERY_TYPE_PIPELINE_STATISTICS, pCreateInfo->pipelineStatistics must be "
582 "a valid combination of VkQueryPipelineStatisticFlagBits values. %s",
583 validation_error_map[VALIDATION_ERROR_11c00630]);
584 }
585 }
586 if (!skip) {
587 result = device_data->dispatch_table.CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool);
588 }
589 return result;
590}
591
592extern bool (*manual_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
593 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer);
594bool pv_vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
595 VkBuffer *pBuffer) {
596 bool skip = false;
597 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
598 debug_report_data *report_data = device_data->report_data;
599
600 if (pCreateInfo != nullptr) {
601 // Buffer size must be greater than 0 (error 00663)
602 skip |=
603 ValidateGreaterThan(report_data, "vkCreateBuffer", "pCreateInfo->size", static_cast<uint32_t>(pCreateInfo->size), 0u);
604
605 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
606 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
607 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
608 if (pCreateInfo->queueFamilyIndexCount <= 1) {
609 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
610 VALIDATION_ERROR_01400724, LayerName,
611 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
612 "pCreateInfo->queueFamilyIndexCount must be greater than 1. %s",
613 validation_error_map[VALIDATION_ERROR_01400724]);
614 }
615
616 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
617 // queueFamilyIndexCount uint32_t values
618 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
619 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
620 VALIDATION_ERROR_01400722, LayerName,
621 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
622 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
623 "pCreateInfo->queueFamilyIndexCount uint32_t values. %s",
624 validation_error_map[VALIDATION_ERROR_01400722]);
625 } else {
626 // TODO: Not in the spec VUs. Probably missing -- KhronosGroup/Vulkan-Docs#501. Update error codes when resolved.
627 skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices,
628 "vkCreateBuffer", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE, INVALID_USAGE,
629 false, "", "");
630 }
631 }
632
633 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
634 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
635 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
636 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
637 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
638 VALIDATION_ERROR_0140072c, LayerName,
639 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
640 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT. %s",
641 validation_error_map[VALIDATION_ERROR_0140072c]);
642 }
643 }
644
645 return skip;
646}
647
648extern bool (*manual_vkCreateImage)(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
649 VkImage *pImage);
650bool pv_vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
651 VkImage *pImage) {
652 bool skip = false;
653 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
654 debug_report_data *report_data = device_data->report_data;
655
656 if (pCreateInfo != nullptr) {
657 if ((device_data->physical_device_features.textureCompressionETC2 == false) &&
658 FormatIsCompressed_ETC2_EAC(pCreateInfo->format)) {
659 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
660 DEVICE_FEATURE, LayerName,
661 "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionETC2 feature is "
662 "not enabled: neither ETC2 nor EAC formats can be used to create images.",
663 string_VkFormat(pCreateInfo->format));
664 }
665
666 if ((device_data->physical_device_features.textureCompressionASTC_LDR == false) &&
667 FormatIsCompressed_ASTC_LDR(pCreateInfo->format)) {
668 skip |=
669 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
670 DEVICE_FEATURE, LayerName,
671 "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionASTC_LDR feature is "
672 "not enabled: ASTC formats cannot be used to create images.",
673 string_VkFormat(pCreateInfo->format));
674 }
675
676 if ((device_data->physical_device_features.textureCompressionBC == false) && FormatIsCompressed_BC(pCreateInfo->format)) {
677 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
678 DEVICE_FEATURE, LayerName,
679 "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionBC feature is "
680 "not enabled: BC compressed formats cannot be used to create images.",
681 string_VkFormat(pCreateInfo->format));
682 }
683
684 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
685 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
686 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
687 if (pCreateInfo->queueFamilyIndexCount <= 1) {
688 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
689 VALIDATION_ERROR_09e0075c, LayerName,
690 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
691 "pCreateInfo->queueFamilyIndexCount must be greater than 1. %s",
692 validation_error_map[VALIDATION_ERROR_09e0075c]);
693 }
694
695 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
696 // queueFamilyIndexCount uint32_t values
697 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
698 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
699 VALIDATION_ERROR_09e0075a, LayerName,
700 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
701 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
702 "pCreateInfo->queueFamilyIndexCount uint32_t values. %s",
703 validation_error_map[VALIDATION_ERROR_09e0075a]);
704 } else {
705 // TODO: Not in the spec VUs. Probably missing -- KhronosGroup/Vulkan-Docs#501. Update error codes when resolved.
706 skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices,
707 "vkCreateImage", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE, INVALID_USAGE,
708 false, "", "");
709 }
710 }
711
712 // width, height, and depth members of extent must be greater than 0
713 skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.width", pCreateInfo->extent.width, 0u);
714 skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.height", pCreateInfo->extent.height, 0u);
715 skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.depth", pCreateInfo->extent.depth, 0u);
716
717 // mipLevels must be greater than 0
718 skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->mipLevels", pCreateInfo->mipLevels, 0u);
719
720 // arrayLayers must be greater than 0
721 skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->arrayLayers", pCreateInfo->arrayLayers, 0u);
722
723 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
724 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && (pCreateInfo->extent.height != 1) && (pCreateInfo->extent.depth != 1)) {
725 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
726 VALIDATION_ERROR_09e00778, LayerName,
727 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both "
728 "pCreateInfo->extent.height and pCreateInfo->extent.depth must be 1. %s",
729 validation_error_map[VALIDATION_ERROR_09e00778]);
730 }
731
732 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
733 // If imageType is VK_IMAGE_TYPE_2D and flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, extent.width and
734 // extent.height must be equal
735 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
736 (pCreateInfo->extent.width != pCreateInfo->extent.height)) {
737 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
738 VALIDATION_ERROR_09e00774, LayerName,
739 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D and "
740 "pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, "
741 "pCreateInfo->extent.width and pCreateInfo->extent.height must be equal. %s",
742 validation_error_map[VALIDATION_ERROR_09e00774]);
743 }
744
745 if (pCreateInfo->extent.depth != 1) {
746 skip |= log_msg(
747 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
748 VALIDATION_ERROR_09e0077a, LayerName,
749 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1. %s",
750 validation_error_map[VALIDATION_ERROR_09e0077a]);
751 }
752 }
753
754 // mipLevels must be less than or equal to floor(log2(max(extent.width,extent.height,extent.depth)))+1
755 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
756 if (pCreateInfo->mipLevels > (floor(log2(maxDim)) + 1)) {
757 skip |=
758 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
759 VALIDATION_ERROR_09e0077c, LayerName,
760 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
761 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1. %s",
762 validation_error_map[VALIDATION_ERROR_09e0077c]);
763 }
764
765 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
766 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
767 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
768 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
769 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
770 VALIDATION_ERROR_09e007b6, LayerName,
771 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
772 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT. %s",
773 validation_error_map[VALIDATION_ERROR_09e007b6]);
774 }
775
776 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
777 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
778 // Linear tiling is unsupported
779 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
780 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
781 INVALID_USAGE, LayerName,
782 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT "
783 "then image tiling of VK_IMAGE_TILING_LINEAR is not supported");
784 }
785
786 // Sparse 1D image isn't valid
787 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
788 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
789 VALIDATION_ERROR_09e00794, LayerName,
790 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image. %s",
791 validation_error_map[VALIDATION_ERROR_09e00794]);
792 }
793
794 // Sparse 2D image when device doesn't support it
795 if ((VK_FALSE == device_data->physical_device_features.sparseResidencyImage2D) &&
796 (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
797 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
798 VALIDATION_ERROR_09e00796, LayerName,
799 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
800 "feature is not enabled on the device. %s",
801 validation_error_map[VALIDATION_ERROR_09e00796]);
802 }
803
804 // Sparse 3D image when device doesn't support it
805 if ((VK_FALSE == device_data->physical_device_features.sparseResidencyImage3D) &&
806 (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
807 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
808 VALIDATION_ERROR_09e00798, LayerName,
809 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
810 "feature is not enabled on the device. %s",
811 validation_error_map[VALIDATION_ERROR_09e00798]);
812 }
813
814 // Multi-sample 2D image when device doesn't support it
815 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
816 if ((VK_FALSE == device_data->physical_device_features.sparseResidency2Samples) &&
817 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
818 skip |= log_msg(
819 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
820 VALIDATION_ERROR_09e0079a, LayerName,
821 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if corresponding "
822 "feature is not enabled on the device. %s",
823 validation_error_map[VALIDATION_ERROR_09e0079a]);
824 } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency4Samples) &&
825 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
826 skip |= log_msg(
827 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
828 VALIDATION_ERROR_09e0079c, LayerName,
829 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if corresponding "
830 "feature is not enabled on the device. %s",
831 validation_error_map[VALIDATION_ERROR_09e0079c]);
832 } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency8Samples) &&
833 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
834 skip |= log_msg(
835 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
836 VALIDATION_ERROR_09e0079e, LayerName,
837 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if corresponding "
838 "feature is not enabled on the device. %s",
839 validation_error_map[VALIDATION_ERROR_09e0079e]);
840 } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency16Samples) &&
841 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
842 skip |= log_msg(
843 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
844 VALIDATION_ERROR_09e007a0, LayerName,
845 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if corresponding "
846 "feature is not enabled on the device. %s",
847 validation_error_map[VALIDATION_ERROR_09e007a0]);
848 }
849 }
850 }
851 }
852 return skip;
853}
854
855extern bool (*manual_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
856 const VkAllocationCallbacks *pAllocator, VkImageView *pView);
857bool pv_vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
858 VkImageView *pView) {
859 bool skip = false;
860 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
861 debug_report_data *report_data = device_data->report_data;
862
863 if (pCreateInfo != nullptr) {
864 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D) || (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_2D)) {
865 if ((pCreateInfo->subresourceRange.layerCount != 1) &&
866 (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) {
867 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
868 LayerName,
869 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD, "
870 "pCreateInfo->subresourceRange.layerCount must be 1",
871 ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D) ? 1 : 2));
872 }
873 } else if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY) ||
874 (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_2D_ARRAY)) {
875 if ((pCreateInfo->subresourceRange.layerCount < 1) &&
876 (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) {
877 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
878 LayerName,
879 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD_ARRAY, "
880 "pCreateInfo->subresourceRange.layerCount must be >= 1",
881 ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY) ? 1 : 2));
882 }
883 } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE) {
884 if ((pCreateInfo->subresourceRange.layerCount != 6) &&
885 (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) {
886 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
887 LayerName,
888 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE, "
889 "pCreateInfo->subresourceRange.layerCount must be 6");
890 }
891 } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) {
892 if (((pCreateInfo->subresourceRange.layerCount == 0) || ((pCreateInfo->subresourceRange.layerCount % 6) != 0)) &&
893 (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) {
894 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
895 LayerName,
896 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE_ARRAY, "
897 "pCreateInfo->subresourceRange.layerCount must be a multiple of 6");
898 }
899 if (!device_data->physical_device_features.imageCubeArray) {
900 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
901 LayerName, "vkCreateImageView: Device feature imageCubeArray not enabled.");
902 }
903 } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_3D) {
904 if (pCreateInfo->subresourceRange.baseArrayLayer != 0) {
905 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
906 LayerName,
907 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, "
908 "pCreateInfo->subresourceRange.baseArrayLayer must be 0");
909 }
910
911 if ((pCreateInfo->subresourceRange.layerCount != 1) &&
912 (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) {
913 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
914 LayerName,
915 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, "
916 "pCreateInfo->subresourceRange.layerCount must be 1");
917 }
918 }
919 }
920 return skip;
921}
922
923extern bool (*manual_vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
924 const VkGraphicsPipelineCreateInfo *pCreateInfos,
925 const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines);
926bool pv_vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
927 const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator,
928 VkPipeline *pPipelines) {
929 bool skip = false;
930 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
931 debug_report_data *report_data = device_data->report_data;
932
933 if (pCreateInfos != nullptr) {
934 for (uint32_t i = 0; i < createInfoCount; ++i) {
935 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
936 if (pCreateInfos[i].pVertexInputState != nullptr) {
937 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
938 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
939 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
940 if (vertex_bind_desc.binding >= device_data->device_limits.maxVertexInputBindings) {
941 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
942 __LINE__, VALIDATION_ERROR_14c004d4, LayerName,
943 "vkCreateGraphicsPipelines: parameter "
944 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
945 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u). %s",
946 i, d, vertex_bind_desc.binding, device_data->device_limits.maxVertexInputBindings,
947 validation_error_map[VALIDATION_ERROR_14c004d4]);
948 }
949
950 if (vertex_bind_desc.stride > device_data->device_limits.maxVertexInputBindingStride) {
951 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
952 __LINE__, VALIDATION_ERROR_14c004d6, LayerName,
953 "vkCreateGraphicsPipelines: parameter "
954 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
955 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u). %s",
956 i, d, vertex_bind_desc.stride, device_data->device_limits.maxVertexInputBindingStride,
957 validation_error_map[VALIDATION_ERROR_14c004d6]);
958 }
959 }
960
961 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
962 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
963 if (vertex_attrib_desc.location >= device_data->device_limits.maxVertexInputAttributes) {
964 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
965 __LINE__, VALIDATION_ERROR_14a004d8, LayerName,
966 "vkCreateGraphicsPipelines: parameter "
967 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
968 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u). %s",
969 i, d, vertex_attrib_desc.location, device_data->device_limits.maxVertexInputAttributes,
970 validation_error_map[VALIDATION_ERROR_14a004d8]);
971 }
972
973 if (vertex_attrib_desc.binding >= device_data->device_limits.maxVertexInputBindings) {
974 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
975 __LINE__, VALIDATION_ERROR_14a004da, LayerName,
976 "vkCreateGraphicsPipelines: parameter "
977 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
978 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u). %s",
979 i, d, vertex_attrib_desc.binding, device_data->device_limits.maxVertexInputBindings,
980 validation_error_map[VALIDATION_ERROR_14a004da]);
981 }
982
983 if (vertex_attrib_desc.offset > device_data->device_limits.maxVertexInputAttributeOffset) {
984 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
985 __LINE__, VALIDATION_ERROR_14a004dc, LayerName,
986 "vkCreateGraphicsPipelines: parameter "
987 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
988 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u). %s",
989 i, d, vertex_attrib_desc.offset, device_data->device_limits.maxVertexInputAttributeOffset,
990 validation_error_map[VALIDATION_ERROR_14a004dc]);
991 }
992 }
993 }
994
995 if (pCreateInfos[i].pStages != nullptr) {
996 bool has_control = false;
997 bool has_eval = false;
998
999 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1000 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1001 has_control = true;
1002 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1003 has_eval = true;
1004 }
1005 }
1006
1007 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1008 if (has_control && has_eval) {
1009 if (pCreateInfos[i].pTessellationState == nullptr) {
1010 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1011 __LINE__, VALIDATION_ERROR_096005b6, LayerName,
1012 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1013 "shader stage and a tessellation evaluation shader stage, "
1014 "pCreateInfos[%d].pTessellationState must not be NULL. %s",
1015 i, i, validation_error_map[VALIDATION_ERROR_096005b6]);
1016 } else {
1017 skip |= validate_struct_pnext(
1018 report_data, "vkCreateGraphicsPipelines",
1019 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), NULL,
1020 pCreateInfos[i].pTessellationState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0961c40d);
1021
1022 skip |= validate_reserved_flags(
1023 report_data, "vkCreateGraphicsPipelines",
1024 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1025 pCreateInfos[i].pTessellationState->flags, VALIDATION_ERROR_10809005);
1026
1027 if (pCreateInfos[i].pTessellationState->sType !=
1028 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO) {
1029 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1030 __LINE__, VALIDATION_ERROR_1082b00b, LayerName,
1031 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pTessellationState->sType must "
1032 "be VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO. %s",
1033 i, validation_error_map[VALIDATION_ERROR_1082b00b]);
1034 }
1035
1036 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1037 pCreateInfos[i].pTessellationState->patchControlPoints >
1038 device_data->device_limits.maxTessellationPatchSize) {
1039 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1040 __LINE__, VALIDATION_ERROR_1080097c, LayerName,
1041 "vkCreateGraphicsPipelines: invalid parameter "
1042 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1043 "should be >0 and <=%u. %s",
1044 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1045 device_data->device_limits.maxTessellationPatchSize,
1046 validation_error_map[VALIDATION_ERROR_1080097c]);
1047 }
1048 }
1049 }
1050 }
1051
1052 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1053 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1054 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1055 if (pCreateInfos[i].pViewportState == nullptr) {
1056 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1057 __LINE__, VALIDATION_ERROR_096005dc, LayerName,
1058 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1059 "is VK_FALSE, pCreateInfos[%d].pViewportState must be a pointer to a valid "
1060 "VkPipelineViewportStateCreateInfo structure. %s",
1061 i, i, validation_error_map[VALIDATION_ERROR_096005dc]);
1062 } else {
1063 if (pCreateInfos[i].pViewportState->scissorCount != pCreateInfos[i].pViewportState->viewportCount) {
1064 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1065 __LINE__, VALIDATION_ERROR_10c00988, LayerName,
1066 "Graphics Pipeline viewport count (%u) must match scissor count (%u). %s",
1067 pCreateInfos[i].pViewportState->viewportCount, pCreateInfos[i].pViewportState->scissorCount,
1068 validation_error_map[VALIDATION_ERROR_10c00988]);
1069 }
1070
1071 skip |= validate_struct_pnext(
1072 report_data, "vkCreateGraphicsPipelines",
1073 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}), NULL,
1074 pCreateInfos[i].pViewportState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_10c1c40d);
1075
1076 skip |= validate_reserved_flags(
1077 report_data, "vkCreateGraphicsPipelines",
1078 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
1079 pCreateInfos[i].pViewportState->flags, VALIDATION_ERROR_10c09005);
1080
1081 if (pCreateInfos[i].pViewportState->sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
1082 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1083 __LINE__, INVALID_STRUCT_STYPE, LayerName,
1084 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pViewportState->sType must be "
1085 "VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO",
1086 i);
1087 }
1088
1089 if (device_data->physical_device_features.multiViewport == false) {
1090 if (pCreateInfos[i].pViewportState->viewportCount != 1) {
1091 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1092 __LINE__, VALIDATION_ERROR_10c00980, LayerName,
1093 "vkCreateGraphicsPipelines: The multiViewport feature is not enabled, so "
1094 "pCreateInfos[%d].pViewportState->viewportCount must be 1 but is %d. %s",
1095 i, pCreateInfos[i].pViewportState->viewportCount,
1096 validation_error_map[VALIDATION_ERROR_10c00980]);
1097 }
1098 if (pCreateInfos[i].pViewportState->scissorCount != 1) {
1099 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1100 __LINE__, VALIDATION_ERROR_10c00982, LayerName,
1101 "vkCreateGraphicsPipelines: The multiViewport feature is not enabled, so "
1102 "pCreateInfos[%d].pViewportState->scissorCount must be 1 but is %d. %s",
1103 i, pCreateInfos[i].pViewportState->scissorCount,
1104 validation_error_map[VALIDATION_ERROR_10c00982]);
1105 }
1106 } else {
1107 if ((pCreateInfos[i].pViewportState->viewportCount < 1) ||
1108 (pCreateInfos[i].pViewportState->viewportCount > device_data->device_limits.maxViewports)) {
1109 skip |=
1110 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1111 __LINE__, VALIDATION_ERROR_10c00984, LayerName,
1112 "vkCreateGraphicsPipelines: multiViewport feature is enabled; "
1113 "pCreateInfos[%d].pViewportState->viewportCount is %d but must be between 1 and "
1114 "maxViewports (%d), inclusive. %s",
1115 i, pCreateInfos[i].pViewportState->viewportCount, device_data->device_limits.maxViewports,
1116 validation_error_map[VALIDATION_ERROR_10c00984]);
1117 }
1118 if ((pCreateInfos[i].pViewportState->scissorCount < 1) ||
1119 (pCreateInfos[i].pViewportState->scissorCount > device_data->device_limits.maxViewports)) {
1120 skip |=
1121 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1122 __LINE__, VALIDATION_ERROR_10c00986, LayerName,
1123 "vkCreateGraphicsPipelines: multiViewport feature is enabled; "
1124 "pCreateInfos[%d].pViewportState->scissorCount is %d but must be between 1 and "
1125 "maxViewports (%d), inclusive. %s",
1126 i, pCreateInfos[i].pViewportState->scissorCount, device_data->device_limits.maxViewports,
1127 validation_error_map[VALIDATION_ERROR_10c00986]);
1128 }
1129 }
1130
1131 if (pCreateInfos[i].pDynamicState != nullptr) {
1132 bool has_dynamic_viewport = false;
1133 bool has_dynamic_scissor = false;
1134
1135 for (uint32_t state_index = 0; state_index < pCreateInfos[i].pDynamicState->dynamicStateCount;
1136 ++state_index) {
1137 if (pCreateInfos[i].pDynamicState->pDynamicStates[state_index] == VK_DYNAMIC_STATE_VIEWPORT) {
1138 has_dynamic_viewport = true;
1139 } else if (pCreateInfos[i].pDynamicState->pDynamicStates[state_index] == VK_DYNAMIC_STATE_SCISSOR) {
1140 has_dynamic_scissor = true;
1141 }
1142 }
1143
1144 // If no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_VIEWPORT, the pViewports
1145 // member of pViewportState must be a pointer to an array of pViewportState->viewportCount VkViewport
1146 // structures
1147 if (!has_dynamic_viewport && (pCreateInfos[i].pViewportState->pViewports == nullptr)) {
1148 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1149 __LINE__, VALIDATION_ERROR_096005d6, LayerName,
1150 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pDynamicState->pDynamicStates does not "
1151 "contain VK_DYNAMIC_STATE_VIEWPORT, pCreateInfos[%d].pViewportState->pViewports must "
1152 "not be NULL. %s",
1153 i, i, validation_error_map[VALIDATION_ERROR_096005d6]);
1154 }
1155
1156 // If no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_SCISSOR, the pScissors
1157 // member
1158 // of pViewportState must be a pointer to an array of pViewportState->scissorCount VkRect2D structures
1159 if (!has_dynamic_scissor && (pCreateInfos[i].pViewportState->pScissors == nullptr)) {
1160 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1161 __LINE__, VALIDATION_ERROR_096005d8, LayerName,
1162 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pDynamicState->pDynamicStates does not "
1163 "contain VK_DYNAMIC_STATE_SCISSOR, pCreateInfos[%d].pViewportState->pScissors must not "
1164 "be NULL. %s",
1165 i, i, validation_error_map[VALIDATION_ERROR_096005d8]);
1166 }
1167 }
1168 }
1169
1170 if (pCreateInfos[i].pMultisampleState == nullptr) {
1171 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1172 __LINE__, VALIDATION_ERROR_096005de, LayerName,
1173 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1174 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL. %s",
1175 i, i, validation_error_map[VALIDATION_ERROR_096005de]);
1176 } else {
1177 skip |= validate_struct_pnext(
1178 report_data, "vkCreateGraphicsPipelines",
1179 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}), NULL,
1180 pCreateInfos[i].pMultisampleState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_1001c40d);
1181
1182 skip |= validate_reserved_flags(
1183 report_data, "vkCreateGraphicsPipelines",
1184 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
1185 pCreateInfos[i].pMultisampleState->flags, VALIDATION_ERROR_10009005);
1186
1187 skip |= validate_bool32(
1188 report_data, "vkCreateGraphicsPipelines",
1189 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1190 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1191
1192 skip |= validate_array(
1193 report_data, "vkCreateGraphicsPipelines",
1194 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1195 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
1196 pCreateInfos[i].pMultisampleState->rasterizationSamples, pCreateInfos[i].pMultisampleState->pSampleMask,
1197 true, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
1198
1199 skip |= validate_bool32(
1200 report_data, "vkCreateGraphicsPipelines",
1201 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1202 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1203
1204 skip |= validate_bool32(
1205 report_data, "vkCreateGraphicsPipelines",
1206 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1207 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1208
1209 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
1210 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1211 __LINE__, INVALID_STRUCT_STYPE, LayerName,
1212 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1213 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1214 i);
1215 }
1216 }
1217
1218 // TODO: Conditional NULL check based on subpass depth/stencil attachment
1219 if (pCreateInfos[i].pDepthStencilState != nullptr) {
1220 skip |= validate_struct_pnext(
1221 report_data, "vkCreateGraphicsPipelines",
1222 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
1223 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0f61c40d);
1224
1225 skip |= validate_reserved_flags(
1226 report_data, "vkCreateGraphicsPipelines",
1227 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
1228 pCreateInfos[i].pDepthStencilState->flags, VALIDATION_ERROR_0f609005);
1229
1230 skip |= validate_bool32(
1231 report_data, "vkCreateGraphicsPipelines",
1232 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
1233 pCreateInfos[i].pDepthStencilState->depthTestEnable);
1234
1235 skip |= validate_bool32(
1236 report_data, "vkCreateGraphicsPipelines",
1237 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
1238 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
1239
1240 skip |= validate_ranged_enum(
1241 report_data, "vkCreateGraphicsPipelines",
1242 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
1243 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
1244 VALIDATION_ERROR_0f604001);
1245
1246 skip |= validate_bool32(
1247 report_data, "vkCreateGraphicsPipelines",
1248 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
1249 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
1250
1251 skip |= validate_bool32(
1252 report_data, "vkCreateGraphicsPipelines",
1253 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
1254 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
1255
1256 skip |= validate_ranged_enum(
1257 report_data, "vkCreateGraphicsPipelines",
1258 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
1259 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
1260 VALIDATION_ERROR_13a08601);
1261
1262 skip |= validate_ranged_enum(
1263 report_data, "vkCreateGraphicsPipelines",
1264 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
1265 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
1266 VALIDATION_ERROR_13a27801);
1267
1268 skip |= validate_ranged_enum(
1269 report_data, "vkCreateGraphicsPipelines",
1270 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
1271 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
1272 VALIDATION_ERROR_13a04201);
1273
1274 skip |= validate_ranged_enum(
1275 report_data, "vkCreateGraphicsPipelines",
1276 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
1277 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
1278 VALIDATION_ERROR_0f604001);
1279
1280 skip |= validate_ranged_enum(
1281 report_data, "vkCreateGraphicsPipelines",
1282 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
1283 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
1284 VALIDATION_ERROR_13a08601);
1285
1286 skip |= validate_ranged_enum(
1287 report_data, "vkCreateGraphicsPipelines",
1288 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
1289 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
1290 VALIDATION_ERROR_13a27801);
1291
1292 skip |= validate_ranged_enum(
1293 report_data, "vkCreateGraphicsPipelines",
1294 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
1295 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
1296 VALIDATION_ERROR_13a04201);
1297
1298 skip |= validate_ranged_enum(
1299 report_data, "vkCreateGraphicsPipelines",
1300 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
1301 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
1302 VALIDATION_ERROR_0f604001);
1303
1304 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
1305 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1306 __LINE__, INVALID_STRUCT_STYPE, LayerName,
1307 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
1308 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
1309 i);
1310 }
1311 }
1312
1313 // TODO: Conditional NULL check based on subpass color attachment
1314 if (pCreateInfos[i].pColorBlendState != nullptr) {
1315 skip |= validate_struct_pnext(
1316 report_data, "vkCreateGraphicsPipelines",
1317 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), NULL,
1318 pCreateInfos[i].pColorBlendState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0f41c40d);
1319
1320 skip |= validate_reserved_flags(
1321 report_data, "vkCreateGraphicsPipelines",
1322 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
1323 pCreateInfos[i].pColorBlendState->flags, VALIDATION_ERROR_0f409005);
1324
1325 skip |= validate_bool32(
1326 report_data, "vkCreateGraphicsPipelines",
1327 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
1328 pCreateInfos[i].pColorBlendState->logicOpEnable);
1329
1330 skip |= validate_array(
1331 report_data, "vkCreateGraphicsPipelines",
1332 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
1333 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
1334 pCreateInfos[i].pColorBlendState->attachmentCount, pCreateInfos[i].pColorBlendState->pAttachments, false,
1335 true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
1336
1337 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
1338 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
1339 ++attachmentIndex) {
1340 skip |= validate_bool32(report_data, "vkCreateGraphicsPipelines",
1341 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
1342 ParameterName::IndexVector{i, attachmentIndex}),
1343 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
1344
1345 skip |= validate_ranged_enum(
1346 report_data, "vkCreateGraphicsPipelines",
1347 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
1348 ParameterName::IndexVector{i, attachmentIndex}),
1349 "VkBlendFactor", AllVkBlendFactorEnums,
1350 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
1351 VALIDATION_ERROR_0f22cc01);
1352
1353 skip |= validate_ranged_enum(
1354 report_data, "vkCreateGraphicsPipelines",
1355 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
1356 ParameterName::IndexVector{i, attachmentIndex}),
1357 "VkBlendFactor", AllVkBlendFactorEnums,
1358 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
1359 VALIDATION_ERROR_0f207001);
1360
1361 skip |= validate_ranged_enum(
1362 report_data, "vkCreateGraphicsPipelines",
1363 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
1364 ParameterName::IndexVector{i, attachmentIndex}),
1365 "VkBlendOp", AllVkBlendOpEnums,
1366 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
1367 VALIDATION_ERROR_0f202001);
1368
1369 skip |= validate_ranged_enum(
1370 report_data, "vkCreateGraphicsPipelines",
1371 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
1372 ParameterName::IndexVector{i, attachmentIndex}),
1373 "VkBlendFactor", AllVkBlendFactorEnums,
1374 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
1375 VALIDATION_ERROR_0f22c601);
1376
1377 skip |= validate_ranged_enum(
1378 report_data, "vkCreateGraphicsPipelines",
1379 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
1380 ParameterName::IndexVector{i, attachmentIndex}),
1381 "VkBlendFactor", AllVkBlendFactorEnums,
1382 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
1383 VALIDATION_ERROR_0f206a01);
1384
1385 skip |= validate_ranged_enum(
1386 report_data, "vkCreateGraphicsPipelines",
1387 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
1388 ParameterName::IndexVector{i, attachmentIndex}),
1389 "VkBlendOp", AllVkBlendOpEnums,
1390 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
1391 VALIDATION_ERROR_0f200801);
1392
1393 skip |=
1394 validate_flags(report_data, "vkCreateGraphicsPipelines",
1395 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
1396 ParameterName::IndexVector{i, attachmentIndex}),
1397 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
1398 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
1399 false, false, VALIDATION_ERROR_0f202201);
1400 }
1401 }
1402
1403 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
1404 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1405 __LINE__, INVALID_STRUCT_STYPE, LayerName,
1406 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
1407 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
1408 i);
1409 }
1410
1411 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
1412 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
1413 skip |= validate_ranged_enum(
1414 report_data, "vkCreateGraphicsPipelines",
1415 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
1416 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp, VALIDATION_ERROR_0f4004be);
1417 }
1418 }
1419 }
1420 }
1421
1422 if (pCreateInfos != nullptr) {
1423 if (pCreateInfos->flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
1424 if (pCreateInfos->basePipelineIndex != -1) {
1425 if (pCreateInfos->basePipelineHandle != VK_NULL_HANDLE) {
1426 skip |= log_msg(
1427 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1428 VALIDATION_ERROR_096005a8, LayerName,
1429 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be VK_NULL_HANDLE if "
1430 "pCreateInfos->flags "
1431 "contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1. %s",
1432 validation_error_map[VALIDATION_ERROR_096005a8]);
1433 }
1434 }
1435
1436 if (pCreateInfos->basePipelineHandle != VK_NULL_HANDLE) {
1437 if (pCreateInfos->basePipelineIndex != -1) {
1438 skip |= log_msg(
1439 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1440 VALIDATION_ERROR_096005aa, LayerName,
1441 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
1442 "pCreateInfos->flags "
1443 "contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineHandle is not "
1444 "VK_NULL_HANDLE. %s",
1445 validation_error_map[VALIDATION_ERROR_096005aa]);
1446 }
1447 }
1448 }
1449
1450 if (pCreateInfos->pRasterizationState != nullptr) {
1451 if (pCreateInfos->pRasterizationState->cullMode & ~VK_CULL_MODE_FRONT_AND_BACK) {
1452 skip |= log_msg(
1453 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1454 UNRECOGNIZED_VALUE, LayerName,
1455 "vkCreateGraphicsPipelines parameter, VkCullMode pCreateInfos->pRasterizationState->cullMode, is an "
1456 "unrecognized enumerator");
1457 }
1458
1459 if ((pCreateInfos->pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
1460 (device_data->physical_device_features.fillModeNonSolid == false)) {
1461 skip |= log_msg(
1462 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1463 DEVICE_FEATURE, LayerName,
1464 "vkCreateGraphicsPipelines parameter, VkPolygonMode pCreateInfos->pRasterizationState->polygonMode cannot "
1465 "be "
1466 "VK_POLYGON_MODE_POINT or VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
1467 }
1468 }
1469
1470 size_t i = 0;
1471 for (size_t j = 0; j < pCreateInfos[i].stageCount; j++) {
1472 skip |= validate_string(device_data->report_data, "vkCreateGraphicsPipelines",
1473 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, j}),
1474 pCreateInfos[i].pStages[j].pName);
1475 }
1476 }
1477 }
1478
1479 return skip;
1480}
1481
1482extern bool (*manual_vkCreateComputePipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
1483 const VkComputePipelineCreateInfo *pCreateInfos,
1484 const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines);
1485bool pv_vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
1486 const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator,
1487 VkPipeline *pPipelines) {
1488 bool skip = false;
1489 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1490
1491 for (uint32_t i = 0; i < createInfoCount; i++) {
1492 skip |= validate_string(device_data->report_data, "vkCreateComputePipelines",
1493 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
1494 pCreateInfos[i].stage.pName);
1495 }
1496
1497 return skip;
1498}
1499
1500extern bool (*manual_vkCreateSampler)(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
1501 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler);
1502bool pv_vkCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
1503 VkSampler *pSampler) {
1504 bool skip = false;
1505 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1506 debug_report_data *report_data = device_data->report_data;
1507
1508 if (pCreateInfo != nullptr) {
1509 if ((device_data->physical_device_features.samplerAnisotropy == false) && (pCreateInfo->maxAnisotropy != 1.0)) {
1510 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1511 DEVICE_FEATURE, LayerName,
1512 "vkCreateSampler(): The samplerAnisotropy feature was not enabled at device-creation time, so the "
1513 "maxAnisotropy member of the VkSamplerCreateInfo structure must be 1.0 but is %f.",
1514 pCreateInfo->maxAnisotropy);
1515 }
1516
1517 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
1518 if (pCreateInfo->compareEnable == VK_TRUE) {
1519 skip |= validate_ranged_enum(report_data, "vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp",
1520 AllVkCompareOpEnums, pCreateInfo->compareOp, VALIDATION_ERROR_12600870);
1521 }
1522
1523 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
1524 // valid VkBorderColor value
1525 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
1526 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
1527 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
1528 skip |= validate_ranged_enum(report_data, "vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor",
1529 AllVkBorderColorEnums, pCreateInfo->borderColor, VALIDATION_ERROR_1260086c);
1530 }
1531
1532 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
1533 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
1534 if (!device_data->extensions.vk_khr_sampler_mirror_clamp_to_edge &&
1535 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
1536 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
1537 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
1538 skip |=
1539 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1540 VALIDATION_ERROR_1260086e, LayerName,
1541 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
1542 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled. %s",
1543 validation_error_map[VALIDATION_ERROR_1260086e]);
1544 }
1545 }
1546
1547 return skip;
1548}
1549
1550extern bool (*manual_vkCreateDescriptorSetLayout)(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
1551 const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout);
1552bool pv_vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
1553 const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout) {
1554 bool skip = false;
1555 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1556 debug_report_data *report_data = device_data->report_data;
1557
1558 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
1559 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
1560 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
1561 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
1562 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount
1563 // is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a pointer to an array of descriptorCount
1564 // valid VkSampler handles
1565 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
1566 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
1567 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
1568 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
1569 ++descriptor_index) {
1570 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
1571 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1572 __LINE__, REQUIRED_PARAMETER, LayerName,
1573 "vkCreateDescriptorSetLayout: required parameter "
1574 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d]"
1575 " specified as VK_NULL_HANDLE",
1576 i, descriptor_index);
1577 }
1578 }
1579 }
1580
1581 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
1582 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
1583 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
1584 skip |= log_msg(
1585 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1586 VALIDATION_ERROR_04e00236, LayerName,
1587 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
1588 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits values. %s",
1589 i, i, validation_error_map[VALIDATION_ERROR_04e00236]);
1590 }
1591 }
1592 }
1593 }
1594
1595 return skip;
1596}
1597
1598extern bool (*manual_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
1599 const VkDescriptorSet *pDescriptorSets);
1600bool pv_vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
1601 const VkDescriptorSet *pDescriptorSets) {
1602 bool skip = false;
1603 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1604 debug_report_data *report_data = device_data->report_data;
1605
1606 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
1607 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
1608 // validate_array()
1609 skip |= validate_array(report_data, "vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount,
1610 pDescriptorSets, true, true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
1611 return skip;
1612}
1613
1614extern bool (*manual_vkUpdateDescriptorSets)(VkDevice device, uint32_t descriptorWriteCount,
1615 const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount,
1616 const VkCopyDescriptorSet *pDescriptorCopies);
1617bool pv_vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites,
1618 uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies) {
1619 bool skip = false;
1620 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1621 debug_report_data *report_data = device_data->report_data;
1622
1623 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
1624 if (pDescriptorWrites != NULL) {
1625 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
1626 // descriptorCount must be greater than 0
1627 if (pDescriptorWrites[i].descriptorCount == 0) {
1628 skip |=
1629 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1630 VALIDATION_ERROR_15c0441b, LayerName,
1631 "vkUpdateDescriptorSets(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0. %s",
1632 i, validation_error_map[VALIDATION_ERROR_15c0441b]);
1633 }
1634
1635 // dstSet must be a valid VkDescriptorSet handle
1636 skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets",
1637 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
1638 pDescriptorWrites[i].dstSet);
1639
1640 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
1641 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
1642 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
1643 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
1644 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
1645 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
1646 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
1647 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
1648 if (pDescriptorWrites[i].pImageInfo == nullptr) {
1649 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1650 __LINE__, VALIDATION_ERROR_15c00284, LayerName,
1651 "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is "
1652 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
1653 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
1654 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL. %s",
1655 i, i, validation_error_map[VALIDATION_ERROR_15c00284]);
1656 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
1657 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
1658 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
1659 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
1660 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
1661 ++descriptor_index) {
1662 skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets",
1663 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
1664 ParameterName::IndexVector{i, descriptor_index}),
1665 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
1666 skip |= validate_ranged_enum(report_data, "vkUpdateDescriptorSets",
1667 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
1668 ParameterName::IndexVector{i, descriptor_index}),
1669 "VkImageLayout", AllVkImageLayoutEnums,
1670 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout,
1671 VALIDATION_ERROR_UNDEFINED);
1672 }
1673 }
1674 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
1675 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
1676 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
1677 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
1678 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1679 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
1680 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
1681 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
1682 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1683 __LINE__, VALIDATION_ERROR_15c00288, LayerName,
1684 "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is "
1685 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
1686 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
1687 "pDescriptorWrites[%d].pBufferInfo must not be NULL. %s",
1688 i, i, validation_error_map[VALIDATION_ERROR_15c00288]);
1689 } else {
1690 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
1691 skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets",
1692 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
1693 ParameterName::IndexVector{i, descriptorIndex}),
1694 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
1695 }
1696 }
1697 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
1698 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
1699 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
1700 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
1701 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
1702 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1703 __LINE__, VALIDATION_ERROR_15c00286, LayerName,
1704 "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is "
1705 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
1706 "pDescriptorWrites[%d].pTexelBufferView must not be NULL. %s",
1707 i, i, validation_error_map[VALIDATION_ERROR_15c00286]);
1708 } else {
1709 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
1710 ++descriptor_index) {
1711 skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets",
1712 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
1713 ParameterName::IndexVector{i, descriptor_index}),
1714 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
1715 }
1716 }
1717 }
1718
1719 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
1720 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
1721 VkDeviceSize uniformAlignment = device_data->device_limits.minUniformBufferOffsetAlignment;
1722 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
1723 if (pDescriptorWrites[i].pBufferInfo != NULL) {
1724 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
1725 skip |= log_msg(
1726 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
1727 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_15c0028e, LayerName,
1728 "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
1729 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ". %s",
1730 i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment,
1731 validation_error_map[VALIDATION_ERROR_15c0028e]);
1732 }
1733 }
1734 }
1735 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
1736 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
1737 VkDeviceSize storageAlignment = device_data->device_limits.minStorageBufferOffsetAlignment;
1738 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
1739 if (pDescriptorWrites[i].pBufferInfo != NULL) {
1740 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
1741 skip |= log_msg(
1742 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
1743 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_15c00290, LayerName,
1744 "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
1745 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ". %s",
1746 i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment,
1747 validation_error_map[VALIDATION_ERROR_15c00290]);
1748 }
1749 }
1750 }
1751 }
1752 }
1753 }
1754 return skip;
1755}
1756
1757extern bool (*manual_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
1758 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass);
1759bool pv_vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
1760 VkRenderPass *pRenderPass) {
1761 bool skip = false;
1762 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1763 uint32_t max_color_attachments = device_data->device_limits.maxColorAttachments;
1764
1765 for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) {
1766 if (pCreateInfo->pAttachments[i].format == VK_FORMAT_UNDEFINED) {
1767 std::stringstream ss;
1768 ss << "vkCreateRenderPass: pCreateInfo->pAttachments[" << i << "].format is VK_FORMAT_UNDEFINED. "
1769 << validation_error_map[VALIDATION_ERROR_00809201];
1770 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1771 __LINE__, VALIDATION_ERROR_00809201, "IMAGE", "%s", ss.str().c_str());
1772 }
1773 if (pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_UNDEFINED ||
1774 pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_PREINITIALIZED) {
1775 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1776 __LINE__, VALIDATION_ERROR_00800696, "DL",
1777 "pCreateInfo->pAttachments[%d].finalLayout must not be VK_IMAGE_LAYOUT_UNDEFINED or "
1778 "VK_IMAGE_LAYOUT_PREINITIALIZED. %s",
1779 i, validation_error_map[VALIDATION_ERROR_00800696]);
1780 }
1781 }
1782
1783 for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) {
1784 if (pCreateInfo->pSubpasses[i].colorAttachmentCount > max_color_attachments) {
1785 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1786 __LINE__, VALIDATION_ERROR_1400069a, "DL",
1787 "Cannot create a render pass with %d color attachments. Max is %d. %s",
1788 pCreateInfo->pSubpasses[i].colorAttachmentCount, max_color_attachments,
1789 validation_error_map[VALIDATION_ERROR_1400069a]);
1790 }
1791 }
1792 return skip;
1793}
1794
1795bool pv_vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
1796 const VkCommandBuffer *pCommandBuffers) {
1797 bool skip = false;
1798 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1799 debug_report_data *report_data = device_data->report_data;
1800
1801 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
1802 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
1803 // validate_array()
1804 skip |= validate_array(report_data, "vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount,
1805 pCommandBuffers, true, true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
1806 return skip;
1807}
1808
1809extern bool (*manual_vkBeginCommandBuffer)(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo);
1810bool pv_vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo) {
1811 bool skip = false;
1812 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
1813 debug_report_data *report_data = device_data->report_data;
1814 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
1815
1816 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
1817 // TODO: pBeginInfo->pInheritanceInfo must not be NULL if commandBuffer is a secondary command buffer
1818 skip |= validate_struct_type(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo",
1819 "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO", pBeginInfo->pInheritanceInfo,
1820 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, false, VALIDATION_ERROR_UNDEFINED);
1821
1822 if (pBeginInfo->pInheritanceInfo != NULL) {
1823 skip |=
1824 validate_struct_pnext(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->pNext", NULL,
1825 pBeginInfo->pInheritanceInfo->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0281c40d);
1826
1827 skip |= validate_bool32(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->occlusionQueryEnable",
1828 pBeginInfo->pInheritanceInfo->occlusionQueryEnable);
1829
1830 // TODO: This only needs to be validated when the inherited queries feature is enabled
1831 // skip |= validate_flags(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->queryFlags",
1832 // "VkQueryControlFlagBits", AllVkQueryControlFlagBits, pBeginInfo->pInheritanceInfo->queryFlags, false);
1833
1834 // TODO: This must be 0 if the pipeline statistics queries feature is not enabled
1835 skip |= validate_flags(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->pipelineStatistics",
1836 "VkQueryPipelineStatisticFlagBits", AllVkQueryPipelineStatisticFlagBits,
1837 pBeginInfo->pInheritanceInfo->pipelineStatistics, false, false, VALIDATION_ERROR_UNDEFINED);
1838 }
1839
1840 if (pInfo != NULL) {
1841 if ((device_data->physical_device_features.inheritedQueries == VK_FALSE) && (pInfo->occlusionQueryEnable != VK_FALSE)) {
1842 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
1843 HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_02a00070, LayerName,
1844 "Cannot set inherited occlusionQueryEnable in vkBeginCommandBuffer() when device does not support "
1845 "inheritedQueries. %s",
1846 validation_error_map[VALIDATION_ERROR_02a00070]);
1847 }
1848 if ((device_data->physical_device_features.inheritedQueries != VK_FALSE) && (pInfo->occlusionQueryEnable != VK_FALSE)) {
1849 skip |= validate_flags(device_data->report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->queryFlags",
1850 "VkQueryControlFlagBits", AllVkQueryControlFlagBits, pInfo->queryFlags, false, false,
1851 VALIDATION_ERROR_02a00072);
1852 }
1853 }
1854
1855 return skip;
1856}
1857
1858extern bool (*manual_vkCmdSetViewport)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
1859 const VkViewport *pViewports);
1860bool pv_vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
1861 const VkViewport *pViewports) {
1862 bool skip = false;
1863 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
1864
1865 skip |= validate_array(device_data->report_data, "vkCmdSetViewport", "viewportCount", "pViewports", viewportCount, pViewports,
1866 true, true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
1867
1868 if (viewportCount > 0 && pViewports != nullptr) {
1869 const VkPhysicalDeviceLimits &limits = device_data->device_limits;
1870 for (uint32_t viewportIndex = 0; viewportIndex < viewportCount; ++viewportIndex) {
1871 const VkViewport &viewport = pViewports[viewportIndex];
1872
1873 if (device_data->physical_device_features.multiViewport == false) {
1874 if (viewportCount != 1) {
1875 skip |= log_msg(
1876 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1877 __LINE__, DEVICE_FEATURE, LayerName,
1878 "vkCmdSetViewport(): The multiViewport feature is not enabled, so viewportCount must be 1 but is %d.",
1879 viewportCount);
1880 }
1881 if (firstViewport != 0) {
1882 skip |= log_msg(
1883 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1884 __LINE__, DEVICE_FEATURE, LayerName,
1885 "vkCmdSetViewport(): The multiViewport feature is not enabled, so firstViewport must be 0 but is %d.",
1886 firstViewport);
1887 }
1888 }
1889
1890 if (viewport.width <= 0 || viewport.width > limits.maxViewportDimensions[0]) {
1891 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1892 __LINE__, VALIDATION_ERROR_15000996, LayerName,
1893 "vkCmdSetViewport %d: width (%f) exceeds permitted bounds (0,%u). %s", viewportIndex,
1894 viewport.width, limits.maxViewportDimensions[0], validation_error_map[VALIDATION_ERROR_15000996]);
1895 }
1896
1897 if (device_data->extensions.vk_amd_negative_viewport_height || device_data->extensions.vk_khr_maintenance1) {
1898 // Check lower bound against negative viewport height instead of zero
1899 if (viewport.height <= -(static_cast<int32_t>(limits.maxViewportDimensions[1])) ||
1900 (viewport.height > limits.maxViewportDimensions[1])) {
1901 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
1902 VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, VALIDATION_ERROR_1500099a, LayerName,
1903 "vkCmdSetViewport %d: height (%f) exceeds permitted bounds (-%u,%u). %s", viewportIndex,
1904 viewport.height, limits.maxViewportDimensions[1], limits.maxViewportDimensions[1],
1905 validation_error_map[VALIDATION_ERROR_1500099a]);
1906 }
1907 } else {
1908 if ((viewport.height <= 0) || (viewport.height > limits.maxViewportDimensions[1])) {
1909 skip |=
1910 log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1911 __LINE__, VALIDATION_ERROR_15000998, LayerName,
1912 "vkCmdSetViewport %d: height (%f) exceeds permitted bounds (0,%u). %s", viewportIndex,
1913 viewport.height, limits.maxViewportDimensions[1], validation_error_map[VALIDATION_ERROR_15000998]);
1914 }
1915 }
1916
1917 if (viewport.x < limits.viewportBoundsRange[0] || viewport.x > limits.viewportBoundsRange[1]) {
1918 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1919 __LINE__, VALIDATION_ERROR_1500099e, LayerName,
1920 "vkCmdSetViewport %d: x (%f) exceeds permitted bounds (%f,%f). %s", viewportIndex, viewport.x,
1921 limits.viewportBoundsRange[0], limits.viewportBoundsRange[1],
1922 validation_error_map[VALIDATION_ERROR_1500099e]);
1923 }
1924
1925 if (viewport.y < limits.viewportBoundsRange[0] || viewport.y > limits.viewportBoundsRange[1]) {
1926 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1927 __LINE__, VALIDATION_ERROR_1500099e, LayerName,
1928 "vkCmdSetViewport %d: y (%f) exceeds permitted bounds (%f,%f). %s", viewportIndex, viewport.y,
1929 limits.viewportBoundsRange[0], limits.viewportBoundsRange[1],
1930 validation_error_map[VALIDATION_ERROR_1500099e]);
1931 }
1932
1933 if (viewport.x + viewport.width > limits.viewportBoundsRange[1]) {
1934 skip |=
1935 log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1936 __LINE__, VALIDATION_ERROR_150009a0, LayerName,
1937 "vkCmdSetViewport %d: x (%f) + width (%f) exceeds permitted bound (%f). %s", viewportIndex, viewport.x,
1938 viewport.width, limits.viewportBoundsRange[1], validation_error_map[VALIDATION_ERROR_150009a0]);
1939 }
1940
1941 if (viewport.y + viewport.height > limits.viewportBoundsRange[1]) {
1942 skip |=
1943 log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1944 __LINE__, VALIDATION_ERROR_150009a2, LayerName,
1945 "vkCmdSetViewport %d: y (%f) + height (%f) exceeds permitted bound (%f). %s", viewportIndex, viewport.y,
1946 viewport.height, limits.viewportBoundsRange[1], validation_error_map[VALIDATION_ERROR_150009a2]);
1947 }
1948 }
1949 }
1950 return skip;
1951}
1952
1953extern bool (*manual_vkCmdSetScissor)(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount,
1954 const VkRect2D *pScissors);
1955bool pv_vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors) {
1956 bool skip = false;
1957 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
1958 debug_report_data *report_data = device_data->report_data;
1959
1960 if (device_data->physical_device_features.multiViewport == false) {
1961 if (scissorCount != 1) {
1962 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1963 DEVICE_FEATURE, LayerName,
1964 "vkCmdSetScissor(): The multiViewport feature is not enabled, so scissorCount must be 1 but is %d.",
1965 scissorCount);
1966 }
1967 if (firstScissor != 0) {
1968 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1969 DEVICE_FEATURE, LayerName,
1970 "vkCmdSetScissor(): The multiViewport feature is not enabled, so firstScissor must be 0 but is %d.",
1971 firstScissor);
1972 }
1973 }
1974
1975 for (uint32_t scissorIndex = 0; scissorIndex < scissorCount; ++scissorIndex) {
1976 const VkRect2D &pScissor = pScissors[scissorIndex];
1977
1978 if (pScissor.offset.x < 0) {
1979 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1980 VALIDATION_ERROR_1d8004a6, LayerName, "vkCmdSetScissor %d: offset.x (%d) must not be negative. %s",
1981 scissorIndex, pScissor.offset.x, validation_error_map[VALIDATION_ERROR_1d8004a6]);
1982 } else if (static_cast<int32_t>(pScissor.extent.width) > (INT_MAX - pScissor.offset.x)) {
1983 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1984 VALIDATION_ERROR_1d8004a8, LayerName,
1985 "vkCmdSetScissor %d: adding offset.x (%d) and extent.width (%u) will overflow. %s", scissorIndex,
1986 pScissor.offset.x, pScissor.extent.width, validation_error_map[VALIDATION_ERROR_1d8004a8]);
1987 }
1988
1989 if (pScissor.offset.y < 0) {
1990 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1991 VALIDATION_ERROR_1d8004a6, LayerName, "vkCmdSetScissor %d: offset.y (%d) must not be negative. %s",
1992 scissorIndex, pScissor.offset.y, validation_error_map[VALIDATION_ERROR_1d8004a6]);
1993 } else if (static_cast<int32_t>(pScissor.extent.height) > (INT_MAX - pScissor.offset.y)) {
1994 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1995 VALIDATION_ERROR_1d8004aa, LayerName,
1996 "vkCmdSetScissor %d: adding offset.y (%d) and extent.height (%u) will overflow. %s", scissorIndex,
1997 pScissor.offset.y, pScissor.extent.height, validation_error_map[VALIDATION_ERROR_1d8004aa]);
1998 }
1999 }
2000 return skip;
2001}
2002
2003extern bool (*manual_vkCmdDraw)(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex,
2004 uint32_t firstInstance);
2005bool pv_vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex,
2006 uint32_t firstInstance) {
2007 bool skip = false;
2008 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2009 if (vertexCount == 0) {
2010 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2011 // this an error or leave as is.
2012 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2013 __LINE__, REQUIRED_PARAMETER, LayerName, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
2014 }
2015
2016 if (instanceCount == 0) {
2017 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2018 // this an error or leave as is.
2019 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2020 __LINE__, REQUIRED_PARAMETER, LayerName, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
2021 }
2022 return skip;
2023}
2024
2025extern bool (*manual_vkCmdDrawIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount,
2026 uint32_t stride);
2027bool pv_vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
2028 bool skip = false;
2029 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2030
2031 if (!device_data->physical_device_features.multiDrawIndirect && ((count > 1))) {
2032 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2033 __LINE__, DEVICE_FEATURE, LayerName,
2034 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
2035 }
2036 return skip;
2037}
2038
2039extern bool (*manual_vkCmdDrawIndexedIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
2040 uint32_t drawCount, uint32_t stride);
2041bool pv_vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count,
2042 uint32_t stride) {
2043 bool skip = false;
2044 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2045 if (!device_data->physical_device_features.multiDrawIndirect && ((count > 1))) {
2046 skip |=
2047 log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2048 DEVICE_FEATURE, LayerName,
2049 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
2050 }
2051 return skip;
2052}
2053
2054extern bool (*manual_vkCmdCopyImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,
2055 VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount,
2056 const VkImageCopy *pRegions);
2057bool pv_vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage,
2058 VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions) {
2059 bool skip = false;
2060 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2061
2062 if (pRegions != nullptr) {
2063 if ((pRegions->srcSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2064 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2065 skip |= log_msg(
2066 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2067 VALIDATION_ERROR_0a600c01, LayerName,
2068 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator. %s",
2069 validation_error_map[VALIDATION_ERROR_0a600c01]);
2070 }
2071 if ((pRegions->dstSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2072 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2073 skip |= log_msg(
2074 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2075 VALIDATION_ERROR_0a600c01, LayerName,
2076 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator. %s",
2077 validation_error_map[VALIDATION_ERROR_0a600c01]);
2078 }
2079 }
2080 return skip;
2081}
2082
2083extern bool (*manual_vkCmdBlitImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,
2084 VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount,
2085 const VkImageBlit *pRegions, VkFilter filter);
2086bool pv_vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage,
2087 VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter) {
2088 bool skip = false;
2089 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2090
2091 if (pRegions != nullptr) {
2092 if ((pRegions->srcSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2093 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2094 skip |= log_msg(
2095 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2096 UNRECOGNIZED_VALUE, LayerName,
2097 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
2098 }
2099 if ((pRegions->dstSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2100 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2101 skip |= log_msg(
2102 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2103 UNRECOGNIZED_VALUE, LayerName,
2104 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
2105 }
2106 }
2107 return skip;
2108}
2109
2110extern bool (*manual_vkCmdCopyBufferToImage)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage,
2111 VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy *pRegions);
2112bool pv_vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout,
2113 uint32_t regionCount, const VkBufferImageCopy *pRegions) {
2114 bool skip = false;
2115 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2116
2117 if (pRegions != nullptr) {
2118 if ((pRegions->imageSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2119 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2120 skip |= log_msg(
2121 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2122 UNRECOGNIZED_VALUE, LayerName,
2123 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
2124 "enumerator");
2125 }
2126 }
2127 return skip;
2128}
2129
2130extern bool (*manual_vkCmdCopyImageToBuffer)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,
2131 VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions);
2132bool pv_vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer,
2133 uint32_t regionCount, const VkBufferImageCopy *pRegions) {
2134 bool skip = false;
2135 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2136
2137 if (pRegions != nullptr) {
2138 if ((pRegions->imageSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2139 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2140 log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2141 UNRECOGNIZED_VALUE, LayerName,
2142 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
2143 "enumerator");
2144 }
2145 }
2146 return skip;
2147}
2148
2149extern bool (*manual_vkCmdUpdateBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset,
2150 VkDeviceSize dataSize, const void *pData);
2151bool pv_vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize,
2152 const void *pData) {
2153 bool skip = false;
2154 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2155
2156 if (dstOffset & 3) {
2157 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2158 __LINE__, VALIDATION_ERROR_1e400048, LayerName,
2159 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4. %s",
2160 dstOffset, validation_error_map[VALIDATION_ERROR_1e400048]);
2161 }
2162
2163 if ((dataSize <= 0) || (dataSize > 65536)) {
2164 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2165 __LINE__, VALIDATION_ERROR_1e40004a, LayerName,
2166 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
2167 "), must be greater than zero and less than or equal to 65536. %s",
2168 dataSize, validation_error_map[VALIDATION_ERROR_1e40004a]);
2169 } else if (dataSize & 3) {
2170 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2171 __LINE__, VALIDATION_ERROR_1e40004c, LayerName,
2172 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4. %s",
2173 dataSize, validation_error_map[VALIDATION_ERROR_1e40004c]);
2174 }
2175 return skip;
2176}
2177
2178extern bool (*manual_vkCmdFillBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size,
2179 uint32_t data);
2180bool pv_vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size,
2181 uint32_t data) {
2182 bool skip = false;
2183 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2184
2185 if (dstOffset & 3) {
2186 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2187 __LINE__, VALIDATION_ERROR_1b400032, LayerName,
2188 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4. %s",
2189 dstOffset, validation_error_map[VALIDATION_ERROR_1b400032]);
2190 }
2191
2192 if (size != VK_WHOLE_SIZE) {
2193 if (size <= 0) {
2194 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2195 __LINE__, VALIDATION_ERROR_1b400034, LayerName,
2196 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero. %s",
2197 size, validation_error_map[VALIDATION_ERROR_1b400034]);
2198 } else if (size & 3) {
2199 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2200 __LINE__, VALIDATION_ERROR_1b400038, LayerName,
2201 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4. %s", size,
2202 validation_error_map[VALIDATION_ERROR_1b400038]);
2203 }
2204 }
2205 return skip;
2206}
2207
2208VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) {
2209 return util_GetLayerProperties(1, &global_layer, pCount, pProperties);
2210}
2211
2212VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
2213 VkLayerProperties *pProperties) {
2214 return util_GetLayerProperties(1, &global_layer, pCount, pProperties);
2215}
2216
2217VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount,
2218 VkExtensionProperties *pProperties) {
2219 if (pLayerName && !strcmp(pLayerName, global_layer.layerName))
2220 return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties);
2221
2222 return VK_ERROR_LAYER_NOT_PRESENT;
2223}
2224
2225VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName,
2226 uint32_t *pPropertyCount, VkExtensionProperties *pProperties) {
2227 // Parameter_validation does not have any physical device extensions
2228 if (pLayerName && !strcmp(pLayerName, global_layer.layerName))
2229 return util_GetExtensionProperties(0, NULL, pPropertyCount, pProperties);
2230
2231 instance_layer_data *local_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
2232 bool skip =
2233 validate_array(local_data->report_data, "vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties",
2234 pPropertyCount, pProperties, true, false, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_2761f401);
2235 if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
2236
2237 return local_data->dispatch_table.EnumerateDeviceExtensionProperties(physicalDevice, NULL, pPropertyCount, pProperties);
2238}
2239
2240static bool require_device_extension(layer_data *device_data, bool flag, char const *function_name, char const *extension_name) {
2241 if (!flag) {
2242 return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2243 __LINE__, EXTENSION_NOT_ENABLED, LayerName,
2244 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
2245 extension_name);
2246 }
2247
2248 return false;
2249}
2250
2251extern bool (*manual_vkCreateSwapchainKHR)(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
2252 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain);
2253bool pv_vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
2254 VkSwapchainKHR *pSwapchain) {
2255 bool skip = false;
2256 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2257 debug_report_data *report_data = device_data->report_data;
2258
2259 if (pCreateInfo != nullptr) {
2260 if ((device_data->physical_device_features.textureCompressionETC2 == false) &&
2261 FormatIsCompressed_ETC2_EAC(pCreateInfo->imageFormat)) {
2262 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2263 DEVICE_FEATURE, LayerName,
2264 "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The "
2265 "textureCompressionETC2 feature is not enabled: neither ETC2 nor EAC formats can be used to create "
2266 "images.",
2267 string_VkFormat(pCreateInfo->imageFormat));
2268 }
2269
2270 if ((device_data->physical_device_features.textureCompressionASTC_LDR == false) &&
2271 FormatIsCompressed_ASTC_LDR(pCreateInfo->imageFormat)) {
2272 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2273 DEVICE_FEATURE, LayerName,
2274 "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The "
2275 "textureCompressionASTC_LDR feature is not enabled: ASTC formats cannot be used to create images.",
2276 string_VkFormat(pCreateInfo->imageFormat));
2277 }
2278
2279 if ((device_data->physical_device_features.textureCompressionBC == false) &&
2280 FormatIsCompressed_BC(pCreateInfo->imageFormat)) {
2281 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2282 DEVICE_FEATURE, LayerName,
2283 "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The "
2284 "textureCompressionBC feature is not enabled: BC compressed formats cannot be used to create images.",
2285 string_VkFormat(pCreateInfo->imageFormat));
2286 }
2287
2288 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2289 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
2290 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
2291 if (pCreateInfo->queueFamilyIndexCount <= 1) {
2292 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2293 VALIDATION_ERROR_146009fc, LayerName,
2294 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
2295 "pCreateInfo->queueFamilyIndexCount must be greater than 1. %s",
2296 validation_error_map[VALIDATION_ERROR_146009fc]);
2297 }
2298
2299 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
2300 // queueFamilyIndexCount uint32_t values
2301 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
2302 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2303 VALIDATION_ERROR_146009fa, LayerName,
2304 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
2305 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
2306 "pCreateInfo->queueFamilyIndexCount uint32_t values. %s",
2307 validation_error_map[VALIDATION_ERROR_146009fa]);
2308 } else {
2309 // TODO: Not in the spec VUs. Probably missing -- KhronosGroup/Vulkan-Docs#501. Update error codes when resolved.
2310 skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices,
2311 "vkCreateSwapchainKHR", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE,
2312 INVALID_USAGE, false, "", "");
2313 }
2314 }
2315
2316 // imageArrayLayers must be greater than 0
2317 skip |= ValidateGreaterThan(report_data, "vkCreateSwapchainKHR", "pCreateInfo->imageArrayLayers",
2318 pCreateInfo->imageArrayLayers, 0u);
2319 }
2320
2321 return skip;
2322}
2323
2324extern bool (*manual_vkQueuePresentKHR)(VkQueue queue, const VkPresentInfoKHR *pPresentInfo);
2325bool pv_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
2326 bool skip = false;
2327 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
2328
2329 if (pPresentInfo && pPresentInfo->pNext) {
2330 // Verify ext struct
2331 struct std_header {
2332 VkStructureType sType;
2333 const void *pNext;
2334 };
2335 std_header *pnext = (std_header *)pPresentInfo->pNext;
2336 while (pnext) {
2337 if (VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR == pnext->sType) {
2338 // TODO: This and all other pNext extension dependencies should be added to code-generation
2339 skip |= require_device_extension(device_data, device_data->extensions.vk_khr_incremental_present,
2340 "vkQueuePresentKHR", VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
2341 VkPresentRegionsKHR *present_regions = (VkPresentRegionsKHR *)pnext;
2342 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
2343 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
2344 VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, INVALID_USAGE, LayerName,
2345 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i"
2346 " but VkPresentRegionsKHR extension swapchainCount is %i. These values must be equal.",
2347 pPresentInfo->swapchainCount, present_regions->swapchainCount);
2348 }
2349 skip |= validate_struct_pnext(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL,
2350 present_regions->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_1121c40d);
2351 skip |= validate_array(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->swapchainCount",
2352 "pCreateInfo->pNext->pRegions", present_regions->swapchainCount, present_regions->pRegions,
2353 true, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
2354 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
2355 skip |=
2356 validate_array(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
2357 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
2358 present_regions->pRegions[i].pRectangles, true, false, VALIDATION_ERROR_UNDEFINED,
2359 VALIDATION_ERROR_UNDEFINED);
2360 }
2361 }
2362 pnext = (std_header *)pnext->pNext;
2363 }
2364 }
2365
2366 return skip;
2367}
2368
2369#ifdef VK_USE_PLATFORM_WIN32_KHR
2370extern bool (*manual_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
2371 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
2372bool pv_vkCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
2373 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
2374 auto device_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
2375 bool skip = false;
2376
2377 if (pCreateInfo->hwnd == nullptr) {
2378 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2379 __LINE__, VALIDATION_ERROR_15a00a38, LayerName,
2380 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL. %s",
2381 validation_error_map[VALIDATION_ERROR_15a00a38]);
2382 }
2383
2384 return skip;
2385}
2386#endif // VK_USE_PLATFORM_WIN32_KHR
2387
2388extern bool (*manual_vkDebugMarkerSetObjectNameEXT)(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo);
2389bool pv_vkDebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) {
2390 auto device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2391 if (pNameInfo->pObjectName) {
2392 device_data->report_data->debugObjectNameMap->insert(
2393 std::make_pair<uint64_t, std::string>((uint64_t &&) pNameInfo->object, pNameInfo->pObjectName));
2394 } else {
2395 device_data->report_data->debugObjectNameMap->erase(pNameInfo->object);
2396 }
2397 return false;
2398}
2399
2400VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *funcName) {
2401 const auto item = name_to_funcptr_map.find(funcName);
2402 if (item != name_to_funcptr_map.end()) {
2403 return reinterpret_cast<PFN_vkVoidFunction>(item->second);
2404 }
2405
2406 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2407 const auto &table = device_data->dispatch_table;
2408 if (!table.GetDeviceProcAddr) return nullptr;
2409 return table.GetDeviceProcAddr(device, funcName);
2410}
2411
2412VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) {
2413 const auto item = name_to_funcptr_map.find(funcName);
2414 if (item != name_to_funcptr_map.end()) {
2415 return reinterpret_cast<PFN_vkVoidFunction>(item->second);
2416 }
2417
2418 auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
2419 auto &table = instance_data->dispatch_table;
2420 if (!table.GetInstanceProcAddr) return nullptr;
2421 return table.GetInstanceProcAddr(instance, funcName);
2422}
2423
2424VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) {
2425 assert(instance);
2426 auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
2427
2428 if (!instance_data->dispatch_table.GetPhysicalDeviceProcAddr) return nullptr;
2429 return instance_data->dispatch_table.GetPhysicalDeviceProcAddr(instance, funcName);
2430}
2431
2432// If additional validation is needed outside of the generated checks, a manual routine can be added to this file
2433// and the address filled in here. The autogenerated source will call these routines if the pointers are not NULL.
2434void InitializeManualParameterValidationFunctionPointers(void) {
2435 manual_vkGetDeviceQueue = pv_vkGetDeviceQueue;
2436 manual_vkCreateBuffer = pv_vkCreateBuffer;
2437 manual_vkCreateImage = pv_vkCreateImage;
2438 manual_vkCreateImageView = pv_vkCreateImageView;
2439 manual_vkCreateGraphicsPipelines = pv_vkCreateGraphicsPipelines;
2440 manual_vkCreateComputePipelines = pv_vkCreateComputePipelines;
2441 manual_vkCreateSampler = pv_vkCreateSampler;
2442 manual_vkCreateDescriptorSetLayout = pv_vkCreateDescriptorSetLayout;
2443 manual_vkFreeDescriptorSets = pv_vkFreeDescriptorSets;
2444 manual_vkUpdateDescriptorSets = pv_vkUpdateDescriptorSets;
2445 manual_vkCreateRenderPass = pv_vkCreateRenderPass;
2446 manual_vkBeginCommandBuffer = pv_vkBeginCommandBuffer;
2447 manual_vkCmdSetViewport = pv_vkCmdSetViewport;
2448 manual_vkCmdSetScissor = pv_vkCmdSetScissor;
2449 manual_vkCmdDraw = pv_vkCmdDraw;
2450 manual_vkCmdDrawIndirect = pv_vkCmdDrawIndirect;
2451 manual_vkCmdDrawIndexedIndirect = pv_vkCmdDrawIndexedIndirect;
2452 manual_vkCmdCopyImage = pv_vkCmdCopyImage;
2453 manual_vkCmdBlitImage = pv_vkCmdBlitImage;
2454 manual_vkCmdCopyBufferToImage = pv_vkCmdCopyBufferToImage;
2455 manual_vkCmdCopyImageToBuffer = pv_vkCmdCopyImageToBuffer;
2456 manual_vkCmdUpdateBuffer = pv_vkCmdUpdateBuffer;
2457 manual_vkCmdFillBuffer = pv_vkCmdFillBuffer;
2458 manual_vkCreateSwapchainKHR = pv_vkCreateSwapchainKHR;
2459 manual_vkQueuePresentKHR = pv_vkQueuePresentKHR;
2460}
2461
2462} // namespace parameter_validation
2463
2464VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount,
2465 VkExtensionProperties *pProperties) {
2466 return parameter_validation::vkEnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties);
2467}
2468
2469VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount,
2470 VkLayerProperties *pProperties) {
2471 return parameter_validation::vkEnumerateInstanceLayerProperties(pCount, pProperties);
2472}
2473
2474VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
2475 VkLayerProperties *pProperties) {
2476 // the layer command handles VK_NULL_HANDLE just fine internally
2477 assert(physicalDevice == VK_NULL_HANDLE);
2478 return parameter_validation::vkEnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties);
2479}
2480
2481VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
2482 const char *pLayerName, uint32_t *pCount,
2483 VkExtensionProperties *pProperties) {
2484 // the layer command handles VK_NULL_HANDLE just fine internally
2485 assert(physicalDevice == VK_NULL_HANDLE);
2486 return parameter_validation::vkEnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties);
2487}
2488
2489VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) {
2490 return parameter_validation::vkGetDeviceProcAddr(dev, funcName);
2491}
2492
2493VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) {
2494 return parameter_validation::vkGetInstanceProcAddr(instance, funcName);
2495}
2496
2497VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance,
2498 const char *funcName) {
2499 return parameter_validation::vkGetPhysicalDeviceProcAddr(instance, funcName);
2500}
2501
2502VK_LAYER_EXPORT bool pv_vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) {
2503 assert(pVersionStruct != NULL);
2504 assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT);
2505
2506 // Fill in the function pointers if our version is at least capable of having the structure contain them.
2507 if (pVersionStruct->loaderLayerInterfaceVersion >= 2) {
2508 pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr;
2509 pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr;
2510 pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr;
2511 }
2512
2513 if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
2514 parameter_validation::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion;
2515 } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
2516 pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION;
2517 }
2518
2519 return VK_SUCCESS;
2520}