fixing crashes
Some checks failed
Build / build (push) Successful in 2m29s
Test / build_and_test (push) Failing after 45m9s

This commit is contained in:
2026-01-27 22:56:03 +01:00
parent f042daa896
commit 1f8415f1b2
8 changed files with 18 additions and 53 deletions

View File

@@ -27,13 +27,9 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
self.* = .{
.interface = interface,
.module = spv.Module.init(
allocator,
code,
.{
.use_simd_vectors_specializations = !std.process.hasEnvVarConstant(lib.NO_SHADER_SIMD_ENV_NAME),
},
) catch |err| switch (err) {
.module = spv.Module.init(allocator, code, .{
.use_simd_vectors_specializations = !std.process.hasEnvVarConstant(lib.NO_SHADER_SIMD_ENV_NAME),
}) catch |err| switch (err) {
spv.Module.ModuleError.OutOfMemory => return VkError.OutOfHostMemory,
else => return VkError.ValidationFailed,
},

View File

@@ -30,5 +30,8 @@ pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.Descr
}
pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
if (self.bindings) |bindings| {
allocator.free(bindings);
}
self.vtable.destroy(self, allocator);
}

View File

@@ -20,12 +20,8 @@ pub const VTable = struct {
};
pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.ShaderModuleCreateInfo) VkError!Self {
if (std.process.hasEnvVarConstant(lib.DRIVER_LOG_SPIRV_ENV_NAME)) {
logShaderModule(allocator, info) catch |e| {
std.log.scoped(.ShaderModule).err("Failed to disassemble SPIR-V module to readable text: {s}", .{@errorName(e)});
};
}
_ = allocator;
_ = info;
return .{
.owner = device,
.vtable = undefined,
@@ -35,38 +31,3 @@ pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.Shade
pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
self.vtable.destroy(self, allocator);
}
fn logShaderModule(allocator: std.mem.Allocator, info: *const vk.ShaderModuleCreateInfo) !void {
std.log.scoped(.ShaderModule).info("Logging SPIR-V module", .{});
var process = std.process.Child.init(&[_][]const u8{ "spirv-dis", "/home/kbz_8/Documents/Code/Zig/SPIRV-Interpreter/example/shader.spv" }, allocator);
process.stdout_behavior = .Pipe;
process.stderr_behavior = .Pipe;
process.stdin_behavior = .Pipe;
var stdout: std.ArrayList(u8) = .empty;
defer stdout.deinit(allocator);
var stderr: std.ArrayList(u8) = .empty;
defer stderr.deinit(allocator);
try process.spawn();
errdefer {
_ = process.kill() catch {};
}
_ = info;
//try process.collectOutput(allocator, &stdout, &stderr, 1024 * 1024);
//if (process.stdin) |stdin| {
// _ = try stdin.write(@as([*]const u8, @ptrCast(info.p_code))[0..info.code_size]);
//} else {
// std.log.scoped(.ShaderModule).err("Failed to disassemble SPIR-V module to readable text.", .{});
//}
_ = try process.wait();
if (stderr.items.len != 0) {
std.log.scoped(.ShaderModule).err("Failed to disassemble SPIR-V module to readable text.\n{s}", .{stderr.items});
} else if (stdout.items.len != 0) {
std.log.scoped(.ShaderModule).info("{s}\n{d}", .{ stdout.items, stdout.items.len });
}
}

View File

@@ -50,8 +50,6 @@ pub const VULKAN_VENDOR_ID = @typeInfo(vk.VendorId).@"enum".fields[@typeInfo(vk.
pub const DRIVER_DEBUG_ALLOCATOR_ENV_NAME = "STROLL_DEBUG_ALLOCATOR";
pub const DRIVER_LOGS_ENV_NAME = "STROLL_LOGS_LEVEL";
pub const DRIVER_LOG_SPIRV_ENV_NAME = "STROLL_LOG_SPIRV";
/// Default driver name
pub const DRIVER_NAME = "Unnamed Stroll Driver";
/// Default Vulkan version

View File

@@ -741,6 +741,7 @@ pub export fn strollCreateComputePipelines(p_device: vk.Device, p_cache: vk.Pipe
defer entryPointEndLogTrace();
const allocator = VulkanAllocator.init(callbacks, .object).allocator();
const device = Dispatchable(Device).fromHandleObject(p_device) catch |err| return toVkResult(err);
const cache = if (p_cache == .null_handle) null else NonDispatchable(PipelineCache).fromHandleObject(p_cache) catch |err| return toVkResult(err);
@@ -772,6 +773,7 @@ pub export fn strollCreateComputePipelines(p_device: vk.Device, p_cache: vk.Pipe
global_res = local_res;
}
}
return global_res;
}