adding software blitter base

This commit is contained in:
2025-12-20 00:00:42 +01:00
parent 084412ac1c
commit 8a641adb8e
9 changed files with 95 additions and 28 deletions

View File

@@ -7,6 +7,8 @@ const lib = @import("lib.zig");
const VkError = base.VkError;
const Device = base.Device;
const SoftDevice = @import("SoftDevice.zig");
const Self = @This();
pub const Interface = base.Image;
@@ -38,3 +40,20 @@ pub fn getMemoryRequirements(interface: *Interface, requirements: *vk.MemoryRequ
_ = interface;
requirements.alignment = lib.MEMORY_REQUIREMENTS_IMAGE_ALIGNMENT;
}
inline fn clear(self: *Self, pixel: *const anyopaque, format: vk.Format, view_format: vk.Format, range: vk.ImageSubresourceRange, area: ?vk.Rect2D) void {
const soft_device: *SoftDevice = @alignCast(@fieldParentPtr("interface", self.interface.owner));
soft_device.blitter.clear(pixel, format, self, view_format, range, area);
}
pub fn clearRange(self: *Self, color: vk.ClearColorValue, range: vk.ImageSubresourceRange) void {
std.debug.assert(range.aspect_mask == vk.ImageAspectFlags{ .color_bit = true });
const clear_format: vk.Format = if (base.vku.vkuFormatIsSINT(@intCast(@intFromEnum(self.interface.format))))
.r32g32b32a32_sint
else if (base.vku.vkuFormatIsUINT(@intCast(@intFromEnum(self.interface.format))))
.r32g32b32a32_uint
else
.r32g32b32a32_sfloat;
self.clear(@ptrCast(&color.float_32), clear_format, self.interface.format, range, null);
}