adding some matrix operations
Build / build (push) Successful in 1m50s
Test / build (push) Successful in 9m32s

This commit is contained in:
2026-05-11 21:36:04 +02:00
parent 769009ad5e
commit ca33cfe3e9
5 changed files with 218 additions and 98 deletions
+28
View File
@@ -847,6 +847,10 @@ pub const Value = union(Type) {
}
}
pub fn getPrimitiveFieldConst(comptime T: PrimitiveType, comptime BitCount: SpvWord, v: *const Value) RuntimeError!*const getPrimitiveFieldType(T, BitCount) {
return getPrimitiveField(T, BitCount, @constCast(v));
}
pub fn getPrimitiveField(comptime T: PrimitiveType, comptime BitCount: SpvWord, v: *Value) RuntimeError!*getPrimitiveFieldType(T, BitCount) {
if (std.meta.activeTag(v.*) == .Pointer) {
return switch (v.Pointer.ptr) {
@@ -926,4 +930,28 @@ pub const Value = union(Type) {
else => .unsigned,
};
}
pub inline fn getVectorSpecialization(self: *const Self, comptime N: usize, comptime T: type) @Vector(N, T) {
return switch (T) {
f32 => switch (N) {
inline 4 => self.Vector4f32,
inline 3 => self.Vector3f32,
inline 2 => self.Vector2f32,
else => unreachable,
},
i32 => switch (N) {
inline 4 => self.Vector4i32,
inline 3 => self.Vector3i32,
inline 2 => self.Vector2i32,
else => unreachable,
},
u32 => switch (N) {
inline 4 => self.Vector4u32,
inline 3 => self.Vector3u32,
inline 2 => self.Vector2u32,
else => unreachable,
},
else => unreachable,
};
}
};