working on queues

This commit is contained in:
2025-11-10 21:19:37 +01:00
parent 4c2963f109
commit 6215a20ed6
7 changed files with 50 additions and 7 deletions

View File

@@ -39,7 +39,7 @@ pub fn create(physical_device: *base.PhysicalDevice, allocator: std.mem.Allocato
.workers = undefined,
};
self.workers.init(.{ .allocator = std.heap.c_allocator }) catch |err| return switch (err) {
self.workers.init(.{ .allocator = self.interface.host_allocator.allocator() }) catch |err| return switch (err) {
SpawnError.OutOfMemory, SpawnError.LockedMemoryLimitExceeded => VkError.OutOfDeviceMemory,
else => VkError.Unknown,
};

View File

@@ -29,7 +29,7 @@ fn requestPhysicalDevices(interface: *Interface, allocator: std.mem.Allocator) V
// Software driver only has one physical device (the CPU)
const physical_device = try SoftPhysicalDevice.create(allocator, interface);
errdefer physical_device.interface.releasePhysicalDevice(allocator) catch {};
interface.physical_devices.append(allocator, try Dispatchable(SoftPhysicalDevice.Interface).wrap(allocator, &physical_device.interface)) catch return VkError.OutOfHostMemory;
interface.physical_devices.append(allocator, try Dispatchable(base.PhysicalDevice).wrap(allocator, &physical_device.interface)) catch return VkError.OutOfHostMemory;
}
fn releasePhysicalDevices(interface: *Interface, allocator: std.mem.Allocator) VkError!void {

View File

@@ -90,7 +90,7 @@ pub fn create(allocator: std.mem.Allocator, instance: *const base.Instance) VkEr
return self;
}
pub fn createDevice(interface: *Interface, allocator: std.mem.Allocator, infos: *const vk.DeviceCreateInfo) VkError!*SoftDevice.Interface {
pub fn createDevice(interface: *Interface, allocator: std.mem.Allocator, infos: *const vk.DeviceCreateInfo) VkError!*base.Device {
const device = try SoftDevice.create(interface, allocator, infos);
return &device.interface;
}

View File

@@ -12,3 +12,41 @@ pub const Interface = base.Queue;
interface: Interface,
mutex: std.Thread.Mutex,
pub fn create(allocator: std.mem.Allocator, device: *const base.Device, index: u32, family_index: u32, flags: vk.DeviceQueueCreateFlags) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
var interface = try Interface.init(allocator, device, index, family_index, flags);
interface.dispatch_table = &.{
.bindSparse = bindSparse,
.submit = submit,
.waitIdle = waitIdle,
};
self.* = .{
.interface = interface,
.mutex = .{},
};
return self;
}
pub fn bindSparse(interface: *Interface, info: []*const vk.BindSparseInfo, fence: ?*base.Fence) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
_ = self;
_ = info;
_ = fence;
}
pub fn submit(interface: *Interface, info: []*const vk.SubmitInfo, fence: ?*base.Fence) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
_ = self;
_ = info;
_ = fence;
}
pub fn waitIdle(interface: *Interface) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
_ = self;
}