blob: bfa0e4a2877023469086ced603d3b041499e26ca [file] [log] [blame]
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06001/* Copyright (c) 2015-2019 The Khronos Group Inc.
2 * Copyright (c) 2015-2019 Valve Corporation
3 * Copyright (c) 2015-2019 LunarG, Inc.
4 * Copyright (C) 2015-2019 Google Inc.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005 *
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: Dustin Graves <dustin@lunarg.com>
19 * Author: Mark Lobodzinski <mark@lunarg.com>
20 */
21
22#pragma once
23
24#include <bitset>
25
26#include "parameter_name.h"
27#include "vk_typemap_helper.h"
28
29// Suppress unused warning on Linux
30#if defined(__GNUC__)
31#define DECORATE_UNUSED __attribute__((unused))
32#else
33#define DECORATE_UNUSED
34#endif
35
36static const char DECORATE_UNUSED *kVUID_PVError_NONE = "UNASSIGNED-GeneralParameterError-Info";
37static const char DECORATE_UNUSED *kVUID_PVError_InvalidUsage = "UNASSIGNED-GeneralParameterError-InvalidUsage";
38static const char DECORATE_UNUSED *kVUID_PVError_InvalidStructSType = "UNASSIGNED-GeneralParameterError-InvalidStructSType";
39static const char DECORATE_UNUSED *kVUID_PVError_InvalidStructPNext = "UNASSIGNED-GeneralParameterError-InvalidStructPNext";
40static const char DECORATE_UNUSED *kVUID_PVError_RequiredParameter = "UNASSIGNED-GeneralParameterError-RequiredParameter";
41static const char DECORATE_UNUSED *kVUID_PVError_ReservedParameter = "UNASSIGNED-GeneralParameterError-ReservedParameter";
42static const char DECORATE_UNUSED *kVUID_PVError_UnrecognizedValue = "UNASSIGNED-GeneralParameterError-UnrecognizedValue";
43static const char DECORATE_UNUSED *kVUID_PVError_DeviceLimit = "UNASSIGNED-GeneralParameterError-DeviceLimit";
44static const char DECORATE_UNUSED *kVUID_PVError_DeviceFeature = "UNASSIGNED-GeneralParameterError-DeviceFeature";
45static const char DECORATE_UNUSED *kVUID_PVError_FailureCode = "UNASSIGNED-GeneralParameterError-FailureCode";
46static const char DECORATE_UNUSED *kVUID_PVError_ExtensionNotEnabled = "UNASSIGNED-GeneralParameterError-ExtensionNotEnabled";
47
48#undef DECORATE_UNUSED
49
50extern const uint32_t GeneratedVulkanHeaderVersion;
51
52extern const VkQueryPipelineStatisticFlags AllVkQueryPipelineStatisticFlagBits;
53extern const VkColorComponentFlags AllVkColorComponentFlagBits;
54extern const VkShaderStageFlags AllVkShaderStageFlagBits;
55extern const VkQueryControlFlags AllVkQueryControlFlagBits;
56extern const VkImageUsageFlags AllVkImageUsageFlagBits;
57
58extern const std::vector<VkCompareOp> AllVkCompareOpEnums;
59extern const std::vector<VkStencilOp> AllVkStencilOpEnums;
60extern const std::vector<VkBlendFactor> AllVkBlendFactorEnums;
61extern const std::vector<VkBlendOp> AllVkBlendOpEnums;
62extern const std::vector<VkLogicOp> AllVkLogicOpEnums;
63extern const std::vector<VkBorderColor> AllVkBorderColorEnums;
64extern const std::vector<VkImageLayout> AllVkImageLayoutEnums;
65
66struct GenericHeader {
67 VkStructureType sType;
68 const void *pNext;
69};
70
71// String returned by string_VkStructureType for an unrecognized type.
72const std::string UnsupportedStructureTypeString = "Unhandled VkStructureType";
73
74// String returned by string_VkResult for an unrecognized type.
75const std::string UnsupportedResultString = "Unhandled VkResult";
76
77// The base value used when computing the offset for an enumeration token value that is added by an extension.
78// When validating enumeration tokens, any value >= to this value is considered to be provided by an extension.
79// See Appendix C.10 "Assigning Extension Token Values" from the Vulkan specification
80const uint32_t ExtEnumBaseValue = 1000000000;
81
82// The value of all VK_xxx_MAX_ENUM tokens
83const uint32_t MaxEnumValue = 0x7FFFFFFF;
84
85// Misc parameters of log_msg that are likely constant per command (or low frequency change)
86struct LogMiscParams {
87 VkDebugReportObjectTypeEXT objectType;
88 uint64_t srcObject;
89 const char *api_name;
90};
91
92class StatelessValidation : public ValidationObject {
93 public:
94 // Map for queue family index to queue count
95 std::unordered_map<uint32_t, uint32_t> queueFamilyIndexMap;
96
97 VkPhysicalDeviceLimits device_limits = {};
98 VkPhysicalDeviceFeatures physical_device_features = {};
99 VkDevice device = VK_NULL_HANDLE;
100 uint32_t api_version;
101
102 // Device extension properties -- storing properties gathered from VkPhysicalDeviceProperties2KHR::pNext chain
103 struct DeviceExtensionProperties {
104 VkPhysicalDeviceShadingRateImagePropertiesNV shading_rate_image_props;
105 VkPhysicalDeviceMeshShaderPropertiesNV mesh_shader_props;
106 };
107 DeviceExtensionProperties phys_dev_ext_props = {};
108
109 struct SubpassesUsageStates {
110 std::unordered_set<uint32_t> subpasses_using_color_attachment;
111 std::unordered_set<uint32_t> subpasses_using_depthstencil_attachment;
112 };
113
114 std::unordered_map<VkRenderPass, SubpassesUsageStates> renderpasses_states;
115
116 // Constructor for stateles validation tracking
117 // StatelessValidation() : {}
118 /**
119 * Validate a minimum value.
120 *
121 * Verify that the specified value is greater than the specified lower bound.
122 *
123 * @param api_name Name of API call being validated.
124 * @param parameter_name Name of parameter being validated.
125 * @param value Value to validate.
126 * @param lower_bound Lower bound value to use for validation.
127 * @return Boolean value indicating that the call should be skipped.
128 */
129 template <typename T>
130 bool ValidateGreaterThan(const T value, const T lower_bound, const ParameterName &parameter_name, const std::string &vuid,
131 const LogMiscParams &misc) {
132 bool skip_call = false;
133
134 if (value <= lower_bound) {
135 std::ostringstream ss;
136 ss << misc.api_name << ": parameter " << parameter_name.get_name() << " (= " << value << ") is greater than "
137 << lower_bound;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700138 skip_call |=
139 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, misc.objectType, misc.srcObject, vuid, "%s", ss.str().c_str());
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700140 }
141
142 return skip_call;
143 }
144
145 template <typename T>
146 bool ValidateGreaterThanZero(const T value, const ParameterName &parameter_name, const std::string &vuid,
147 const LogMiscParams &misc) {
148 return ValidateGreaterThan(value, T{0}, parameter_name, vuid, misc);
149 }
150 /**
151 * Validate a required pointer.
152 *
153 * Verify that a required pointer is not NULL.
154 *
155 * @param apiName Name of API call being validated.
156 * @param parameterName Name of parameter being validated.
157 * @param value Pointer to validate.
158 * @return Boolean value indicating that the call should be skipped.
159 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700160 bool validate_required_pointer(const char *apiName, const ParameterName &parameterName, const void *value,
161 const std::string &vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700162 bool skip_call = false;
163
164 if (value == NULL) {
165 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
166 "%s: required parameter %s specified as NULL.", apiName, parameterName.get_name().c_str());
167 }
168
169 return skip_call;
170 }
171
172 /**
173 * Validate array count and pointer to array.
174 *
175 * Verify that required count and array parameters are not 0 or NULL. If the
176 * count parameter is not optional, verify that it is not 0. If the array
177 * parameter is NULL, and it is not optional, verify that count is 0.
178 *
179 * @param apiName Name of API call being validated.
180 * @param countName Name of count parameter.
181 * @param arrayName Name of array parameter.
182 * @param count Number of elements in the array.
183 * @param array Array to validate.
184 * @param countRequired The 'count' parameter may not be 0 when true.
185 * @param arrayRequired The 'array' parameter may not be NULL when true.
186 * @return Boolean value indicating that the call should be skipped.
187 */
188 template <typename T1, typename T2>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700189 bool validate_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName, T1 count,
190 const T2 *array, bool countRequired, bool arrayRequired, const std::string &count_required_vuid,
191 const std::string &array_required_vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700192 bool skip_call = false;
193
194 // Count parameters not tagged as optional cannot be 0
195 if (countRequired && (count == 0)) {
196 skip_call |=
197 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, count_required_vuid,
198 "%s: parameter %s must be greater than 0.", apiName, countName.get_name().c_str());
199 }
200
201 // Array parameters not tagged as optional cannot be NULL, unless the count is 0
202 if (arrayRequired && (count != 0) && (*array == NULL)) {
203 skip_call |=
204 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, array_required_vuid,
205 "%s: required parameter %s specified as NULL.", apiName, arrayName.get_name().c_str());
206 }
207
208 return skip_call;
209 }
210
211 /**
212 * Validate pointer to array count and pointer to array.
213 *
214 * Verify that required count and array parameters are not NULL. If count
215 * is not NULL and its value is not optional, verify that it is not 0. If the
216 * array parameter is NULL, and it is not optional, verify that count is 0.
217 * The array parameter will typically be optional for this case (where count is
218 * a pointer), allowing the caller to retrieve the available count.
219 *
220 * @param apiName Name of API call being validated.
221 * @param countName Name of count parameter.
222 * @param arrayName Name of array parameter.
223 * @param count Pointer to the number of elements in the array.
224 * @param array Array to validate.
225 * @param countPtrRequired The 'count' parameter may not be NULL when true.
226 * @param countValueRequired The '*count' value may not be 0 when true.
227 * @param arrayRequired The 'array' parameter may not be NULL when true.
228 * @return Boolean value indicating that the call should be skipped.
229 */
230 template <typename T1, typename T2>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700231 bool validate_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName, const T1 *count,
232 const T2 *array, bool countPtrRequired, bool countValueRequired, bool arrayRequired,
233 const std::string &count_required_vuid, const std::string &array_required_vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700234 bool skip_call = false;
235
236 if (count == NULL) {
237 if (countPtrRequired) {
238 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
239 kVUID_PVError_RequiredParameter, "%s: required parameter %s specified as NULL", apiName,
240 countName.get_name().c_str());
241 }
242 } else {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700243 skip_call |= validate_array(apiName, countName, arrayName, *array ? (*count) : 0, &array, countValueRequired,
244 arrayRequired, count_required_vuid, array_required_vuid);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700245 }
246
247 return skip_call;
248 }
249
250 /**
251 * Validate a pointer to a Vulkan structure.
252 *
253 * Verify that a required pointer to a structure is not NULL. If the pointer is
254 * not NULL, verify that each structure's sType field is set to the correct
255 * VkStructureType value.
256 *
257 * @param apiName Name of API call being validated.
258 * @param parameterName Name of struct parameter being validated.
259 * @param sTypeName Name of expected VkStructureType value.
260 * @param value Pointer to the struct to validate.
261 * @param sType VkStructureType for structure validation.
262 * @param required The parameter may not be NULL when true.
263 * @return Boolean value indicating that the call should be skipped.
264 */
265 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700266 bool validate_struct_type(const char *apiName, const ParameterName &parameterName, const char *sTypeName, const T *value,
267 VkStructureType sType, bool required, const std::string &struct_vuid, const std::string &stype_vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700268 bool skip_call = false;
269
270 if (value == NULL) {
271 if (required) {
272 skip_call |=
273 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, struct_vuid,
274 "%s: required parameter %s specified as NULL", apiName, parameterName.get_name().c_str());
275 }
276 } else if (value->sType != sType) {
277 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, stype_vuid,
278 "%s: parameter %s->sType must be %s.", apiName, parameterName.get_name().c_str(), sTypeName);
279 }
280
281 return skip_call;
282 }
283
284 /**
285 * Validate an array of Vulkan structures
286 *
287 * Verify that required count and array parameters are not 0 or NULL. If
288 * the array contains 1 or more structures, verify that each structure's
289 * sType field is set to the correct VkStructureType value.
290 *
291 * @param apiName Name of API call being validated.
292 * @param countName Name of count parameter.
293 * @param arrayName Name of array parameter.
294 * @param sTypeName Name of expected VkStructureType value.
295 * @param count Number of elements in the array.
296 * @param array Array to validate.
297 * @param sType VkStructureType for structure validation.
298 * @param countRequired The 'count' parameter may not be 0 when true.
299 * @param arrayRequired The 'array' parameter may not be NULL when true.
300 * @return Boolean value indicating that the call should be skipped.
301 */
302 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700303 bool validate_struct_type_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName,
304 const char *sTypeName, uint32_t count, const T *array, VkStructureType sType,
305 bool countRequired, bool arrayRequired, const std::string &stype_vuid,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700306 const std::string &param_vuid) {
307 bool skip_call = false;
308
309 if ((count == 0) || (array == NULL)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700310 skip_call |= validate_array(apiName, countName, arrayName, count, &array, countRequired, arrayRequired, kVUIDUndefined,
311 param_vuid);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700312 } else {
313 // Verify that all structs in the array have the correct type
314 for (uint32_t i = 0; i < count; ++i) {
315 if (array[i].sType != sType) {
316 skip_call |=
317 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, stype_vuid,
318 "%s: parameter %s[%d].sType must be %s", apiName, arrayName.get_name().c_str(), i, sTypeName);
319 }
320 }
321 }
322
323 return skip_call;
324 }
325
326 /**
327 * Validate an array of Vulkan structures.
328 *
329 * Verify that required count and array parameters are not NULL. If count
330 * is not NULL and its value is not optional, verify that it is not 0.
331 * If the array contains 1 or more structures, verify that each structure's
332 * sType field is set to the correct VkStructureType value.
333 *
334 * @param apiName Name of API call being validated.
335 * @param countName Name of count parameter.
336 * @param arrayName Name of array parameter.
337 * @param sTypeName Name of expected VkStructureType value.
338 * @param count Pointer to the number of elements in the array.
339 * @param array Array to validate.
340 * @param sType VkStructureType for structure validation.
341 * @param countPtrRequired The 'count' parameter may not be NULL when true.
342 * @param countValueRequired The '*count' value may not be 0 when true.
343 * @param arrayRequired The 'array' parameter may not be NULL when true.
344 * @return Boolean value indicating that the call should be skipped.
345 */
346 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700347 bool validate_struct_type_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName,
348 const char *sTypeName, uint32_t *count, const T *array, VkStructureType sType,
349 bool countPtrRequired, bool countValueRequired, bool arrayRequired,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700350 const std::string &stype_vuid, const std::string &param_vuid) {
351 bool skip_call = false;
352
353 if (count == NULL) {
354 if (countPtrRequired) {
355 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
356 kVUID_PVError_RequiredParameter, "%s: required parameter %s specified as NULL", apiName,
357 countName.get_name().c_str());
358 }
359 } else {
360 skip_call |= validate_struct_type_array(apiName, countName, arrayName, sTypeName, (*count), array, sType,
361 countValueRequired, arrayRequired, stype_vuid, param_vuid);
362 }
363
364 return skip_call;
365 }
366
367 /**
368 * Validate a Vulkan handle.
369 *
370 * Verify that the specified handle is not VK_NULL_HANDLE.
371 *
372 * @param api_name Name of API call being validated.
373 * @param parameter_name Name of struct parameter being validated.
374 * @param value Handle to validate.
375 * @return Boolean value indicating that the call should be skipped.
376 */
377 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700378 bool validate_required_handle(const char *api_name, const ParameterName &parameter_name, T value) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700379 bool skip_call = false;
380
381 if (value == VK_NULL_HANDLE) {
382 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
383 kVUID_PVError_RequiredParameter, "%s: required parameter %s specified as VK_NULL_HANDLE", api_name,
384 parameter_name.get_name().c_str());
385 }
386
387 return skip_call;
388 }
389
390 /**
391 * Validate an array of Vulkan handles.
392 *
393 * Verify that required count and array parameters are not NULL. If count
394 * is not NULL and its value is not optional, verify that it is not 0.
395 * If the array contains 1 or more handles, verify that no handle is set to
396 * VK_NULL_HANDLE.
397 *
398 * @note This function is only intended to validate arrays of handles when none
399 * of the handles are allowed to be VK_NULL_HANDLE. For arrays of handles
400 * that are allowed to contain VK_NULL_HANDLE, use validate_array() instead.
401 *
402 * @param api_name Name of API call being validated.
403 * @param count_name Name of count parameter.
404 * @param array_name Name of array parameter.
405 * @param count Number of elements in the array.
406 * @param array Array to validate.
407 * @param count_required The 'count' parameter may not be 0 when true.
408 * @param array_required The 'array' parameter may not be NULL when true.
409 * @return Boolean value indicating that the call should be skipped.
410 */
411 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700412 bool validate_handle_array(const char *api_name, const ParameterName &count_name, const ParameterName &array_name,
413 uint32_t count, const T *array, bool count_required, bool array_required) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700414 bool skip_call = false;
415
416 if ((count == 0) || (array == NULL)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700417 skip_call |= validate_array(api_name, count_name, array_name, count, &array, count_required, array_required,
418 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700419 } else {
420 // Verify that no handles in the array are VK_NULL_HANDLE
421 for (uint32_t i = 0; i < count; ++i) {
422 if (array[i] == VK_NULL_HANDLE) {
423 skip_call |=
424 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
425 kVUID_PVError_RequiredParameter, "%s: required parameter %s[%d] specified as VK_NULL_HANDLE",
426 api_name, array_name.get_name().c_str(), i);
427 }
428 }
429 }
430
431 return skip_call;
432 }
433
434 /**
435 * Validate string array count and content.
436 *
437 * Verify that required count and array parameters are not 0 or NULL. If the
438 * count parameter is not optional, verify that it is not 0. If the array
439 * parameter is NULL, and it is not optional, verify that count is 0. If the
440 * array parameter is not NULL, verify that none of the strings are NULL.
441 *
442 * @param apiName Name of API call being validated.
443 * @param countName Name of count parameter.
444 * @param arrayName Name of array parameter.
445 * @param count Number of strings in the array.
446 * @param array Array of strings to validate.
447 * @param countRequired The 'count' parameter may not be 0 when true.
448 * @param arrayRequired The 'array' parameter may not be NULL when true.
449 * @return Boolean value indicating that the call should be skipped.
450 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700451 bool validate_string_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName, uint32_t count,
452 const char *const *array, bool countRequired, bool arrayRequired,
453 const std::string &count_required_vuid, const std::string &array_required_vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700454 bool skip_call = false;
455
456 if ((count == 0) || (array == NULL)) {
457 skip_call |= validate_array(apiName, countName, arrayName, count, &array, countRequired, arrayRequired,
458 count_required_vuid, array_required_vuid);
459 } else {
460 // Verify that strings in the array are not NULL
461 for (uint32_t i = 0; i < count; ++i) {
462 if (array[i] == NULL) {
463 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
464 kVUID_PVError_RequiredParameter, "%s: required parameter %s[%d] specified as NULL",
465 apiName, arrayName.get_name().c_str(), i);
466 }
467 }
468 }
469
470 return skip_call;
471 }
472
473 // Forward declaration for pNext validation
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700474 bool ValidatePnextStructContents(const char *api_name, const ParameterName &parameter_name, const GenericHeader *header);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700475
476 /**
477 * Validate a structure's pNext member.
478 *
479 * Verify that the specified pNext value points to the head of a list of
480 * allowed extension structures. If no extension structures are allowed,
481 * verify that pNext is null.
482 *
483 * @param api_name Name of API call being validated.
484 * @param parameter_name Name of parameter being validated.
485 * @param allowed_struct_names Names of allowed structs.
486 * @param next Pointer to validate.
487 * @param allowed_type_count Total number of allowed structure types.
488 * @param allowed_types Array of structure types allowed for pNext.
489 * @param header_version Version of header defining the pNext validation rules.
490 * @return Boolean value indicating that the call should be skipped.
491 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700492 bool validate_struct_pnext(const char *api_name, const ParameterName &parameter_name, const char *allowed_struct_names,
493 const void *next, size_t allowed_type_count, const VkStructureType *allowed_types,
494 uint32_t header_version, const std::string &vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700495 bool skip_call = false;
496 std::unordered_set<const void *> cycle_check;
497 std::unordered_set<VkStructureType, std::hash<int>> unique_stype_check;
498
499 const char disclaimer[] =
500 "This warning is based on the Valid Usage documentation for version %d of the Vulkan header. It is possible that you "
501 "are "
502 "using a struct from a private extension or an extension that was added to a later version of the Vulkan header, in "
503 "which "
504 "case your use of %s is perfectly valid but is not guaranteed to work correctly with validation enabled";
505
506 // TODO: The valid pNext structure types are not recursive. Each structure has its own list of valid sTypes for pNext.
507 // Codegen a map of vectors containing the allowable pNext types for each struct and use that here -- also simplifies parms.
508 if (next != NULL) {
509 if (allowed_type_count == 0) {
510 std::string message = "%s: value of %s must be NULL. ";
511 message += disclaimer;
512 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
513 message.c_str(), api_name, parameter_name.get_name().c_str(), header_version,
514 parameter_name.get_name().c_str());
515 } else {
516 const VkStructureType *start = allowed_types;
517 const VkStructureType *end = allowed_types + allowed_type_count;
518 const GenericHeader *current = reinterpret_cast<const GenericHeader *>(next);
519
520 cycle_check.insert(next);
521
522 while (current != NULL) {
523 if (((strncmp(api_name, "vkCreateInstance", strlen(api_name)) != 0) ||
524 (current->sType != VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO)) &&
525 ((strncmp(api_name, "vkCreateDevice", strlen(api_name)) != 0) ||
526 (current->sType != VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO))) {
527 if (cycle_check.find(current->pNext) != cycle_check.end()) {
528 std::string message = "%s: %s chain contains a cycle -- pNext pointer " PRIx64 " is repeated.";
529 skip_call |=
530 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
531 kVUID_PVError_InvalidStructPNext, message.c_str(), api_name,
532 parameter_name.get_name().c_str(), reinterpret_cast<uint64_t>(next));
533 break;
534 } else {
535 cycle_check.insert(current->pNext);
536 }
537
538 std::string type_name = string_VkStructureType(current->sType);
539 if (unique_stype_check.find(current->sType) != unique_stype_check.end()) {
540 std::string message = "%s: %s chain contains duplicate structure types: %s appears multiple times.";
541 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
542 VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, kVUID_PVError_InvalidStructPNext,
543 message.c_str(), api_name, parameter_name.get_name().c_str(), type_name.c_str());
544 } else {
545 unique_stype_check.insert(current->sType);
546 }
547
548 if (std::find(start, end, current->sType) == end) {
549 if (type_name == UnsupportedStructureTypeString) {
550 std::string message =
551 "%s: %s chain includes a structure with unknown VkStructureType (%d); Allowed structures are "
552 "[%s]. ";
553 message += disclaimer;
554 skip_call |=
555 log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
556 0, vuid, message.c_str(), api_name, parameter_name.get_name().c_str(), current->sType,
557 allowed_struct_names, header_version, parameter_name.get_name().c_str());
558 } else {
559 std::string message =
560 "%s: %s chain includes a structure with unexpected VkStructureType %s; Allowed structures are "
561 "[%s]. ";
562 message += disclaimer;
563 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT,
564 VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid, message.c_str(), api_name,
565 parameter_name.get_name().c_str(), type_name.c_str(), allowed_struct_names,
566 header_version, parameter_name.get_name().c_str());
567 }
568 }
569 skip_call |= ValidatePnextStructContents(api_name, parameter_name, current);
570 }
571 current = reinterpret_cast<const GenericHeader *>(current->pNext);
572 }
573 }
574 }
575
576 return skip_call;
577 }
578
579 /**
580 * Validate a VkBool32 value.
581 *
582 * Generate a warning if a VkBool32 value is neither VK_TRUE nor VK_FALSE.
583 *
584 * @param apiName Name of API call being validated.
585 * @param parameterName Name of parameter being validated.
586 * @param value Boolean value to validate.
587 * @return Boolean value indicating that the call should be skipped.
588 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700589 bool validate_bool32(const char *apiName, const ParameterName &parameterName, VkBool32 value) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700590 bool skip_call = false;
591
592 if ((value != VK_TRUE) && (value != VK_FALSE)) {
593 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
594 kVUID_PVError_UnrecognizedValue, "%s: value of %s (%d) is neither VK_TRUE nor VK_FALSE", apiName,
595 parameterName.get_name().c_str(), value);
596 }
597
598 return skip_call;
599 }
600
601 /**
602 * Validate a Vulkan enumeration value.
603 *
604 * Generate a warning if an enumeration token value does not fall within the core enumeration
605 * begin and end token values, and was not added to the enumeration by an extension. Extension
606 * provided enumerations use the equation specified in Appendix C.10 of the Vulkan specification,
607 * with 1,000,000,000 as the base token value.
608 *
609 * @note This function does not expect to process enumerations defining bitmask flag bits.
610 *
611 * @param apiName Name of API call being validated.
612 * @param parameterName Name of parameter being validated.
613 * @param enumName Name of the enumeration being validated.
614 * @param valid_values The list of valid values for the enumeration.
615 * @param value Enumeration value to validate.
616 * @return Boolean value indicating that the call should be skipped.
617 */
618 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700619 bool validate_ranged_enum(const char *apiName, const ParameterName &parameterName, const char *enumName,
620 const std::vector<T> &valid_values, T value, const std::string &vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700621 bool skip = false;
622
623 if (std::find(valid_values.begin(), valid_values.end(), value) == valid_values.end()) {
624 skip |=
625 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
626 "%s: value of %s (%d) does not fall within the begin..end range of the core %s enumeration tokens and is "
627 "not an extension added token.",
628 apiName, parameterName.get_name().c_str(), value, enumName);
629 }
630
631 return skip;
632 }
633
634 /**
635 * Validate an array of Vulkan enumeration value.
636 *
637 * Process all enumeration token values in the specified array and generate a warning if a value
638 * does not fall within the core enumeration begin and end token values, and was not added to
639 * the enumeration by an extension. Extension provided enumerations use the equation specified
640 * in Appendix C.10 of the Vulkan specification, with 1,000,000,000 as the base token value.
641 *
642 * @note This function does not expect to process enumerations defining bitmask flag bits.
643 *
644 * @param apiName Name of API call being validated.
645 * @param countName Name of count parameter.
646 * @param arrayName Name of array parameter.
647 * @param enumName Name of the enumeration being validated.
648 * @param valid_values The list of valid values for the enumeration.
649 * @param count Number of enumeration values in the array.
650 * @param array Array of enumeration values to validate.
651 * @param countRequired The 'count' parameter may not be 0 when true.
652 * @param arrayRequired The 'array' parameter may not be NULL when true.
653 * @return Boolean value indicating that the call should be skipped.
654 */
655 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700656 bool validate_ranged_enum_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName,
657 const char *enumName, const std::vector<T> &valid_values, uint32_t count, const T *array,
658 bool countRequired, bool arrayRequired) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700659 bool skip_call = false;
660
661 if ((count == 0) || (array == NULL)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700662 skip_call |= validate_array(apiName, countName, arrayName, count, &array, countRequired, arrayRequired, kVUIDUndefined,
663 kVUIDUndefined);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700664 } else {
665 for (uint32_t i = 0; i < count; ++i) {
666 if (std::find(valid_values.begin(), valid_values.end(), array[i]) == valid_values.end()) {
667 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
668 kVUID_PVError_UnrecognizedValue,
669 "%s: value of %s[%d] (%d) does not fall within the begin..end range of the core %s "
670 "enumeration tokens and is not an extension added token",
671 apiName, arrayName.get_name().c_str(), i, array[i], enumName);
672 }
673 }
674 }
675
676 return skip_call;
677 }
678
679 /**
680 * Verify that a reserved VkFlags value is zero.
681 *
682 * Verify that the specified value is zero, to check VkFlags values that are reserved for
683 * future use.
684 *
685 * @param api_name Name of API call being validated.
686 * @param parameter_name Name of parameter being validated.
687 * @param value Value to validate.
688 * @return Boolean value indicating that the call should be skipped.
689 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700690 bool validate_reserved_flags(const char *api_name, const ParameterName &parameter_name, VkFlags value,
691 const std::string &vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700692 bool skip_call = false;
693
694 if (value != 0) {
695 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
696 "%s: parameter %s must be 0.", api_name, parameter_name.get_name().c_str());
697 }
698
699 return skip_call;
700 }
701
702 /**
703 * Validate a Vulkan bitmask value.
704 *
705 * Generate a warning if a value with a VkFlags derived type does not contain valid flag bits
706 * for that type.
707 *
708 * @param api_name Name of API call being validated.
709 * @param parameter_name Name of parameter being validated.
710 * @param flag_bits_name Name of the VkFlags type being validated.
711 * @param all_flags A bit mask combining all valid flag bits for the VkFlags type being validated.
712 * @param value VkFlags value to validate.
713 * @param flags_required The 'value' parameter may not be 0 when true.
714 * @param singleFlag The 'value' parameter may not contain more than one bit from all_flags.
715 * @return Boolean value indicating that the call should be skipped.
716 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700717 bool validate_flags(const char *api_name, const ParameterName &parameter_name, const char *flag_bits_name, VkFlags all_flags,
718 VkFlags value, bool flags_required, bool singleFlag, const std::string &vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700719 bool skip_call = false;
720
721 if (value == 0) {
722 if (flags_required) {
723 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
724 "%s: value of %s must not be 0.", api_name, parameter_name.get_name().c_str());
725 }
726 } else if ((value & (~all_flags)) != 0) {
727 skip_call |=
728 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
729 kVUID_PVError_UnrecognizedValue, "%s: value of %s contains flag bits that are not recognized members of %s",
730 api_name, parameter_name.get_name().c_str(), flag_bits_name);
731 } else if (singleFlag && (std::bitset<sizeof(VkFlags) * 8>(value).count() > 1)) {
732 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
733 kVUID_PVError_UnrecognizedValue,
734 "%s: value of %s contains multiple members of %s when only a single value is allowed", api_name,
735 parameter_name.get_name().c_str(), flag_bits_name);
736 }
737
738 return skip_call;
739 }
740
741 /**
742 * Validate an array of Vulkan bitmask values.
743 *
744 * Generate a warning if a value with a VkFlags derived type does not contain valid flag bits
745 * for that type.
746 *
747 * @param api_name Name of API call being validated.
748 * @param count_name Name of parameter being validated.
749 * @param array_name Name of parameter being validated.
750 * @param flag_bits_name Name of the VkFlags type being validated.
751 * @param all_flags A bitmask combining all valid flag bits for the VkFlags type being validated.
752 * @param count Number of VkFlags values in the array.
753 * @param array Array of VkFlags value to validate.
754 * @param count_required The 'count' parameter may not be 0 when true.
755 * @param array_required The 'array' parameter may not be NULL when true.
756 * @return Boolean value indicating that the call should be skipped.
757 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700758 bool validate_flags_array(const char *api_name, const ParameterName &count_name, const ParameterName &array_name,
759 const char *flag_bits_name, VkFlags all_flags, uint32_t count, const VkFlags *array,
760 bool count_required, bool array_required) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700761 bool skip_call = false;
762
763 if ((count == 0) || (array == NULL)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700764 skip_call |= validate_array(api_name, count_name, array_name, count, &array, count_required, array_required,
765 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700766 } else {
767 // Verify that all VkFlags values in the array
768 for (uint32_t i = 0; i < count; ++i) {
769 if (array[i] == 0) {
770 // Current XML registry logic for validity generation uses the array parameter's optional tag to determine if
771 // elements in the array are allowed be 0
772 if (array_required) {
773 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
774 kVUID_PVError_RequiredParameter, "%s: value of %s[%d] must not be 0", api_name,
775 array_name.get_name().c_str(), i);
776 }
777 } else if ((array[i] & (~all_flags)) != 0) {
778 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
779 kVUID_PVError_UnrecognizedValue,
780 "%s: value of %s[%d] contains flag bits that are not recognized members of %s", api_name,
781 array_name.get_name().c_str(), i, flag_bits_name);
782 }
783 }
784 }
785
786 return skip_call;
787 }
788
789 template <typename ExtensionState>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700790 bool validate_extension_reqs(const ExtensionState &extensions, const std::string &vuid, const char *extension_type,
791 const char *extension_name) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700792 bool skip = false;
793 if (!extension_name) {
794 return skip; // Robust to invalid char *
795 }
796 auto info = ExtensionState::get_info(extension_name);
797
798 if (!info.state) {
799 return skip; // Unknown extensions cannot be checked so report OK
800 }
801
802 // Check against the required list in the info
803 std::vector<const char *> missing;
804 for (const auto &req : info.requires) {
805 if (!(extensions.*(req.enabled))) {
806 missing.push_back(req.name);
807 }
808 }
809
810 // Report any missing requirements
811 if (missing.size()) {
812 std::string missing_joined_list = string_join(", ", missing);
813 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700814 HandleToUint64(instance), vuid, "Missing extension%s required by the %s extension %s: %s.",
815 ((missing.size() > 1) ? "s" : ""), extension_type, extension_name, missing_joined_list.c_str());
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700816 }
817 return skip;
818 }
819
820 enum RenderPassCreateVersion { RENDER_PASS_VERSION_1 = 0, RENDER_PASS_VERSION_2 = 1 };
821
822 template <typename RenderPassCreateInfoGeneric>
823 bool CreateRenderPassGeneric(VkDevice device, const RenderPassCreateInfoGeneric *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700824 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
825 RenderPassCreateVersion rp_version) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700826 bool skip = false;
827 uint32_t max_color_attachments = device_limits.maxColorAttachments;
828 bool use_rp2 = (rp_version == RENDER_PASS_VERSION_2);
829 const char *vuid;
830
831 for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) {
832 if (pCreateInfo->pAttachments[i].format == VK_FORMAT_UNDEFINED) {
833 std::stringstream ss;
834 ss << (use_rp2 ? "vkCreateRenderPass2KHR" : "vkCreateRenderPass") << ": pCreateInfo->pAttachments[" << i
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700835 << "].format is VK_FORMAT_UNDEFINED. ";
836 vuid =
837 use_rp2 ? "VUID-VkAttachmentDescription2KHR-format-parameter" : "VUID-VkAttachmentDescription-format-parameter";
838 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
839 "%s", ss.str().c_str());
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700840 }
841 if (pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_UNDEFINED ||
842 pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_PREINITIALIZED) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700843 vuid = use_rp2 ? "VUID-VkAttachmentDescription2KHR-finalLayout-03061"
844 : "VUID-VkAttachmentDescription-finalLayout-00843";
845 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
846 "pCreateInfo->pAttachments[%d].finalLayout must not be VK_IMAGE_LAYOUT_UNDEFINED or "
847 "VK_IMAGE_LAYOUT_PREINITIALIZED.",
848 i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700849 }
850 }
851
852 for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) {
853 if (pCreateInfo->pSubpasses[i].colorAttachmentCount > max_color_attachments) {
854 vuid = use_rp2 ? "VUID-VkSubpassDescription2KHR-colorAttachmentCount-03063"
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700855 : "VUID-VkSubpassDescription-colorAttachmentCount-00845";
856 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
857 "Cannot create a render pass with %d color attachments. Max is %d.",
858 pCreateInfo->pSubpasses[i].colorAttachmentCount, max_color_attachments);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700859 }
860 }
861 return skip;
862 }
863
864 template <typename T>
865 void RecordRenderPass(VkRenderPass renderPass, const T *pCreateInfo) {
866 auto &renderpass_state = renderpasses_states[renderPass];
867
868 for (uint32_t subpass = 0; subpass < pCreateInfo->subpassCount; ++subpass) {
869 bool uses_color = false;
870 for (uint32_t i = 0; i < pCreateInfo->pSubpasses[subpass].colorAttachmentCount && !uses_color; ++i)
871 if (pCreateInfo->pSubpasses[subpass].pColorAttachments[i].attachment != VK_ATTACHMENT_UNUSED) uses_color = true;
872
873 bool uses_depthstencil = false;
874 if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment)
875 if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED)
876 uses_depthstencil = true;
877
878 if (uses_color) renderpass_state.subpasses_using_color_attachment.insert(subpass);
879 if (uses_depthstencil) renderpass_state.subpasses_using_depthstencil_attachment.insert(subpass);
880 }
881 }
882
883 bool require_device_extension(bool flag, char const *function_name, char const *extension_name);
884
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700885 bool validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo);
886
887 bool validate_api_version(uint32_t api_version, uint32_t effective_api_version);
888
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700889 bool validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid, const char *validateString);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700890
891 bool ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order);
892
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700893 bool ValidateQueueFamilies(uint32_t queue_family_count, const uint32_t *queue_families, const char *cmd_name,
894 const char *array_parameter_name, const std::string &unique_error_code,
895 const std::string &valid_error_code, bool optional);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700896
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700897 bool ValidateDeviceQueueFamily(uint32_t queue_family, const char *cmd_name, const char *parameter_name,
898 const std::string &error_code, bool optional);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700899
900 bool OutputExtensionError(const std::string &api_name, const std::string &extension_name);
901
902 void PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
903 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass);
904 void PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
905 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass);
906 void PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator);
907 void PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
908 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
909
910 void PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
911 VkInstance *pInstance);
912
913 bool manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
914 const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool);
915
916 bool manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
917 VkInstance *pInstance);
918
919 bool manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
920 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
921
922 bool manual_PreCallValidateGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue);
923
924 bool manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
925 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer);
926
927 bool manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
928 const VkAllocationCallbacks *pAllocator, VkImage *pImage);
929
930 bool manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
931 const VkAllocationCallbacks *pAllocator, VkImageView *pView);
932
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700933 bool manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name, const char *param_name,
934 VkDebugReportObjectTypeEXT object_type, uint64_t object);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700935
936 bool manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
937 const VkGraphicsPipelineCreateInfo *pCreateInfos,
938 const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines);
939 bool manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
940 const VkComputePipelineCreateInfo *pCreateInfos,
941 const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines);
942
943 bool manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
944 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler);
945 bool manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700946 const VkAllocationCallbacks *pAllocator,
947 VkDescriptorSetLayout *pSetLayout);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700948
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700949 bool manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
950 const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount,
951 const VkCopyDescriptorSet *pDescriptorCopies);
952 ;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700953 bool manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
954 const VkDescriptorSet *pDescriptorSets);
955
956 bool manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
957 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass);
958
959 bool manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
960 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass);
961
962 bool manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
963 const VkCommandBuffer *pCommandBuffers);
964
965 bool manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo);
966
967 bool manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
968 const VkViewport *pViewports);
969
970 bool manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount,
971 const VkRect2D *pScissors);
972 bool manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth);
973
974 bool manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
975 uint32_t firstVertex, uint32_t firstInstance);
976
977 bool manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count,
978 uint32_t stride);
979
980 bool manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
981 uint32_t count, uint32_t stride);
982
983 bool manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,
984 VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount,
985 const VkImageCopy *pRegions);
986
987 bool manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,
988 VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount,
989 const VkImageBlit *pRegions, VkFilter filter);
990
991 bool manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage,
992 VkImageLayout dstImageLayout, uint32_t regionCount,
993 const VkBufferImageCopy *pRegions);
994
995 bool manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,
996 VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions);
997
998 bool manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset,
999 VkDeviceSize dataSize, const void *pData);
1000
1001 bool manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset,
1002 VkDeviceSize size, uint32_t data);
1003
1004 bool manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
1005 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain);
1006 bool manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo);
1007
1008#ifdef VK_USE_PLATFORM_WIN32_KHR
1009 bool manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
1010 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
1011#endif // VK_USE_PLATFORM_WIN32_KHR
1012
1013 bool manual_PreCallValidateDebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo);
1014
1015 bool manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
1016 const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool);
1017 bool manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY,
1018 uint32_t groupCountZ);
1019
1020 bool manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset);
1021
1022 bool manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY,
1023 uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY,
1024 uint32_t groupCountZ);
1025 bool manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor,
1026 uint32_t exclusiveScissorCount, const VkRect2D *pExclusiveScissors);
1027 bool manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
1028 uint32_t viewportCount,
1029 const VkShadingRatePaletteNV *pShadingRatePalettes);
1030
1031 bool manual_PreCallValidateCmdSetCoarseSampleOrderNV(VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType,
1032 uint32_t customSampleOrderCount,
1033 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders);
1034
1035 bool manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask);
1036 bool manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
1037 uint32_t drawCount, uint32_t stride);
1038
1039 bool manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
1040 VkBuffer countBuffer, VkDeviceSize countBufferOffset,
1041 uint32_t maxDrawCount, uint32_t stride);
1042 bool manual_PreCallValidateCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo,
1043 const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool);
1044
1045 bool manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName,
1046 uint32_t *pPropertyCount, VkExtensionProperties *pProperties);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06001047 bool manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
1048 const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001049#include "parameter_validation.h"
1050}; // Class StatelessValidation