blob: 4f446ad039d37d75ad7bee5fc030df8cae56fbcf [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"
John Zulaufde972ac2017-10-26 12:07:05 -060042#include "vk_typemap_helper.h"
Mark Lobodzinskid4950072017-08-01 13:02:20 -060043
44#include "vk_layer_table.h"
45#include "vk_layer_data.h"
46#include "vk_layer_logging.h"
47#include "vk_layer_extension_utils.h"
48#include "vk_layer_utils.h"
49
50#include "parameter_name.h"
51#include "parameter_validation.h"
52
Mark Lobodzinskid4950072017-08-01 13:02:20 -060053namespace parameter_validation {
54
Mark Lobodzinski78a12a92017-08-08 14:16:51 -060055extern std::unordered_map<std::string, void *> custom_functions;
56
Mark Lobodzinskid4950072017-08-01 13:02:20 -060057extern bool parameter_validation_vkCreateInstance(VkInstance instance, const VkInstanceCreateInfo *pCreateInfo,
58 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance);
59extern bool parameter_validation_vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator);
60extern bool parameter_validation_vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
61 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
62extern bool parameter_validation_vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator);
63extern bool parameter_validation_vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
64 const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool);
65extern bool parameter_validation_vkCreateDebugReportCallbackEXT(VkInstance instance,
66 const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
67 const VkAllocationCallbacks *pAllocator,
68 VkDebugReportCallbackEXT *pMsgCallback);
69extern bool parameter_validation_vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback,
70 const VkAllocationCallbacks *pAllocator);
71extern bool parameter_validation_vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo,
72 const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool);
Petr Krause91f7a12017-12-14 20:57:36 +010073extern bool parameter_validation_vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
74 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass);
75extern bool parameter_validation_vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
76 const VkAllocationCallbacks *pAllocator);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060077
78// TODO : This can be much smarter, using separate locks for separate global data
79std::mutex global_lock;
80
81static uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION;
82std::unordered_map<void *, layer_data *> layer_data_map;
83std::unordered_map<void *, instance_layer_data *> instance_layer_data_map;
84
85void InitializeManualParameterValidationFunctionPointers(void);
86
87static void init_parameter_validation(instance_layer_data *instance_data, const VkAllocationCallbacks *pAllocator) {
88 layer_debug_actions(instance_data->report_data, instance_data->logging_callback, pAllocator, "lunarg_parameter_validation");
89}
90
91static const VkExtensionProperties instance_extensions[] = {{VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}};
92
93static const VkLayerProperties global_layer = {
94 "VK_LAYER_LUNARG_parameter_validation", VK_LAYER_API_VERSION, 1, "LunarG Validation Layer",
95};
96
97static const int MaxParamCheckerStringLength = 256;
98
John Zulauf71968502017-10-26 13:51:15 -060099template <typename T>
100static inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
101 // Using only < for generality and || for early abort
102 return !((value < min) || (max < value));
103}
104
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600105static 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
John Zulaufde972ac2017-10-26 12:07:05 -0600355 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
356 if (features2) {
357 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
358 skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
359 __LINE__, INVALID_USAGE, LayerName,
360 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
361 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600362 }
363 }
364
365 // Validate pCreateInfo->pQueueCreateInfos
366 if (pCreateInfo->pQueueCreateInfos) {
367 std::unordered_set<uint32_t> set;
368
369 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
370 const uint32_t requested_queue_family = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex;
371 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
372 skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
373 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__,
374 VALIDATION_ERROR_06c002fa, LayerName,
375 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
376 "].queueFamilyIndex is "
377 "VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family index value. %s",
378 i, validation_error_map[VALIDATION_ERROR_06c002fa]);
379 } else if (set.count(requested_queue_family)) {
380 skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
381 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__,
382 VALIDATION_ERROR_056002e8, LayerName,
383 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
384 ") is "
385 "not unique within pCreateInfo->pQueueCreateInfos array. %s",
386 i, requested_queue_family, validation_error_map[VALIDATION_ERROR_056002e8]);
387 } else {
388 set.insert(requested_queue_family);
389 }
390
391 if (pCreateInfo->pQueueCreateInfos[i].pQueuePriorities != nullptr) {
392 for (uint32_t j = 0; j < pCreateInfo->pQueueCreateInfos[i].queueCount; ++j) {
393 const float queue_priority = pCreateInfo->pQueueCreateInfos[i].pQueuePriorities[j];
394 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
395 skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
396 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, HandleToUint64(physicalDevice), __LINE__,
397 VALIDATION_ERROR_06c002fe, LayerName,
398 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
399 "] (=%f) is not between 0 and 1 (inclusive). %s",
400 i, j, queue_priority, validation_error_map[VALIDATION_ERROR_06c002fe]);
401 }
402 }
403 }
404 }
405 }
406
407 return skip;
408}
409
410VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
411 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) {
412 // NOTE: Don't validate physicalDevice or any dispatchable object as the first parameter. We couldn't get here if it was wrong!
413
414 VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
415 bool skip = false;
416 auto my_instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
417 assert(my_instance_data != nullptr);
418 std::unique_lock<std::mutex> lock(global_lock);
419
420 skip |= parameter_validation_vkCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);
421
422 if (pCreateInfo != NULL) skip |= ValidateDeviceCreateInfo(my_instance_data, physicalDevice, pCreateInfo);
423
424 if (!skip) {
425 VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
426 assert(chain_info != nullptr);
427 assert(chain_info->u.pLayerInfo != nullptr);
428
429 PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
430 PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;
431 PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(my_instance_data->instance, "vkCreateDevice");
432 if (fpCreateDevice == NULL) {
433 return VK_ERROR_INITIALIZATION_FAILED;
434 }
435
436 // Advance the link info for the next element on the chain
437 chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
438
439 lock.unlock();
440
441 result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);
442
443 lock.lock();
444
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600445 if (result == VK_SUCCESS) {
446 layer_data *my_device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
447 assert(my_device_data != nullptr);
448
449 my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice);
450 layer_init_device_dispatch_table(*pDevice, &my_device_data->dispatch_table, fpGetDeviceProcAddr);
451
452 my_device_data->extensions.InitFromDeviceCreateInfo(&my_instance_data->extensions, pCreateInfo);
453
454 // Store createdevice data
455 if ((pCreateInfo != nullptr) && (pCreateInfo->pQueueCreateInfos != nullptr)) {
456 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
457 my_device_data->queueFamilyIndexMap.insert(std::make_pair(pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex,
458 pCreateInfo->pQueueCreateInfos[i].queueCount));
459 }
460 }
461
462 // Query and save physical device limits for this device
463 VkPhysicalDeviceProperties device_properties = {};
464 my_instance_data->dispatch_table.GetPhysicalDeviceProperties(physicalDevice, &device_properties);
465 memcpy(&my_device_data->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
466 my_device_data->physical_device = physicalDevice;
467 my_device_data->device = *pDevice;
468
469 // Save app-enabled features in this device's layer_data structure
John Zulauf1bde5bb2017-10-18 18:21:23 -0600470 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
471 const VkPhysicalDeviceFeatures *enabled_features_found = pCreateInfo->pEnabledFeatures;
472 if ((nullptr == enabled_features_found) && my_device_data->extensions.vk_khr_get_physical_device_properties_2) {
John Zulaufde972ac2017-10-26 12:07:05 -0600473 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
474 if (features2) {
475 enabled_features_found = &(features2->features);
John Zulauf1bde5bb2017-10-18 18:21:23 -0600476 }
477 }
478 if (enabled_features_found) {
479 my_device_data->physical_device_features = *enabled_features_found;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600480 } else {
481 memset(&my_device_data->physical_device_features, 0, sizeof(VkPhysicalDeviceFeatures));
482 }
483 }
484 }
485
486 return result;
487}
488
489VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) {
490 dispatch_key key = get_dispatch_key(device);
491 bool skip = false;
492 layer_data *device_data = GetLayerDataPtr(key, layer_data_map);
493 {
494 std::unique_lock<std::mutex> lock(global_lock);
495 skip |= parameter_validation_vkDestroyDevice(device, pAllocator);
496 }
497
498 if (!skip) {
499 layer_debug_report_destroy_device(device);
500 device_data->dispatch_table.DestroyDevice(device, pAllocator);
501 }
502 FreeLayerDataPtr(key, layer_data_map);
503}
504
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600505bool pv_vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) {
506 bool skip = false;
507 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
508
509 skip |=
510 ValidateDeviceQueueFamily(device_data, queueFamilyIndex, "vkGetDeviceQueue", "queueFamilyIndex", VALIDATION_ERROR_29600300);
511 const auto &queue_data = device_data->queueFamilyIndexMap.find(queueFamilyIndex);
512 if (queue_data != device_data->queueFamilyIndexMap.end() && queue_data->second <= queueIndex) {
513 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
514 HandleToUint64(device), __LINE__, VALIDATION_ERROR_29600302, LayerName,
515 "vkGetDeviceQueue: queueIndex (=%" PRIu32
516 ") is not less than the number of queues requested from "
517 "queueFamilyIndex (=%" PRIu32 ") when the device was created (i.e. is not less than %" PRIu32 "). %s",
518 queueIndex, queueFamilyIndex, queue_data->second, validation_error_map[VALIDATION_ERROR_29600302]);
519 }
520 return skip;
521}
522
523VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo,
524 const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool) {
525 layer_data *local_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
526 bool skip = false;
527 VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
528 std::unique_lock<std::mutex> lock(global_lock);
529
530 skip |= ValidateDeviceQueueFamily(local_data, pCreateInfo->queueFamilyIndex, "vkCreateCommandPool",
531 "pCreateInfo->queueFamilyIndex", VALIDATION_ERROR_02c0004e);
532
533 skip |= parameter_validation_vkCreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool);
534
535 lock.unlock();
536 if (!skip) {
537 result = local_data->dispatch_table.CreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool);
538 }
539 return result;
540}
541
542VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
543 const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool) {
544 VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
545 bool skip = false;
546 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
547
548 skip |= parameter_validation_vkCreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool);
549
550 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
551 if (pCreateInfo != nullptr) {
552 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
553 // VkQueryPipelineStatisticFlagBits values
554 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
555 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
556 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
557 __LINE__, VALIDATION_ERROR_11c00630, LayerName,
558 "vkCreateQueryPool(): if pCreateInfo->queryType is "
559 "VK_QUERY_TYPE_PIPELINE_STATISTICS, pCreateInfo->pipelineStatistics must be "
560 "a valid combination of VkQueryPipelineStatisticFlagBits values. %s",
561 validation_error_map[VALIDATION_ERROR_11c00630]);
562 }
563 }
564 if (!skip) {
565 result = device_data->dispatch_table.CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool);
566 }
567 return result;
568}
569
Petr Krause91f7a12017-12-14 20:57:36 +0100570VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
571 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass) {
572 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
573 bool skip = false;
574 VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
575
576 {
577 std::unique_lock<std::mutex> lock(global_lock);
578 skip |= parameter_validation_vkCreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass);
579
580 typedef bool (*PFN_manual_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass);
581 PFN_manual_vkCreateRenderPass custom_func = (PFN_manual_vkCreateRenderPass)custom_functions["vkCreateRenderPass"];
582 if (custom_func != nullptr) {
583 skip |= custom_func(device, pCreateInfo, pAllocator, pRenderPass);
584 }
585 }
586
587 if (!skip) {
588 result = device_data->dispatch_table.CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass);
589
590 // track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
591 if (result == VK_SUCCESS) {
592 std::unique_lock<std::mutex> lock(global_lock);
593 const auto renderPass = *pRenderPass;
594 auto &renderpass_state = device_data->renderpasses_states[renderPass];
595
596 for (uint32_t subpass = 0; subpass < pCreateInfo->subpassCount; ++subpass) {
597 bool uses_color = false;
598 for (uint32_t i = 0; i < pCreateInfo->pSubpasses[subpass].colorAttachmentCount && !uses_color; ++i)
599 if (pCreateInfo->pSubpasses[subpass].pColorAttachments[i].attachment != VK_ATTACHMENT_UNUSED) uses_color = true;
600
601 bool uses_depthstencil = false;
602 if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment)
603 if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED)
604 uses_depthstencil = true;
605
606 if (uses_color) renderpass_state.subpasses_using_color_attachment.insert(subpass);
607 if (uses_depthstencil) renderpass_state.subpasses_using_depthstencil_attachment.insert(subpass);
608 }
609 }
610 }
611 return result;
612}
613
614VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator) {
615 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
616 bool skip = false;
617
618 {
619 std::unique_lock<std::mutex> lock(global_lock);
620 skip |= parameter_validation_vkDestroyRenderPass(device, renderPass, pAllocator);
621
622 typedef bool (*PFN_manual_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* pAllocator);
623 PFN_manual_vkDestroyRenderPass custom_func = (PFN_manual_vkDestroyRenderPass)custom_functions["vkDestroyRenderPass"];
624 if (custom_func != nullptr) {
625 skip |= custom_func(device, renderPass, pAllocator);
626 }
627 }
628
629 if (!skip) {
630 device_data->dispatch_table.DestroyRenderPass(device, renderPass, pAllocator);
631
632 // track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
633 {
634 std::unique_lock<std::mutex> lock(global_lock);
635 device_data->renderpasses_states.erase(renderPass);
636 }
637 }
638}
639
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600640bool pv_vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
641 VkBuffer *pBuffer) {
642 bool skip = false;
643 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
644 debug_report_data *report_data = device_data->report_data;
645
646 if (pCreateInfo != nullptr) {
647 // Buffer size must be greater than 0 (error 00663)
648 skip |=
Mike Schuchardt52c3ce22017-12-13 09:45:36 -0700649 ValidateGreaterThan(report_data, "vkCreateBuffer", "pCreateInfo->size", pCreateInfo->size, static_cast<VkDeviceSize>(0));
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600650
651 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
652 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
653 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
654 if (pCreateInfo->queueFamilyIndexCount <= 1) {
655 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
656 VALIDATION_ERROR_01400724, LayerName,
657 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
658 "pCreateInfo->queueFamilyIndexCount must be greater than 1. %s",
659 validation_error_map[VALIDATION_ERROR_01400724]);
660 }
661
662 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
663 // queueFamilyIndexCount uint32_t values
664 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
665 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
666 VALIDATION_ERROR_01400722, LayerName,
667 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
668 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
669 "pCreateInfo->queueFamilyIndexCount uint32_t values. %s",
670 validation_error_map[VALIDATION_ERROR_01400722]);
671 } else {
672 // TODO: Not in the spec VUs. Probably missing -- KhronosGroup/Vulkan-Docs#501. Update error codes when resolved.
673 skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices,
674 "vkCreateBuffer", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE, INVALID_USAGE,
675 false, "", "");
676 }
677 }
678
679 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
680 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
681 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
682 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
683 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
684 VALIDATION_ERROR_0140072c, LayerName,
685 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
686 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT. %s",
687 validation_error_map[VALIDATION_ERROR_0140072c]);
688 }
689 }
690
691 return skip;
692}
693
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600694bool pv_vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
695 VkImage *pImage) {
696 bool skip = false;
697 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
698 debug_report_data *report_data = device_data->report_data;
699
700 if (pCreateInfo != nullptr) {
701 if ((device_data->physical_device_features.textureCompressionETC2 == false) &&
702 FormatIsCompressed_ETC2_EAC(pCreateInfo->format)) {
703 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
704 DEVICE_FEATURE, LayerName,
705 "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionETC2 feature is "
706 "not enabled: neither ETC2 nor EAC formats can be used to create images.",
707 string_VkFormat(pCreateInfo->format));
708 }
709
710 if ((device_data->physical_device_features.textureCompressionASTC_LDR == false) &&
711 FormatIsCompressed_ASTC_LDR(pCreateInfo->format)) {
712 skip |=
713 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
714 DEVICE_FEATURE, LayerName,
715 "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionASTC_LDR feature is "
716 "not enabled: ASTC formats cannot be used to create images.",
717 string_VkFormat(pCreateInfo->format));
718 }
719
720 if ((device_data->physical_device_features.textureCompressionBC == false) && FormatIsCompressed_BC(pCreateInfo->format)) {
721 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
722 DEVICE_FEATURE, LayerName,
723 "vkCreateImage(): Attempting to create VkImage with format %s. The textureCompressionBC feature is "
724 "not enabled: BC compressed formats cannot be used to create images.",
725 string_VkFormat(pCreateInfo->format));
726 }
727
728 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
729 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
730 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
731 if (pCreateInfo->queueFamilyIndexCount <= 1) {
732 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
733 VALIDATION_ERROR_09e0075c, LayerName,
734 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
735 "pCreateInfo->queueFamilyIndexCount must be greater than 1. %s",
736 validation_error_map[VALIDATION_ERROR_09e0075c]);
737 }
738
739 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
740 // queueFamilyIndexCount uint32_t values
741 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
742 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
743 VALIDATION_ERROR_09e0075a, LayerName,
744 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
745 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
746 "pCreateInfo->queueFamilyIndexCount uint32_t values. %s",
747 validation_error_map[VALIDATION_ERROR_09e0075a]);
748 } else {
749 // TODO: Not in the spec VUs. Probably missing -- KhronosGroup/Vulkan-Docs#501. Update error codes when resolved.
750 skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices,
751 "vkCreateImage", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE, INVALID_USAGE,
752 false, "", "");
753 }
754 }
755
756 // width, height, and depth members of extent must be greater than 0
757 skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.width", pCreateInfo->extent.width, 0u);
758 skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.height", pCreateInfo->extent.height, 0u);
759 skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->extent.depth", pCreateInfo->extent.depth, 0u);
760
761 // mipLevels must be greater than 0
762 skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->mipLevels", pCreateInfo->mipLevels, 0u);
763
764 // arrayLayers must be greater than 0
765 skip |= ValidateGreaterThan(report_data, "vkCreateImage", "pCreateInfo->arrayLayers", pCreateInfo->arrayLayers, 0u);
766
767 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
768 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && (pCreateInfo->extent.height != 1) && (pCreateInfo->extent.depth != 1)) {
769 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
770 VALIDATION_ERROR_09e00778, LayerName,
771 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both "
772 "pCreateInfo->extent.height and pCreateInfo->extent.depth must be 1. %s",
773 validation_error_map[VALIDATION_ERROR_09e00778]);
774 }
775
776 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
777 // If imageType is VK_IMAGE_TYPE_2D and flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, extent.width and
778 // extent.height must be equal
779 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
780 (pCreateInfo->extent.width != pCreateInfo->extent.height)) {
781 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
782 VALIDATION_ERROR_09e00774, LayerName,
783 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D and "
784 "pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, "
785 "pCreateInfo->extent.width and pCreateInfo->extent.height must be equal. %s",
786 validation_error_map[VALIDATION_ERROR_09e00774]);
787 }
788
789 if (pCreateInfo->extent.depth != 1) {
790 skip |= log_msg(
791 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
792 VALIDATION_ERROR_09e0077a, LayerName,
793 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1. %s",
794 validation_error_map[VALIDATION_ERROR_09e0077a]);
795 }
796 }
797
798 // mipLevels must be less than or equal to floor(log2(max(extent.width,extent.height,extent.depth)))+1
799 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
800 if (pCreateInfo->mipLevels > (floor(log2(maxDim)) + 1)) {
801 skip |=
802 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
803 VALIDATION_ERROR_09e0077c, LayerName,
804 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
805 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1. %s",
806 validation_error_map[VALIDATION_ERROR_09e0077c]);
807 }
808
809 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
810 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
811 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
812 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
813 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
814 VALIDATION_ERROR_09e007b6, LayerName,
815 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
816 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT. %s",
817 validation_error_map[VALIDATION_ERROR_09e007b6]);
818 }
819
820 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
821 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
822 // Linear tiling is unsupported
823 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
824 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
825 INVALID_USAGE, LayerName,
826 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT "
827 "then image tiling of VK_IMAGE_TILING_LINEAR is not supported");
828 }
829
830 // Sparse 1D image isn't valid
831 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
832 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
833 VALIDATION_ERROR_09e00794, LayerName,
834 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image. %s",
835 validation_error_map[VALIDATION_ERROR_09e00794]);
836 }
837
838 // Sparse 2D image when device doesn't support it
839 if ((VK_FALSE == device_data->physical_device_features.sparseResidencyImage2D) &&
840 (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
841 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
842 VALIDATION_ERROR_09e00796, LayerName,
843 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
844 "feature is not enabled on the device. %s",
845 validation_error_map[VALIDATION_ERROR_09e00796]);
846 }
847
848 // Sparse 3D image when device doesn't support it
849 if ((VK_FALSE == device_data->physical_device_features.sparseResidencyImage3D) &&
850 (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
851 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
852 VALIDATION_ERROR_09e00798, LayerName,
853 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
854 "feature is not enabled on the device. %s",
855 validation_error_map[VALIDATION_ERROR_09e00798]);
856 }
857
858 // Multi-sample 2D image when device doesn't support it
859 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
860 if ((VK_FALSE == device_data->physical_device_features.sparseResidency2Samples) &&
861 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
862 skip |= log_msg(
863 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
864 VALIDATION_ERROR_09e0079a, LayerName,
865 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if corresponding "
866 "feature is not enabled on the device. %s",
867 validation_error_map[VALIDATION_ERROR_09e0079a]);
868 } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency4Samples) &&
869 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
870 skip |= log_msg(
871 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
872 VALIDATION_ERROR_09e0079c, LayerName,
873 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if corresponding "
874 "feature is not enabled on the device. %s",
875 validation_error_map[VALIDATION_ERROR_09e0079c]);
876 } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency8Samples) &&
877 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
878 skip |= log_msg(
879 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
880 VALIDATION_ERROR_09e0079e, LayerName,
881 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if corresponding "
882 "feature is not enabled on the device. %s",
883 validation_error_map[VALIDATION_ERROR_09e0079e]);
884 } else if ((VK_FALSE == device_data->physical_device_features.sparseResidency16Samples) &&
885 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
886 skip |= log_msg(
887 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
888 VALIDATION_ERROR_09e007a0, LayerName,
889 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if corresponding "
890 "feature is not enabled on the device. %s",
891 validation_error_map[VALIDATION_ERROR_09e007a0]);
892 }
893 }
894 }
895 }
896 return skip;
897}
898
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600899bool pv_vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
900 VkImageView *pView) {
901 bool skip = false;
902 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
903 debug_report_data *report_data = device_data->report_data;
904
905 if (pCreateInfo != nullptr) {
906 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D) || (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_2D)) {
907 if ((pCreateInfo->subresourceRange.layerCount != 1) &&
908 (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) {
909 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
910 LayerName,
911 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD, "
912 "pCreateInfo->subresourceRange.layerCount must be 1",
913 ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D) ? 1 : 2));
914 }
915 } else if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY) ||
916 (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_2D_ARRAY)) {
917 if ((pCreateInfo->subresourceRange.layerCount < 1) &&
918 (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) {
919 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
920 LayerName,
921 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_%dD_ARRAY, "
922 "pCreateInfo->subresourceRange.layerCount must be >= 1",
923 ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY) ? 1 : 2));
924 }
925 } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE) {
926 if ((pCreateInfo->subresourceRange.layerCount != 6) &&
927 (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) {
928 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
929 LayerName,
930 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE, "
931 "pCreateInfo->subresourceRange.layerCount must be 6");
932 }
933 } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) {
934 if (((pCreateInfo->subresourceRange.layerCount == 0) || ((pCreateInfo->subresourceRange.layerCount % 6) != 0)) &&
935 (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) {
936 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
937 LayerName,
938 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_CUBE_ARRAY, "
939 "pCreateInfo->subresourceRange.layerCount must be a multiple of 6");
940 }
941 if (!device_data->physical_device_features.imageCubeArray) {
942 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
943 LayerName, "vkCreateImageView: Device feature imageCubeArray not enabled.");
944 }
945 } else if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_3D) {
946 if (pCreateInfo->subresourceRange.baseArrayLayer != 0) {
947 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
948 LayerName,
949 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, "
950 "pCreateInfo->subresourceRange.baseArrayLayer must be 0");
951 }
952
953 if ((pCreateInfo->subresourceRange.layerCount != 1) &&
954 (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS)) {
955 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1,
956 LayerName,
957 "vkCreateImageView: if pCreateInfo->viewType is VK_IMAGE_TYPE_3D, "
958 "pCreateInfo->subresourceRange.layerCount must be 1");
959 }
960 }
961 }
962 return skip;
963}
964
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600965bool pv_vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
966 const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator,
967 VkPipeline *pPipelines) {
968 bool skip = false;
969 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
970 debug_report_data *report_data = device_data->report_data;
971
972 if (pCreateInfos != nullptr) {
973 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +0100974 bool has_dynamic_viewport = false;
975 bool has_dynamic_scissor = false;
976 bool has_dynamic_line_width = false;
977 if (pCreateInfos[i].pDynamicState != nullptr) {
978 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
979 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
980 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
981 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) has_dynamic_viewport = true;
982 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) has_dynamic_scissor = true;
983 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) has_dynamic_line_width = true;
984 }
985 }
986
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600987 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
988 if (pCreateInfos[i].pVertexInputState != nullptr) {
989 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
990 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
991 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
992 if (vertex_bind_desc.binding >= device_data->device_limits.maxVertexInputBindings) {
993 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
994 __LINE__, VALIDATION_ERROR_14c004d4, LayerName,
995 "vkCreateGraphicsPipelines: parameter "
996 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
997 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u). %s",
998 i, d, vertex_bind_desc.binding, device_data->device_limits.maxVertexInputBindings,
999 validation_error_map[VALIDATION_ERROR_14c004d4]);
1000 }
1001
1002 if (vertex_bind_desc.stride > device_data->device_limits.maxVertexInputBindingStride) {
1003 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1004 __LINE__, VALIDATION_ERROR_14c004d6, LayerName,
1005 "vkCreateGraphicsPipelines: parameter "
1006 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1007 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u). %s",
1008 i, d, vertex_bind_desc.stride, device_data->device_limits.maxVertexInputBindingStride,
1009 validation_error_map[VALIDATION_ERROR_14c004d6]);
1010 }
1011 }
1012
1013 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1014 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
1015 if (vertex_attrib_desc.location >= device_data->device_limits.maxVertexInputAttributes) {
1016 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1017 __LINE__, VALIDATION_ERROR_14a004d8, LayerName,
1018 "vkCreateGraphicsPipelines: parameter "
1019 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1020 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u). %s",
1021 i, d, vertex_attrib_desc.location, device_data->device_limits.maxVertexInputAttributes,
1022 validation_error_map[VALIDATION_ERROR_14a004d8]);
1023 }
1024
1025 if (vertex_attrib_desc.binding >= device_data->device_limits.maxVertexInputBindings) {
1026 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1027 __LINE__, VALIDATION_ERROR_14a004da, LayerName,
1028 "vkCreateGraphicsPipelines: parameter "
1029 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1030 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u). %s",
1031 i, d, vertex_attrib_desc.binding, device_data->device_limits.maxVertexInputBindings,
1032 validation_error_map[VALIDATION_ERROR_14a004da]);
1033 }
1034
1035 if (vertex_attrib_desc.offset > device_data->device_limits.maxVertexInputAttributeOffset) {
1036 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1037 __LINE__, VALIDATION_ERROR_14a004dc, LayerName,
1038 "vkCreateGraphicsPipelines: parameter "
1039 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1040 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u). %s",
1041 i, d, vertex_attrib_desc.offset, device_data->device_limits.maxVertexInputAttributeOffset,
1042 validation_error_map[VALIDATION_ERROR_14a004dc]);
1043 }
1044 }
1045 }
1046
1047 if (pCreateInfos[i].pStages != nullptr) {
1048 bool has_control = false;
1049 bool has_eval = false;
1050
1051 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1052 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1053 has_control = true;
1054 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1055 has_eval = true;
1056 }
1057 }
1058
1059 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1060 if (has_control && has_eval) {
1061 if (pCreateInfos[i].pTessellationState == nullptr) {
1062 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1063 __LINE__, VALIDATION_ERROR_096005b6, LayerName,
1064 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1065 "shader stage and a tessellation evaluation shader stage, "
1066 "pCreateInfos[%d].pTessellationState must not be NULL. %s",
1067 i, i, validation_error_map[VALIDATION_ERROR_096005b6]);
1068 } else {
1069 skip |= validate_struct_pnext(
1070 report_data, "vkCreateGraphicsPipelines",
1071 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), NULL,
1072 pCreateInfos[i].pTessellationState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0961c40d);
1073
1074 skip |= validate_reserved_flags(
1075 report_data, "vkCreateGraphicsPipelines",
1076 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1077 pCreateInfos[i].pTessellationState->flags, VALIDATION_ERROR_10809005);
1078
1079 if (pCreateInfos[i].pTessellationState->sType !=
1080 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO) {
1081 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1082 __LINE__, VALIDATION_ERROR_1082b00b, LayerName,
1083 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pTessellationState->sType must "
1084 "be VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO. %s",
1085 i, validation_error_map[VALIDATION_ERROR_1082b00b]);
1086 }
1087
1088 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1089 pCreateInfos[i].pTessellationState->patchControlPoints >
1090 device_data->device_limits.maxTessellationPatchSize) {
1091 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1092 __LINE__, VALIDATION_ERROR_1080097c, LayerName,
1093 "vkCreateGraphicsPipelines: invalid parameter "
1094 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1095 "should be >0 and <=%u. %s",
1096 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1097 device_data->device_limits.maxTessellationPatchSize,
1098 validation_error_map[VALIDATION_ERROR_1080097c]);
1099 }
1100 }
1101 }
1102 }
1103
1104 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1105 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1106 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1107 if (pCreateInfos[i].pViewportState == nullptr) {
Petr Krausa6103552017-11-16 21:21:58 +01001108 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1109 VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_096005dc, LayerName,
1110 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1111 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1112 "].pViewportState (=NULL) is not a valid pointer. %s",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001113 i, i, validation_error_map[VALIDATION_ERROR_096005dc]);
1114 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001115 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1116
1117 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
1118 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1119 VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c2b00b, LayerName,
1120 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1121 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO. %s",
1122 i, validation_error_map[VALIDATION_ERROR_10c2b00b]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001123 }
1124
Petr Krausa6103552017-11-16 21:21:58 +01001125 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1126 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
1127 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV};
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001128 skip |= validate_struct_pnext(
1129 report_data, "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001130 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
1131 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV",
1132 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
1133 allowed_structs_VkPipelineViewportStateCreateInfo, 65, VALIDATION_ERROR_10c1c40d);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001134
1135 skip |= validate_reserved_flags(
1136 report_data, "vkCreateGraphicsPipelines",
1137 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Petr Krausa6103552017-11-16 21:21:58 +01001138 viewport_state.flags, VALIDATION_ERROR_10c09005);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001139
Petr Krausa6103552017-11-16 21:21:58 +01001140 if (!device_data->physical_device_features.multiViewport) {
1141 if (viewport_state.viewportCount != 1) {
1142 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1143 VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c00980, LayerName,
1144 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1145 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1146 ") is not 1. %s",
1147 i, viewport_state.viewportCount, validation_error_map[VALIDATION_ERROR_10c00980]);
1148 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001149
Petr Krausa6103552017-11-16 21:21:58 +01001150 if (viewport_state.scissorCount != 1) {
1151 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1152 VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c00982, LayerName,
1153 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1154 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1155 ") is not 1. %s",
1156 i, viewport_state.scissorCount, validation_error_map[VALIDATION_ERROR_10c00982]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001157 }
Petr Krausa6103552017-11-16 21:21:58 +01001158 } else { // multiViewport enabled
1159 if (viewport_state.viewportCount == 0) {
1160 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1161 VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c30a1b, LayerName,
Petr Krausf62dd8f2017-11-23 15:47:38 +01001162 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
Petr Krausa6103552017-11-16 21:21:58 +01001163 "].pViewportState->viewportCount is 0. %s",
1164 i, validation_error_map[VALIDATION_ERROR_10c30a1b]);
1165 } else if (viewport_state.viewportCount > device_data->device_limits.maxViewports) {
1166 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1167 VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c00984, LayerName,
1168 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1169 "].pViewportState->viewportCount (=%" PRIu32
1170 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "). %s",
1171 i, viewport_state.viewportCount, device_data->device_limits.maxViewports,
1172 validation_error_map[VALIDATION_ERROR_10c00984]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001173 }
Petr Krausa6103552017-11-16 21:21:58 +01001174
1175 if (viewport_state.scissorCount == 0) {
1176 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1177 VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c2b61b, LayerName,
Petr Krausf62dd8f2017-11-23 15:47:38 +01001178 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
Petr Krausa6103552017-11-16 21:21:58 +01001179 "].pViewportState->scissorCount is 0. %s",
1180 i, validation_error_map[VALIDATION_ERROR_10c2b61b]);
1181 } else if (viewport_state.scissorCount > device_data->device_limits.maxViewports) {
1182 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1183 VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c00986, LayerName,
1184 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1185 "].pViewportState->scissorCount (=%" PRIu32
1186 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "). %s",
1187 i, viewport_state.scissorCount, device_data->device_limits.maxViewports,
1188 validation_error_map[VALIDATION_ERROR_10c00986]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001189 }
1190 }
1191
Petr Krausa6103552017-11-16 21:21:58 +01001192 if (viewport_state.scissorCount != viewport_state.viewportCount) {
1193 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1194 VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_10c00988, LayerName,
1195 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1196 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1197 "].pViewportState->viewportCount (=%" PRIu32 "). %s",
1198 i, viewport_state.scissorCount, i, viewport_state.viewportCount,
1199 validation_error_map[VALIDATION_ERROR_10c00988]);
1200 }
1201
Petr Krausa6103552017-11-16 21:21:58 +01001202 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
1203 skip |= log_msg(
1204 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE,
1205 __LINE__, VALIDATION_ERROR_096005d6, LayerName,
1206 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1207 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Petr Krausf62dd8f2017-11-23 15:47:38 +01001208 "].pViewportState->pViewports (=NULL) is an invalid pointer. %s",
Petr Krausa6103552017-11-16 21:21:58 +01001209 i, i, validation_error_map[VALIDATION_ERROR_096005d6]);
1210 }
1211
1212 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
1213 skip |= log_msg(
1214 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE,
1215 __LINE__, VALIDATION_ERROR_096005d8, LayerName,
1216 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1217 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Petr Krausf62dd8f2017-11-23 15:47:38 +01001218 "].pViewportState->pScissors (=NULL) is an invalid pointer. %s",
Petr Krausa6103552017-11-16 21:21:58 +01001219 i, i, validation_error_map[VALIDATION_ERROR_096005d8]);
1220 }
1221
1222 // TODO: validate the VkViewports in pViewports here
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001223 }
1224
1225 if (pCreateInfos[i].pMultisampleState == nullptr) {
1226 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1227 __LINE__, VALIDATION_ERROR_096005de, LayerName,
1228 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1229 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL. %s",
1230 i, i, validation_error_map[VALIDATION_ERROR_096005de]);
1231 } else {
Mike Schuchardt97662b02017-12-06 13:31:29 -07001232 const VkStructureType valid_next_stypes[] = {
John Zulauf96b0e422017-11-14 11:43:19 -07001233 LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1234 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1235 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001236 const char *valid_struct_names =
John Zulauf96b0e422017-11-14 11:43:19 -07001237 "VkPipelineCoverageModulationStateCreateInfoNV, "
1238 "VkPipelineCoverageToColorStateCreateInfoNV, "
1239 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001240 skip |= validate_struct_pnext(
1241 report_data, "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001242 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
1243 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes, GeneratedHeaderVersion,
1244 VALIDATION_ERROR_1001c40d);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001245
1246 skip |= validate_reserved_flags(
1247 report_data, "vkCreateGraphicsPipelines",
1248 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
1249 pCreateInfos[i].pMultisampleState->flags, VALIDATION_ERROR_10009005);
1250
1251 skip |= validate_bool32(
1252 report_data, "vkCreateGraphicsPipelines",
1253 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1254 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1255
1256 skip |= validate_array(
1257 report_data, "vkCreateGraphicsPipelines",
1258 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1259 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
1260 pCreateInfos[i].pMultisampleState->rasterizationSamples, pCreateInfos[i].pMultisampleState->pSampleMask,
1261 true, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
1262
1263 skip |= validate_bool32(
1264 report_data, "vkCreateGraphicsPipelines",
1265 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1266 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1267
1268 skip |= validate_bool32(
1269 report_data, "vkCreateGraphicsPipelines",
1270 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1271 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1272
1273 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
1274 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1275 __LINE__, INVALID_STRUCT_STYPE, LayerName,
1276 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1277 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1278 i);
1279 }
John Zulauf7acac592017-11-06 11:15:53 -07001280 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
1281 if (!device_data->physical_device_features.sampleRateShading) {
1282 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1283 __LINE__, VALIDATION_ERROR_10000620, LayerName,
1284 "vkCreateGraphicsPipelines(): parameter "
1285 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable: %s",
1286 i, validation_error_map[VALIDATION_ERROR_10000620]);
1287 }
1288 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1289 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1290 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
1291 skip |= log_msg(
1292 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1293 VALIDATION_ERROR_10000624, LayerName,
1294 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading: %s",
1295 i, validation_error_map[VALIDATION_ERROR_10000624]);
1296 }
1297 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001298 }
1299
Petr Krause91f7a12017-12-14 20:57:36 +01001300 bool uses_color_attachment = false;
1301 bool uses_depthstencil_attachment = false;
1302 {
1303 const auto subpasses_uses_it = device_data->renderpasses_states.find(pCreateInfos[i].renderPass);
1304 if (subpasses_uses_it != device_data->renderpasses_states.end()) {
1305 const auto &subpasses_uses = subpasses_uses_it->second;
1306 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
1307 uses_color_attachment = true;
1308 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
1309 uses_depthstencil_attachment = true;
1310 }
1311 }
1312
1313 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001314 skip |= validate_struct_pnext(
1315 report_data, "vkCreateGraphicsPipelines",
1316 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
1317 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0f61c40d);
1318
1319 skip |= validate_reserved_flags(
1320 report_data, "vkCreateGraphicsPipelines",
1321 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
1322 pCreateInfos[i].pDepthStencilState->flags, VALIDATION_ERROR_0f609005);
1323
1324 skip |= validate_bool32(
1325 report_data, "vkCreateGraphicsPipelines",
1326 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
1327 pCreateInfos[i].pDepthStencilState->depthTestEnable);
1328
1329 skip |= validate_bool32(
1330 report_data, "vkCreateGraphicsPipelines",
1331 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
1332 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
1333
1334 skip |= validate_ranged_enum(
1335 report_data, "vkCreateGraphicsPipelines",
1336 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
1337 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
1338 VALIDATION_ERROR_0f604001);
1339
1340 skip |= validate_bool32(
1341 report_data, "vkCreateGraphicsPipelines",
1342 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
1343 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
1344
1345 skip |= validate_bool32(
1346 report_data, "vkCreateGraphicsPipelines",
1347 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
1348 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
1349
1350 skip |= validate_ranged_enum(
1351 report_data, "vkCreateGraphicsPipelines",
1352 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
1353 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
1354 VALIDATION_ERROR_13a08601);
1355
1356 skip |= validate_ranged_enum(
1357 report_data, "vkCreateGraphicsPipelines",
1358 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
1359 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
1360 VALIDATION_ERROR_13a27801);
1361
1362 skip |= validate_ranged_enum(
1363 report_data, "vkCreateGraphicsPipelines",
1364 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
1365 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
1366 VALIDATION_ERROR_13a04201);
1367
1368 skip |= validate_ranged_enum(
1369 report_data, "vkCreateGraphicsPipelines",
1370 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
1371 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
1372 VALIDATION_ERROR_0f604001);
1373
1374 skip |= validate_ranged_enum(
1375 report_data, "vkCreateGraphicsPipelines",
1376 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
1377 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
1378 VALIDATION_ERROR_13a08601);
1379
1380 skip |= validate_ranged_enum(
1381 report_data, "vkCreateGraphicsPipelines",
1382 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
1383 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
1384 VALIDATION_ERROR_13a27801);
1385
1386 skip |= validate_ranged_enum(
1387 report_data, "vkCreateGraphicsPipelines",
1388 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
1389 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
1390 VALIDATION_ERROR_13a04201);
1391
1392 skip |= validate_ranged_enum(
1393 report_data, "vkCreateGraphicsPipelines",
1394 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
1395 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
1396 VALIDATION_ERROR_0f604001);
1397
1398 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
1399 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1400 __LINE__, INVALID_STRUCT_STYPE, LayerName,
1401 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
1402 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
1403 i);
1404 }
1405 }
1406
Petr Krause91f7a12017-12-14 20:57:36 +01001407 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001408 skip |= validate_struct_pnext(
1409 report_data, "vkCreateGraphicsPipelines",
1410 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), NULL,
1411 pCreateInfos[i].pColorBlendState->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0f41c40d);
1412
1413 skip |= validate_reserved_flags(
1414 report_data, "vkCreateGraphicsPipelines",
1415 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
1416 pCreateInfos[i].pColorBlendState->flags, VALIDATION_ERROR_0f409005);
1417
1418 skip |= validate_bool32(
1419 report_data, "vkCreateGraphicsPipelines",
1420 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
1421 pCreateInfos[i].pColorBlendState->logicOpEnable);
1422
1423 skip |= validate_array(
1424 report_data, "vkCreateGraphicsPipelines",
1425 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
1426 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
1427 pCreateInfos[i].pColorBlendState->attachmentCount, pCreateInfos[i].pColorBlendState->pAttachments, false,
1428 true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
1429
1430 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
1431 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
1432 ++attachmentIndex) {
1433 skip |= validate_bool32(report_data, "vkCreateGraphicsPipelines",
1434 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
1435 ParameterName::IndexVector{i, attachmentIndex}),
1436 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
1437
1438 skip |= validate_ranged_enum(
1439 report_data, "vkCreateGraphicsPipelines",
1440 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
1441 ParameterName::IndexVector{i, attachmentIndex}),
1442 "VkBlendFactor", AllVkBlendFactorEnums,
1443 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
1444 VALIDATION_ERROR_0f22cc01);
1445
1446 skip |= validate_ranged_enum(
1447 report_data, "vkCreateGraphicsPipelines",
1448 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
1449 ParameterName::IndexVector{i, attachmentIndex}),
1450 "VkBlendFactor", AllVkBlendFactorEnums,
1451 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
1452 VALIDATION_ERROR_0f207001);
1453
1454 skip |= validate_ranged_enum(
1455 report_data, "vkCreateGraphicsPipelines",
1456 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
1457 ParameterName::IndexVector{i, attachmentIndex}),
1458 "VkBlendOp", AllVkBlendOpEnums,
1459 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
1460 VALIDATION_ERROR_0f202001);
1461
1462 skip |= validate_ranged_enum(
1463 report_data, "vkCreateGraphicsPipelines",
1464 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
1465 ParameterName::IndexVector{i, attachmentIndex}),
1466 "VkBlendFactor", AllVkBlendFactorEnums,
1467 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
1468 VALIDATION_ERROR_0f22c601);
1469
1470 skip |= validate_ranged_enum(
1471 report_data, "vkCreateGraphicsPipelines",
1472 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
1473 ParameterName::IndexVector{i, attachmentIndex}),
1474 "VkBlendFactor", AllVkBlendFactorEnums,
1475 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
1476 VALIDATION_ERROR_0f206a01);
1477
1478 skip |= validate_ranged_enum(
1479 report_data, "vkCreateGraphicsPipelines",
1480 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
1481 ParameterName::IndexVector{i, attachmentIndex}),
1482 "VkBlendOp", AllVkBlendOpEnums,
1483 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
1484 VALIDATION_ERROR_0f200801);
1485
1486 skip |=
1487 validate_flags(report_data, "vkCreateGraphicsPipelines",
1488 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
1489 ParameterName::IndexVector{i, attachmentIndex}),
1490 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
1491 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
1492 false, false, VALIDATION_ERROR_0f202201);
1493 }
1494 }
1495
1496 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
1497 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1498 __LINE__, INVALID_STRUCT_STYPE, LayerName,
1499 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
1500 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
1501 i);
1502 }
1503
1504 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
1505 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
1506 skip |= validate_ranged_enum(
1507 report_data, "vkCreateGraphicsPipelines",
1508 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
1509 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp, VALIDATION_ERROR_0f4004be);
1510 }
1511 }
1512 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001513
Petr Kraus9752aae2017-11-24 03:05:50 +01001514 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
1515 if (pCreateInfos[i].basePipelineIndex != -1) {
1516 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001517 skip |= log_msg(
1518 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1519 VALIDATION_ERROR_096005a8, LayerName,
1520 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be VK_NULL_HANDLE if "
1521 "pCreateInfos->flags "
1522 "contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1. %s",
1523 validation_error_map[VALIDATION_ERROR_096005a8]);
1524 }
1525 }
1526
Petr Kraus9752aae2017-11-24 03:05:50 +01001527 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
1528 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001529 skip |= log_msg(
1530 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1531 VALIDATION_ERROR_096005aa, LayerName,
1532 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
1533 "pCreateInfos->flags "
1534 "contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineHandle is not "
1535 "VK_NULL_HANDLE. %s",
1536 validation_error_map[VALIDATION_ERROR_096005aa]);
1537 }
1538 }
1539 }
1540
Petr Kraus9752aae2017-11-24 03:05:50 +01001541 if (pCreateInfos[i].pRasterizationState) {
1542 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001543 (device_data->physical_device_features.fillModeNonSolid == false)) {
1544 skip |= log_msg(
1545 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1546 DEVICE_FEATURE, LayerName,
1547 "vkCreateGraphicsPipelines parameter, VkPolygonMode pCreateInfos->pRasterizationState->polygonMode cannot "
1548 "be "
1549 "VK_POLYGON_MODE_POINT or VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
1550 }
Petr Kraus299ba622017-11-24 03:09:03 +01001551
1552 if (!has_dynamic_line_width && !device_data->physical_device_features.wideLines &&
1553 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
1554 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
1555 VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, 0, __LINE__, VALIDATION_ERROR_096005da, LayerName,
1556 "The line width state is static (pCreateInfos[%" PRIu32
1557 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
1558 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
1559 "].pRasterizationState->lineWidth (=%f) is not 1.0. %s",
1560 i, i, pCreateInfos[i].pRasterizationState->lineWidth,
1561 validation_error_map[VALIDATION_ERROR_096005da]);
1562 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001563 }
1564
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001565 for (size_t j = 0; j < pCreateInfos[i].stageCount; j++) {
1566 skip |= validate_string(device_data->report_data, "vkCreateGraphicsPipelines",
1567 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, j}),
1568 pCreateInfos[i].pStages[j].pName);
1569 }
1570 }
1571 }
1572
1573 return skip;
1574}
1575
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001576bool pv_vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
1577 const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator,
1578 VkPipeline *pPipelines) {
1579 bool skip = false;
1580 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1581
1582 for (uint32_t i = 0; i < createInfoCount; i++) {
1583 skip |= validate_string(device_data->report_data, "vkCreateComputePipelines",
1584 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
1585 pCreateInfos[i].stage.pName);
1586 }
1587
1588 return skip;
1589}
1590
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001591bool pv_vkCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
1592 VkSampler *pSampler) {
1593 bool skip = false;
1594 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1595 debug_report_data *report_data = device_data->report_data;
1596
1597 if (pCreateInfo != nullptr) {
John Zulauf71968502017-10-26 13:51:15 -06001598 const auto &features = device_data->physical_device_features;
1599 const auto &limits = device_data->device_limits;
1600 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
1601 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
1602 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1603 VALIDATION_ERROR_1260085e, LayerName,
1604 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found. %s",
1605 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
1606 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy,
1607 validation_error_map[VALIDATION_ERROR_1260085e]);
1608 }
1609
1610 // Anistropy cannot be enabled in sampler unless enabled as a feature
1611 if (features.samplerAnisotropy == VK_FALSE) {
1612 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1613 VALIDATION_ERROR_1260085c, LayerName,
1614 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE. %s",
1615 "pCreateInfo->anisotropyEnable", validation_error_map[VALIDATION_ERROR_1260085c]);
1616 }
1617
1618 // Anistropy and unnormalized coordinates cannot be enabled simultaneously
1619 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
1620 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1621 VALIDATION_ERROR_12600868, LayerName,
1622 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates "
1623 "must not both be VK_TRUE. %s",
1624 validation_error_map[VALIDATION_ERROR_12600868]);
1625 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001626 }
1627
1628 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
1629 if (pCreateInfo->compareEnable == VK_TRUE) {
1630 skip |= validate_ranged_enum(report_data, "vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp",
1631 AllVkCompareOpEnums, pCreateInfo->compareOp, VALIDATION_ERROR_12600870);
1632 }
1633
1634 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
1635 // valid VkBorderColor value
1636 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
1637 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
1638 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
1639 skip |= validate_ranged_enum(report_data, "vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor",
1640 AllVkBorderColorEnums, pCreateInfo->borderColor, VALIDATION_ERROR_1260086c);
1641 }
1642
1643 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
1644 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
1645 if (!device_data->extensions.vk_khr_sampler_mirror_clamp_to_edge &&
1646 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
1647 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
1648 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
1649 skip |=
1650 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1651 VALIDATION_ERROR_1260086e, LayerName,
1652 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
1653 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled. %s",
1654 validation_error_map[VALIDATION_ERROR_1260086e]);
1655 }
John Zulauf275805c2017-10-26 15:34:49 -06001656
1657 // Checks for the IMG cubic filtering extension
1658 if (device_data->extensions.vk_img_filter_cubic) {
1659 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
1660 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
1661 skip |=
1662 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1663 VALIDATION_ERROR_12600872, LayerName,
1664 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter are "
1665 "VK_FILTER_CUBIC_IMG. %s",
1666 validation_error_map[VALIDATION_ERROR_12600872]);
1667 }
1668 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001669 }
1670
1671 return skip;
1672}
1673
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001674bool pv_vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
1675 const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout) {
1676 bool skip = false;
1677 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1678 debug_report_data *report_data = device_data->report_data;
1679
1680 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
1681 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
1682 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
1683 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
1684 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount
1685 // is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a pointer to an array of descriptorCount
1686 // valid VkSampler handles
1687 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
1688 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
1689 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
1690 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
1691 ++descriptor_index) {
1692 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
1693 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1694 __LINE__, REQUIRED_PARAMETER, LayerName,
1695 "vkCreateDescriptorSetLayout: required parameter "
1696 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d]"
1697 " specified as VK_NULL_HANDLE",
1698 i, descriptor_index);
1699 }
1700 }
1701 }
1702
1703 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
1704 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
1705 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
1706 skip |= log_msg(
1707 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1708 VALIDATION_ERROR_04e00236, LayerName,
1709 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
1710 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits values. %s",
1711 i, i, validation_error_map[VALIDATION_ERROR_04e00236]);
1712 }
1713 }
1714 }
1715 }
1716
1717 return skip;
1718}
1719
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001720bool pv_vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
1721 const VkDescriptorSet *pDescriptorSets) {
1722 bool skip = false;
1723 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1724 debug_report_data *report_data = device_data->report_data;
1725
1726 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
1727 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
1728 // validate_array()
1729 skip |= validate_array(report_data, "vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount,
1730 pDescriptorSets, true, true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
1731 return skip;
1732}
1733
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001734bool pv_vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites,
1735 uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies) {
1736 bool skip = false;
1737 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1738 debug_report_data *report_data = device_data->report_data;
1739
1740 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
1741 if (pDescriptorWrites != NULL) {
1742 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
1743 // descriptorCount must be greater than 0
1744 if (pDescriptorWrites[i].descriptorCount == 0) {
1745 skip |=
1746 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
1747 VALIDATION_ERROR_15c0441b, LayerName,
1748 "vkUpdateDescriptorSets(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0. %s",
1749 i, validation_error_map[VALIDATION_ERROR_15c0441b]);
1750 }
1751
1752 // dstSet must be a valid VkDescriptorSet handle
1753 skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets",
1754 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
1755 pDescriptorWrites[i].dstSet);
1756
1757 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
1758 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
1759 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
1760 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
1761 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
1762 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
1763 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
1764 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
1765 if (pDescriptorWrites[i].pImageInfo == nullptr) {
1766 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1767 __LINE__, VALIDATION_ERROR_15c00284, LayerName,
1768 "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is "
1769 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
1770 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
1771 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL. %s",
1772 i, i, validation_error_map[VALIDATION_ERROR_15c00284]);
1773 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
1774 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
1775 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
1776 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
1777 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
1778 ++descriptor_index) {
1779 skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets",
1780 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
1781 ParameterName::IndexVector{i, descriptor_index}),
1782 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
1783 skip |= validate_ranged_enum(report_data, "vkUpdateDescriptorSets",
1784 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
1785 ParameterName::IndexVector{i, descriptor_index}),
1786 "VkImageLayout", AllVkImageLayoutEnums,
1787 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout,
1788 VALIDATION_ERROR_UNDEFINED);
1789 }
1790 }
1791 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
1792 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
1793 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
1794 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
1795 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1796 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
1797 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
1798 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
1799 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1800 __LINE__, VALIDATION_ERROR_15c00288, LayerName,
1801 "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is "
1802 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
1803 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
1804 "pDescriptorWrites[%d].pBufferInfo must not be NULL. %s",
1805 i, i, validation_error_map[VALIDATION_ERROR_15c00288]);
1806 } else {
1807 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
1808 skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets",
1809 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
1810 ParameterName::IndexVector{i, descriptorIndex}),
1811 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
1812 }
1813 }
1814 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
1815 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
1816 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
1817 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
1818 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
1819 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1820 __LINE__, VALIDATION_ERROR_15c00286, LayerName,
1821 "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is "
1822 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
1823 "pDescriptorWrites[%d].pTexelBufferView must not be NULL. %s",
1824 i, i, validation_error_map[VALIDATION_ERROR_15c00286]);
1825 } else {
1826 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
1827 ++descriptor_index) {
1828 skip |= validate_required_handle(report_data, "vkUpdateDescriptorSets",
1829 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
1830 ParameterName::IndexVector{i, descriptor_index}),
1831 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
1832 }
1833 }
1834 }
1835
1836 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
1837 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
1838 VkDeviceSize uniformAlignment = device_data->device_limits.minUniformBufferOffsetAlignment;
1839 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
1840 if (pDescriptorWrites[i].pBufferInfo != NULL) {
1841 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
1842 skip |= log_msg(
1843 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
1844 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_15c0028e, LayerName,
1845 "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
1846 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ". %s",
1847 i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment,
1848 validation_error_map[VALIDATION_ERROR_15c0028e]);
1849 }
1850 }
1851 }
1852 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
1853 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
1854 VkDeviceSize storageAlignment = device_data->device_limits.minStorageBufferOffsetAlignment;
1855 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
1856 if (pDescriptorWrites[i].pBufferInfo != NULL) {
1857 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
1858 skip |= log_msg(
1859 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
1860 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, VALIDATION_ERROR_15c00290, LayerName,
1861 "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
1862 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ". %s",
1863 i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment,
1864 validation_error_map[VALIDATION_ERROR_15c00290]);
1865 }
1866 }
1867 }
1868 }
1869 }
1870 }
1871 return skip;
1872}
1873
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001874bool pv_vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
1875 VkRenderPass *pRenderPass) {
1876 bool skip = false;
1877 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1878 uint32_t max_color_attachments = device_data->device_limits.maxColorAttachments;
1879
1880 for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) {
1881 if (pCreateInfo->pAttachments[i].format == VK_FORMAT_UNDEFINED) {
1882 std::stringstream ss;
1883 ss << "vkCreateRenderPass: pCreateInfo->pAttachments[" << i << "].format is VK_FORMAT_UNDEFINED. "
1884 << validation_error_map[VALIDATION_ERROR_00809201];
1885 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1886 __LINE__, VALIDATION_ERROR_00809201, "IMAGE", "%s", ss.str().c_str());
1887 }
1888 if (pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_UNDEFINED ||
1889 pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_PREINITIALIZED) {
1890 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1891 __LINE__, VALIDATION_ERROR_00800696, "DL",
1892 "pCreateInfo->pAttachments[%d].finalLayout must not be VK_IMAGE_LAYOUT_UNDEFINED or "
1893 "VK_IMAGE_LAYOUT_PREINITIALIZED. %s",
1894 i, validation_error_map[VALIDATION_ERROR_00800696]);
1895 }
1896 }
1897
1898 for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) {
1899 if (pCreateInfo->pSubpasses[i].colorAttachmentCount > max_color_attachments) {
1900 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1901 __LINE__, VALIDATION_ERROR_1400069a, "DL",
1902 "Cannot create a render pass with %d color attachments. Max is %d. %s",
1903 pCreateInfo->pSubpasses[i].colorAttachmentCount, max_color_attachments,
1904 validation_error_map[VALIDATION_ERROR_1400069a]);
1905 }
1906 }
1907 return skip;
1908}
1909
1910bool pv_vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
1911 const VkCommandBuffer *pCommandBuffers) {
1912 bool skip = false;
1913 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1914 debug_report_data *report_data = device_data->report_data;
1915
1916 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
1917 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
1918 // validate_array()
1919 skip |= validate_array(report_data, "vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount,
1920 pCommandBuffers, true, true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
1921 return skip;
1922}
1923
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001924bool pv_vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo) {
1925 bool skip = false;
1926 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
1927 debug_report_data *report_data = device_data->report_data;
1928 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
1929
1930 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
1931 // TODO: pBeginInfo->pInheritanceInfo must not be NULL if commandBuffer is a secondary command buffer
1932 skip |= validate_struct_type(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo",
1933 "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO", pBeginInfo->pInheritanceInfo,
1934 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, false, VALIDATION_ERROR_UNDEFINED);
1935
1936 if (pBeginInfo->pInheritanceInfo != NULL) {
1937 skip |=
1938 validate_struct_pnext(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->pNext", NULL,
1939 pBeginInfo->pInheritanceInfo->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_0281c40d);
1940
1941 skip |= validate_bool32(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->occlusionQueryEnable",
1942 pBeginInfo->pInheritanceInfo->occlusionQueryEnable);
1943
1944 // TODO: This only needs to be validated when the inherited queries feature is enabled
1945 // skip |= validate_flags(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->queryFlags",
1946 // "VkQueryControlFlagBits", AllVkQueryControlFlagBits, pBeginInfo->pInheritanceInfo->queryFlags, false);
1947
1948 // TODO: This must be 0 if the pipeline statistics queries feature is not enabled
1949 skip |= validate_flags(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->pipelineStatistics",
1950 "VkQueryPipelineStatisticFlagBits", AllVkQueryPipelineStatisticFlagBits,
1951 pBeginInfo->pInheritanceInfo->pipelineStatistics, false, false, VALIDATION_ERROR_UNDEFINED);
1952 }
1953
1954 if (pInfo != NULL) {
1955 if ((device_data->physical_device_features.inheritedQueries == VK_FALSE) && (pInfo->occlusionQueryEnable != VK_FALSE)) {
1956 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
1957 HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_02a00070, LayerName,
1958 "Cannot set inherited occlusionQueryEnable in vkBeginCommandBuffer() when device does not support "
1959 "inheritedQueries. %s",
1960 validation_error_map[VALIDATION_ERROR_02a00070]);
1961 }
1962 if ((device_data->physical_device_features.inheritedQueries != VK_FALSE) && (pInfo->occlusionQueryEnable != VK_FALSE)) {
1963 skip |= validate_flags(device_data->report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->queryFlags",
1964 "VkQueryControlFlagBits", AllVkQueryControlFlagBits, pInfo->queryFlags, false, false,
1965 VALIDATION_ERROR_02a00072);
1966 }
1967 }
1968
1969 return skip;
1970}
1971
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001972bool pv_vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
1973 const VkViewport *pViewports) {
1974 bool skip = false;
1975 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
1976
1977 skip |= validate_array(device_data->report_data, "vkCmdSetViewport", "viewportCount", "pViewports", viewportCount, pViewports,
1978 true, true, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
1979
1980 if (viewportCount > 0 && pViewports != nullptr) {
1981 const VkPhysicalDeviceLimits &limits = device_data->device_limits;
1982 for (uint32_t viewportIndex = 0; viewportIndex < viewportCount; ++viewportIndex) {
1983 const VkViewport &viewport = pViewports[viewportIndex];
1984
1985 if (device_data->physical_device_features.multiViewport == false) {
1986 if (viewportCount != 1) {
1987 skip |= log_msg(
1988 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1989 __LINE__, DEVICE_FEATURE, LayerName,
1990 "vkCmdSetViewport(): The multiViewport feature is not enabled, so viewportCount must be 1 but is %d.",
1991 viewportCount);
1992 }
1993 if (firstViewport != 0) {
1994 skip |= log_msg(
1995 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1996 __LINE__, DEVICE_FEATURE, LayerName,
1997 "vkCmdSetViewport(): The multiViewport feature is not enabled, so firstViewport must be 0 but is %d.",
1998 firstViewport);
1999 }
2000 }
2001
2002 if (viewport.width <= 0 || viewport.width > limits.maxViewportDimensions[0]) {
2003 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2004 __LINE__, VALIDATION_ERROR_15000996, LayerName,
2005 "vkCmdSetViewport %d: width (%f) exceeds permitted bounds (0,%u). %s", viewportIndex,
2006 viewport.width, limits.maxViewportDimensions[0], validation_error_map[VALIDATION_ERROR_15000996]);
2007 }
2008
2009 if (device_data->extensions.vk_amd_negative_viewport_height || device_data->extensions.vk_khr_maintenance1) {
2010 // Check lower bound against negative viewport height instead of zero
2011 if (viewport.height <= -(static_cast<int32_t>(limits.maxViewportDimensions[1])) ||
2012 (viewport.height > limits.maxViewportDimensions[1])) {
2013 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
2014 VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, VALIDATION_ERROR_1500099a, LayerName,
2015 "vkCmdSetViewport %d: height (%f) exceeds permitted bounds (-%u,%u). %s", viewportIndex,
2016 viewport.height, limits.maxViewportDimensions[1], limits.maxViewportDimensions[1],
2017 validation_error_map[VALIDATION_ERROR_1500099a]);
2018 }
2019 } else {
2020 if ((viewport.height <= 0) || (viewport.height > limits.maxViewportDimensions[1])) {
2021 skip |=
2022 log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2023 __LINE__, VALIDATION_ERROR_15000998, LayerName,
2024 "vkCmdSetViewport %d: height (%f) exceeds permitted bounds (0,%u). %s", viewportIndex,
2025 viewport.height, limits.maxViewportDimensions[1], validation_error_map[VALIDATION_ERROR_15000998]);
2026 }
2027 }
2028
2029 if (viewport.x < limits.viewportBoundsRange[0] || viewport.x > limits.viewportBoundsRange[1]) {
2030 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2031 __LINE__, VALIDATION_ERROR_1500099e, LayerName,
2032 "vkCmdSetViewport %d: x (%f) exceeds permitted bounds (%f,%f). %s", viewportIndex, viewport.x,
2033 limits.viewportBoundsRange[0], limits.viewportBoundsRange[1],
2034 validation_error_map[VALIDATION_ERROR_1500099e]);
2035 }
2036
2037 if (viewport.y < limits.viewportBoundsRange[0] || viewport.y > limits.viewportBoundsRange[1]) {
2038 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2039 __LINE__, VALIDATION_ERROR_1500099e, LayerName,
2040 "vkCmdSetViewport %d: y (%f) exceeds permitted bounds (%f,%f). %s", viewportIndex, viewport.y,
2041 limits.viewportBoundsRange[0], limits.viewportBoundsRange[1],
2042 validation_error_map[VALIDATION_ERROR_1500099e]);
2043 }
2044
2045 if (viewport.x + viewport.width > limits.viewportBoundsRange[1]) {
2046 skip |=
2047 log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2048 __LINE__, VALIDATION_ERROR_150009a0, LayerName,
2049 "vkCmdSetViewport %d: x (%f) + width (%f) exceeds permitted bound (%f). %s", viewportIndex, viewport.x,
2050 viewport.width, limits.viewportBoundsRange[1], validation_error_map[VALIDATION_ERROR_150009a0]);
2051 }
2052
2053 if (viewport.y + viewport.height > limits.viewportBoundsRange[1]) {
2054 skip |=
2055 log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2056 __LINE__, VALIDATION_ERROR_150009a2, LayerName,
2057 "vkCmdSetViewport %d: y (%f) + height (%f) exceeds permitted bound (%f). %s", viewportIndex, viewport.y,
2058 viewport.height, limits.viewportBoundsRange[1], validation_error_map[VALIDATION_ERROR_150009a2]);
2059 }
2060 }
2061 }
2062 return skip;
2063}
2064
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002065bool pv_vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors) {
2066 bool skip = false;
2067 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2068 debug_report_data *report_data = device_data->report_data;
2069
2070 if (device_data->physical_device_features.multiViewport == false) {
2071 if (scissorCount != 1) {
2072 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2073 DEVICE_FEATURE, LayerName,
2074 "vkCmdSetScissor(): The multiViewport feature is not enabled, so scissorCount must be 1 but is %d.",
2075 scissorCount);
2076 }
2077 if (firstScissor != 0) {
2078 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2079 DEVICE_FEATURE, LayerName,
2080 "vkCmdSetScissor(): The multiViewport feature is not enabled, so firstScissor must be 0 but is %d.",
2081 firstScissor);
2082 }
2083 }
2084
2085 for (uint32_t scissorIndex = 0; scissorIndex < scissorCount; ++scissorIndex) {
2086 const VkRect2D &pScissor = pScissors[scissorIndex];
2087
2088 if (pScissor.offset.x < 0) {
2089 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2090 VALIDATION_ERROR_1d8004a6, LayerName, "vkCmdSetScissor %d: offset.x (%d) must not be negative. %s",
2091 scissorIndex, pScissor.offset.x, validation_error_map[VALIDATION_ERROR_1d8004a6]);
2092 } else if (static_cast<int32_t>(pScissor.extent.width) > (INT_MAX - pScissor.offset.x)) {
2093 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2094 VALIDATION_ERROR_1d8004a8, LayerName,
2095 "vkCmdSetScissor %d: adding offset.x (%d) and extent.width (%u) will overflow. %s", scissorIndex,
2096 pScissor.offset.x, pScissor.extent.width, validation_error_map[VALIDATION_ERROR_1d8004a8]);
2097 }
2098
2099 if (pScissor.offset.y < 0) {
2100 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2101 VALIDATION_ERROR_1d8004a6, LayerName, "vkCmdSetScissor %d: offset.y (%d) must not be negative. %s",
2102 scissorIndex, pScissor.offset.y, validation_error_map[VALIDATION_ERROR_1d8004a6]);
2103 } else if (static_cast<int32_t>(pScissor.extent.height) > (INT_MAX - pScissor.offset.y)) {
2104 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2105 VALIDATION_ERROR_1d8004aa, LayerName,
2106 "vkCmdSetScissor %d: adding offset.y (%d) and extent.height (%u) will overflow. %s", scissorIndex,
2107 pScissor.offset.y, pScissor.extent.height, validation_error_map[VALIDATION_ERROR_1d8004aa]);
2108 }
2109 }
2110 return skip;
2111}
2112
Petr Kraus299ba622017-11-24 03:09:03 +01002113bool pv_vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) {
2114 bool skip = false;
2115 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2116 debug_report_data *report_data = device_data->report_data;
2117
2118 if (!device_data->physical_device_features.wideLines && (lineWidth != 1.0f)) {
2119 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
2120 HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_1d600628, LayerName,
2121 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0. %s", lineWidth,
2122 validation_error_map[VALIDATION_ERROR_1d600628]);
2123 }
2124
2125 return skip;
2126}
2127
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002128bool pv_vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex,
2129 uint32_t firstInstance) {
2130 bool skip = false;
2131 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2132 if (vertexCount == 0) {
2133 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2134 // this an error or leave as is.
2135 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2136 __LINE__, REQUIRED_PARAMETER, LayerName, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
2137 }
2138
2139 if (instanceCount == 0) {
2140 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2141 // this an error or leave as is.
2142 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2143 __LINE__, REQUIRED_PARAMETER, LayerName, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
2144 }
2145 return skip;
2146}
2147
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002148bool pv_vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
2149 bool skip = false;
2150 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2151
2152 if (!device_data->physical_device_features.multiDrawIndirect && ((count > 1))) {
2153 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2154 __LINE__, DEVICE_FEATURE, LayerName,
2155 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
2156 }
2157 return skip;
2158}
2159
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002160bool pv_vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count,
2161 uint32_t stride) {
2162 bool skip = false;
2163 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2164 if (!device_data->physical_device_features.multiDrawIndirect && ((count > 1))) {
2165 skip |=
2166 log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2167 DEVICE_FEATURE, LayerName,
2168 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
2169 }
2170 return skip;
2171}
2172
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002173bool pv_vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage,
2174 VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions) {
2175 bool skip = false;
2176 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2177
2178 if (pRegions != nullptr) {
2179 if ((pRegions->srcSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2180 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2181 skip |= log_msg(
2182 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2183 VALIDATION_ERROR_0a600c01, LayerName,
2184 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator. %s",
2185 validation_error_map[VALIDATION_ERROR_0a600c01]);
2186 }
2187 if ((pRegions->dstSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2188 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2189 skip |= log_msg(
2190 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2191 VALIDATION_ERROR_0a600c01, LayerName,
2192 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator. %s",
2193 validation_error_map[VALIDATION_ERROR_0a600c01]);
2194 }
2195 }
2196 return skip;
2197}
2198
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002199bool pv_vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage,
2200 VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter) {
2201 bool skip = false;
2202 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2203
2204 if (pRegions != nullptr) {
2205 if ((pRegions->srcSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2206 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2207 skip |= log_msg(
2208 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2209 UNRECOGNIZED_VALUE, LayerName,
2210 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
2211 }
2212 if ((pRegions->dstSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2213 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2214 skip |= log_msg(
2215 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2216 UNRECOGNIZED_VALUE, LayerName,
2217 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
2218 }
2219 }
2220 return skip;
2221}
2222
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002223bool pv_vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout,
2224 uint32_t regionCount, const VkBufferImageCopy *pRegions) {
2225 bool skip = false;
2226 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2227
2228 if (pRegions != nullptr) {
2229 if ((pRegions->imageSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2230 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2231 skip |= log_msg(
2232 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2233 UNRECOGNIZED_VALUE, LayerName,
2234 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
2235 "enumerator");
2236 }
2237 }
2238 return skip;
2239}
2240
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002241bool pv_vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer,
2242 uint32_t regionCount, const VkBufferImageCopy *pRegions) {
2243 bool skip = false;
2244 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2245
2246 if (pRegions != nullptr) {
2247 if ((pRegions->imageSubresource.aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT |
2248 VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) {
2249 log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2250 UNRECOGNIZED_VALUE, LayerName,
2251 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
2252 "enumerator");
2253 }
2254 }
2255 return skip;
2256}
2257
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002258bool pv_vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize,
2259 const void *pData) {
2260 bool skip = false;
2261 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2262
2263 if (dstOffset & 3) {
2264 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2265 __LINE__, VALIDATION_ERROR_1e400048, LayerName,
2266 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4. %s",
2267 dstOffset, validation_error_map[VALIDATION_ERROR_1e400048]);
2268 }
2269
2270 if ((dataSize <= 0) || (dataSize > 65536)) {
2271 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2272 __LINE__, VALIDATION_ERROR_1e40004a, LayerName,
2273 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
2274 "), must be greater than zero and less than or equal to 65536. %s",
2275 dataSize, validation_error_map[VALIDATION_ERROR_1e40004a]);
2276 } else if (dataSize & 3) {
2277 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2278 __LINE__, VALIDATION_ERROR_1e40004c, LayerName,
2279 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4. %s",
2280 dataSize, validation_error_map[VALIDATION_ERROR_1e40004c]);
2281 }
2282 return skip;
2283}
2284
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002285bool pv_vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size,
2286 uint32_t data) {
2287 bool skip = false;
2288 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2289
2290 if (dstOffset & 3) {
2291 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2292 __LINE__, VALIDATION_ERROR_1b400032, LayerName,
2293 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4. %s",
2294 dstOffset, validation_error_map[VALIDATION_ERROR_1b400032]);
2295 }
2296
2297 if (size != VK_WHOLE_SIZE) {
2298 if (size <= 0) {
2299 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2300 __LINE__, VALIDATION_ERROR_1b400034, LayerName,
2301 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero. %s",
2302 size, validation_error_map[VALIDATION_ERROR_1b400034]);
2303 } else if (size & 3) {
2304 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2305 __LINE__, VALIDATION_ERROR_1b400038, LayerName,
2306 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4. %s", size,
2307 validation_error_map[VALIDATION_ERROR_1b400038]);
2308 }
2309 }
2310 return skip;
2311}
2312
2313VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) {
2314 return util_GetLayerProperties(1, &global_layer, pCount, pProperties);
2315}
2316
2317VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
2318 VkLayerProperties *pProperties) {
2319 return util_GetLayerProperties(1, &global_layer, pCount, pProperties);
2320}
2321
2322VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount,
2323 VkExtensionProperties *pProperties) {
2324 if (pLayerName && !strcmp(pLayerName, global_layer.layerName))
2325 return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties);
2326
2327 return VK_ERROR_LAYER_NOT_PRESENT;
2328}
2329
2330VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName,
2331 uint32_t *pPropertyCount, VkExtensionProperties *pProperties) {
2332 // Parameter_validation does not have any physical device extensions
2333 if (pLayerName && !strcmp(pLayerName, global_layer.layerName))
2334 return util_GetExtensionProperties(0, NULL, pPropertyCount, pProperties);
2335
2336 instance_layer_data *local_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map);
2337 bool skip =
2338 validate_array(local_data->report_data, "vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties",
2339 pPropertyCount, pProperties, true, false, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_2761f401);
2340 if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
2341
2342 return local_data->dispatch_table.EnumerateDeviceExtensionProperties(physicalDevice, NULL, pPropertyCount, pProperties);
2343}
2344
2345static bool require_device_extension(layer_data *device_data, bool flag, char const *function_name, char const *extension_name) {
2346 if (!flag) {
2347 return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2348 __LINE__, EXTENSION_NOT_ENABLED, LayerName,
2349 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
2350 extension_name);
2351 }
2352
2353 return false;
2354}
2355
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002356bool pv_vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
2357 VkSwapchainKHR *pSwapchain) {
2358 bool skip = false;
2359 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2360 debug_report_data *report_data = device_data->report_data;
2361
2362 if (pCreateInfo != nullptr) {
2363 if ((device_data->physical_device_features.textureCompressionETC2 == false) &&
2364 FormatIsCompressed_ETC2_EAC(pCreateInfo->imageFormat)) {
2365 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2366 DEVICE_FEATURE, LayerName,
2367 "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The "
2368 "textureCompressionETC2 feature is not enabled: neither ETC2 nor EAC formats can be used to create "
2369 "images.",
2370 string_VkFormat(pCreateInfo->imageFormat));
2371 }
2372
2373 if ((device_data->physical_device_features.textureCompressionASTC_LDR == false) &&
2374 FormatIsCompressed_ASTC_LDR(pCreateInfo->imageFormat)) {
2375 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2376 DEVICE_FEATURE, LayerName,
2377 "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The "
2378 "textureCompressionASTC_LDR feature is not enabled: ASTC formats cannot be used to create images.",
2379 string_VkFormat(pCreateInfo->imageFormat));
2380 }
2381
2382 if ((device_data->physical_device_features.textureCompressionBC == false) &&
2383 FormatIsCompressed_BC(pCreateInfo->imageFormat)) {
2384 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2385 DEVICE_FEATURE, LayerName,
2386 "vkCreateSwapchainKHR(): Attempting to create swapchain VkImage with format %s. The "
2387 "textureCompressionBC feature is not enabled: BC compressed formats cannot be used to create images.",
2388 string_VkFormat(pCreateInfo->imageFormat));
2389 }
2390
2391 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2392 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
2393 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
2394 if (pCreateInfo->queueFamilyIndexCount <= 1) {
2395 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2396 VALIDATION_ERROR_146009fc, LayerName,
2397 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
2398 "pCreateInfo->queueFamilyIndexCount must be greater than 1. %s",
2399 validation_error_map[VALIDATION_ERROR_146009fc]);
2400 }
2401
2402 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
2403 // queueFamilyIndexCount uint32_t values
2404 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
2405 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
2406 VALIDATION_ERROR_146009fa, LayerName,
2407 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
2408 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
2409 "pCreateInfo->queueFamilyIndexCount uint32_t values. %s",
2410 validation_error_map[VALIDATION_ERROR_146009fa]);
2411 } else {
2412 // TODO: Not in the spec VUs. Probably missing -- KhronosGroup/Vulkan-Docs#501. Update error codes when resolved.
2413 skip |= ValidateQueueFamilies(device_data, pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices,
2414 "vkCreateSwapchainKHR", "pCreateInfo->pQueueFamilyIndices", INVALID_USAGE,
2415 INVALID_USAGE, false, "", "");
2416 }
2417 }
2418
2419 // imageArrayLayers must be greater than 0
2420 skip |= ValidateGreaterThan(report_data, "vkCreateSwapchainKHR", "pCreateInfo->imageArrayLayers",
2421 pCreateInfo->imageArrayLayers, 0u);
2422 }
2423
2424 return skip;
2425}
2426
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002427bool pv_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
2428 bool skip = false;
2429 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
2430
2431 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06002432 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
2433 if (present_regions) {
2434 // TODO: This and all other pNext extension dependencies should be added to code-generation
2435 skip |= require_device_extension(device_data, device_data->extensions.vk_khr_incremental_present, "vkQueuePresentKHR",
2436 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
2437 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
2438 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2439 __LINE__, INVALID_USAGE, LayerName,
2440 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i"
2441 " but VkPresentRegionsKHR extension swapchainCount is %i. These values must be equal.",
2442 pPresentInfo->swapchainCount, present_regions->swapchainCount);
2443 }
2444 skip |= validate_struct_pnext(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL,
2445 present_regions->pNext, 0, NULL, GeneratedHeaderVersion, VALIDATION_ERROR_1121c40d);
2446 skip |= validate_array(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->swapchainCount",
2447 "pCreateInfo->pNext->pRegions", present_regions->swapchainCount, present_regions->pRegions, true,
2448 false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED);
2449 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
2450 skip |= validate_array(device_data->report_data, "QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002451 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
2452 present_regions->pRegions[i].pRectangles, true, false, VALIDATION_ERROR_UNDEFINED,
2453 VALIDATION_ERROR_UNDEFINED);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002454 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002455 }
2456 }
2457
2458 return skip;
2459}
2460
2461#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002462bool pv_vkCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
2463 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
2464 auto device_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
2465 bool skip = false;
2466
2467 if (pCreateInfo->hwnd == nullptr) {
2468 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2469 __LINE__, VALIDATION_ERROR_15a00a38, LayerName,
2470 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL. %s",
2471 validation_error_map[VALIDATION_ERROR_15a00a38]);
2472 }
2473
2474 return skip;
2475}
2476#endif // VK_USE_PLATFORM_WIN32_KHR
2477
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002478bool pv_vkDebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) {
2479 auto device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2480 if (pNameInfo->pObjectName) {
2481 device_data->report_data->debugObjectNameMap->insert(
2482 std::make_pair<uint64_t, std::string>((uint64_t &&) pNameInfo->object, pNameInfo->pObjectName));
2483 } else {
2484 device_data->report_data->debugObjectNameMap->erase(pNameInfo->object);
2485 }
2486 return false;
2487}
2488
Petr Krausc8655be2017-09-27 18:56:51 +02002489bool pv_vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
2490 const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool) {
2491 auto device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2492 bool skip = false;
2493
2494 if (pCreateInfo) {
2495 if (pCreateInfo->maxSets <= 0) {
2496 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
2497 VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_0480025a,
2498 LayerName, "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0. %s",
2499 validation_error_map[VALIDATION_ERROR_0480025a]);
2500 }
2501
2502 if (pCreateInfo->pPoolSizes) {
2503 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
2504 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
2505 skip |= log_msg(
2506 device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT,
2507 VK_NULL_HANDLE, __LINE__, VALIDATION_ERROR_04a0025c, LayerName,
2508 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0. %s",
2509 i, validation_error_map[VALIDATION_ERROR_04a0025c]);
2510 }
2511 }
2512 }
2513 }
2514
2515 return skip;
2516}
2517
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002518VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *funcName) {
2519 const auto item = name_to_funcptr_map.find(funcName);
2520 if (item != name_to_funcptr_map.end()) {
2521 return reinterpret_cast<PFN_vkVoidFunction>(item->second);
2522 }
2523
2524 layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2525 const auto &table = device_data->dispatch_table;
2526 if (!table.GetDeviceProcAddr) return nullptr;
2527 return table.GetDeviceProcAddr(device, funcName);
2528}
2529
2530VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) {
2531 const auto item = name_to_funcptr_map.find(funcName);
2532 if (item != name_to_funcptr_map.end()) {
2533 return reinterpret_cast<PFN_vkVoidFunction>(item->second);
2534 }
2535
2536 auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
2537 auto &table = instance_data->dispatch_table;
2538 if (!table.GetInstanceProcAddr) return nullptr;
2539 return table.GetInstanceProcAddr(instance, funcName);
2540}
2541
2542VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) {
2543 assert(instance);
2544 auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map);
2545
2546 if (!instance_data->dispatch_table.GetPhysicalDeviceProcAddr) return nullptr;
2547 return instance_data->dispatch_table.GetPhysicalDeviceProcAddr(instance, funcName);
2548}
2549
2550// If additional validation is needed outside of the generated checks, a manual routine can be added to this file
2551// and the address filled in here. The autogenerated source will call these routines if the pointers are not NULL.
Petr Krausc8655be2017-09-27 18:56:51 +02002552void InitializeManualParameterValidationFunctionPointers() {
Mark Lobodzinski78a12a92017-08-08 14:16:51 -06002553 custom_functions["vkGetDeviceQueue"] = (void*)pv_vkGetDeviceQueue;
2554 custom_functions["vkCreateBuffer"] = (void*)pv_vkCreateBuffer;
2555 custom_functions["vkCreateImage"] = (void*)pv_vkCreateImage;
2556 custom_functions["vkCreateImageView"] = (void*)pv_vkCreateImageView;
2557 custom_functions["vkCreateGraphicsPipelines"] = (void*)pv_vkCreateGraphicsPipelines;
2558 custom_functions["vkCreateComputePipelines"] = (void*)pv_vkCreateComputePipelines;
2559 custom_functions["vkCreateSampler"] = (void*)pv_vkCreateSampler;
2560 custom_functions["vkCreateDescriptorSetLayout"] = (void*)pv_vkCreateDescriptorSetLayout;
2561 custom_functions["vkFreeDescriptorSets"] = (void*)pv_vkFreeDescriptorSets;
2562 custom_functions["vkUpdateDescriptorSets"] = (void*)pv_vkUpdateDescriptorSets;
2563 custom_functions["vkCreateRenderPass"] = (void*)pv_vkCreateRenderPass;
2564 custom_functions["vkBeginCommandBuffer"] = (void*)pv_vkBeginCommandBuffer;
2565 custom_functions["vkCmdSetViewport"] = (void*)pv_vkCmdSetViewport;
2566 custom_functions["vkCmdSetScissor"] = (void*)pv_vkCmdSetScissor;
Petr Kraus299ba622017-11-24 03:09:03 +01002567 custom_functions["vkCmdSetLineWidth"] = (void *)pv_vkCmdSetLineWidth;
Mark Lobodzinski78a12a92017-08-08 14:16:51 -06002568 custom_functions["vkCmdDraw"] = (void*)pv_vkCmdDraw;
2569 custom_functions["vkCmdDrawIndirect"] = (void*)pv_vkCmdDrawIndirect;
2570 custom_functions["vkCmdDrawIndexedIndirect"] = (void*)pv_vkCmdDrawIndexedIndirect;
2571 custom_functions["vkCmdCopyImage"] = (void*)pv_vkCmdCopyImage;
2572 custom_functions["vkCmdBlitImage"] = (void*)pv_vkCmdBlitImage;
2573 custom_functions["vkCmdCopyBufferToImage"] = (void*)pv_vkCmdCopyBufferToImage;
2574 custom_functions["vkCmdCopyImageToBuffer"] = (void*)pv_vkCmdCopyImageToBuffer;
2575 custom_functions["vkCmdUpdateBuffer"] = (void*)pv_vkCmdUpdateBuffer;
2576 custom_functions["vkCmdFillBuffer"] = (void*)pv_vkCmdFillBuffer;
2577 custom_functions["vkCreateSwapchainKHR"] = (void*)pv_vkCreateSwapchainKHR;
2578 custom_functions["vkQueuePresentKHR"] = (void*)pv_vkQueuePresentKHR;
Petr Krausc8655be2017-09-27 18:56:51 +02002579 custom_functions["vkCreateDescriptorPool"] = (void*)pv_vkCreateDescriptorPool;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002580}
2581
2582} // namespace parameter_validation
2583
2584VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount,
2585 VkExtensionProperties *pProperties) {
2586 return parameter_validation::vkEnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties);
2587}
2588
2589VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount,
2590 VkLayerProperties *pProperties) {
2591 return parameter_validation::vkEnumerateInstanceLayerProperties(pCount, pProperties);
2592}
2593
2594VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
2595 VkLayerProperties *pProperties) {
2596 // the layer command handles VK_NULL_HANDLE just fine internally
2597 assert(physicalDevice == VK_NULL_HANDLE);
2598 return parameter_validation::vkEnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties);
2599}
2600
2601VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
2602 const char *pLayerName, uint32_t *pCount,
2603 VkExtensionProperties *pProperties) {
2604 // the layer command handles VK_NULL_HANDLE just fine internally
2605 assert(physicalDevice == VK_NULL_HANDLE);
2606 return parameter_validation::vkEnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties);
2607}
2608
2609VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) {
2610 return parameter_validation::vkGetDeviceProcAddr(dev, funcName);
2611}
2612
2613VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) {
2614 return parameter_validation::vkGetInstanceProcAddr(instance, funcName);
2615}
2616
2617VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance,
2618 const char *funcName) {
2619 return parameter_validation::vkGetPhysicalDeviceProcAddr(instance, funcName);
2620}
2621
2622VK_LAYER_EXPORT bool pv_vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) {
2623 assert(pVersionStruct != NULL);
2624 assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT);
2625
2626 // Fill in the function pointers if our version is at least capable of having the structure contain them.
2627 if (pVersionStruct->loaderLayerInterfaceVersion >= 2) {
2628 pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr;
2629 pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr;
2630 pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr;
2631 }
2632
2633 if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
2634 parameter_validation::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion;
2635 } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
2636 pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION;
2637 }
2638
2639 return VK_SUCCESS;
2640}