diff --git a/README.md b/README.md index 5fa9200..0643485 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,6 @@ vkUpdateDescriptorSets | ⚙️ WIP vkWaitForFences | ✅ Implemented -\ [Here](https://vulkan-driver-cts-report.kbz8.me/) shalt thou find a most meticulous account of the Vulkan 1.0 conformance trials, set forth for thy scrutiny. ## License diff --git a/build.zig b/build.zig index d702b9f..513043a 100644 --- a/build.zig +++ b/build.zig @@ -7,7 +7,7 @@ const ImplementationDesc = struct { name: []const u8, root_source_file: []const u8, vulkan_version: std.SemanticVersion, - custom: ?*const fn (*std.Build, *std.Build.Module) anyerror!void = null, + custom: ?*const fn (*std.Build, *std.Build.Step.Compile) anyerror!void = null, }; const implementations = [_]ImplementationDesc{ @@ -59,10 +59,6 @@ pub fn build(b: *std.Build) !void { lib_mod.addSystemIncludePath(vulkan_headers.path("include")); - if (impl.custom) |custom| { - custom(b, lib_mod) catch continue; - } - const lib = b.addLibrary(.{ .name = b.fmt("vulkan_{s}", .{impl.name}), .root_module = lib_mod, @@ -70,6 +66,10 @@ pub fn build(b: *std.Build) !void { .use_llvm = true, // Fixes some random bugs happenning with custom backend. Investigations needed }); + if (impl.custom) |custom| { + custom(b, lib) catch continue; + } + const icd_file = b.addWriteFile( b.getInstallPath(.lib, b.fmt("vk_stroll_{s}.json", .{impl.name})), b.fmt( @@ -122,9 +122,10 @@ pub fn build(b: *std.Build) !void { docs_step.dependOn(&install_docs.step); } -fn customSoft(b: *std.Build, mod: *std.Build.Module) !void { +fn customSoft(b: *std.Build, lib: *std.Build.Step.Compile) !void { const cpuinfo = b.lazyDependency("cpuinfo", .{}) orelse return error.UnresolvedDependency; - mod.addImport("cpuinfo", cpuinfo.module("cpuinfo")); + lib.addSystemIncludePath(cpuinfo.path("include")); + lib.linkLibrary(cpuinfo.artifact("cpuinfo")); } fn addCTest(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, vulkan_headers: *std.Build.Dependency, impl: *const ImplementationDesc, impl_lib: *std.Build.Step.Compile) !*std.Build.Step.Compile { diff --git a/build.zig.zon b/build.zig.zon index f694e28..843aa72 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -30,8 +30,8 @@ .hash = "N-V-__8AAAQc6QJfozxsyRgirFFsKICXgADgmdztIaZkDBmF", }, .cpuinfo = .{ - .url = "git+https://github.com/Kbz-8/cpuinfo-zig#77f82a1248194e7fb706967343c66021f8522766", - .hash = "cpuinfo-0.1.0-V7dMLcghAADJuG7dkd3MnwDPZ232pBK_8uGjxY43eP5u", + .url = "git+https://github.com/Kbz-8/cpuinfo#4883954cfcec3f6c9ca9c4aaddfc26107e08726f", + .hash = "cpuinfo-0.0.1-RLgIQTLRMgF4dLo8AJ-HvnpFsJe6jmXCJjMWWjil6RF1", .lazy = true, }, .volk = .{ diff --git a/src/soft/SoftPhysicalDevice.zig b/src/soft/SoftPhysicalDevice.zig index b6411e8..6c18f89 100644 --- a/src/soft/SoftPhysicalDevice.zig +++ b/src/soft/SoftPhysicalDevice.zig @@ -2,7 +2,7 @@ const std = @import("std"); const vk = @import("vulkan"); const base = @import("base"); const root = @import("lib.zig"); -const cpuinfo = @import("cpuinfo"); +const cpuinfo = @cImport(@cInclude("cpuinfo.h")); const SoftDevice = @import("SoftDevice.zig"); @@ -193,12 +193,13 @@ pub fn create(allocator: std.mem.Allocator, instance: *const base.Instance) VkEr interface.queue_family_props.appendSlice(allocator, queue_family_props[0..]) catch return VkError.OutOfHostMemory; if (device_name[0] == 0) { - // TODO: use Pytorch's cpuinfo someday const name = blk: { - const info = cpuinfo.get(command_allocator) catch break :blk command_allocator.dupe(u8, "Unkown") catch return VkError.OutOfHostMemory; - defer info.deinit(command_allocator); - - break :blk command_allocator.dupe(u8, info.name) catch return VkError.OutOfHostMemory; + if (cpuinfo.cpuinfo_initialize()) { + const package = cpuinfo.cpuinfo_get_package(0).*; + const non_sentinel_name = package.name[0..(std.mem.len(@as([*:0]const u8, @ptrCast(&package.name))))]; + break :blk std.fmt.allocPrint(command_allocator, "{s} {d} cores", .{ non_sentinel_name, package.processor_count }) catch return VkError.OutOfHostMemory; + } + break :blk command_allocator.dupe(u8, "Unkown") catch return VkError.OutOfHostMemory; }; defer command_allocator.free(name);