From d4a04e0bea045f273c21a997583181e02b854a7f Mon Sep 17 00:00:00 2001 From: bluesillybeard Date: Fri, 26 Apr 2024 20:42:44 -0600 Subject: [PATCH] Implement initial suggestions on PR --- generator/vulkan/render.zig | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/generator/vulkan/render.zig b/generator/vulkan/render.zig index 3b9115a..18720d0 100644 --- a/generator/vulkan/render.zig +++ b/generator/vulkan/render.zig @@ -1050,8 +1050,8 @@ fn Renderer(comptime WriterType: type) type { try self.writer.writeAll("= Info {\n"); try self.writer.print(".name = \"{s}\", .version = {},", .{ ext.name, ext.version }); // collect extension functions - for(ext.requires) |require| { - for(require.commands) |command_name| { + for (ext.requires) |require| { + for (require.commands) |command_name| { const decl = self.resolveDeclaration(command_name) orelse continue; // If the target type does not exist, it was likely an empty enum - // assume spec is correct and that this was not a function alias. @@ -1063,36 +1063,19 @@ fn Renderer(comptime WriterType: type) type { const class = classifyCommandDispatch(command_name, command); switch (class) { // Vulkan extensions cannot add base functions. - .base => continue, - // TODO: some extensions have multiple separate requirements. - // For example, "VK_KHR_push_descriptor" depends on either "VK_VERSION_1_1" or "VK_KHR_descriptor_update_template", - // which causes the same function to be mentioned twice; once for each requirement. - // For now, duplicate functions are just removed, - // However in the future it might be worth exposing these separate requirements somehow. + .base => return error.InvalidRegistry, .instance => { - var duplicate = false; - for(instance_commands.items) |cmd| { - if(std.mem.eql(u8, cmd, command_name)) { - duplicate = true; - } - } - if(!duplicate) try instance_commands.append(command_name); + try instance_commands.append(command_name); }, .device => { - var duplicate = false; - for(device_commands.items) |cmd| { - if(std.mem.eql(u8, cmd, command_name)) { - duplicate = true; - } - } - if(!duplicate) try device_commands.append(command_name); + try device_commands.append(command_name); }, } } } // and write them out try self.writer.writeAll(".instance_functions = .{\n"); - for(instance_commands.items) |command_name| { + for (instance_commands.items) |command_name| { try self.writer.writeAll("."); try self.writeIdentifierWithCase(.camel, trimVkNamespace(command_name)); try self.writer.writeAll(" = true, \n"); @@ -1101,7 +1084,7 @@ fn Renderer(comptime WriterType: type) type { instance_commands.clearRetainingCapacity(); try self.writer.writeAll(".device_functions = .{\n"); - for(device_commands.items) |command_name| { + for (device_commands.items) |command_name| { try self.writer.writeAll("."); try self.writeIdentifierWithCase(.camel, trimVkNamespace(command_name)); try self.writer.writeAll(" = true, \n");