adding image to png export to C test
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user