working on the blitter
Build / build (push) Successful in 1m5s
Test / build_and_test (push) Successful in 43m5s

This commit is contained in:
2026-04-21 02:39:48 +02:00
parent 16d54c339f
commit 602ade81d4
10 changed files with 473 additions and 238 deletions
+4
View File
@@ -91,3 +91,7 @@ pub inline fn formatFromAspect(self: *const Self, aspect_mask: vk.ImageAspectFla
pub inline fn formatToAspect(self: *const Self, aspect_mask: vk.ImageAspectFlags) vk.ImageAspectFlags {
return lib.format.toAspect(self.format, aspect_mask);
}
pub fn getLastLayerIndex(self: *const Self, range: vk.ImageSubresourceRange) u32 {
return (if (range.layer_count == vk.REMAINING_ARRAY_LAYERS) self.array_layers else range.base_array_layer + range.layer_count) - 1;
}
+126
View File
@@ -1,6 +1,7 @@
const std = @import("std");
const vk = @import("vulkan");
const lib = @import("lib.zig");
const zm = @import("zmath");
pub fn fromAspect(format: vk.Format, aspect: vk.ImageAspectFlags) vk.Format {
if (aspect.color_bit or (aspect.color_bit and aspect.stencil_bit)) {
@@ -118,3 +119,128 @@ pub inline fn isUint(format: vk.Format) bool {
pub inline fn isUnorm(format: vk.Format) bool {
return lib.vku.vkuFormatIsUNORM(@intCast(@intFromEnum(format)));
}
pub fn getScale(format: vk.Format) zm.F32x4 {
return switch (format) {
.r4g4_unorm_pack8,
.r4g4b4a4_unorm_pack16,
.b4g4r4a4_unorm_pack16,
.a4r4g4b4_unorm_pack16,
.a4b4g4r4_unorm_pack16,
=> zm.f32x4(0xf, 0xf, 0xf, 0xf),
.r8_unorm,
.r8g8_unorm,
.a8b8g8r8_unorm_pack32,
.r8g8b8a8_unorm,
.b8g8r8a8_unorm,
.r8_srgb,
.r8g8_srgb,
.a8b8g8r8_srgb_pack32,
.r8g8b8a8_srgb,
.b8g8r8a8_srgb,
=> zm.f32x4(0xff, 0xff, 0xff, 0xff),
.r8_snorm,
.r8g8_snorm,
.a8b8g8r8_snorm_pack32,
.r8g8b8a8_snorm,
.b8g8r8a8_snorm,
=> zm.f32x4(0x7f, 0x7f, 0x7f, 0x7f),
.r16_unorm,
.r16g16_unorm,
.r16g16b16_unorm,
.r16g16b16a16_unorm,
=> zm.f32x4(0xffff, 0xffff, 0xffff, 0xffff),
.r16_snorm,
.r16g16_snorm,
.r16g16b16_snorm,
.r16g16b16a16_snorm,
=> zm.f32x4(0x7fff, 0x7fff, 0x7fff, 0x7fff),
.r8_sint,
.r8_uint,
.r8g8_sint,
.r8g8_uint,
.r8g8b8a8_sint,
.r8g8b8a8_uint,
.a8b8g8r8_sint_pack32,
.a8b8g8r8_uint_pack32,
.b8g8r8a8_sint,
.b8g8r8a8_uint,
.r8_uscaled,
.r8g8_uscaled,
.r8g8b8a8_uscaled,
.b8g8r8a8_uscaled,
.a8b8g8r8_uscaled_pack32,
.r8_sscaled,
.r8g8_sscaled,
.r8g8b8a8_sscaled,
.b8g8r8a8_sscaled,
.a8b8g8r8_sscaled_pack32,
.r16_sint,
.r16_uint,
.r16g16_sint,
.r16g16_uint,
.r16g16b16a16_sint,
.r16g16b16a16_uint,
.r16_sscaled,
.r16g16_sscaled,
.r16g16b16_sscaled,
.r16g16b16a16_sscaled,
.r16_uscaled,
.r16g16_uscaled,
.r16g16b16_uscaled,
.r16g16b16a16_uscaled,
.r32_sint,
.r32_uint,
.r32g32_sint,
.r32g32_uint,
.r32g32b32_sint,
.r32g32b32_uint,
.r32g32b32a32_sint,
.r32g32b32a32_uint,
.r32g32b32a32_sfloat,
.r32g32b32_sfloat,
.r32g32_sfloat,
.r32_sfloat,
.r16g16b16a16_sfloat,
.r16g16b16_sfloat,
.r16g16_sfloat,
.r16_sfloat,
.b10g11r11_ufloat_pack32,
.e5b9g9r9_ufloat_pack32,
.a2r10g10b10_uscaled_pack32,
.a2r10g10b10_sscaled_pack32,
.a2r10g10b10_uint_pack32,
.a2r10g10b10_sint_pack32,
.a2b10g10r10_uscaled_pack32,
.a2b10g10r10_sscaled_pack32,
.a2b10g10r10_uint_pack32,
.a2b10g10r10_sint_pack32,
=> zm.f32x4(1.0, 1.0, 1.0, 1.0),
.r5g5b5a1_unorm_pack16,
.b5g5r5a1_unorm_pack16,
.a1r5g5b5_unorm_pack16,
=> zm.f32x4(0x1f, 0x1f, 0x1f, 0x01),
.r5g6b5_unorm_pack16,
.b5g6r5_unorm_pack16,
=> zm.f32x4(0x1f, 0x3f, 0x1f, 1.0),
.a2r10g10b10_unorm_pack32,
.a2b10g10r10_unorm_pack32,
=> zm.f32x4(0x3ff, 0x3ff, 0x3ff, 0x03),
.a2r10g10b10_snorm_pack32,
.a2b10g10r10_snorm_pack32,
=> zm.f32x4(0x1ff, 0x1ff, 0x1ff, 0x01),
.d16_unorm,
=> zm.f32x4(0xffff, 0.0, 0.0, 0.0),
.d24_unorm_s8_uint,
.x8_d24_unorm_pack32,
=> zm.f32x4(0xffffff, 0.0, 0.0, 0.0),
.d32_sfloat,
.d32_sfloat_s8_uint,
.s8_uint,
=> zm.f32x4(1.0, 1.0, 1.0, 1.0),
else => blk: {
lib.unsupported("format scale {any}", .{format});
break :blk zm.f32x4s(1.0);
},
};
}
+2
View File
@@ -7,6 +7,8 @@ pub const vku = @cImport({
@cInclude("vulkan/utility/vk_format_utils.h");
});
pub const zm = @import("zmath");
pub const errors = @import("error_set.zig");
pub const lib_vulkan = @import("lib_vulkan.zig");
pub const logger = @import("logger.zig");