This commit is contained in:
2025-11-02 22:41:17 +01:00
parent c94e15b639
commit a2948bd65d
3 changed files with 22 additions and 2 deletions

View File

@@ -26,13 +26,21 @@ pub fn build(b: *std.Build) !void {
.link_libc = true,
});
const interface_dependency = b.dependency("interface", .{
.target = target,
.optimize = optimize,
});
const vulkan_headers = b.dependency("vulkan_headers", .{});
const vulkan = b.dependency("vulkan_zig", .{
.registry = vulkan_headers.path("registry/vk.xml"),
}).module("vulkan-zig");
const interface_mod = interface_dependency.module("interface");
common_mod.addImport("vulkan", vulkan);
common_mod.addImport("interface", interface_mod);
common_mod.addSystemIncludePath(vulkan_headers.path("include"));
for (implementations) |impl| {
@@ -44,6 +52,7 @@ pub fn build(b: *std.Build) !void {
.imports = &.{
.{ .name = "common", .module = common_mod },
.{ .name = "vulkan", .module = vulkan },
.{ .name = "interface", .module = interface_mod },
},
});

View File

@@ -18,6 +18,10 @@
.hash = "cpuinfo-0.1.0-V7dMLcghAADJuG7dkd3MnwDPZ232pBK_8uGjxY43eP5u",
.lazy = true,
},
.interface = .{
.url = "git+https://github.com/nilslice/zig-interface#19f2c937b77e42b15bc8cacaa2894ce5b783d94d",
.hash = "interface-0.0.2-GFlWJ7KOAQAkHikqZU0XV86AhX7R9jCyGza85lTIqcEU",
},
},
.paths = .{

View File

@@ -3,6 +3,7 @@ const vk = @import("vulkan");
const Instance = @import("Instance.zig");
const common = @import("common");
const root = @import("root");
const cpuinfo = @import("cpuinfo");
const dispatchable = common.dispatchable;
@@ -13,6 +14,8 @@ instance: *const Instance,
common_physical_device: common.PhysicalDevice,
pub fn init(self: *Self) !void {
const allocator = std.heap.c_allocator;
self.common_physical_device.props = .{
.api_version = @bitCast(root.VULKAN_VERSION),
.driver_version = @bitCast(root.DRIVER_VERSION),
@@ -24,8 +27,12 @@ pub fn init(self: *Self) !void {
.limits = undefined,
.sparse_properties = undefined,
};
var writer = std.io.Writer.fixed(&self.common_physical_device.props.device_name);
try writer.print("Software Vulkan Driver", .{});
const info = try cpuinfo.get(allocator);
defer info.deinit(allocator);
var writer = std.io.Writer.fixed(self.common_physical_device.props.device_name[0 .. vk.MAX_PHYSICAL_DEVICE_NAME_SIZE - 1]);
try writer.print("{s} [Soft Vulkan Driver]", .{info.name});
}
pub fn getProperties(p_physical_device: vk.PhysicalDevice, properties: *vk.PhysicalDeviceProperties) callconv(vk.vulkan_call_conv) void {