adding util to runtime api
Test / build (push) Failing after 31s
Build / build (push) Successful in 48s

This commit is contained in:
2026-06-05 17:48:21 +02:00
parent ee5a400010
commit ad87703ea8
4 changed files with 166 additions and 1 deletions
+33
View File
@@ -169,6 +169,39 @@ pub const Value = union(Type) {
};
}
pub fn resolvePrimitiveType(self: *const Self) RuntimeError!PrimitiveType {
return switch (self.*) {
.Bool => .Bool,
.Float,
.Vector2f32,
.Vector3f32,
.Vector4f32,
=> .Float,
.Int => |int| if (int.is_signed) .SInt else .UInt,
.Vector2i32,
.Vector3i32,
.Vector4i32,
=> .SInt,
.Vector2u32,
.Vector3u32,
.Vector4u32,
=> .UInt,
.Vector => |lanes| {
if (lanes.len == 0)
return RuntimeError.InvalidValueType;
return lanes[0].resolvePrimitiveType();
},
else => RuntimeError.InvalidValueType,
};
}
pub fn isInteger(self: *const Self) bool {
return switch (self.resolvePrimitiveType() catch return false) {
.SInt, .UInt => true,
else => false,
};
}
pub fn init(allocator: std.mem.Allocator, results: []const Result, target_type: SpvWord, is_externally_visible: bool) RuntimeError!Self {
const resolved = results[target_type].resolveTypeWordOrNull() orelse target_type;
return initUnresolved(allocator, results, resolved, is_externally_visible);