working on queues

This commit is contained in:
2025-11-09 21:06:33 +01:00
parent b4b88ac2db
commit b2d964c96a
10 changed files with 84 additions and 39 deletions

View File

@@ -10,8 +10,11 @@ const VkError = base.VkError;
const Self = @This();
pub const Interface = base.Device;
const SpawnError = std.Thread.SpawnError;
interface: Interface,
device_allocator: std.heap.ThreadSafeAllocator,
workers: std.Thread.Pool,
pub fn create(physical_device: *base.PhysicalDevice, allocator: std.mem.Allocator, info: *const vk.DeviceCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
@@ -32,13 +35,20 @@ pub fn create(physical_device: *base.PhysicalDevice, allocator: std.mem.Allocato
self.* = .{
.interface = interface,
.device_allocator = .{ .child_allocator = std.heap.c_allocator }, // TODO: better device allocator base
.device_allocator = .{ .child_allocator = std.heap.c_allocator }, // TODO: better device allocator
.workers = undefined,
};
self.workers.init(.{ .allocator = std.heap.c_allocator }) catch |err| return switch (err) {
SpawnError.OutOfMemory, SpawnError.LockedMemoryLimitExceeded => VkError.OutOfDeviceMemory,
else => VkError.Unknown,
};
return self;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
self.workers.deinit();
allocator.destroy(self);
}

14
src/soft/SoftQueue.zig git.filemode.normal_file
View File

@@ -0,0 +1,14 @@
const std = @import("std");
const vk = @import("vulkan");
const base = @import("base");
const SoftDeviceMemory = @import("SoftDeviceMemory.zig");
const SoftFence = @import("SoftFence.zig");
const VkError = base.VkError;
const Self = @This();
pub const Interface = base.Queue;
interface: Interface,
mutex: std.Thread.Mutex,

View File

@@ -4,8 +4,11 @@ pub const base = @import("base");
pub const SoftInstance = @import("SoftInstance.zig");
pub const SoftDevice = @import("SoftDevice.zig");
pub const SoftDeviceMemory = @import("SoftDeviceMemory.zig");
pub const SoftPhysicalDevice = @import("SoftPhysicalDevice.zig");
pub const SoftQueue = @import("SoftQueue.zig");
pub const SoftDeviceMemory = @import("SoftDeviceMemory.zig");
pub const SoftFence = @import("SoftFence.zig");
pub const Instance = SoftInstance;