aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMark Lobodzinski <mark@lunarg.com>2018-03-27 14:49:31 -0600
committerMark Lobodzinski <mark@lunarg.com>2018-04-05 15:04:01 -0600
commit2748b0579d45b2c40787700b985c5fa5cf5a6101 (patch)
tree2339d663931bafc487badc9b55c389b9d50dc53e /scripts
parent0ef2749ec8a7fb032abbfecd3838af9c7299a649 (diff)
downloadvulkan-validation-layers-2748b0579d45b2c40787700b985c5fa5cf5a6101.tar.gz
scripts: Output vuid-string->message map
Change-Id: Id4123053da62fb8d2b4d32393d11e4aa6c030f92
Diffstat (limited to 'scripts')
-rw-r--r--scripts/spec.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/scripts/spec.py b/scripts/spec.py
index 68dd92246..2c9507f23 100644
--- a/scripts/spec.py
+++ b/scripts/spec.py
@@ -188,27 +188,32 @@ class Specification:
file_contents.append('\n#pragma once')
file_contents.append('\n// Disable auto-formatting for generated file')
file_contents.append('// clang-format off')
- file_contents.append('\n#include <unordered_map>')
+ file_contents.append('\n#include <string>')
+ file_contents.append('#include <unordered_map>')
file_contents.append('\n// enum values for unique validation error codes')
file_contents.append('// Corresponding validation error message for each enum is given in the mapping table below')
file_contents.append('// When a given error occurs, these enum values should be passed to the as the messageCode')
file_contents.append('// parameter to the PFN_vkDebugReportCallbackEXT function')
enum_decl = ['enum UNIQUE_VALIDATION_ERROR_CODE {\n VALIDATION_ERROR_UNDEFINED = -1,']
- error_string_map = ['static std::unordered_map<int, char const *const> validation_error_map{']
+ vuid_int_to_error_map = ['static std::unordered_map<int, char const *const> validation_error_map{']
+ vuid_string_to_error_map = ['static std::unordered_map<std::string, int> validation_error_text_map{']
enum_value = 0
max_enum_val = 0
for enum in sorted(self.error_db_dict):
enum_decl.append(' %s = 0x%s,' % (enum, enum[-8:]))
- error_string_map.append(' {%s, "%s"},' % (enum, self.error_db_dict[enum]['error_msg'].replace('"', '\\"')))
+ vuid_int_to_error_map.append(' {%s, "%s"},' % (enum, self.error_db_dict[enum]['error_msg'].replace('"', '\\"')))
+ vuid_str = self.error_db_dict[enum]['vuid_string']
+ vuid_string_to_error_map.append(' {"%s", %s},' % (vuid_str, enum))
max_enum_val = max(max_enum_val, enum_value)
enum_decl.append(' %sMAX_ENUM = %d,' % (validation_error_enum_name, max_enum_val + 1))
enum_decl.append('};')
- error_string_map.append('};\n')
+ vuid_int_to_error_map.append('};\n')
+ vuid_string_to_error_map.append('};\n')
file_contents.extend(enum_decl)
- file_contents.append('\n// Mapping from unique validation error enum to the corresponding error message')
- file_contents.append('// The error message should be appended to the end of a custom error message that is passed')
- file_contents.append('// as the pMessage parameter to the PFN_vkDebugReportCallbackEXT function')
- file_contents.extend(error_string_map)
+ file_contents.append('\n// Mapping from unique validation error enum to the corresponding spec text')
+ file_contents.extend(vuid_int_to_error_map)
+ file_contents.append('\n// Mapping from spec validation error text string to unique validation error enum')
+ file_contents.extend(vuid_string_to_error_map)
#print ("File contents: %s" % (file_contents))
with open(header_file, "w") as outfile:
outfile.write("\n".join(file_contents))