[IR/Flint] adding shared SPIR-V IR and Gen9 vertex lowering
Mirror Gitea refs to GitHub / mirror (push) Successful in 15s
Test / build_and_test (push) Successful in 3m26s
Build / build (push) Successful in 4m53s

This commit is contained in:
2026-08-05 17:20:49 +02:00
parent 85ae10d69a
commit 937b84cbc3
19 changed files with 1672 additions and 250 deletions
+6 -10
View File
@@ -5,15 +5,14 @@ const spv = @import("spv");
const VkError = base.VkError;
const Self = @This();
pub const Interface = base.ShaderModule;
interface: Interface,
module: spv.Module,
/// Pipelines need SPIR-V module reference so shader module may not
/// be destroy on call to `vkDestroyShaderModule`
/// Pipelines need a SPIR-V module reference so the shader module may outlive
/// the application's `vkDestroyShaderModule` call.
ref_count: std.atomic.Value(usize),
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.ShaderModuleCreateInfo) VkError!*Self {
@@ -21,6 +20,7 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
errdefer allocator.destroy(self);
var interface = try Interface.init(device, allocator, info);
errdefer interface.deinit();
const device_allocator = device.device_allocator.allocator();
@@ -28,11 +28,9 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
.destroy = destroy,
};
const code = info.p_code[0..@divExact(info.code_size, 4)];
self.* = .{
.interface = interface,
.module = spv.Module.init(device_allocator, code, .{
.module = spv.Module.init(device_allocator, interface.code(), .{
.use_simd_vectors_specializations = base.config.soft_shaders_simd,
}) catch |err| switch (err) {
spv.Module.ModuleError.OutOfMemory => return VkError.OutOfHostMemory,
@@ -59,9 +57,8 @@ pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
pub fn drop(self: *Self, allocator: std.mem.Allocator) void {
const device_allocator = self.interface.owner.device_allocator.allocator();
self.module.deinit(device_allocator);
self.interface.deinit();
allocator.destroy(self);
}
@@ -70,7 +67,6 @@ pub fn ref(self: *Self) void {
}
pub fn unref(self: *Self, allocator: std.mem.Allocator) void {
if (self.ref_count.fetchSub(1, .release) == 1) {
if (self.ref_count.fetchSub(1, .acq_rel) == 1)
self.drop(allocator);
}
}