From 2a1dba26ff84f40aff0c0724757ceea5608d8c15 Mon Sep 17 00:00:00 2001 From: Robin Voetter Date: Sat, 19 Jul 2025 13:26:20 +0200 Subject: [PATCH] Add workaround for incorrect StdVideoH265HrdParameters encoding See https://github.com/KhronosGroup/Vulkan-Docs/issues/2557 --- src/main.zig | 42 ++++++++++++++++++++++++------------------ src/vulkan/parse.zig | 12 ++++++++++-- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/main.zig b/src/main.zig index 8ad8be1..f2ee7bd 100644 --- a/src/main.zig +++ b/src/main.zig @@ -110,24 +110,30 @@ pub fn main() !void { var out_buffer = std.ArrayList(u8).init(allocator); var w = out_buffer.writer().adaptToNewApi(); - generator.generate(allocator, api, xml_src, maybe_video_xml_src, &w.new_interface) catch |err| switch (err) { - error.InvalidXml => { - std.log.err("invalid vulkan registry - invalid xml", .{}); - std.log.err("please check that the correct vk.xml file is passed", .{}); - std.process.exit(1); - }, - error.InvalidRegistry => { - std.log.err("invalid vulkan registry - registry is valid xml but contents are invalid", .{}); - std.log.err("please check that the correct vk.xml file is passed", .{}); - std.process.exit(1); - }, - error.UnhandledBitfieldStruct => { - std.log.err("unhandled struct with bit fields detected in vk.xml", .{}); - std.log.err("this is a bug in vulkan-zig", .{}); - std.log.err("please make a bug report at https://github.com/Snektron/vulkan-zig/issues/", .{}); - std.process.exit(1); - }, - error.OutOfMemory, error.WriteFailed => @panic("oom"), + generator.generate(allocator, api, xml_src, maybe_video_xml_src, &w.new_interface) catch |err| { + if (debug) { + return err; + } + + switch (err) { + error.InvalidXml => { + std.log.err("invalid vulkan registry - invalid xml", .{}); + std.log.err("please check that the correct vk.xml file is passed", .{}); + std.process.exit(1); + }, + error.InvalidRegistry => { + std.log.err("invalid vulkan registry - registry is valid xml but contents are invalid", .{}); + std.log.err("please check that the correct vk.xml file is passed", .{}); + std.process.exit(1); + }, + error.UnhandledBitfieldStruct => { + std.log.err("unhandled struct with bit fields detected in vk.xml", .{}); + std.log.err("this is a bug in vulkan-zig", .{}); + std.log.err("please make a bug report at https://github.com/Snektron/vulkan-zig/issues/", .{}); + std.process.exit(1); + }, + error.OutOfMemory, error.WriteFailed => @panic("oom"), + } }; out_buffer.append(0) catch @panic("oom"); diff --git a/src/vulkan/parse.zig b/src/vulkan/parse.zig index 548572b..7cd72c1 100644 --- a/src/vulkan/parse.zig +++ b/src/vulkan/parse.zig @@ -365,10 +365,18 @@ fn parsePointerMeta(fields: Fields, type_info: *registry.TypeInfo, elem: *xml.El else => break, }; - if (it.next()) |_| { + if (it.next()) |_| ignore: { // There are more elements in the `len` attribute than there are pointers // Something probably went wrong - std.log.err("len: {s}", .{lens}); + switch (current_type_info.*) { + .name => |name| if (std.mem.eql(u8, name, "StdVideoH265SubLayerHrdParameters")) { + // Known issue: https://github.com/KhronosGroup/Vulkan-Docs/issues/2557 + break :ignore; + }, + else => {}, + } + + std.log.err("excessive pointer lengths: {s}", .{lens}); return error.InvalidRegistry; } }