adding base Image and ICD file generation

This commit is contained in:
2025-11-23 02:39:56 +01:00
parent b586ff18e1
commit b65d5cf183
17 changed files with 438 additions and 48 deletions

View File

@@ -38,6 +38,7 @@ dispatch_table: *const DispatchTable,
pub const DispatchTable = struct {
begin: *const fn (*Self, *const vk.CommandBufferBeginInfo) VkError!void,
copyBuffer: *const fn (*Self, *Buffer, *Buffer, []const vk.BufferCopy) VkError!void,
end: *const fn (*Self) VkError!void,
fillBuffer: *const fn (*Self, *Buffer, vk.DeviceSize, vk.DeviceSize, u32) VkError!void,
reset: *const fn (*Self, vk.CommandBufferResetFlags) VkError!void,
@@ -71,6 +72,7 @@ inline fn transitionState(self: *Self, target: State, from_allowed: []const Stat
}
pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
self.cleanCommandList();
self.commands.deinit(allocator);
self.vtable.destroy(self, allocator);
}
@@ -94,6 +96,8 @@ pub inline fn reset(self: *Self, flags: vk.CommandBufferResetFlags) VkError!void
if (!self.pool.flags.reset_command_buffer_bit) {
return VkError.ValidationFailed;
}
defer self.cleanCommandList();
self.transitionState(.Initial, &.{ .Initial, .Recording, .Executable, .Invalid }) catch return VkError.ValidationFailed;
try self.dispatch_table.reset(self, flags);
}
@@ -107,15 +111,19 @@ pub inline fn submit(self: *Self) VkError!void {
self.transitionState(.Pending, &.{ .Pending, .Executable }) catch return VkError.ValidationFailed;
}
fn cleanCommandList(self: *Self) void {
const allocator = self.host_allocator.allocator();
_ = allocator;
for (self.commands.items) |command| {
switch (command) {
else => {},
}
}
}
// Commands ====================================================================================================
pub inline fn fillBuffer(self: *Self, buffer: *Buffer, offset: vk.DeviceSize, size: vk.DeviceSize, data: u32) VkError!void {
if (offset >= buffer.size) return VkError.ValidationFailed;
if (size != vk.WHOLE_SIZE and (size == 0 or size > offset + buffer.size)) return VkError.ValidationFailed;
if ((size != vk.WHOLE_SIZE and @mod(size, 4) != 0) or @mod(offset, 4) != 0) return VkError.ValidationFailed;
if (!buffer.usage.transfer_dst_bit) return VkError.ValidationFailed;
if (buffer.memory == null) return VkError.ValidationFailed;
const allocator = self.host_allocator.allocator();
self.commands.append(allocator, .{ .FillBuffer = .{
.buffer = buffer,
@@ -125,3 +133,13 @@ pub inline fn fillBuffer(self: *Self, buffer: *Buffer, offset: vk.DeviceSize, si
} }) catch return VkError.OutOfHostMemory;
try self.dispatch_table.fillBuffer(self, buffer, offset, size, data);
}
pub inline fn copyBuffer(self: *Self, src: *Buffer, dst: *Buffer, regions: []const vk.BufferCopy) VkError!void {
const allocator = self.host_allocator.allocator();
self.commands.append(allocator, .{ .CopyBuffer = .{
.src = src,
.dst = dst,
.regions = regions,
} }) catch return VkError.OutOfHostMemory;
try self.dispatch_table.copyBuffer(self, src, dst, regions);
}