adding command descriptors and buffer base

This commit is contained in:
2025-11-19 21:21:36 +01:00
parent 8ee6c9f63d
commit 4c91713ccd
2 changed files with 92 additions and 1 deletions

View File

@@ -2,12 +2,42 @@ const std = @import("std");
const vk = @import("vulkan");
const VkError = @import("error_set.zig").VkError;
const DeviceMemory = @import("DeviceMemory.zig");
const Device = @import("Device.zig");
const Self = @This();
pub const ObjectType: vk.ObjectType = .buffer;
owner: *const Device,
owner: *Device,
size: vk.DeviceSize,
offset: vk.DeviceSize,
usage: vk.BufferUsageFlags,
memory: ?*DeviceMemory,
allowed_memory_types: u32,
vtable: *const VTable,
pub const VTable = struct {
getMemoryRequirements: *const fn (*Self, *vk.MemoryRequirements) void,
};
pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.BufferCreateInfo) VkError!Self {
_ = allocator;
return .{
.owner = device,
.size = info.size,
.offset = 0,
.usage = info.usage,
.memory = null,
.allowed_memory_types = 0,
.vtable = undefined,
};
}
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;
}
self.memory = memory;
self.offset = offset;
}