adding base Buffer, refactoring of unnecessary device layer functions

This commit is contained in:
2025-11-20 17:40:23 +01:00
parent 4c91713ccd
commit 967451a458
11 changed files with 208 additions and 190 deletions

View File

@@ -18,6 +18,7 @@ allowed_memory_types: u32,
vtable: *const VTable,
pub const VTable = struct {
destroy: *const fn (*Self, std.mem.Allocator) void,
getMemoryRequirements: *const fn (*Self, *vk.MemoryRequirements) void,
};
@@ -34,6 +35,10 @@ pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.Buffe
};
}
pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
self.vtable.destroy(self, allocator);
}
pub inline fn bindMemory(self: *Self, memory: *DeviceMemory, offset: vk.DeviceSize) VkError!void {
if (offset >= self.size or self.allowed_memory_types & memory.memory_type_index == 0) {
return VkError.ValidationFailed;
@@ -41,3 +46,9 @@ pub inline fn bindMemory(self: *Self, memory: *DeviceMemory, offset: vk.DeviceSi
self.memory = memory;
self.offset = offset;
}
pub inline fn getMemoryRequirements(self: *Self, requirements: *vk.MemoryRequirements) void {
requirements.size = self.size;
requirements.memory_type_bits = self.allowed_memory_types;
self.vtable.getMemoryRequirements(self, requirements);
}