working on commands
This commit is contained in:
@@ -43,6 +43,7 @@ pub const DispatchTable = struct {
|
||||
clearColorImage: *const fn (*Self, *Image, vk.ImageLayout, *const vk.ClearColorValue, vk.ImageSubresourceRange) VkError!void,
|
||||
copyBuffer: *const fn (*Self, *Buffer, *Buffer, []const vk.BufferCopy) VkError!void,
|
||||
copyImage: *const fn (*Self, *Image, vk.ImageLayout, *Image, vk.ImageLayout, []const vk.ImageCopy) VkError!void,
|
||||
copyImageToBuffer: *const fn (*Self, *Image, vk.ImageLayout, *Buffer, []const vk.BufferImageCopy) 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,
|
||||
@@ -124,6 +125,7 @@ fn cleanCommandList(self: *Self) void {
|
||||
switch (command) {
|
||||
.CopyBuffer => |data| allocator.free(data.regions),
|
||||
.CopyImage => |data| allocator.free(data.regions),
|
||||
.CopyImageToBuffer => |data| allocator.free(data.regions),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
@@ -166,6 +168,17 @@ pub inline fn copyImage(self: *Self, src: *Image, src_layout: vk.ImageLayout, ds
|
||||
try self.dispatch_table.copyImage(self, src, src_layout, dst, dst_layout, regions);
|
||||
}
|
||||
|
||||
pub inline fn copyImageToBuffer(self: *Self, src: *Image, src_layout: vk.ImageLayout, dst: *Buffer, regions: []const vk.BufferImageCopy) VkError!void {
|
||||
const allocator = self.host_allocator.allocator();
|
||||
self.commands.append(allocator, .{ .CopyImageToBuffer = .{
|
||||
.src = src,
|
||||
.src_layout = src_layout,
|
||||
.dst = dst,
|
||||
.regions = allocator.dupe(vk.BufferImageCopy, regions) catch return VkError.OutOfHostMemory,
|
||||
} }) catch return VkError.OutOfHostMemory;
|
||||
try self.dispatch_table.copyImageToBuffer(self, src, src_layout, dst, regions);
|
||||
}
|
||||
|
||||
pub inline fn fillBuffer(self: *Self, buffer: *Buffer, offset: vk.DeviceSize, size: vk.DeviceSize, data: u32) VkError!void {
|
||||
const allocator = self.host_allocator.allocator();
|
||||
self.commands.append(allocator, .{ .FillBuffer = .{
|
||||
|
||||
@@ -88,6 +88,15 @@ pub inline fn getTotalSize(self: *Self) usize {
|
||||
return self.extent.width * self.extent.height * self.extent.depth * pixel_size;
|
||||
}
|
||||
|
||||
pub inline fn getFormatPixelSize(format: vk.Format) usize {
|
||||
return lib.vku.vkuFormatTexelBlockSize(@intCast(@intFromEnum(format)));
|
||||
}
|
||||
|
||||
pub inline fn getFormatTotalSize(self: *Self, format: vk.Format) usize {
|
||||
const pixel_size = self.getFormatPixelSize(format);
|
||||
return self.extent.width * self.extent.height * self.extent.depth * pixel_size;
|
||||
}
|
||||
|
||||
pub fn formatSupportsColorAttachemendBlend(format: vk.Format) bool {
|
||||
return switch (format) {
|
||||
// Vulkan 1.1 mandatory
|
||||
|
||||
@@ -10,6 +10,7 @@ pub const CommandType = enum {
|
||||
ClearColorImage,
|
||||
CopyBuffer,
|
||||
CopyImage,
|
||||
CopyImageToBuffer,
|
||||
Draw,
|
||||
DrawIndexed,
|
||||
DrawIndexedIndirect,
|
||||
@@ -43,6 +44,12 @@ pub const CommandCopyImage = struct {
|
||||
dst_layout: vk.ImageLayout,
|
||||
regions: []const vk.ImageCopy,
|
||||
};
|
||||
pub const CommandCopyImageToBuffer = struct {
|
||||
src: *Image,
|
||||
src_layout: vk.ImageLayout,
|
||||
dst: *Buffer,
|
||||
regions: []const vk.BufferImageCopy,
|
||||
};
|
||||
pub const CommandDraw = struct {
|
||||
vertex_count: u32,
|
||||
instance_count: u32,
|
||||
@@ -81,6 +88,7 @@ pub const Command = union(CommandType) {
|
||||
ClearColorImage: CommandClearColorImage,
|
||||
CopyBuffer: CommandCopyBuffer,
|
||||
CopyImage: CommandCopyImage,
|
||||
CopyImageToBuffer: CommandCopyImageToBuffer,
|
||||
Draw: CommandDraw,
|
||||
DrawIndexed: CommandDrawIndexed,
|
||||
DrawIndexedIndirect: CommandDrawIndexedIndirect,
|
||||
|
||||
@@ -1839,15 +1839,7 @@ pub export fn strollCmdCopyImageToBuffer(p_cmd: vk.CommandBuffer, p_src: vk.Imag
|
||||
const cmd = Dispatchable(CommandBuffer).fromHandleObject(p_cmd) catch |err| return errorLogger(err);
|
||||
const src = NonDispatchable(Image).fromHandleObject(p_src) catch |err| return errorLogger(err);
|
||||
const dst = NonDispatchable(Buffer).fromHandleObject(p_dst) catch |err| return errorLogger(err);
|
||||
|
||||
notImplementedWarning();
|
||||
|
||||
_ = cmd;
|
||||
_ = src;
|
||||
_ = dst;
|
||||
_ = layout;
|
||||
_ = count;
|
||||
_ = regions;
|
||||
cmd.copyImageToBuffer(src, layout, dst, regions[0..count]) catch |err| return errorLogger(err);
|
||||
}
|
||||
|
||||
pub export fn strollCmdCopyQueryPoolResults(p_cmd: vk.CommandBuffer, p_pool: vk.QueryPool, first: u32, count: u32, p_dst: vk.Buffer, offset: vk.DeviceSize, stride: vk.DeviceSize, flags: vk.QueryResultFlags) callconv(vk.vulkan_call_conv) void {
|
||||
|
||||
Reference in New Issue
Block a user