Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2016 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2016 Valve Corporation |
| 3 | * Copyright (c) 2015-2016 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2016 Google Inc. |
| 5 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 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 |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 9 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 11 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 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. |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 17 | * |
| 18 | * Author: Dustin Graves <dustin@lunarg.com> |
| 19 | */ |
| 20 | |
Mark Lobodzinski | 739391a | 2016-03-17 15:08:18 -0600 | [diff] [blame] | 21 | #ifndef PARAMETER_VALIDATION_UTILS_H |
| 22 | #define PARAMETER_VALIDATION_UTILS_H |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 23 | |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 24 | #include <algorithm> |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 25 | #include <cstdlib> |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 26 | #include <string> |
Mike Schuchardt | 47619c8 | 2017-05-31 09:14:22 -0600 | [diff] [blame^] | 27 | #include <bitset> |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 28 | |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 29 | #include "vulkan/vulkan.h" |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 30 | #include "vk_enum_string_helper.h" |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 31 | #include "vk_layer_logging.h" |
Karl Schultz | a9ef1e5 | 2016-10-06 17:53:48 -0600 | [diff] [blame] | 32 | #include "vk_validation_error_messages.h" |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 33 | |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 34 | #include "parameter_name.h" |
| 35 | |
Dustin Graves | b83fc2d | 2016-05-04 12:56:08 -0600 | [diff] [blame] | 36 | namespace parameter_validation { |
| 37 | |
Dustin Graves | f233e50 | 2016-05-05 13:44:21 -0600 | [diff] [blame] | 38 | enum ErrorCode { |
Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 39 | NONE, // Used for INFO & other non-error messages |
| 40 | INVALID_USAGE, // The value of a parameter is not consistent |
| 41 | // with the valid usage criteria defined in |
| 42 | // the Vulkan specification. |
| 43 | INVALID_STRUCT_STYPE, // The sType field of a Vulkan structure does |
| 44 | // not contain the value expected for a structure |
| 45 | // of that type. |
| 46 | INVALID_STRUCT_PNEXT, // The pNext field of a Vulkan structure references |
| 47 | // a value that is not compatible with a structure of |
| 48 | // that type or is not NULL when a structure of that |
| 49 | // type has no compatible pNext values. |
| 50 | REQUIRED_PARAMETER, // A required parameter was specified as 0 or NULL. |
| 51 | RESERVED_PARAMETER, // A parameter reserved for future use was not |
| 52 | // specified as 0 or NULL. |
| 53 | UNRECOGNIZED_VALUE, // A Vulkan enumeration, VkFlags, or VkBool32 parameter |
| 54 | // contains a value that is not recognized as valid for |
| 55 | // that type. |
| 56 | DEVICE_LIMIT, // A specified parameter exceeds the limits returned |
| 57 | // by the physical device |
| 58 | DEVICE_FEATURE, // Use of a requested feature is not supported by |
| 59 | // the device |
| 60 | FAILURE_RETURN_CODE, // A Vulkan return code indicating a failure condition |
| 61 | // was encountered. |
| 62 | EXTENSION_NOT_ENABLED, // An extension entrypoint was called, but the required |
| 63 | // extension was not enabled at CreateInstance or |
| 64 | // CreateDevice time. |
Dustin Graves | f233e50 | 2016-05-05 13:44:21 -0600 | [diff] [blame] | 65 | }; |
| 66 | |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 67 | struct GenericHeader { |
| 68 | VkStructureType sType; |
| 69 | const void *pNext; |
| 70 | }; |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 71 | |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 72 | // Layer name string to be logged with validation messages. |
Dustin Graves | b83fc2d | 2016-05-04 12:56:08 -0600 | [diff] [blame] | 73 | const char LayerName[] = "ParameterValidation"; |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 74 | |
| 75 | // String returned by string_VkStructureType for an unrecognized type. |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 76 | const std::string UnsupportedStructureTypeString = "Unhandled VkStructureType"; |
| 77 | |
Dustin Graves | ca7aa7c | 2016-03-25 15:13:28 -0600 | [diff] [blame] | 78 | // String returned by string_VkResult for an unrecognized type. |
| 79 | const std::string UnsupportedResultString = "Unhandled VkResult"; |
| 80 | |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 81 | // The base value used when computing the offset for an enumeration token value that is added by an extension. |
| 82 | // When validating enumeration tokens, any value >= to this value is considered to be provided by an extension. |
| 83 | // See Appendix C.10 "Assigning Extension Token Values" from the Vulkan specification |
| 84 | const uint32_t ExtEnumBaseValue = 1000000000; |
| 85 | |
Cort Stratton | edbe9b8 | 2017-05-16 07:38:35 -0700 | [diff] [blame] | 86 | // The value of all VK_xxx_MAX_ENUM tokens |
| 87 | const uint32_t MaxEnumValue = 0x7FFFFFFF; |
| 88 | |
Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 89 | template <typename T> |
| 90 | bool is_extension_added_token(T value) { |
Cort Stratton | edbe9b8 | 2017-05-16 07:38:35 -0700 | [diff] [blame] | 91 | return (value != MaxEnumValue) && (static_cast<uint32_t>(std::abs(static_cast<int32_t>(value))) >= ExtEnumBaseValue); |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | // VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE token is a special case that was converted from a core token to an |
| 95 | // extension added token. Its original value was intentionally preserved after the conversion, so it does not use |
| 96 | // the base value that other extension added tokens use, and it does not fall within the enum's begin/end range. |
Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 97 | template <> |
| 98 | bool is_extension_added_token(VkSamplerAddressMode value) { |
Cort Stratton | edbe9b8 | 2017-05-16 07:38:35 -0700 | [diff] [blame] | 99 | bool result = is_extension_added_token(static_cast<uint32_t>(value)); |
| 100 | return result || (value == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE); |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 101 | } |
| 102 | |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 103 | /** |
Dustin Graves | f8032f2 | 2016-05-11 18:31:44 -0600 | [diff] [blame] | 104 | * Validate a minimum value. |
| 105 | * |
| 106 | * Verify that the specified value is greater than the specified lower bound. |
| 107 | * |
| 108 | * @param report_data debug_report_data object for routing validation messages. |
| 109 | * @param api_name Name of API call being validated. |
| 110 | * @param parameter_name Name of parameter being validated. |
| 111 | * @param value Value to validate. |
| 112 | * @param lower_bound Lower bound value to use for validation. |
| 113 | * @return Boolean value indicating that the call should be skipped. |
| 114 | */ |
| 115 | template <typename T> |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 116 | bool ValidateGreaterThan(debug_report_data *report_data, const char *api_name, const ParameterName ¶meter_name, T value, |
| 117 | T lower_bound) { |
Dustin Graves | f8032f2 | 2016-05-11 18:31:44 -0600 | [diff] [blame] | 118 | bool skip_call = false; |
| 119 | |
| 120 | if (value <= lower_bound) { |
Mark Lobodzinski | eb9e73f | 2017-04-13 10:06:48 -0600 | [diff] [blame] | 121 | skip_call |= |
| 122 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, 1, LayerName, |
| 123 | "%s: parameter %s must be greater than %d", api_name, parameter_name.get_name().c_str(), lower_bound); |
Dustin Graves | f8032f2 | 2016-05-11 18:31:44 -0600 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | return skip_call; |
| 127 | } |
| 128 | |
| 129 | /** |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 130 | * Validate a required pointer. |
| 131 | * |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 132 | * Verify that a required pointer is not NULL. |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 133 | * |
| 134 | * @param report_data debug_report_data object for routing validation messages. |
| 135 | * @param apiName Name of API call being validated. |
| 136 | * @param parameterName Name of parameter being validated. |
| 137 | * @param value Pointer to validate. |
| 138 | * @return Boolean value indicating that the call should be skipped. |
| 139 | */ |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 140 | static bool validate_required_pointer(debug_report_data *report_data, const char *apiName, const ParameterName ¶meterName, |
Dustin Graves | 080069b | 2016-04-05 13:48:15 -0600 | [diff] [blame] | 141 | const void *value) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 142 | bool skip_call = false; |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 143 | |
| 144 | if (value == NULL) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 145 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 146 | REQUIRED_PARAMETER, LayerName, "%s: required parameter %s specified as NULL", apiName, |
| 147 | parameterName.get_name().c_str()); |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 150 | return skip_call; |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Validate array count and pointer to array. |
| 155 | * |
Dustin Graves | 58d114b | 2016-03-08 14:42:59 -0700 | [diff] [blame] | 156 | * Verify that required count and array parameters are not 0 or NULL. If the |
| 157 | * count parameter is not optional, verify that it is not 0. If the array |
| 158 | * parameter is NULL, and it is not optional, verify that count is 0. |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 159 | * |
| 160 | * @param report_data debug_report_data object for routing validation messages. |
| 161 | * @param apiName Name of API call being validated. |
| 162 | * @param countName Name of count parameter. |
| 163 | * @param arrayName Name of array parameter. |
| 164 | * @param count Number of elements in the array. |
| 165 | * @param array Array to validate. |
| 166 | * @param countRequired The 'count' parameter may not be 0 when true. |
| 167 | * @param arrayRequired The 'array' parameter may not be NULL when true. |
| 168 | * @return Boolean value indicating that the call should be skipped. |
| 169 | */ |
| 170 | template <typename T> |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 171 | bool validate_array(debug_report_data *report_data, const char *apiName, const ParameterName &countName, |
| 172 | const ParameterName &arrayName, T count, const void *array, bool countRequired, bool arrayRequired) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 173 | bool skip_call = false; |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 174 | |
| 175 | // Count parameters not tagged as optional cannot be 0 |
Józef Kucia | 20bb8fb | 2016-09-23 12:45:04 +0200 | [diff] [blame] | 176 | if (countRequired && (count == 0)) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 177 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
Mark Lobodzinski | 729a8d3 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 178 | REQUIRED_PARAMETER, LayerName, "%s: parameter %s must be greater than 0", apiName, |
| 179 | countName.get_name().c_str()); |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Dustin Graves | 0d15c6e | 2016-04-26 16:34:10 -0600 | [diff] [blame] | 182 | // Array parameters not tagged as optional cannot be NULL, unless the count is 0 |
Dustin Graves | 080069b | 2016-04-05 13:48:15 -0600 | [diff] [blame] | 183 | if ((array == NULL) && arrayRequired && (count != 0)) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 184 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
Mark Lobodzinski | 729a8d3 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 185 | REQUIRED_PARAMETER, LayerName, "%s: required parameter %s specified as NULL", apiName, |
| 186 | arrayName.get_name().c_str()); |
Dustin Graves | b83fc2d | 2016-05-04 12:56:08 -0600 | [diff] [blame] | 187 | } |
| 188 | |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 189 | return skip_call; |
Dustin Graves | b83fc2d | 2016-05-04 12:56:08 -0600 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Validate pointer to array count and pointer to array. |
| 194 | * |
| 195 | * Verify that required count and array parameters are not NULL. If count |
| 196 | * is not NULL and its value is not optional, verify that it is not 0. If the |
| 197 | * array parameter is NULL, and it is not optional, verify that count is 0. |
| 198 | * The array parameter will typically be optional for this case (where count is |
| 199 | * a pointer), allowing the caller to retrieve the available count. |
| 200 | * |
| 201 | * @param report_data debug_report_data object for routing validation messages. |
| 202 | * @param apiName Name of API call being validated. |
| 203 | * @param countName Name of count parameter. |
| 204 | * @param arrayName Name of array parameter. |
| 205 | * @param count Pointer to the number of elements in the array. |
| 206 | * @param array Array to validate. |
| 207 | * @param countPtrRequired The 'count' parameter may not be NULL when true. |
| 208 | * @param countValueRequired The '*count' value may not be 0 when true. |
| 209 | * @param arrayRequired The 'array' parameter may not be NULL when true. |
| 210 | * @return Boolean value indicating that the call should be skipped. |
| 211 | */ |
| 212 | template <typename T> |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 213 | bool validate_array(debug_report_data *report_data, const char *apiName, const ParameterName &countName, |
| 214 | const ParameterName &arrayName, const T *count, const void *array, bool countPtrRequired, |
| 215 | bool countValueRequired, bool arrayRequired) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 216 | bool skip_call = false; |
Dustin Graves | b83fc2d | 2016-05-04 12:56:08 -0600 | [diff] [blame] | 217 | |
| 218 | if (count == NULL) { |
| 219 | if (countPtrRequired) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 220 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 221 | REQUIRED_PARAMETER, LayerName, "%s: required parameter %s specified as NULL", apiName, |
| 222 | countName.get_name().c_str()); |
Dustin Graves | b83fc2d | 2016-05-04 12:56:08 -0600 | [diff] [blame] | 223 | } |
Mark Lobodzinski | 729a8d3 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 224 | } else { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 225 | skip_call |= validate_array(report_data, apiName, countName, arrayName, (*count), array, countValueRequired, arrayRequired); |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 226 | } |
| 227 | |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 228 | return skip_call; |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | /** |
Dustin Graves | 20fd66f | 2016-04-18 18:33:21 -0600 | [diff] [blame] | 232 | * Validate a pointer to a Vulkan structure. |
| 233 | * |
| 234 | * Verify that a required pointer to a structure is not NULL. If the pointer is |
| 235 | * not NULL, verify that each structure's sType field is set to the correct |
| 236 | * VkStructureType value. |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 237 | * |
| 238 | * @param report_data debug_report_data object for routing validation messages. |
| 239 | * @param apiName Name of API call being validated. |
| 240 | * @param parameterName Name of struct parameter being validated. |
| 241 | * @param sTypeName Name of expected VkStructureType value. |
| 242 | * @param value Pointer to the struct to validate. |
| 243 | * @param sType VkStructureType for structure validation. |
| 244 | * @param required The parameter may not be NULL when true. |
| 245 | * @return Boolean value indicating that the call should be skipped. |
| 246 | */ |
| 247 | template <typename T> |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 248 | bool validate_struct_type(debug_report_data *report_data, const char *apiName, const ParameterName ¶meterName, |
| 249 | const char *sTypeName, const T *value, VkStructureType sType, bool required) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 250 | bool skip_call = false; |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 251 | |
| 252 | if (value == NULL) { |
Dustin Graves | 080069b | 2016-04-05 13:48:15 -0600 | [diff] [blame] | 253 | if (required) { |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 254 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 255 | REQUIRED_PARAMETER, LayerName, "%s: required parameter %s specified as NULL", apiName, |
| 256 | parameterName.get_name().c_str()); |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 257 | } |
| 258 | } else if (value->sType != sType) { |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 259 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 260 | INVALID_STRUCT_STYPE, LayerName, "%s: parameter %s->sType must be %s", apiName, |
| 261 | parameterName.get_name().c_str(), sTypeName); |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 262 | } |
| 263 | |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 264 | return skip_call; |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | /** |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 268 | * Validate an array of Vulkan structures |
| 269 | * |
| 270 | * Verify that required count and array parameters are not 0 or NULL. If |
| 271 | * the array contains 1 or more structures, verify that each structure's |
| 272 | * sType field is set to the correct VkStructureType value. |
| 273 | * |
| 274 | * @param report_data debug_report_data object for routing validation messages. |
| 275 | * @param apiName Name of API call being validated. |
| 276 | * @param countName Name of count parameter. |
| 277 | * @param arrayName Name of array parameter. |
| 278 | * @param sTypeName Name of expected VkStructureType value. |
| 279 | * @param count Number of elements in the array. |
| 280 | * @param array Array to validate. |
| 281 | * @param sType VkStructureType for structure validation. |
| 282 | * @param countRequired The 'count' parameter may not be 0 when true. |
| 283 | * @param arrayRequired The 'array' parameter may not be NULL when true. |
| 284 | * @return Boolean value indicating that the call should be skipped. |
| 285 | */ |
| 286 | template <typename T> |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 287 | bool validate_struct_type_array(debug_report_data *report_data, const char *apiName, const ParameterName &countName, |
| 288 | const ParameterName &arrayName, const char *sTypeName, uint32_t count, const T *array, |
| 289 | VkStructureType sType, bool countRequired, bool arrayRequired) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 290 | bool skip_call = false; |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 291 | |
| 292 | if ((count == 0) || (array == NULL)) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 293 | skip_call |= validate_array(report_data, apiName, countName, arrayName, count, array, countRequired, arrayRequired); |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 294 | } else { |
| 295 | // Verify that all structs in the array have the correct type |
| 296 | for (uint32_t i = 0; i < count; ++i) { |
| 297 | if (array[i].sType != sType) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 298 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 299 | __LINE__, INVALID_STRUCT_STYPE, LayerName, "%s: parameter %s[%d].sType must be %s", apiName, |
| 300 | arrayName.get_name().c_str(), i, sTypeName); |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 301 | } |
| 302 | } |
| 303 | } |
| 304 | |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 305 | return skip_call; |
Dustin Graves | 1e92cd7 | 2016-02-09 14:00:18 -0700 | [diff] [blame] | 306 | } |
| 307 | |
Dustin Graves | 58d114b | 2016-03-08 14:42:59 -0700 | [diff] [blame] | 308 | /** |
Mark Young | 3938987 | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 309 | * Validate an array of Vulkan structures. |
| 310 | * |
| 311 | * Verify that required count and array parameters are not NULL. If count |
| 312 | * is not NULL and its value is not optional, verify that it is not 0. |
| 313 | * If the array contains 1 or more structures, verify that each structure's |
| 314 | * sType field is set to the correct VkStructureType value. |
| 315 | * |
| 316 | * @param report_data debug_report_data object for routing validation messages. |
| 317 | * @param apiName Name of API call being validated. |
| 318 | * @param countName Name of count parameter. |
| 319 | * @param arrayName Name of array parameter. |
| 320 | * @param sTypeName Name of expected VkStructureType value. |
| 321 | * @param count Pointer to the number of elements in the array. |
| 322 | * @param array Array to validate. |
| 323 | * @param sType VkStructureType for structure validation. |
| 324 | * @param countPtrRequired The 'count' parameter may not be NULL when true. |
| 325 | * @param countValueRequired The '*count' value may not be 0 when true. |
| 326 | * @param arrayRequired The 'array' parameter may not be NULL when true. |
| 327 | * @return Boolean value indicating that the call should be skipped. |
| 328 | */ |
| 329 | template <typename T> |
| 330 | bool validate_struct_type_array(debug_report_data *report_data, const char *apiName, const ParameterName &countName, |
| 331 | const ParameterName &arrayName, const char *sTypeName, uint32_t *count, const T *array, |
| 332 | VkStructureType sType, bool countPtrRequired, bool countValueRequired, bool arrayRequired) { |
| 333 | bool skip_call = false; |
| 334 | |
| 335 | if (count == NULL) { |
| 336 | if (countPtrRequired) { |
| 337 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 338 | REQUIRED_PARAMETER, LayerName, "%s: required parameter %s specified as NULL", apiName, |
| 339 | countName.get_name().c_str()); |
| 340 | } |
| 341 | } else { |
| 342 | skip_call |= validate_struct_type_array(report_data, apiName, countName, arrayName, sTypeName, (*count), array, sType, |
| 343 | countValueRequired, arrayRequired); |
| 344 | } |
| 345 | |
| 346 | return skip_call; |
| 347 | } |
| 348 | |
| 349 | /** |
Dustin Graves | 20fd66f | 2016-04-18 18:33:21 -0600 | [diff] [blame] | 350 | * Validate a Vulkan handle. |
| 351 | * |
| 352 | * Verify that the specified handle is not VK_NULL_HANDLE. |
| 353 | * |
| 354 | * @param report_data debug_report_data object for routing validation messages. |
| 355 | * @param api_name Name of API call being validated. |
| 356 | * @param parameter_name Name of struct parameter being validated. |
| 357 | * @param value Handle to validate. |
| 358 | * @return Boolean value indicating that the call should be skipped. |
| 359 | */ |
| 360 | template <typename T> |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 361 | bool validate_required_handle(debug_report_data *report_data, const char *api_name, const ParameterName ¶meter_name, T value) { |
Dustin Graves | 20fd66f | 2016-04-18 18:33:21 -0600 | [diff] [blame] | 362 | bool skip_call = false; |
| 363 | |
| 364 | if (value == VK_NULL_HANDLE) { |
Dustin Graves | f233e50 | 2016-05-05 13:44:21 -0600 | [diff] [blame] | 365 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 366 | REQUIRED_PARAMETER, LayerName, "%s: required parameter %s specified as VK_NULL_HANDLE", api_name, |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 367 | parameter_name.get_name().c_str()); |
Dustin Graves | 20fd66f | 2016-04-18 18:33:21 -0600 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | return skip_call; |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * Validate an array of Vulkan handles. |
| 375 | * |
| 376 | * Verify that required count and array parameters are not NULL. If count |
| 377 | * is not NULL and its value is not optional, verify that it is not 0. |
| 378 | * If the array contains 1 or more handles, verify that no handle is set to |
| 379 | * VK_NULL_HANDLE. |
| 380 | * |
| 381 | * @note This function is only intended to validate arrays of handles when none |
| 382 | * of the handles are allowed to be VK_NULL_HANDLE. For arrays of handles |
| 383 | * that are allowed to contain VK_NULL_HANDLE, use validate_array() instead. |
| 384 | * |
| 385 | * @param report_data debug_report_data object for routing validation messages. |
| 386 | * @param api_name Name of API call being validated. |
| 387 | * @param count_name Name of count parameter. |
| 388 | * @param array_name Name of array parameter. |
| 389 | * @param count Number of elements in the array. |
| 390 | * @param array Array to validate. |
| 391 | * @param count_required The 'count' parameter may not be 0 when true. |
| 392 | * @param array_required The 'array' parameter may not be NULL when true. |
| 393 | * @return Boolean value indicating that the call should be skipped. |
| 394 | */ |
| 395 | template <typename T> |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 396 | bool validate_handle_array(debug_report_data *report_data, const char *api_name, const ParameterName &count_name, |
| 397 | const ParameterName &array_name, uint32_t count, const T *array, bool count_required, |
| 398 | bool array_required) { |
Dustin Graves | 20fd66f | 2016-04-18 18:33:21 -0600 | [diff] [blame] | 399 | bool skip_call = false; |
| 400 | |
| 401 | if ((count == 0) || (array == NULL)) { |
Dustin Graves | 0d15c6e | 2016-04-26 16:34:10 -0600 | [diff] [blame] | 402 | skip_call |= validate_array(report_data, api_name, count_name, array_name, count, array, count_required, array_required); |
Dustin Graves | 20fd66f | 2016-04-18 18:33:21 -0600 | [diff] [blame] | 403 | } else { |
| 404 | // Verify that no handles in the array are VK_NULL_HANDLE |
| 405 | for (uint32_t i = 0; i < count; ++i) { |
| 406 | if (array[i] == VK_NULL_HANDLE) { |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 407 | skip_call |= |
| 408 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 409 | REQUIRED_PARAMETER, LayerName, "%s: required parameter %s[%d] specified as VK_NULL_HANDLE", api_name, |
| 410 | array_name.get_name().c_str(), i); |
Dustin Graves | 20fd66f | 2016-04-18 18:33:21 -0600 | [diff] [blame] | 411 | } |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | return skip_call; |
| 416 | } |
| 417 | |
| 418 | /** |
Dustin Graves | 58d114b | 2016-03-08 14:42:59 -0700 | [diff] [blame] | 419 | * Validate string array count and content. |
| 420 | * |
| 421 | * Verify that required count and array parameters are not 0 or NULL. If the |
| 422 | * count parameter is not optional, verify that it is not 0. If the array |
| 423 | * parameter is NULL, and it is not optional, verify that count is 0. If the |
| 424 | * array parameter is not NULL, verify that none of the strings are NULL. |
| 425 | * |
| 426 | * @param report_data debug_report_data object for routing validation messages. |
| 427 | * @param apiName Name of API call being validated. |
| 428 | * @param countName Name of count parameter. |
| 429 | * @param arrayName Name of array parameter. |
| 430 | * @param count Number of strings in the array. |
| 431 | * @param array Array of strings to validate. |
| 432 | * @param countRequired The 'count' parameter may not be 0 when true. |
| 433 | * @param arrayRequired The 'array' parameter may not be NULL when true. |
| 434 | * @return Boolean value indicating that the call should be skipped. |
| 435 | */ |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 436 | static bool validate_string_array(debug_report_data *report_data, const char *apiName, const ParameterName &countName, |
| 437 | const ParameterName &arrayName, uint32_t count, const char *const *array, bool countRequired, |
| 438 | bool arrayRequired) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 439 | bool skip_call = false; |
Dustin Graves | 58d114b | 2016-03-08 14:42:59 -0700 | [diff] [blame] | 440 | |
| 441 | if ((count == 0) || (array == NULL)) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 442 | skip_call |= validate_array(report_data, apiName, countName, arrayName, count, array, countRequired, arrayRequired); |
Dustin Graves | 58d114b | 2016-03-08 14:42:59 -0700 | [diff] [blame] | 443 | } else { |
Dustin Graves | 0d15c6e | 2016-04-26 16:34:10 -0600 | [diff] [blame] | 444 | // Verify that strings in the array are not NULL |
Dustin Graves | 58d114b | 2016-03-08 14:42:59 -0700 | [diff] [blame] | 445 | for (uint32_t i = 0; i < count; ++i) { |
| 446 | if (array[i] == NULL) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 447 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 448 | __LINE__, REQUIRED_PARAMETER, LayerName, "%s: required parameter %s[%d] specified as NULL", |
| 449 | apiName, arrayName.get_name().c_str(), i); |
Dustin Graves | 58d114b | 2016-03-08 14:42:59 -0700 | [diff] [blame] | 450 | } |
| 451 | } |
| 452 | } |
| 453 | |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 454 | return skip_call; |
Dustin Graves | 58d114b | 2016-03-08 14:42:59 -0700 | [diff] [blame] | 455 | } |
| 456 | |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 457 | /** |
| 458 | * Validate a structure's pNext member. |
| 459 | * |
| 460 | * Verify that the specified pNext value points to the head of a list of |
| 461 | * allowed extension structures. If no extension structures are allowed, |
| 462 | * verify that pNext is null. |
| 463 | * |
| 464 | * @param report_data debug_report_data object for routing validation messages. |
Dustin Graves | af5c029 | 2016-07-19 13:43:53 -0600 | [diff] [blame] | 465 | * @param api_name Name of API call being validated. |
| 466 | * @param parameter_name Name of parameter being validated. |
| 467 | * @param allowed_struct_names Names of allowed structs. |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 468 | * @param next Pointer to validate. |
Dustin Graves | af5c029 | 2016-07-19 13:43:53 -0600 | [diff] [blame] | 469 | * @param allowed_type_count Total number of allowed structure types. |
| 470 | * @param allowed_types Array of strcuture types allowed for pNext. |
| 471 | * @param header_version Version of header defining the pNext validation rules. |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 472 | * @return Boolean value indicating that the call should be skipped. |
| 473 | */ |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 474 | static bool validate_struct_pnext(debug_report_data *report_data, const char *api_name, const ParameterName ¶meter_name, |
Dustin Graves | af5c029 | 2016-07-19 13:43:53 -0600 | [diff] [blame] | 475 | const char *allowed_struct_names, const void *next, size_t allowed_type_count, |
| 476 | const VkStructureType *allowed_types, uint32_t header_version) { |
| 477 | bool skip_call = false; |
Mark Lobodzinski | c9b74d3 | 2017-03-27 11:52:02 -0600 | [diff] [blame] | 478 | std::unordered_set<const void *> cycle_check; |
| 479 | std::unordered_set<VkStructureType, std::hash<int>> unique_stype_check; |
| 480 | |
Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 481 | const char disclaimer[] = |
| 482 | "This warning is based on the Valid Usage documentation for version %d of the Vulkan header. It " |
| 483 | "is possible that you are using a struct from a private extension or an extension that was added " |
| 484 | "to a later version of the Vulkan header, in which case your use of %s is perfectly valid but " |
| 485 | "is not guaranteed to work correctly with validation enabled"; |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 486 | |
Mark Lobodzinski | c9b74d3 | 2017-03-27 11:52:02 -0600 | [diff] [blame] | 487 | // TODO: The valid pNext structure types are not recursive. Each structure has its own list of valid sTypes for pNext. |
| 488 | // Codegen a map of vectors containing the allowable pNext types for each struct and use that here -- also simplifies parms. |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 489 | if (next != NULL) { |
Dustin Graves | af5c029 | 2016-07-19 13:43:53 -0600 | [diff] [blame] | 490 | if (allowed_type_count == 0) { |
| 491 | std::string message = "%s: value of %s must be NULL. "; |
| 492 | message += disclaimer; |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 493 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 494 | INVALID_STRUCT_PNEXT, LayerName, message.c_str(), api_name, parameter_name.get_name().c_str(), |
| 495 | header_version, parameter_name.get_name().c_str()); |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 496 | } else { |
Dustin Graves | af5c029 | 2016-07-19 13:43:53 -0600 | [diff] [blame] | 497 | const VkStructureType *start = allowed_types; |
| 498 | const VkStructureType *end = allowed_types + allowed_type_count; |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 499 | const GenericHeader *current = reinterpret_cast<const GenericHeader *>(next); |
| 500 | |
Mark Lobodzinski | c9b74d3 | 2017-03-27 11:52:02 -0600 | [diff] [blame] | 501 | cycle_check.insert(next); |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 502 | |
Mark Lobodzinski | c9b74d3 | 2017-03-27 11:52:02 -0600 | [diff] [blame] | 503 | |
| 504 | while (current != NULL) { |
| 505 | if (cycle_check.find(current->pNext) != cycle_check.end()) { |
| 506 | std::string message = "%s: %s chain contains a cycle -- pNext pointer " PRIx64 " is repeated."; |
| 507 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 508 | __LINE__, INVALID_STRUCT_PNEXT, LayerName, message.c_str(), api_name, |
| 509 | parameter_name.get_name().c_str(), reinterpret_cast<uint64_t>(next)); |
| 510 | break; |
| 511 | } else { |
| 512 | cycle_check.insert(current->pNext); |
| 513 | } |
| 514 | |
| 515 | std::string type_name = string_VkStructureType(current->sType); |
| 516 | if (unique_stype_check.find(current->sType) != unique_stype_check.end()) { |
| 517 | std::string message = "%s: %s chain contains duplicate structure types: %s appears multiple times."; |
| 518 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 519 | __LINE__, INVALID_STRUCT_PNEXT, LayerName, message.c_str(), api_name, |
| 520 | parameter_name.get_name().c_str(), type_name.c_str()); |
| 521 | } else { |
| 522 | unique_stype_check.insert(current->sType); |
| 523 | } |
| 524 | |
| 525 | if (std::find(start, end, current->sType) == end) { |
Dustin Graves | af5c029 | 2016-07-19 13:43:53 -0600 | [diff] [blame] | 526 | if (type_name == UnsupportedStructureTypeString) { |
Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 527 | std::string message = |
| 528 | "%s: %s chain includes a structure with unexpected VkStructureType (%d); Allowed " |
| 529 | "structures are [%s]. "; |
Dustin Graves | af5c029 | 2016-07-19 13:43:53 -0600 | [diff] [blame] | 530 | message += disclaimer; |
| 531 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, |
| 532 | 0, __LINE__, INVALID_STRUCT_PNEXT, LayerName, message.c_str(), api_name, |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 533 | parameter_name.get_name().c_str(), current->sType, allowed_struct_names, |
| 534 | header_version, parameter_name.get_name().c_str()); |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 535 | } else { |
Dustin Graves | af5c029 | 2016-07-19 13:43:53 -0600 | [diff] [blame] | 536 | std::string message = |
| 537 | "%s: %s chain includes a structure with unexpected VkStructureType %s; Allowed structures are [%s]. "; |
| 538 | message += disclaimer; |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 539 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, |
| 540 | 0, __LINE__, INVALID_STRUCT_PNEXT, LayerName, message.c_str(), api_name, |
| 541 | parameter_name.get_name().c_str(), type_name.c_str(), allowed_struct_names, |
| 542 | header_version, parameter_name.get_name().c_str()); |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 543 | } |
| 544 | } |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 545 | current = reinterpret_cast<const GenericHeader *>(current->pNext); |
| 546 | } |
| 547 | } |
| 548 | } |
| 549 | |
Dustin Graves | af5c029 | 2016-07-19 13:43:53 -0600 | [diff] [blame] | 550 | return skip_call; |
Dustin Graves | 58c2f66 | 2016-03-08 17:48:20 -0700 | [diff] [blame] | 551 | } |
| 552 | |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 553 | /** |
| 554 | * Validate a VkBool32 value. |
| 555 | * |
| 556 | * Generate a warning if a VkBool32 value is neither VK_TRUE nor VK_FALSE. |
| 557 | * |
| 558 | * @param report_data debug_report_data object for routing validation messages. |
| 559 | * @param apiName Name of API call being validated. |
| 560 | * @param parameterName Name of parameter being validated. |
| 561 | * @param value Boolean value to validate. |
| 562 | * @return Boolean value indicating that the call should be skipped. |
| 563 | */ |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 564 | static bool validate_bool32(debug_report_data *report_data, const char *apiName, const ParameterName ¶meterName, |
| 565 | VkBool32 value) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 566 | bool skip_call = false; |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 567 | |
| 568 | if ((value != VK_TRUE) && (value != VK_FALSE)) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 569 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 570 | UNRECOGNIZED_VALUE, LayerName, "%s: value of %s (%d) is neither VK_TRUE nor VK_FALSE", apiName, |
| 571 | parameterName.get_name().c_str(), value); |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 572 | } |
| 573 | |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 574 | return skip_call; |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | /** |
| 578 | * Validate a Vulkan enumeration value. |
| 579 | * |
| 580 | * Generate a warning if an enumeration token value does not fall within the core enumeration |
| 581 | * begin and end token values, and was not added to the enumeration by an extension. Extension |
| 582 | * provided enumerations use the equation specified in Appendix C.10 of the Vulkan specification, |
| 583 | * with 1,000,000,000 as the base token value. |
| 584 | * |
| 585 | * @note This function does not expect to process enumerations defining bitmask flag bits. |
| 586 | * |
| 587 | * @param report_data debug_report_data object for routing validation messages. |
| 588 | * @param apiName Name of API call being validated. |
| 589 | * @param parameterName Name of parameter being validated. |
| 590 | * @param enumName Name of the enumeration being validated. |
| 591 | * @param begin The begin range value for the enumeration. |
| 592 | * @param end The end range value for the enumeration. |
Dustin Graves | 9c6b62b | 2016-04-26 15:37:10 -0600 | [diff] [blame] | 593 | * @param value Enumeration value to validate. |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 594 | * @return Boolean value indicating that the call should be skipped. |
| 595 | */ |
| 596 | template <typename T> |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 597 | bool validate_ranged_enum(debug_report_data *report_data, const char *apiName, const ParameterName ¶meterName, |
| 598 | const char *enumName, T begin, T end, T value) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 599 | bool skip_call = false; |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 600 | |
| 601 | if (((value < begin) || (value > end)) && !is_extension_added_token(value)) { |
Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 602 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 603 | UNRECOGNIZED_VALUE, LayerName, |
| 604 | "%s: value of %s (%d) does not fall within the begin..end range of the core %s " |
| 605 | "enumeration tokens and is not an extension added token", |
| 606 | apiName, parameterName.get_name().c_str(), value, enumName); |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 607 | } |
| 608 | |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 609 | return skip_call; |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | /** |
| 613 | * Validate an array of Vulkan enumeration value. |
| 614 | * |
| 615 | * Process all enumeration token values in the specified array and generate a warning if a value |
| 616 | * does not fall within the core enumeration begin and end token values, and was not added to |
| 617 | * the enumeration by an extension. Extension provided enumerations use the equation specified |
| 618 | * in Appendix C.10 of the Vulkan specification, with 1,000,000,000 as the base token value. |
| 619 | * |
| 620 | * @note This function does not expect to process enumerations defining bitmask flag bits. |
| 621 | * |
| 622 | * @param report_data debug_report_data object for routing validation messages. |
| 623 | * @param apiName Name of API call being validated. |
Dustin Graves | 0d15c6e | 2016-04-26 16:34:10 -0600 | [diff] [blame] | 624 | * @param countName Name of count parameter. |
| 625 | * @param arrayName Name of array parameter. |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 626 | * @param enumName Name of the enumeration being validated. |
| 627 | * @param begin The begin range value for the enumeration. |
| 628 | * @param end The end range value for the enumeration. |
Dustin Graves | 0d15c6e | 2016-04-26 16:34:10 -0600 | [diff] [blame] | 629 | * @param count Number of enumeration values in the array. |
| 630 | * @param array Array of enumeration values to validate. |
| 631 | * @param countRequired The 'count' parameter may not be 0 when true. |
| 632 | * @param arrayRequired The 'array' parameter may not be NULL when true. |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 633 | * @return Boolean value indicating that the call should be skipped. |
| 634 | */ |
| 635 | template <typename T> |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 636 | static bool validate_ranged_enum_array(debug_report_data *report_data, const char *apiName, const ParameterName &countName, |
| 637 | const ParameterName &arrayName, const char *enumName, T begin, T end, uint32_t count, |
| 638 | const T *array, bool countRequired, bool arrayRequired) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 639 | bool skip_call = false; |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 640 | |
Dustin Graves | 0d15c6e | 2016-04-26 16:34:10 -0600 | [diff] [blame] | 641 | if ((count == 0) || (array == NULL)) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 642 | skip_call |= validate_array(report_data, apiName, countName, arrayName, count, array, countRequired, arrayRequired); |
Dustin Graves | 0d15c6e | 2016-04-26 16:34:10 -0600 | [diff] [blame] | 643 | } else { |
| 644 | for (uint32_t i = 0; i < count; ++i) { |
| 645 | if (((array[i] < begin) || (array[i] > end)) && !is_extension_added_token(array[i])) { |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 646 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 647 | __LINE__, UNRECOGNIZED_VALUE, LayerName, |
| 648 | "%s: value of %s[%d] (%d) does not fall within the begin..end range of the core %s " |
| 649 | "enumeration tokens and is not an extension added token", |
| 650 | apiName, arrayName.get_name().c_str(), i, array[i], enumName); |
Dustin Graves | 0d15c6e | 2016-04-26 16:34:10 -0600 | [diff] [blame] | 651 | } |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 652 | } |
| 653 | } |
| 654 | |
Mark Lobodzinski | 72ecd91 | 2016-08-11 13:25:38 -0600 | [diff] [blame] | 655 | return skip_call; |
Dustin Graves | 29148ff | 2016-03-23 19:44:00 -0600 | [diff] [blame] | 656 | } |
| 657 | |
Dustin Graves | ca7aa7c | 2016-03-25 15:13:28 -0600 | [diff] [blame] | 658 | /** |
Dustin Graves | 78df851 | 2016-04-28 17:58:59 -0600 | [diff] [blame] | 659 | * Verify that a reserved VkFlags value is zero. |
| 660 | * |
| 661 | * Verify that the specified value is zero, to check VkFlags values that are reserved for |
| 662 | * future use. |
| 663 | * |
| 664 | * @param report_data debug_report_data object for routing validation messages. |
| 665 | * @param api_name Name of API call being validated. |
| 666 | * @param parameter_name Name of parameter being validated. |
| 667 | * @param value Value to validate. |
| 668 | * @return Boolean value indicating that the call should be skipped. |
| 669 | */ |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 670 | static bool validate_reserved_flags(debug_report_data *report_data, const char *api_name, const ParameterName ¶meter_name, |
Dustin Graves | 78df851 | 2016-04-28 17:58:59 -0600 | [diff] [blame] | 671 | VkFlags value) { |
| 672 | bool skip_call = false; |
| 673 | |
| 674 | if (value != 0) { |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 675 | skip_call |= |
| 676 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 677 | RESERVED_PARAMETER, LayerName, "%s: parameter %s must be 0", api_name, parameter_name.get_name().c_str()); |
Dustin Graves | 78df851 | 2016-04-28 17:58:59 -0600 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | return skip_call; |
| 681 | } |
| 682 | |
| 683 | /** |
Dustin Graves | 9c6b62b | 2016-04-26 15:37:10 -0600 | [diff] [blame] | 684 | * Validate a Vulkan bitmask value. |
| 685 | * |
| 686 | * Generate a warning if a value with a VkFlags derived type does not contain valid flag bits |
| 687 | * for that type. |
| 688 | * |
| 689 | * @param report_data debug_report_data object for routing validation messages. |
| 690 | * @param api_name Name of API call being validated. |
| 691 | * @param parameter_name Name of parameter being validated. |
| 692 | * @param flag_bits_name Name of the VkFlags type being validated. |
| 693 | * @param all_flags A bit mask combining all valid flag bits for the VkFlags type being validated. |
| 694 | * @param value VkFlags value to validate. |
| 695 | * @param flags_required The 'value' parameter may not be 0 when true. |
Mike Schuchardt | 47619c8 | 2017-05-31 09:14:22 -0600 | [diff] [blame^] | 696 | * @param singleFlag The 'value' parameter may not contain more than one bit from all_flags. |
Dustin Graves | 9c6b62b | 2016-04-26 15:37:10 -0600 | [diff] [blame] | 697 | * @return Boolean value indicating that the call should be skipped. |
| 698 | */ |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 699 | static bool validate_flags(debug_report_data *report_data, const char *api_name, const ParameterName ¶meter_name, |
Mike Schuchardt | 47619c8 | 2017-05-31 09:14:22 -0600 | [diff] [blame^] | 700 | const char *flag_bits_name, VkFlags all_flags, VkFlags value, bool flags_required, bool singleFlag) { |
Dustin Graves | 9c6b62b | 2016-04-26 15:37:10 -0600 | [diff] [blame] | 701 | bool skip_call = false; |
| 702 | |
| 703 | if (value == 0) { |
| 704 | if (flags_required) { |
Dustin Graves | f233e50 | 2016-05-05 13:44:21 -0600 | [diff] [blame] | 705 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 706 | REQUIRED_PARAMETER, LayerName, "%s: value of %s must not be 0", api_name, |
| 707 | parameter_name.get_name().c_str()); |
Dustin Graves | 9c6b62b | 2016-04-26 15:37:10 -0600 | [diff] [blame] | 708 | } |
| 709 | } else if ((value & (~all_flags)) != 0) { |
Dustin Graves | f233e50 | 2016-05-05 13:44:21 -0600 | [diff] [blame] | 710 | skip_call |= |
| 711 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 712 | UNRECOGNIZED_VALUE, LayerName, "%s: value of %s contains flag bits that are not recognized members of %s", |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 713 | api_name, parameter_name.get_name().c_str(), flag_bits_name); |
Mike Schuchardt | 47619c8 | 2017-05-31 09:14:22 -0600 | [diff] [blame^] | 714 | } else if (singleFlag && (std::bitset<sizeof(VkFlags) * 8>(value).count() > 1)) { |
| 715 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 716 | UNRECOGNIZED_VALUE, LayerName, |
| 717 | "%s: value of %s contains multiple members of %s when only a single value is allowed", api_name, |
| 718 | parameter_name.get_name().c_str(), flag_bits_name); |
Dustin Graves | 9c6b62b | 2016-04-26 15:37:10 -0600 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | return skip_call; |
| 722 | } |
| 723 | |
| 724 | /** |
| 725 | * Validate an array of Vulkan bitmask values. |
| 726 | * |
| 727 | * Generate a warning if a value with a VkFlags derived type does not contain valid flag bits |
| 728 | * for that type. |
| 729 | * |
| 730 | * @param report_data debug_report_data object for routing validation messages. |
| 731 | * @param api_name Name of API call being validated. |
| 732 | * @param count_name Name of parameter being validated. |
| 733 | * @param array_name Name of parameter being validated. |
| 734 | * @param flag_bits_name Name of the VkFlags type being validated. |
| 735 | * @param all_flags A bitmask combining all valid flag bits for the VkFlags type being validated. |
| 736 | * @param count Number of VkFlags values in the array. |
| 737 | * @param array Array of VkFlags value to validate. |
| 738 | * @param count_required The 'count' parameter may not be 0 when true. |
| 739 | * @param array_required The 'array' parameter may not be NULL when true. |
| 740 | * @return Boolean value indicating that the call should be skipped. |
| 741 | */ |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 742 | static bool validate_flags_array(debug_report_data *report_data, const char *api_name, const ParameterName &count_name, |
| 743 | const ParameterName &array_name, const char *flag_bits_name, VkFlags all_flags, uint32_t count, |
Dustin Graves | 78df851 | 2016-04-28 17:58:59 -0600 | [diff] [blame] | 744 | const VkFlags *array, bool count_required, bool array_required) { |
Dustin Graves | 9c6b62b | 2016-04-26 15:37:10 -0600 | [diff] [blame] | 745 | bool skip_call = false; |
| 746 | |
| 747 | if ((count == 0) || (array == NULL)) { |
| 748 | skip_call |= validate_array(report_data, api_name, count_name, array_name, count, array, count_required, array_required); |
| 749 | } else { |
| 750 | // Verify that all VkFlags values in the array |
| 751 | for (uint32_t i = 0; i < count; ++i) { |
Dustin Graves | 78df851 | 2016-04-28 17:58:59 -0600 | [diff] [blame] | 752 | if (array[i] == 0) { |
| 753 | // Current XML registry logic for validity generation uses the array parameter's optional tag to determine if |
| 754 | // elements in the array are allowed be 0 |
| 755 | if (array_required) { |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 756 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 757 | __LINE__, REQUIRED_PARAMETER, LayerName, "%s: value of %s[%d] must not be 0", api_name, |
| 758 | array_name.get_name().c_str(), i); |
Dustin Graves | 78df851 | 2016-04-28 17:58:59 -0600 | [diff] [blame] | 759 | } |
| 760 | } else if ((array[i] & (~all_flags)) != 0) { |
Dustin Graves | f233e50 | 2016-05-05 13:44:21 -0600 | [diff] [blame] | 761 | skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 762 | __LINE__, UNRECOGNIZED_VALUE, LayerName, |
| 763 | "%s: value of %s[%d] contains flag bits that are not recognized members of %s", api_name, |
Dustin Graves | 8ffbbf6 | 2016-07-22 13:19:46 -0600 | [diff] [blame] | 764 | array_name.get_name().c_str(), i, flag_bits_name); |
Dustin Graves | 9c6b62b | 2016-04-26 15:37:10 -0600 | [diff] [blame] | 765 | } |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | return skip_call; |
| 770 | } |
| 771 | |
| 772 | /** |
Dustin Graves | ca7aa7c | 2016-03-25 15:13:28 -0600 | [diff] [blame] | 773 | * Get VkResult code description. |
| 774 | * |
Dustin Graves | 9c6b62b | 2016-04-26 15:37:10 -0600 | [diff] [blame] | 775 | * Returns a string describing the specified VkResult code. The description is based on the language in the Vulkan API |
| 776 | * specification. |
Dustin Graves | ca7aa7c | 2016-03-25 15:13:28 -0600 | [diff] [blame] | 777 | * |
| 778 | * @param value VkResult code to process. |
| 779 | * @return String describing the specified VkResult code. |
| 780 | */ |
| 781 | static std::string get_result_description(VkResult result) { |
| 782 | // clang-format off |
| 783 | switch (result) { |
| 784 | case VK_SUCCESS: return "a command completed successfully"; |
| 785 | case VK_NOT_READY: return "a fence or query has not yet completed"; |
| 786 | case VK_TIMEOUT: return "a wait operation has not completed in the specified time"; |
| 787 | case VK_EVENT_SET: return "an event is signaled"; |
| 788 | case VK_EVENT_RESET: return "an event is unsignalled"; |
| 789 | case VK_INCOMPLETE: return "a return array was too small for the result"; |
| 790 | case VK_ERROR_OUT_OF_HOST_MEMORY: return "a host memory allocation has failed"; |
| 791 | case VK_ERROR_OUT_OF_DEVICE_MEMORY: return "a device memory allocation has failed"; |
Dustin Graves | 2adca84 | 2016-05-16 18:35:55 -0600 | [diff] [blame] | 792 | case VK_ERROR_INITIALIZATION_FAILED: return "initialization of an object has failed"; |
| 793 | case VK_ERROR_DEVICE_LOST: return "the logical device has been lost"; |
Dustin Graves | ca7aa7c | 2016-03-25 15:13:28 -0600 | [diff] [blame] | 794 | case VK_ERROR_MEMORY_MAP_FAILED: return "mapping of a memory object has failed"; |
| 795 | case VK_ERROR_LAYER_NOT_PRESENT: return "the specified layer does not exist"; |
| 796 | case VK_ERROR_EXTENSION_NOT_PRESENT: return "the specified extension does not exist"; |
| 797 | case VK_ERROR_FEATURE_NOT_PRESENT: return "the requested feature is not available on this device"; |
| 798 | case VK_ERROR_INCOMPATIBLE_DRIVER: return "a Vulkan driver could not be found"; |
| 799 | case VK_ERROR_TOO_MANY_OBJECTS: return "too many objects of the type have already been created"; |
| 800 | case VK_ERROR_FORMAT_NOT_SUPPORTED: return "the requested format is not supported on this device"; |
| 801 | case VK_ERROR_SURFACE_LOST_KHR: return "a surface is no longer available"; |
| 802 | case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: return "the requested window is already connected to another " |
| 803 | "VkSurfaceKHR object, or some other non-Vulkan surface object"; |
| 804 | case VK_SUBOPTIMAL_KHR: return "an image became available, and the swapchain no longer " |
| 805 | "matches the surface properties exactly, but can still be used to " |
| 806 | "present to the surface successfully."; |
| 807 | case VK_ERROR_OUT_OF_DATE_KHR: return "a surface has changed in such a way that it is no " |
| 808 | "longer compatible with the swapchain"; |
| 809 | case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: return "the display used by a swapchain does not use the same " |
| 810 | "presentable image layout, or is incompatible in a way that prevents " |
| 811 | "sharing an image"; |
| 812 | case VK_ERROR_VALIDATION_FAILED_EXT: return "API validation has detected an invalid use of the API"; |
| 813 | case VK_ERROR_INVALID_SHADER_NV: return "one or more shaders failed to compile or link"; |
Eric Engestrom | bcbb0fd | 2016-04-02 22:06:13 +0100 | [diff] [blame] | 814 | default: return "an error has occurred"; |
Dustin Graves | ca7aa7c | 2016-03-25 15:13:28 -0600 | [diff] [blame] | 815 | }; |
| 816 | // clang-format on |
| 817 | } |
| 818 | |
| 819 | /** |
| 820 | * Validate return code. |
| 821 | * |
| 822 | * Print a message describing the reason for failure when an error code is returned. |
| 823 | * |
| 824 | * @param report_data debug_report_data object for routing validation messages. |
| 825 | * @param apiName Name of API call being validated. |
Mark Lobodzinski | b42e51b | 2017-05-09 13:49:59 -0600 | [diff] [blame] | 826 | * @param ignore vector of VkResult return codes to be ignored |
Dustin Graves | ca7aa7c | 2016-03-25 15:13:28 -0600 | [diff] [blame] | 827 | * @param value VkResult value to validate. |
| 828 | */ |
Mark Lobodzinski | b42e51b | 2017-05-09 13:49:59 -0600 | [diff] [blame] | 829 | static void validate_result(debug_report_data *report_data, const char *apiName, std::vector<VkResult> const &ignore, |
| 830 | VkResult result) { |
Chris Forbes | f1f4e38 | 2016-10-13 14:44:03 +1300 | [diff] [blame] | 831 | if (result < 0 && result != VK_ERROR_VALIDATION_FAILED_EXT) { |
Mark Lobodzinski | b42e51b | 2017-05-09 13:49:59 -0600 | [diff] [blame] | 832 | if (std::find(ignore.begin(), ignore.end(), result) != ignore.end()) { |
| 833 | return; |
| 834 | } |
Dustin Graves | ca7aa7c | 2016-03-25 15:13:28 -0600 | [diff] [blame] | 835 | std::string resultName = string_VkResult(result); |
Dustin Graves | ca7aa7c | 2016-03-25 15:13:28 -0600 | [diff] [blame] | 836 | if (resultName == UnsupportedResultString) { |
| 837 | // Unrecognized result code |
Dustin Graves | f233e50 | 2016-05-05 13:44:21 -0600 | [diff] [blame] | 838 | log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 839 | FAILURE_RETURN_CODE, LayerName, "%s: returned a result code indicating that an error has occurred", apiName); |
Dustin Graves | ca7aa7c | 2016-03-25 15:13:28 -0600 | [diff] [blame] | 840 | } else { |
| 841 | std::string resultDesc = get_result_description(result); |
Dustin Graves | f233e50 | 2016-05-05 13:44:21 -0600 | [diff] [blame] | 842 | log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, |
| 843 | FAILURE_RETURN_CODE, LayerName, "%s: returned %s, indicating that %s", apiName, resultName.c_str(), |
| 844 | resultDesc.c_str()); |
Dustin Graves | ca7aa7c | 2016-03-25 15:13:28 -0600 | [diff] [blame] | 845 | } |
| 846 | } |
| 847 | } |
| 848 | |
Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 849 | } // namespace parameter_validation |
Dustin Graves | b83fc2d | 2016-05-04 12:56:08 -0600 | [diff] [blame] | 850 | |
Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 851 | #endif // PARAMETER_VALIDATION_UTILS_H |