blob: b609e223a39b3a4cbfe60adfad826d6287c8f4ca [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
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "parameter_name.h"
25#include "vk_typemap_helper.h"
26
27// Suppress unused warning on Linux
28#if defined(__GNUC__)
29#define DECORATE_UNUSED __attribute__((unused))
30#else
31#define DECORATE_UNUSED
32#endif
33
34static const char DECORATE_UNUSED *kVUID_PVError_NONE = "UNASSIGNED-GeneralParameterError-Info";
35static const char DECORATE_UNUSED *kVUID_PVError_InvalidUsage = "UNASSIGNED-GeneralParameterError-InvalidUsage";
36static const char DECORATE_UNUSED *kVUID_PVError_InvalidStructSType = "UNASSIGNED-GeneralParameterError-InvalidStructSType";
37static const char DECORATE_UNUSED *kVUID_PVError_InvalidStructPNext = "UNASSIGNED-GeneralParameterError-InvalidStructPNext";
38static const char DECORATE_UNUSED *kVUID_PVError_RequiredParameter = "UNASSIGNED-GeneralParameterError-RequiredParameter";
39static const char DECORATE_UNUSED *kVUID_PVError_ReservedParameter = "UNASSIGNED-GeneralParameterError-ReservedParameter";
40static const char DECORATE_UNUSED *kVUID_PVError_UnrecognizedValue = "UNASSIGNED-GeneralParameterError-UnrecognizedValue";
41static const char DECORATE_UNUSED *kVUID_PVError_DeviceLimit = "UNASSIGNED-GeneralParameterError-DeviceLimit";
42static const char DECORATE_UNUSED *kVUID_PVError_DeviceFeature = "UNASSIGNED-GeneralParameterError-DeviceFeature";
43static const char DECORATE_UNUSED *kVUID_PVError_FailureCode = "UNASSIGNED-GeneralParameterError-FailureCode";
44static const char DECORATE_UNUSED *kVUID_PVError_ExtensionNotEnabled = "UNASSIGNED-GeneralParameterError-ExtensionNotEnabled";
locke-lunargb1909cd2019-08-01 23:40:05 -060045static const char DECORATE_UNUSED *kVUID_PVPerfWarn_SuboptimalSwapchain = "UNASSIGNED-GeneralParameterPerfWarn-SuboptimalSwapchain";
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070046
47#undef DECORATE_UNUSED
48
49extern const uint32_t GeneratedVulkanHeaderVersion;
50
51extern const VkQueryPipelineStatisticFlags AllVkQueryPipelineStatisticFlagBits;
52extern const VkColorComponentFlags AllVkColorComponentFlagBits;
53extern const VkShaderStageFlags AllVkShaderStageFlagBits;
54extern const VkQueryControlFlags AllVkQueryControlFlagBits;
55extern const VkImageUsageFlags AllVkImageUsageFlagBits;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -060056extern const VkSampleCountFlags AllVkSampleCountFlagBits;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070057
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;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -060065extern const std::vector<VkFormat> AllVkFormatEnums;
66extern const std::vector<VkVertexInputRate> AllVkVertexInputRateEnums;
67extern const std::vector<VkPrimitiveTopology> AllVkPrimitiveTopologyEnums;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070068
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070069// String returned by string_VkStructureType for an unrecognized type.
70const std::string UnsupportedStructureTypeString = "Unhandled VkStructureType";
71
72// String returned by string_VkResult for an unrecognized type.
73const std::string UnsupportedResultString = "Unhandled VkResult";
74
75// The base value used when computing the offset for an enumeration token value that is added by an extension.
76// When validating enumeration tokens, any value >= to this value is considered to be provided by an extension.
77// See Appendix C.10 "Assigning Extension Token Values" from the Vulkan specification
78const uint32_t ExtEnumBaseValue = 1000000000;
79
80// The value of all VK_xxx_MAX_ENUM tokens
81const uint32_t MaxEnumValue = 0x7FFFFFFF;
82
83// Misc parameters of log_msg that are likely constant per command (or low frequency change)
84struct LogMiscParams {
85 VkDebugReportObjectTypeEXT objectType;
86 uint64_t srcObject;
87 const char *api_name;
88};
89
90class StatelessValidation : public ValidationObject {
91 public:
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070092 VkPhysicalDeviceLimits device_limits = {};
93 VkPhysicalDeviceFeatures physical_device_features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070094
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -070095 // Override chassis read/write locks for this validation object
96 // This override takes a deferred lock. i.e. it is not acquired.
97 std::unique_lock<std::mutex> write_lock() { return std::unique_lock<std::mutex>(validation_object_mutex, std::defer_lock); }
98
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070099 // Device extension properties -- storing properties gathered from VkPhysicalDeviceProperties2KHR::pNext chain
100 struct DeviceExtensionProperties {
101 VkPhysicalDeviceShadingRateImagePropertiesNV shading_rate_image_props;
102 VkPhysicalDeviceMeshShaderPropertiesNV mesh_shader_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700103 VkPhysicalDeviceRayTracingPropertiesNV ray_tracing_props;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700104 };
105 DeviceExtensionProperties phys_dev_ext_props = {};
106
107 struct SubpassesUsageStates {
108 std::unordered_set<uint32_t> subpasses_using_color_attachment;
109 std::unordered_set<uint32_t> subpasses_using_depthstencil_attachment;
110 };
111
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -0700112 // Though this validation object is predominantly statless, the Framebuffer checks are greatly simplified by creating and
113 // updating a map of the renderpass usage states, and these accesses need thread protection. Use a mutex separate from the
114 // parent object's to maintain that functionality.
115 std::mutex renderpass_map_mutex;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700116 std::unordered_map<VkRenderPass, SubpassesUsageStates> renderpasses_states;
117
118 // Constructor for stateles validation tracking
119 // StatelessValidation() : {}
120 /**
121 * Validate a minimum value.
122 *
123 * Verify that the specified value is greater than the specified lower bound.
124 *
125 * @param api_name Name of API call being validated.
126 * @param parameter_name Name of parameter being validated.
127 * @param value Value to validate.
128 * @param lower_bound Lower bound value to use for validation.
129 * @return Boolean value indicating that the call should be skipped.
130 */
131 template <typename T>
132 bool ValidateGreaterThan(const T value, const T lower_bound, const ParameterName &parameter_name, const std::string &vuid,
133 const LogMiscParams &misc) {
134 bool skip_call = false;
135
136 if (value <= lower_bound) {
137 std::ostringstream ss;
138 ss << misc.api_name << ": parameter " << parameter_name.get_name() << " (= " << value << ") is greater than "
139 << lower_bound;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700140 skip_call |=
141 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 -0700142 }
143
144 return skip_call;
145 }
146
147 template <typename T>
148 bool ValidateGreaterThanZero(const T value, const ParameterName &parameter_name, const std::string &vuid,
149 const LogMiscParams &misc) {
150 return ValidateGreaterThan(value, T{0}, parameter_name, vuid, misc);
151 }
152 /**
153 * Validate a required pointer.
154 *
155 * Verify that a required pointer is not NULL.
156 *
157 * @param apiName Name of API call being validated.
158 * @param parameterName Name of parameter being validated.
159 * @param value Pointer to validate.
160 * @return Boolean value indicating that the call should be skipped.
161 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700162 bool validate_required_pointer(const char *apiName, const ParameterName &parameterName, const void *value,
163 const std::string &vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700164 bool skip_call = false;
165
166 if (value == NULL) {
167 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
168 "%s: required parameter %s specified as NULL.", apiName, parameterName.get_name().c_str());
169 }
170
171 return skip_call;
172 }
173
174 /**
175 * Validate array count and pointer to array.
176 *
177 * Verify that required count and array parameters are not 0 or NULL. If the
178 * count parameter is not optional, verify that it is not 0. If the array
179 * parameter is NULL, and it is not optional, verify that count is 0.
180 *
181 * @param apiName Name of API call being validated.
182 * @param countName Name of count parameter.
183 * @param arrayName Name of array parameter.
184 * @param count Number of elements in the array.
185 * @param array Array to validate.
186 * @param countRequired The 'count' parameter may not be 0 when true.
187 * @param arrayRequired The 'array' parameter may not be NULL when true.
188 * @return Boolean value indicating that the call should be skipped.
189 */
190 template <typename T1, typename T2>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700191 bool validate_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName, T1 count,
Jeff Bolzfdd0d852019-02-03 21:55:12 -0600192 const T2 *array, bool countRequired, bool arrayRequired, const char *count_required_vuid,
193 const char *array_required_vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700194 bool skip_call = false;
195
196 // Count parameters not tagged as optional cannot be 0
197 if (countRequired && (count == 0)) {
198 skip_call |=
199 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, count_required_vuid,
200 "%s: parameter %s must be greater than 0.", apiName, countName.get_name().c_str());
201 }
202
203 // Array parameters not tagged as optional cannot be NULL, unless the count is 0
204 if (arrayRequired && (count != 0) && (*array == NULL)) {
205 skip_call |=
206 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, array_required_vuid,
207 "%s: required parameter %s specified as NULL.", apiName, arrayName.get_name().c_str());
208 }
209
210 return skip_call;
211 }
212
213 /**
214 * Validate pointer to array count and pointer to array.
215 *
216 * Verify that required count and array parameters are not NULL. If count
217 * is not NULL and its value is not optional, verify that it is not 0. If the
218 * array parameter is NULL, and it is not optional, verify that count is 0.
219 * The array parameter will typically be optional for this case (where count is
220 * a pointer), allowing the caller to retrieve the available count.
221 *
222 * @param apiName Name of API call being validated.
223 * @param countName Name of count parameter.
224 * @param arrayName Name of array parameter.
225 * @param count Pointer to the number of elements in the array.
226 * @param array Array to validate.
227 * @param countPtrRequired The 'count' parameter may not be NULL when true.
228 * @param countValueRequired The '*count' value may not be 0 when true.
229 * @param arrayRequired The 'array' parameter may not be NULL when true.
230 * @return Boolean value indicating that the call should be skipped.
231 */
232 template <typename T1, typename T2>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700233 bool validate_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName, const T1 *count,
234 const T2 *array, bool countPtrRequired, bool countValueRequired, bool arrayRequired,
Jeff Bolzfdd0d852019-02-03 21:55:12 -0600235 const char *count_required_vuid, const char *array_required_vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700236 bool skip_call = false;
237
238 if (count == NULL) {
239 if (countPtrRequired) {
240 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
241 kVUID_PVError_RequiredParameter, "%s: required parameter %s specified as NULL", apiName,
242 countName.get_name().c_str());
243 }
244 } else {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700245 skip_call |= validate_array(apiName, countName, arrayName, *array ? (*count) : 0, &array, countValueRequired,
246 arrayRequired, count_required_vuid, array_required_vuid);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700247 }
248
249 return skip_call;
250 }
251
252 /**
253 * Validate a pointer to a Vulkan structure.
254 *
255 * Verify that a required pointer to a structure is not NULL. If the pointer is
256 * not NULL, verify that each structure's sType field is set to the correct
257 * VkStructureType value.
258 *
259 * @param apiName Name of API call being validated.
260 * @param parameterName Name of struct parameter being validated.
261 * @param sTypeName Name of expected VkStructureType value.
262 * @param value Pointer to the struct to validate.
263 * @param sType VkStructureType for structure validation.
264 * @param required The parameter may not be NULL when true.
265 * @return Boolean value indicating that the call should be skipped.
266 */
267 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700268 bool validate_struct_type(const char *apiName, const ParameterName &parameterName, const char *sTypeName, const T *value,
Jeff Bolzfdd0d852019-02-03 21:55:12 -0600269 VkStructureType sType, bool required, const char *struct_vuid, const char *stype_vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700270 bool skip_call = false;
271
272 if (value == NULL) {
273 if (required) {
274 skip_call |=
275 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, struct_vuid,
276 "%s: required parameter %s specified as NULL", apiName, parameterName.get_name().c_str());
277 }
278 } else if (value->sType != sType) {
279 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, stype_vuid,
280 "%s: parameter %s->sType must be %s.", apiName, parameterName.get_name().c_str(), sTypeName);
281 }
282
283 return skip_call;
284 }
285
286 /**
287 * Validate an array of Vulkan structures
288 *
289 * Verify that required count and array parameters are not 0 or NULL. If
290 * the array contains 1 or more structures, verify that each structure's
291 * sType field is set to the correct VkStructureType value.
292 *
293 * @param apiName Name of API call being validated.
294 * @param countName Name of count parameter.
295 * @param arrayName Name of array parameter.
296 * @param sTypeName Name of expected VkStructureType value.
297 * @param count Number of elements in the array.
298 * @param array Array to validate.
299 * @param sType VkStructureType for structure validation.
300 * @param countRequired The 'count' parameter may not be 0 when true.
301 * @param arrayRequired The 'array' parameter may not be NULL when true.
302 * @return Boolean value indicating that the call should be skipped.
303 */
304 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700305 bool validate_struct_type_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName,
306 const char *sTypeName, uint32_t count, const T *array, VkStructureType sType,
Jasper St. Pierre6c98f8c2019-01-22 15:18:03 -0800307 bool countRequired, bool arrayRequired, const char *stype_vuid, const char *param_vuid,
308 const char *count_required_vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700309 bool skip_call = false;
310
311 if ((count == 0) || (array == NULL)) {
Jasper St. Pierre6c98f8c2019-01-22 15:18:03 -0800312 skip_call |= validate_array(apiName, countName, arrayName, count, &array, countRequired, arrayRequired,
313 count_required_vuid, param_vuid);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700314 } else {
315 // Verify that all structs in the array have the correct type
316 for (uint32_t i = 0; i < count; ++i) {
317 if (array[i].sType != sType) {
318 skip_call |=
319 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, stype_vuid,
320 "%s: parameter %s[%d].sType must be %s", apiName, arrayName.get_name().c_str(), i, sTypeName);
321 }
322 }
323 }
324
325 return skip_call;
326 }
327
328 /**
329 * Validate an array of Vulkan structures.
330 *
331 * Verify that required count and array parameters are not NULL. If count
332 * is not NULL and its value is not optional, verify that it is not 0.
333 * If the array contains 1 or more structures, verify that each structure's
334 * sType field is set to the correct VkStructureType value.
335 *
336 * @param apiName Name of API call being validated.
337 * @param countName Name of count parameter.
338 * @param arrayName Name of array parameter.
339 * @param sTypeName Name of expected VkStructureType value.
340 * @param count Pointer to the number of elements in the array.
341 * @param array Array to validate.
342 * @param sType VkStructureType for structure validation.
343 * @param countPtrRequired The 'count' parameter may not be NULL when true.
344 * @param countValueRequired The '*count' value may not be 0 when true.
345 * @param arrayRequired The 'array' parameter may not be NULL when true.
346 * @return Boolean value indicating that the call should be skipped.
347 */
348 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700349 bool validate_struct_type_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName,
350 const char *sTypeName, uint32_t *count, const T *array, VkStructureType sType,
Jeff Bolzfdd0d852019-02-03 21:55:12 -0600351 bool countPtrRequired, bool countValueRequired, bool arrayRequired, const char *stype_vuid,
Jasper St. Pierre6c98f8c2019-01-22 15:18:03 -0800352 const char *param_vuid, const char *count_required_vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700353 bool skip_call = false;
354
355 if (count == NULL) {
356 if (countPtrRequired) {
357 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
358 kVUID_PVError_RequiredParameter, "%s: required parameter %s specified as NULL", apiName,
359 countName.get_name().c_str());
360 }
361 } else {
362 skip_call |= validate_struct_type_array(apiName, countName, arrayName, sTypeName, (*count), array, sType,
Jasper St. Pierre6c98f8c2019-01-22 15:18:03 -0800363 countValueRequired, arrayRequired, stype_vuid, param_vuid, count_required_vuid);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700364 }
365
366 return skip_call;
367 }
368
369 /**
370 * Validate a Vulkan handle.
371 *
372 * Verify that the specified handle is not VK_NULL_HANDLE.
373 *
374 * @param api_name Name of API call being validated.
375 * @param parameter_name Name of struct parameter being validated.
376 * @param value Handle to validate.
377 * @return Boolean value indicating that the call should be skipped.
378 */
379 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700380 bool validate_required_handle(const char *api_name, const ParameterName &parameter_name, T value) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700381 bool skip_call = false;
382
383 if (value == VK_NULL_HANDLE) {
384 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
385 kVUID_PVError_RequiredParameter, "%s: required parameter %s specified as VK_NULL_HANDLE", api_name,
386 parameter_name.get_name().c_str());
387 }
388
389 return skip_call;
390 }
391
392 /**
393 * Validate an array of Vulkan handles.
394 *
395 * Verify that required count and array parameters are not NULL. If count
396 * is not NULL and its value is not optional, verify that it is not 0.
397 * If the array contains 1 or more handles, verify that no handle is set to
398 * VK_NULL_HANDLE.
399 *
400 * @note This function is only intended to validate arrays of handles when none
401 * of the handles are allowed to be VK_NULL_HANDLE. For arrays of handles
402 * that are allowed to contain VK_NULL_HANDLE, use validate_array() instead.
403 *
404 * @param api_name Name of API call being validated.
405 * @param count_name Name of count parameter.
406 * @param array_name Name of array parameter.
407 * @param count Number of elements in the array.
408 * @param array Array to validate.
409 * @param count_required The 'count' parameter may not be 0 when true.
410 * @param array_required The 'array' parameter may not be NULL when true.
411 * @return Boolean value indicating that the call should be skipped.
412 */
413 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700414 bool validate_handle_array(const char *api_name, const ParameterName &count_name, const ParameterName &array_name,
415 uint32_t count, const T *array, bool count_required, bool array_required) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700416 bool skip_call = false;
417
418 if ((count == 0) || (array == NULL)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700419 skip_call |= validate_array(api_name, count_name, array_name, count, &array, count_required, array_required,
420 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700421 } else {
422 // Verify that no handles in the array are VK_NULL_HANDLE
423 for (uint32_t i = 0; i < count; ++i) {
424 if (array[i] == VK_NULL_HANDLE) {
425 skip_call |=
426 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
427 kVUID_PVError_RequiredParameter, "%s: required parameter %s[%d] specified as VK_NULL_HANDLE",
428 api_name, array_name.get_name().c_str(), i);
429 }
430 }
431 }
432
433 return skip_call;
434 }
435
436 /**
437 * Validate string array count and content.
438 *
439 * Verify that required count and array parameters are not 0 or NULL. If the
440 * count parameter is not optional, verify that it is not 0. If the array
441 * parameter is NULL, and it is not optional, verify that count is 0. If the
442 * array parameter is not NULL, verify that none of the strings are NULL.
443 *
444 * @param apiName Name of API call being validated.
445 * @param countName Name of count parameter.
446 * @param arrayName Name of array parameter.
447 * @param count Number of strings in the array.
448 * @param array Array of strings to validate.
449 * @param countRequired The 'count' parameter may not be 0 when true.
450 * @param arrayRequired The 'array' parameter may not be NULL when true.
451 * @return Boolean value indicating that the call should be skipped.
452 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700453 bool validate_string_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName, uint32_t count,
Jeff Bolzfdd0d852019-02-03 21:55:12 -0600454 const char *const *array, bool countRequired, bool arrayRequired, const char *count_required_vuid,
455 const char *array_required_vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700456 bool skip_call = false;
457
458 if ((count == 0) || (array == NULL)) {
459 skip_call |= validate_array(apiName, countName, arrayName, count, &array, countRequired, arrayRequired,
460 count_required_vuid, array_required_vuid);
461 } else {
462 // Verify that strings in the array are not NULL
463 for (uint32_t i = 0; i < count; ++i) {
464 if (array[i] == NULL) {
465 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
466 kVUID_PVError_RequiredParameter, "%s: required parameter %s[%d] specified as NULL",
467 apiName, arrayName.get_name().c_str(), i);
468 }
469 }
470 }
471
472 return skip_call;
473 }
474
475 // Forward declaration for pNext validation
Lockefbdd1af2019-04-16 15:07:23 -0600476 bool ValidatePnextStructContents(const char *api_name, const ParameterName &parameter_name, const VkBaseOutStructure *header);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700477
478 /**
479 * Validate a structure's pNext member.
480 *
481 * Verify that the specified pNext value points to the head of a list of
482 * allowed extension structures. If no extension structures are allowed,
483 * verify that pNext is null.
484 *
485 * @param api_name Name of API call being validated.
486 * @param parameter_name Name of parameter being validated.
487 * @param allowed_struct_names Names of allowed structs.
488 * @param next Pointer to validate.
489 * @param allowed_type_count Total number of allowed structure types.
490 * @param allowed_types Array of structure types allowed for pNext.
491 * @param header_version Version of header defining the pNext validation rules.
492 * @return Boolean value indicating that the call should be skipped.
493 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700494 bool validate_struct_pnext(const char *api_name, const ParameterName &parameter_name, const char *allowed_struct_names,
495 const void *next, size_t allowed_type_count, const VkStructureType *allowed_types,
Jeff Bolzfdd0d852019-02-03 21:55:12 -0600496 uint32_t header_version, const char *vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700497 bool skip_call = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700498
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700499 // TODO: The valid pNext structure types are not recursive. Each structure has its own list of valid sTypes for pNext.
500 // Codegen a map of vectors containing the allowable pNext types for each struct and use that here -- also simplifies parms.
501 if (next != NULL) {
Jeff Bolzfdd0d852019-02-03 21:55:12 -0600502 std::unordered_set<const void *> cycle_check;
503 std::unordered_set<VkStructureType, std::hash<int>> unique_stype_check;
504
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600505 const char *disclaimer =
506 "This warning is based on the Valid Usage documentation for version %d of the Vulkan header. It is possible that "
507 "you "
508 "are "
509 "using a struct from a private extension or an extension that was added to a later version of the Vulkan header, "
510 "in "
511 "which "
512 "case your use of %s is perfectly valid but is not guaranteed to work correctly with validation enabled";
513
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700514 if (allowed_type_count == 0) {
515 std::string message = "%s: value of %s must be NULL. ";
516 message += disclaimer;
517 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
518 message.c_str(), api_name, parameter_name.get_name().c_str(), header_version,
519 parameter_name.get_name().c_str());
520 } else {
521 const VkStructureType *start = allowed_types;
522 const VkStructureType *end = allowed_types + allowed_type_count;
Lockefbdd1af2019-04-16 15:07:23 -0600523 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(next);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700524
525 cycle_check.insert(next);
526
527 while (current != NULL) {
528 if (((strncmp(api_name, "vkCreateInstance", strlen(api_name)) != 0) ||
529 (current->sType != VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO)) &&
530 ((strncmp(api_name, "vkCreateDevice", strlen(api_name)) != 0) ||
531 (current->sType != VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO))) {
532 if (cycle_check.find(current->pNext) != cycle_check.end()) {
533 std::string message = "%s: %s chain contains a cycle -- pNext pointer " PRIx64 " is repeated.";
534 skip_call |=
535 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
536 kVUID_PVError_InvalidStructPNext, message.c_str(), api_name,
537 parameter_name.get_name().c_str(), reinterpret_cast<uint64_t>(next));
538 break;
539 } else {
540 cycle_check.insert(current->pNext);
541 }
542
543 std::string type_name = string_VkStructureType(current->sType);
544 if (unique_stype_check.find(current->sType) != unique_stype_check.end()) {
545 std::string message = "%s: %s chain contains duplicate structure types: %s appears multiple times.";
546 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
547 VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, kVUID_PVError_InvalidStructPNext,
548 message.c_str(), api_name, parameter_name.get_name().c_str(), type_name.c_str());
549 } else {
550 unique_stype_check.insert(current->sType);
551 }
552
553 if (std::find(start, end, current->sType) == end) {
554 if (type_name == UnsupportedStructureTypeString) {
555 std::string message =
556 "%s: %s chain includes a structure with unknown VkStructureType (%d); Allowed structures are "
557 "[%s]. ";
558 message += disclaimer;
559 skip_call |=
560 log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
561 0, vuid, message.c_str(), api_name, parameter_name.get_name().c_str(), current->sType,
562 allowed_struct_names, header_version, parameter_name.get_name().c_str());
563 } else {
564 std::string message =
565 "%s: %s chain includes a structure with unexpected VkStructureType %s; Allowed structures are "
566 "[%s]. ";
567 message += disclaimer;
568 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT,
569 VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid, message.c_str(), api_name,
570 parameter_name.get_name().c_str(), type_name.c_str(), allowed_struct_names,
571 header_version, parameter_name.get_name().c_str());
572 }
573 }
574 skip_call |= ValidatePnextStructContents(api_name, parameter_name, current);
575 }
Lockefbdd1af2019-04-16 15:07:23 -0600576 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700577 }
578 }
579 }
580
581 return skip_call;
582 }
583
584 /**
585 * Validate a VkBool32 value.
586 *
587 * Generate a warning if a VkBool32 value is neither VK_TRUE nor VK_FALSE.
588 *
589 * @param apiName Name of API call being validated.
590 * @param parameterName Name of parameter being validated.
591 * @param value Boolean value to validate.
592 * @return Boolean value indicating that the call should be skipped.
593 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700594 bool validate_bool32(const char *apiName, const ParameterName &parameterName, VkBool32 value) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700595 bool skip_call = false;
596
597 if ((value != VK_TRUE) && (value != VK_FALSE)) {
598 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
599 kVUID_PVError_UnrecognizedValue, "%s: value of %s (%d) is neither VK_TRUE nor VK_FALSE", apiName,
600 parameterName.get_name().c_str(), value);
601 }
602
603 return skip_call;
604 }
605
606 /**
607 * Validate a Vulkan enumeration value.
608 *
609 * Generate a warning if an enumeration token value does not fall within the core enumeration
610 * begin and end token values, and was not added to the enumeration by an extension. Extension
611 * provided enumerations use the equation specified in Appendix C.10 of the Vulkan specification,
612 * with 1,000,000,000 as the base token value.
613 *
614 * @note This function does not expect to process enumerations defining bitmask flag bits.
615 *
616 * @param apiName Name of API call being validated.
617 * @param parameterName Name of parameter being validated.
618 * @param enumName Name of the enumeration being validated.
619 * @param valid_values The list of valid values for the enumeration.
620 * @param value Enumeration value to validate.
621 * @return Boolean value indicating that the call should be skipped.
622 */
623 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700624 bool validate_ranged_enum(const char *apiName, const ParameterName &parameterName, const char *enumName,
Jeff Bolzfdd0d852019-02-03 21:55:12 -0600625 const std::vector<T> &valid_values, T value, const char *vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700626 bool skip = false;
627
628 if (std::find(valid_values.begin(), valid_values.end(), value) == valid_values.end()) {
629 skip |=
630 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
631 "%s: value of %s (%d) does not fall within the begin..end range of the core %s enumeration tokens and is "
632 "not an extension added token.",
633 apiName, parameterName.get_name().c_str(), value, enumName);
634 }
635
636 return skip;
637 }
638
639 /**
640 * Validate an array of Vulkan enumeration value.
641 *
642 * Process all enumeration token values in the specified array and generate a warning if a value
643 * does not fall within the core enumeration begin and end token values, and was not added to
644 * the enumeration by an extension. Extension provided enumerations use the equation specified
645 * in Appendix C.10 of the Vulkan specification, with 1,000,000,000 as the base token value.
646 *
647 * @note This function does not expect to process enumerations defining bitmask flag bits.
648 *
649 * @param apiName Name of API call being validated.
650 * @param countName Name of count parameter.
651 * @param arrayName Name of array parameter.
652 * @param enumName Name of the enumeration being validated.
653 * @param valid_values The list of valid values for the enumeration.
654 * @param count Number of enumeration values in the array.
655 * @param array Array of enumeration values to validate.
656 * @param countRequired The 'count' parameter may not be 0 when true.
657 * @param arrayRequired The 'array' parameter may not be NULL when true.
658 * @return Boolean value indicating that the call should be skipped.
659 */
660 template <typename T>
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700661 bool validate_ranged_enum_array(const char *apiName, const ParameterName &countName, const ParameterName &arrayName,
662 const char *enumName, const std::vector<T> &valid_values, uint32_t count, const T *array,
663 bool countRequired, bool arrayRequired) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700664 bool skip_call = false;
665
666 if ((count == 0) || (array == NULL)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700667 skip_call |= validate_array(apiName, countName, arrayName, count, &array, countRequired, arrayRequired, kVUIDUndefined,
668 kVUIDUndefined);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700669 } else {
670 for (uint32_t i = 0; i < count; ++i) {
671 if (std::find(valid_values.begin(), valid_values.end(), array[i]) == valid_values.end()) {
672 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
673 kVUID_PVError_UnrecognizedValue,
674 "%s: value of %s[%d] (%d) does not fall within the begin..end range of the core %s "
675 "enumeration tokens and is not an extension added token",
676 apiName, arrayName.get_name().c_str(), i, array[i], enumName);
677 }
678 }
679 }
680
681 return skip_call;
682 }
683
684 /**
685 * Verify that a reserved VkFlags value is zero.
686 *
687 * Verify that the specified value is zero, to check VkFlags values that are reserved for
688 * future use.
689 *
690 * @param api_name Name of API call being validated.
691 * @param parameter_name Name of parameter being validated.
692 * @param value Value to validate.
693 * @return Boolean value indicating that the call should be skipped.
694 */
Jeff Bolzfdd0d852019-02-03 21:55:12 -0600695 bool validate_reserved_flags(const char *api_name, const ParameterName &parameter_name, VkFlags value, const char *vuid) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700696 bool skip_call = false;
697
698 if (value != 0) {
699 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
700 "%s: parameter %s must be 0.", api_name, parameter_name.get_name().c_str());
701 }
702
703 return skip_call;
704 }
705
Petr Kraus52758be2019-08-12 00:53:58 +0200706 enum FlagType { kRequiredFlags, kOptionalFlags, kRequiredSingleBit, kOptionalSingleBit };
707
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700708 /**
709 * Validate a Vulkan bitmask value.
710 *
711 * Generate a warning if a value with a VkFlags derived type does not contain valid flag bits
712 * for that type.
713 *
714 * @param api_name Name of API call being validated.
715 * @param parameter_name Name of parameter being validated.
716 * @param flag_bits_name Name of the VkFlags type being validated.
717 * @param all_flags A bit mask combining all valid flag bits for the VkFlags type being validated.
718 * @param value VkFlags value to validate.
Petr Kraus52758be2019-08-12 00:53:58 +0200719 * @param flag_type The type of flag, like optional, or single bit.
720 * @param vuid VUID used for flag that is outside defined bits (or has more than one bit for Bits type).
721 * @param flags_zero_vuid VUID used for non-optional Flags that are zero.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700722 * @return Boolean value indicating that the call should be skipped.
723 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700724 bool validate_flags(const char *api_name, const ParameterName &parameter_name, const char *flag_bits_name, VkFlags all_flags,
Petr Kraus52758be2019-08-12 00:53:58 +0200725 VkFlags value, const FlagType flag_type, const char *vuid, const char *flags_zero_vuid = nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700726 bool skip_call = false;
727
Petr Kraus52758be2019-08-12 00:53:58 +0200728 if ((value & ~all_flags) != 0) {
729 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
730 "%s: value of %s contains flag bits that are not recognized members of %s", api_name,
731 parameter_name.get_name().c_str(), flag_bits_name);
732 }
733
734 const bool required = flag_type == kRequiredFlags || flag_type == kRequiredSingleBit;
735 const char *zero_vuid = flag_type == kRequiredFlags ? flags_zero_vuid : vuid;
736 if (required && value == 0) {
737 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, zero_vuid,
738 "%s: value of %s must not be 0.", api_name, parameter_name.get_name().c_str());
739 }
740
741 const auto HasMaxOneBitSet = [](const VkFlags f) {
742 // Decrement flips bits from right upto first 1.
743 // Rest stays same, and if there was any other 1s &ded together they would be non-zero. QED
744 return f == 0 || !(f & (f - 1));
745 };
746
747 const bool is_bits_type = flag_type == kRequiredSingleBit || flag_type == kOptionalSingleBit;
748 if (is_bits_type && !HasMaxOneBitSet(value)) {
749 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700750 "%s: value of %s contains multiple members of %s when only a single value is allowed", api_name,
751 parameter_name.get_name().c_str(), flag_bits_name);
752 }
753
754 return skip_call;
755 }
756
757 /**
758 * Validate an array of Vulkan bitmask values.
759 *
760 * Generate a warning if a value with a VkFlags derived type does not contain valid flag bits
761 * for that type.
762 *
763 * @param api_name Name of API call being validated.
764 * @param count_name Name of parameter being validated.
765 * @param array_name Name of parameter being validated.
766 * @param flag_bits_name Name of the VkFlags type being validated.
767 * @param all_flags A bitmask combining all valid flag bits for the VkFlags type being validated.
768 * @param count Number of VkFlags values in the array.
769 * @param array Array of VkFlags value to validate.
770 * @param count_required The 'count' parameter may not be 0 when true.
771 * @param array_required The 'array' parameter may not be NULL when true.
772 * @return Boolean value indicating that the call should be skipped.
773 */
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700774 bool validate_flags_array(const char *api_name, const ParameterName &count_name, const ParameterName &array_name,
775 const char *flag_bits_name, VkFlags all_flags, uint32_t count, const VkFlags *array,
776 bool count_required, bool array_required) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700777 bool skip_call = false;
778
779 if ((count == 0) || (array == NULL)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700780 skip_call |= validate_array(api_name, count_name, array_name, count, &array, count_required, array_required,
781 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700782 } else {
783 // Verify that all VkFlags values in the array
784 for (uint32_t i = 0; i < count; ++i) {
785 if (array[i] == 0) {
786 // Current XML registry logic for validity generation uses the array parameter's optional tag to determine if
787 // elements in the array are allowed be 0
788 if (array_required) {
789 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
790 kVUID_PVError_RequiredParameter, "%s: value of %s[%d] must not be 0", api_name,
791 array_name.get_name().c_str(), i);
792 }
793 } else if ((array[i] & (~all_flags)) != 0) {
794 skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
795 kVUID_PVError_UnrecognizedValue,
796 "%s: value of %s[%d] contains flag bits that are not recognized members of %s", api_name,
797 array_name.get_name().c_str(), i, flag_bits_name);
798 }
799 }
800 }
801
802 return skip_call;
803 }
804
805 template <typename ExtensionState>
Jeff Bolzfdd0d852019-02-03 21:55:12 -0600806 bool validate_extension_reqs(const ExtensionState &extensions, const char *vuid, const char *extension_type,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700807 const char *extension_name) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700808 bool skip = false;
809 if (!extension_name) {
810 return skip; // Robust to invalid char *
811 }
812 auto info = ExtensionState::get_info(extension_name);
813
814 if (!info.state) {
815 return skip; // Unknown extensions cannot be checked so report OK
816 }
817
818 // Check against the required list in the info
819 std::vector<const char *> missing;
820 for (const auto &req : info.requires) {
821 if (!(extensions.*(req.enabled))) {
822 missing.push_back(req.name);
823 }
824 }
825
826 // Report any missing requirements
827 if (missing.size()) {
828 std::string missing_joined_list = string_join(", ", missing);
829 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 -0700830 HandleToUint64(instance), vuid, "Missing extension%s required by the %s extension %s: %s.",
831 ((missing.size() > 1) ? "s" : ""), extension_type, extension_name, missing_joined_list.c_str());
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700832 }
833 return skip;
834 }
835
836 enum RenderPassCreateVersion { RENDER_PASS_VERSION_1 = 0, RENDER_PASS_VERSION_2 = 1 };
837
838 template <typename RenderPassCreateInfoGeneric>
Petr Kraus3e52eba2019-07-10 01:24:10 +0200839 bool ValidateSubpassGraphicsFlags(const debug_report_data *report_data, const RenderPassCreateInfoGeneric *pCreateInfo,
840 uint32_t dependency_index, uint32_t subpass, VkPipelineStageFlags stages, const char *vuid,
841 const char *target) {
Petr Krausdfd26442019-08-13 03:25:19 +0200842 const VkPipelineStageFlags kCommonStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT | VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
843 const VkPipelineStageFlags kFramebufferStages =
844 VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
845 VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
846 const VkPipelineStageFlags kPrimitiveShadingPipelineStages =
847 kCommonStages | VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT | VK_PIPELINE_STAGE_VERTEX_INPUT_BIT |
Petr Kraus3e52eba2019-07-10 01:24:10 +0200848 VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT |
849 VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT |
Petr Krausdfd26442019-08-13 03:25:19 +0200850 VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT | VK_PIPELINE_STAGE_SHADING_RATE_IMAGE_BIT_NV | kFramebufferStages;
851 const VkPipelineStageFlags kMeshShadingPipelineStages =
852 kCommonStages | VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT | VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV |
853 VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV | VK_PIPELINE_STAGE_SHADING_RATE_IMAGE_BIT_NV | kFramebufferStages;
854 const VkPipelineStageFlags kFragmentDensityStages = VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT;
855 const VkPipelineStageFlags kConditionalRenderingStages = VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT;
856 const VkPipelineStageFlags kCommandProcessingPipelineStages = kCommonStages | VK_PIPELINE_STAGE_COMMAND_PROCESS_BIT_NVX;
857
858 const VkPipelineStageFlags kGraphicsStages = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT | kPrimitiveShadingPipelineStages |
859 kMeshShadingPipelineStages | kFragmentDensityStages |
860 kConditionalRenderingStages | kCommandProcessingPipelineStages;
861
862 const VkPipelineStageFlags kRayTracingPipelineStages = kCommonStages | VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_NV;
863 const VkPipelineStageFlags kRayTracingAccellerationStructOpsStages =
864 kCommonStages | VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_NV;
865 const VkPipelineStageFlags kRayTracingStages = kCommonStages | kRayTracingPipelineStages |
866 kRayTracingAccellerationStructOpsStages | kFragmentDensityStages |
867 kConditionalRenderingStages | kCommandProcessingPipelineStages;
Petr Kraus3e52eba2019-07-10 01:24:10 +0200868
869 bool skip = false;
Petr Krausdfd26442019-08-13 03:25:19 +0200870
871 const auto IsPipeline = [pCreateInfo](uint32_t subpass, const VkPipelineBindPoint stage) {
Petr Kraus3e52eba2019-07-10 01:24:10 +0200872 if (subpass == VK_SUBPASS_EXTERNAL)
873 return false;
874 else
Petr Krausdfd26442019-08-13 03:25:19 +0200875 return pCreateInfo->pSubpasses[subpass].pipelineBindPoint == stage;
Petr Kraus3e52eba2019-07-10 01:24:10 +0200876 };
877
Petr Krausdfd26442019-08-13 03:25:19 +0200878 const bool is_all_graphics_stages = (stages & ~kGraphicsStages) == 0;
879 if (IsPipeline(subpass, VK_PIPELINE_BIND_POINT_GRAPHICS) && !is_all_graphics_stages) {
Petr Kraus3e52eba2019-07-10 01:24:10 +0200880 skip |=
881 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, 0, vuid,
882 "Dependency pDependencies[%" PRIu32
883 "] specifies a %sStageMask that contains stages (%s) that are not part "
884 "of the Graphics pipeline, as specified by the %sSubpass (= %" PRIu32 ") in pipelineBindPoint.",
885 dependency_index, target, string_VkPipelineStageFlags(stages & ~kGraphicsStages).c_str(), target, subpass);
886 }
887
Petr Krausdfd26442019-08-13 03:25:19 +0200888 // TODO: Raytracing also allowed here? See https://github.com/KhronosGroup/Vulkan-Docs/issues/1021
889 // There's no harm in validating it even if not sure, I think...
890 const bool is_all_raytracing_stages = (stages & ~kRayTracingStages) == 0;
891 if (IsPipeline(subpass, VK_PIPELINE_BIND_POINT_RAY_TRACING_NV) && !is_all_raytracing_stages) {
892 skip |=
893 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, 0, vuid,
894 "Dependency pDependencies[%" PRIu32
895 "] specifies a %sStageMask that contains stages (%s) that are not part "
896 "of the Ray Tracing pipeline, as specified by the %sSubpass (= %" PRIu32 ") in pipelineBindPoint.",
897 dependency_index, target, string_VkPipelineStageFlags(stages & ~kGraphicsStages).c_str(), target, subpass);
898 }
899
Petr Kraus3e52eba2019-07-10 01:24:10 +0200900 return skip;
901 };
902
903 template <typename RenderPassCreateInfoGeneric>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700904 bool CreateRenderPassGeneric(VkDevice device, const RenderPassCreateInfoGeneric *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700905 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
906 RenderPassCreateVersion rp_version) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700907 bool skip = false;
908 uint32_t max_color_attachments = device_limits.maxColorAttachments;
909 bool use_rp2 = (rp_version == RENDER_PASS_VERSION_2);
910 const char *vuid;
911
912 for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) {
913 if (pCreateInfo->pAttachments[i].format == VK_FORMAT_UNDEFINED) {
914 std::stringstream ss;
915 ss << (use_rp2 ? "vkCreateRenderPass2KHR" : "vkCreateRenderPass") << ": pCreateInfo->pAttachments[" << i
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700916 << "].format is VK_FORMAT_UNDEFINED. ";
917 vuid =
918 use_rp2 ? "VUID-VkAttachmentDescription2KHR-format-parameter" : "VUID-VkAttachmentDescription-format-parameter";
919 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
920 "%s", ss.str().c_str());
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700921 }
922 if (pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_UNDEFINED ||
923 pCreateInfo->pAttachments[i].finalLayout == VK_IMAGE_LAYOUT_PREINITIALIZED) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700924 vuid = use_rp2 ? "VUID-VkAttachmentDescription2KHR-finalLayout-03061"
925 : "VUID-VkAttachmentDescription-finalLayout-00843";
926 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
927 "pCreateInfo->pAttachments[%d].finalLayout must not be VK_IMAGE_LAYOUT_UNDEFINED or "
928 "VK_IMAGE_LAYOUT_PREINITIALIZED.",
929 i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700930 }
931 }
932
933 for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) {
934 if (pCreateInfo->pSubpasses[i].colorAttachmentCount > max_color_attachments) {
935 vuid = use_rp2 ? "VUID-VkSubpassDescription2KHR-colorAttachmentCount-03063"
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700936 : "VUID-VkSubpassDescription-colorAttachmentCount-00845";
937 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
938 "Cannot create a render pass with %d color attachments. Max is %d.",
939 pCreateInfo->pSubpasses[i].colorAttachmentCount, max_color_attachments);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700940 }
941 }
Petr Kraus3e52eba2019-07-10 01:24:10 +0200942
943 for (uint32_t i = 0; i < pCreateInfo->dependencyCount; ++i) {
944 const auto &dependency = pCreateInfo->pDependencies[i];
945
946 // Spec currently only supports Graphics pipeline in render pass -- so only that pipeline is currently checked
947 vuid =
948 use_rp2 ? "VUID-VkRenderPassCreateInfo2KHR-pDependencies-03054" : "VUID-VkRenderPassCreateInfo-pDependencies-00837";
949 skip |= ValidateSubpassGraphicsFlags(report_data, pCreateInfo, i, dependency.srcSubpass, dependency.srcStageMask, vuid,
950 "src");
951
952 vuid =
953 use_rp2 ? "VUID-VkRenderPassCreateInfo2KHR-pDependencies-03055" : "VUID-VkRenderPassCreateInfo-pDependencies-00838";
954 skip |= ValidateSubpassGraphicsFlags(report_data, pCreateInfo, i, dependency.dstSubpass, dependency.dstStageMask, vuid,
955 "dst");
956 }
957
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700958 return skip;
959 }
960
961 template <typename T>
962 void RecordRenderPass(VkRenderPass renderPass, const T *pCreateInfo) {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -0700963 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700964 auto &renderpass_state = renderpasses_states[renderPass];
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -0700965 lock.unlock();
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700966
967 for (uint32_t subpass = 0; subpass < pCreateInfo->subpassCount; ++subpass) {
968 bool uses_color = false;
969 for (uint32_t i = 0; i < pCreateInfo->pSubpasses[subpass].colorAttachmentCount && !uses_color; ++i)
970 if (pCreateInfo->pSubpasses[subpass].pColorAttachments[i].attachment != VK_ATTACHMENT_UNUSED) uses_color = true;
971
972 bool uses_depthstencil = false;
973 if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment)
974 if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED)
975 uses_depthstencil = true;
976
977 if (uses_color) renderpass_state.subpasses_using_color_attachment.insert(subpass);
978 if (uses_depthstencil) renderpass_state.subpasses_using_depthstencil_attachment.insert(subpass);
979 }
980 }
981
982 bool require_device_extension(bool flag, char const *function_name, char const *extension_name);
983
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700984 bool validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo);
985
986 bool validate_api_version(uint32_t api_version, uint32_t effective_api_version);
987
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700988 bool validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid, const char *validateString);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700989
990 bool ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order);
991
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700992 bool ValidateQueueFamilies(uint32_t queue_family_count, const uint32_t *queue_families, const char *cmd_name,
993 const char *array_parameter_name, const std::string &unique_error_code,
994 const std::string &valid_error_code, bool optional);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700995
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700996 bool ValidateDeviceQueueFamily(uint32_t queue_family, const char *cmd_name, const char *parameter_name,
997 const std::string &error_code, bool optional);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700998
Jason Macnak192fa0e2019-07-26 15:07:16 -0700999 bool ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles, VkDebugReportObjectTypeEXT object_type,
1000 uint64_t object_handle, const char *func_name) const;
1001 bool ValidateGeometryAABBNV(const VkGeometryAABBNV &geometry, VkDebugReportObjectTypeEXT object_type, uint64_t object_handle,
1002 const char *func_name) const;
1003 bool ValidateGeometryNV(const VkGeometryNV &geometry, VkDebugReportObjectTypeEXT object_type, uint64_t object_handle,
1004 const char *func_name) const;
1005 bool ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info, VkDebugReportObjectTypeEXT object_type,
1006 uint64_t object_handle, const char *func_nam) const;
Jason Macnak5c954952019-07-09 15:46:12 -07001007
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001008 bool OutputExtensionError(const std::string &api_name, const std::string &extension_name);
1009
1010 void PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07001011 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, VkResult result);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001012 void PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07001013 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, VkResult result);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001014 void PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator);
1015 void PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07001016 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001017
1018 void PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07001019 VkInstance *pInstance, VkResult result);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001020
locke-lunargb1909cd2019-08-01 23:40:05 -06001021 void PostCallRecordQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo, VkResult result);
1022
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001023 bool manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
1024 const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool);
1025
1026 bool manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
1027 VkInstance *pInstance);
1028
1029 bool manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
1030 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
1031
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001032 bool manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
1033 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer);
1034
1035 bool manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
1036 const VkAllocationCallbacks *pAllocator, VkImage *pImage);
1037
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001038 bool manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name, const ParameterName &parameter_name,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001039 VkDebugReportObjectTypeEXT object_type, uint64_t object);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001040
1041 bool manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
1042 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1043 const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines);
1044 bool manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
1045 const VkComputePipelineCreateInfo *pCreateInfos,
1046 const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines);
1047
1048 bool manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
1049 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler);
1050 bool manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001051 const VkAllocationCallbacks *pAllocator,
1052 VkDescriptorSetLayout *pSetLayout);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001053
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001054 bool manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
1055 const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount,
1056 const VkCopyDescriptorSet *pDescriptorCopies);
Jason Macnak5c954952019-07-09 15:46:12 -07001057
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001058 bool manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
1059 const VkDescriptorSet *pDescriptorSets);
1060
1061 bool manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
1062 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass);
1063
1064 bool manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
1065 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass);
1066
1067 bool manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
1068 const VkCommandBuffer *pCommandBuffers);
1069
1070 bool manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo);
1071
1072 bool manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
1073 const VkViewport *pViewports);
1074
1075 bool manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount,
1076 const VkRect2D *pScissors);
1077 bool manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth);
1078
1079 bool manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
1080 uint32_t firstVertex, uint32_t firstInstance);
1081
1082 bool manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count,
1083 uint32_t stride);
1084
1085 bool manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
1086 uint32_t count, uint32_t stride);
1087
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06001088 bool manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
1089 const VkClearAttachment *pAttachments, uint32_t rectCount,
1090 const VkClearRect *pRects);
1091
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001092 bool manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,
1093 VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount,
1094 const VkImageCopy *pRegions);
1095
1096 bool manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,
1097 VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount,
1098 const VkImageBlit *pRegions, VkFilter filter);
1099
1100 bool manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage,
1101 VkImageLayout dstImageLayout, uint32_t regionCount,
1102 const VkBufferImageCopy *pRegions);
1103
1104 bool manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,
1105 VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions);
1106
1107 bool manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset,
1108 VkDeviceSize dataSize, const void *pData);
1109
1110 bool manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset,
1111 VkDeviceSize size, uint32_t data);
1112
1113 bool manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
1114 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain);
1115 bool manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo);
1116
1117#ifdef VK_USE_PLATFORM_WIN32_KHR
1118 bool manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
1119 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
1120#endif // VK_USE_PLATFORM_WIN32_KHR
1121
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001122 bool manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
1123 const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool);
1124 bool manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY,
1125 uint32_t groupCountZ);
1126
1127 bool manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset);
1128
1129 bool manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY,
1130 uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY,
1131 uint32_t groupCountZ);
1132 bool manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor,
1133 uint32_t exclusiveScissorCount, const VkRect2D *pExclusiveScissors);
1134 bool manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
1135 uint32_t viewportCount,
1136 const VkShadingRatePaletteNV *pShadingRatePalettes);
1137
1138 bool manual_PreCallValidateCmdSetCoarseSampleOrderNV(VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType,
1139 uint32_t customSampleOrderCount,
1140 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders);
1141
1142 bool manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask);
1143 bool manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
1144 uint32_t drawCount, uint32_t stride);
1145
1146 bool manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
1147 VkBuffer countBuffer, VkDeviceSize countBufferOffset,
1148 uint32_t maxDrawCount, uint32_t stride);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001149
1150 bool manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName,
1151 uint32_t *pPropertyCount, VkExtensionProperties *pProperties);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06001152 bool manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
1153 const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory);
Ricardo Garciaa4935972019-02-21 17:43:18 +01001154
1155 bool manual_PreCallValidateCreateAccelerationStructureNV(VkDevice device,
1156 const VkAccelerationStructureCreateInfoNV *pCreateInfo,
1157 const VkAllocationCallbacks *pAllocator,
1158 VkAccelerationStructureNV *pAccelerationStructure);
Jason Macnak5c954952019-07-09 15:46:12 -07001159 bool manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
1160 const VkAccelerationStructureInfoNV *pInfo, VkBuffer instanceData,
1161 VkDeviceSize instanceOffset, VkBool32 update,
1162 VkAccelerationStructureNV dst, VkAccelerationStructureNV src,
1163 VkBuffer scratch, VkDeviceSize scratchOffset);
1164 bool manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device, VkAccelerationStructureNV accelerationStructure,
1165 size_t dataSize, void *pData);
Peter Chen85366392019-05-14 15:20:11 -04001166 bool manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
1167 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
1168 const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines);
Mike Schuchardt21638df2019-03-16 10:52:02 -07001169
1170#ifdef VK_USE_PLATFORM_WIN32_KHR
1171 bool PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
1172 VkDeviceGroupPresentModeFlagsKHR *pModes);
1173#endif // VK_USE_PLATFORM_WIN32_KHR
Tobias Hectorebb855f2019-07-23 12:17:33 +01001174
1175 bool manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
1176 const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer);
1177
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001178#include "parameter_validation.h"
1179}; // Class StatelessValidation