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