forked from mirror/vulkan-zig
SPIR-V render setup
This commit is contained in:
@@ -5,5 +5,6 @@ pub const ShaderCompileStep = @import("build_integration.zig").ShaderCompileStep
|
|||||||
|
|
||||||
test "main" {
|
test "main" {
|
||||||
_ = @import("xml.zig");
|
_ = @import("xml.zig");
|
||||||
_ = @import("vulkan/c-parse.zig");
|
_ = @import("vulkan/c_parse.zig");
|
||||||
|
_ = @import("spirv/generator.zig");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const reg = @import("registry.zig");
|
const reg = @import("registry.zig");
|
||||||
|
const renderSpirv = @import("render.zig").render;
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
|
|
||||||
pub fn generate(allocator: *Allocator, spec_jsons: []const []const u8, writer: anytype) !void {
|
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) {
|
if (ext_registry_i != num_ext_registries) {
|
||||||
return error.MultipleCoreRegistries;
|
return error.MultipleCoreRegistries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try renderSpirv(writer, allocator, &core_registry, ext_registries);
|
||||||
}
|
}
|
||||||
|
|||||||
49
generator/spirv/render.zig
Normal file
49
generator/spirv/render.zig
Normal 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();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user