diff options
author | Charles Giessen <charles@lunarg.com> | 2023-10-05 11:29:43 -0600 |
---|---|---|
committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2023-10-05 14:05:20 -0600 |
commit | 8197ec6dae2d27744f0795769277a4e44717d33b (patch) | |
tree | ad0bc3319ed776ab8fc72c3b6865ed0284fa6325 | |
parent | 0067d4cb64dad8e8c753efcf1dd120347e682300 (diff) | |
download | Vulkan-Tools-8197ec6dae2d27744f0795769277a4e44717d33b.tar.gz Vulkan-Tools-8197ec6dae2d27744f0795769277a4e44717d33b.tar.bz2 Vulkan-Tools-8197ec6dae2d27744f0795769277a4e44717d33b.zip |
vulkaninfo: Fix printing arrays of Enums
Previously, the code generator assumed enums were always printed as
key-value pairs, and not in an array. This led to using object
syntax inside of arrays in the JSON output, which is invalid, and is
now fixed.
-rw-r--r-- | scripts/vulkaninfo_generator.py | 11 | ||||
-rw-r--r-- | vulkaninfo/generated/vulkaninfo.hpp | 15 |
2 files changed, 19 insertions, 7 deletions
diff --git a/scripts/vulkaninfo_generator.py b/scripts/vulkaninfo_generator.py index 9d7d683a..3aa2a4ec 100644 --- a/scripts/vulkaninfo_generator.py +++ b/scripts/vulkaninfo_generator.py @@ -601,10 +601,13 @@ def PrintStructure(struct, types_to_gen, structure_names, aliases): out += f' ArrayWrapper arr(p,"{v.name}", obj.' + v.arrayLength + ');\n' out += f" for (uint32_t i = 0; i < obj.{v.arrayLength}; i++) {{\n" if v.typeID in types_to_gen: - out += f" if (obj.{v.name} != nullptr) {{\n" - out += f" p.SetElementIndex(i);\n" - out += f' Dump{v.typeID}(p, "{v.name}", obj.{v.name}[i]);\n' - out += f" }}\n" + out += f' if (obj.{v.name} != nullptr) {{\n' + out += f' p.SetElementIndex(i);\n' + out += ' if (p.Type() == OutputType::json)\n' + out += f' p.PrintString(std::string("VK_") + {v.typeID}String(obj.{v.name}[i]));\n' + out += ' else\n' + out += f' p.PrintString({v.typeID}String(obj.{v.name}[i]));\n' + out += f' }}\n' else: out += f" p.PrintElement(obj.{v.name}[i]);\n" out += f" }}\n" diff --git a/vulkaninfo/generated/vulkaninfo.hpp b/vulkaninfo/generated/vulkaninfo.hpp index 765e9030..3c5b7da2 100644 --- a/vulkaninfo/generated/vulkaninfo.hpp +++ b/vulkaninfo/generated/vulkaninfo.hpp @@ -1983,7 +1983,10 @@ void DumpVkPhysicalDeviceHostImageCopyPropertiesEXT(Printer &p, std::string name for (uint32_t i = 0; i < obj.copySrcLayoutCount; i++) { if (obj.pCopySrcLayouts != nullptr) { p.SetElementIndex(i); - DumpVkImageLayout(p, "pCopySrcLayouts", obj.pCopySrcLayouts[i]); + if (p.Type() == OutputType::json) + p.PrintString(std::string("VK_") + VkImageLayoutString(obj.pCopySrcLayouts[i])); + else + p.PrintString(VkImageLayoutString(obj.pCopySrcLayouts[i])); } } } @@ -1993,7 +1996,10 @@ void DumpVkPhysicalDeviceHostImageCopyPropertiesEXT(Printer &p, std::string name for (uint32_t i = 0; i < obj.copyDstLayoutCount; i++) { if (obj.pCopyDstLayouts != nullptr) { p.SetElementIndex(i); - DumpVkImageLayout(p, "pCopyDstLayouts", obj.pCopyDstLayouts[i]); + if (p.Type() == OutputType::json) + p.PrintString(std::string("VK_") + VkImageLayoutString(obj.pCopyDstLayouts[i])); + else + p.PrintString(VkImageLayoutString(obj.pCopyDstLayouts[i])); } } } @@ -3215,7 +3221,10 @@ void DumpVkSurfacePresentModeCompatibilityEXT(Printer &p, std::string name, cons for (uint32_t i = 0; i < obj.presentModeCount; i++) { if (obj.pPresentModes != nullptr) { p.SetElementIndex(i); - DumpVkPresentModeKHR(p, "pPresentModes", obj.pPresentModes[i]); + if (p.Type() == OutputType::json) + p.PrintString(std::string("VK_") + VkPresentModeKHRString(obj.pPresentModes[i])); + else + p.PrintString(VkPresentModeKHRString(obj.pPresentModes[i])); } } } |