fixing crashes
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@ scripts/__pycache__/
|
||||
*.xml
|
||||
*.html
|
||||
*.pyc
|
||||
*.spv
|
||||
|
||||
@@ -32,6 +32,7 @@ pub fn build(b: *std.Build) !void {
|
||||
|
||||
const zdt = b.dependency("zdt", .{}).module("zdt");
|
||||
const zigrc = b.dependency("zigrc", .{}).module("zigrc");
|
||||
//const spv_tools = b.dependency("SPIRV_Tools", .{}).module("zigrc");
|
||||
const vulkan_headers = b.dependency("vulkan_headers", .{});
|
||||
const vulkan_utility_libraries = b.dependency("vulkan_utility_libraries", .{});
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
.minimum_zig_version = "0.15.2",
|
||||
|
||||
.dependencies = .{
|
||||
//.SPIRV_Tools = .{
|
||||
// .url = "git+https://git.kbz8.me/kbz_8/SPIRV-Toolz#2eed675251bbcf21ef34368d289be49d83bce781",
|
||||
// .hash = "SPIRV_Tools-2026.1.0-7hzMwUeVAAA2Q60MBfoAvZypYnJ9Rzf-hxUkZAaJAo57",
|
||||
//},
|
||||
.compile_commands = .{
|
||||
.url = "git+https://github.com/the-argus/zig-compile-commands#f74e2d13e43fafab3a71e19557a0e1cfbf0f2e1b",
|
||||
.hash = "zig_compile_commands-0.0.1-OZg5-a3CAACM-h32Kjb1obTMqrKGs9YoDhorVZ8-LGle",
|
||||
@@ -34,9 +38,8 @@
|
||||
.hash = "zigrc-1.0.0-lENlWzvQAACulrbkL9PVhWjFsWSkYhi7AmfSbCM-2Xlh",
|
||||
},
|
||||
.SPIRV_Interpreter = .{
|
||||
.url = "git+https://git.kbz8.me/kbz_8/SPIRV-Interpreter#e21d26d9975b96a222b70648ceeea9e473e9657f",
|
||||
.hash = "SPIRV_Interpreter-0.0.1-ajmpn2tAAwCBI0oWa3VKlYX3MEM0OxN4iXQ-PwO6_Vhx",
|
||||
//.path = "../SPIRV-Interpreter",
|
||||
.url = "git+https://git.kbz8.me/kbz_8/SPIRV-Interpreter#57de432d0b43f050b5117a7c6add09e3906664fd",
|
||||
.hash = "SPIRV_Interpreter-0.0.1-ajmpnyg_AwCeuAEr4KMaBqdCWA2IUsT8Q3mGuUo1PZ2b",
|
||||
},
|
||||
.cpuinfo = .{
|
||||
.url = "git+https://github.com/Kbz-8/cpuinfo#4883954cfcec3f6c9ca9c4aaddfc26107e08726f",
|
||||
|
||||
@@ -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,
|
||||
.{
|
||||
.module = spv.Module.init(allocator, code, .{
|
||||
.use_simd_vectors_specializations = !std.process.hasEnvVarConstant(lib.NO_SHADER_SIMD_ENV_NAME),
|
||||
},
|
||||
) catch |err| switch (err) {
|
||||
}) catch |err| switch (err) {
|
||||
spv.Module.ModuleError.OutOfMemory => return VkError.OutOfHostMemory,
|
||||
else => return VkError.ValidationFailed,
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user