ci skip; start of update to zig 0.16
Build / build (push) Has been skipped
Test / build_and_test (push) Has been skipped

This commit is contained in:
2026-04-16 22:15:07 +02:00
parent ee0ffbe09d
commit 5be875c07e
15 changed files with 243 additions and 105 deletions
+25 -2
View File
@@ -14,6 +14,8 @@ pub const Interface = base.DescriptorPool;
interface: Interface,
list: std.ArrayList(*SoftDescriptorSet),
pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const vk.DescriptorPoolCreateInfo) VkError!*Self {
const self = allocator.create(Self) catch return VkError.OutOfHostMemory;
errdefer allocator.destroy(self);
@@ -24,27 +26,48 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
.allocateDescriptorSet = allocateDescriptorSet,
.destroy = destroy,
.freeDescriptorSet = freeDescriptorSet,
.reset = reset,
};
self.* = .{
.interface = interface,
.list = std.ArrayList(*SoftDescriptorSet).initCapacity(allocator, info.max_sets) catch return VkError.OutOfHostMemory,
};
return self;
}
pub fn allocateDescriptorSet(interface: *Interface, layout: *base.DescriptorSetLayout) VkError!*base.DescriptorSet {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
const allocator = VulkanAllocator.init(null, .object).allocator();
const set = try SoftDescriptorSet.create(interface.owner, allocator, layout);
self.list.appendAssumeCapacity(set);
return &set.interface;
}
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
self.list.deinit(allocator);
allocator.destroy(self);
}
pub fn freeDescriptorSet(interface: *Interface, set: *base.DescriptorSet) VkError!void {
_ = interface;
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
const soft_set: *SoftDescriptorSet = @alignCast(@fieldParentPtr("interface", set));
if (std.mem.indexOfScalar(*SoftDescriptorSet, self.list.items, soft_set)) |pos| {
_ = self.list.orderedRemove(pos);
}
const allocator = VulkanAllocator.init(null, .object).allocator();
allocator.destroy(set);
allocator.destroy(soft_set);
}
pub fn reset(interface: *Interface, _: vk.DescriptorPoolResetFlags) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
const allocator = VulkanAllocator.init(null, .object).allocator();
for (self.list.items) |set| {
allocator.destroy(set);
}
self.list.clearRetainingCapacity();
}