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