SPIR-V render setup

This commit is contained in:
Robin Voetter
2020-08-13 01:42:41 +02:00
parent d87868c510
commit 2e4ce7c37e
3 changed files with 54 additions and 1 deletions

View File

@@ -5,5 +5,6 @@ pub const ShaderCompileStep = @import("build_integration.zig").ShaderCompileStep
test "main" {
_ = @import("xml.zig");
_ = @import("vulkan/c-parse.zig");
_ = @import("vulkan/c_parse.zig");
_ = @import("spirv/generator.zig");
}

View File

@@ -1,5 +1,6 @@
const std = @import("std");
const reg = @import("registry.zig");
const renderSpirv = @import("render.zig").render;
const Allocator = std.mem.Allocator;
pub fn generate(allocator: *Allocator, spec_jsons: []const []const u8, writer: anytype) !void {
@@ -32,4 +33,6 @@ pub fn generate(allocator: *Allocator, spec_jsons: []const []const u8, writer: a
if (ext_registry_i != num_ext_registries) {
return error.MultipleCoreRegistries;
}
try renderSpirv(writer, allocator, &core_registry, ext_registries);
}

View File

@@ -0,0 +1,49 @@
const std = @import("std");
const reg = @import("registry.zig");
const IdRenderer = @import("../id_render.zig").IdRenderer;
const Allocator = std.mem.Allocator;
// The SPIR-V spec doesn't contain any tag information like vulkan.xml does,
// so the tags are just hardcoded. They are retrieved from
// https://github.com/KhronosGroup/SPIRV-Registry/tree/master/extensions
const tags = [_][]const u8{
"AMD",
"EXT",
"GOOGLE",
"INTEL",
"KHR",
"NV",
};
fn Renderer(comptime WriterType: type) type {
return struct {
const Self = @This();
writer: WriterType,
allocator: *Allocator,
core: *const reg.CoreRegistry,
extensions: []const reg.ExtensionRegistry,
id_renderer: IdRenderer,
fn deinit(self: Self) void {
}
fn render(self: *Self) !void {
}
};
}
pub fn render(writer: anytype, allocator: *Allocator, core: *const reg.CoreRegistry, extensions: []const reg.ExtensionRegistry) !void {
const id_renderer = IdRenderer.init(allocator, &tags);
var renderer = Renderer(@TypeOf(writer)) {
.writer = writer,
.allocator = allocator,
.core = core,
.extensions = extensions,
.id_renderer = id_renderer,
};
defer renderer.deinit();
try renderer.render();
}