adding image to png export to C test

This commit is contained in:
2025-11-23 22:00:24 +01:00
parent 823f058612
commit ea6260a638
15 changed files with 247 additions and 82 deletions

View File

@@ -18,12 +18,31 @@ pub fn deinit(self: *Self) void {
pub fn dispatch(self: *Self, command: *const cmd.Command) VkError!void {
_ = self;
switch (command.*) {
.ClearColorImage => |data| try clearColorImage(&data),
.CopyBuffer => |data| try copyBuffer(&data),
.CopyImage => |data| try copyImage(&data),
.FillBuffer => |data| try fillBuffer(&data),
else => {},
}
}
fn clearColorImage(data: *const cmd.CommandClearColorImage) VkError!void {
// TODO: use a blitter
const image = data.image;
for (data.ranges) |range| {
const image_size = image.getTotalSize();
const memory = if (image.memory) |memory| memory else return VkError.ValidationFailed;
var memory_map: []u32 = @as([*]u32, @ptrCast(@alignCast(try memory.map(0, image_size))))[0..image_size];
_ = range;
_ = &memory_map;
memory.unmap();
}
}
fn copyBuffer(data: *const cmd.CommandCopyBuffer) VkError!void {
for (data.regions) |region| {
const src_memory = if (data.src.memory) |memory| memory else return VkError.ValidationFailed;
@@ -39,10 +58,13 @@ fn copyBuffer(data: *const cmd.CommandCopyBuffer) VkError!void {
}
}
fn copyImage(data: *const cmd.CommandCopyImage) VkError!void {
_ = data;
}
fn fillBuffer(data: *const cmd.CommandFillBuffer) VkError!void {
const memory = if (data.buffer.memory) |memory| memory else return VkError.ValidationFailed;
const raw_memory_map: [*]u32 = @ptrCast(@alignCast(try memory.map(data.offset, data.size)));
var memory_map: []u32 = raw_memory_map[0..data.size];
var memory_map: []u32 = @as([*]u32, @ptrCast(@alignCast(try memory.map(data.offset, data.size))))[0..data.size];
for (0..@divExact(data.size, @sizeOf(u32))) |i| {
memory_map[i] = data.data;