adding icd base

This commit is contained in:
2025-11-04 17:44:10 +01:00
parent 795b38bdcc
commit 12ad577c25
6 changed files with 7202 additions and 31 deletions

View File

@@ -11,9 +11,9 @@ physical_devices: std.ArrayList(*Dispatchable(PhysicalDevice)),
dispatch_table: *const DispatchTable,
pub const DispatchTable = struct {
requestPhysicalDevices: *const fn (*Self, std.mem.Allocator) VkError!void,
releasePhysicalDevices: *const fn (*Self, std.mem.Allocator) VkError!void,
destroyInstance: *const fn (*Self, std.mem.Allocator) VkError!void,
releasePhysicalDevices: *const fn (*Self, std.mem.Allocator) VkError!void,
requestPhysicalDevices: *const fn (*Self, std.mem.Allocator) VkError!void,
};
pub fn init(allocator: std.mem.Allocator, infos: *const vk.InstanceCreateInfo) VkError!Self {
@@ -25,6 +25,26 @@ pub fn init(allocator: std.mem.Allocator, infos: *const vk.InstanceCreateInfo) V
};
}
pub fn deinit(self: *Self, allocator: std.mem.Allocator) VkError!void {
try self.dispatch_table.releasePhysicalDevices(self, allocator);
try self.dispatch_table.destroyInstance(self, allocator);
}
pub fn enumerateExtensionProperties(layer_name: ?[]const u8, property_count: *u32, properties: ?*vk.ExtensionProperties) VkError!void {
if (layer_name) |_| {
return VkError.LayerNotPresent;
}
_ = properties;
_ = std.StaticStringMap(vk.ExtensionProperties).initComptime(.{});
property_count.* = 0;
}
pub fn releasePhysicalDevices(self: *Self, allocator: std.mem.Allocator) VkError!void {
try self.dispatch_table.releasePhysicalDevices(self, allocator);
}
pub fn requestPhysicalDevices(self: *Self, allocator: std.mem.Allocator) VkError!void {
try self.dispatch_table.requestPhysicalDevices(self, allocator);
if (self.physical_devices.items.len == 0) {
@@ -35,12 +55,3 @@ pub fn requestPhysicalDevices(self: *Self, allocator: std.mem.Allocator) VkError
std.log.scoped(.vkCreateInstance).info("Found VkPhysicalDevice named {s}", .{physical_device.object.props.device_name});
}
}
pub fn releasePhysicalDevices(self: *Self, allocator: std.mem.Allocator) VkError!void {
try self.dispatch_table.releasePhysicalDevices(self, allocator);
}
pub fn deinit(self: *Self, allocator: std.mem.Allocator) VkError!void {
try self.dispatch_table.releasePhysicalDevices(self, allocator);
try self.dispatch_table.destroyInstance(self, allocator);
}