adding stride to regular arrays
All checks were successful
Build / build (push) Successful in 6m0s
Test / build (push) Successful in 11m19s

This commit is contained in:
2026-03-26 01:10:29 +01:00
parent a503f54e43
commit 3c7054fae0
3 changed files with 60 additions and 24 deletions

View File

@@ -1160,7 +1160,8 @@ fn copyValue(dst: *Value, src: *const Value) void {
inline fn getDstSlice(v: *Value) ?[]Value {
return switch (v.*) {
.Vector, .Matrix, .Array => |s| s,
.Vector, .Matrix => |s| s,
.Array => |a| a.values,
.Structure => |s| s.values,
else => null,
};
@@ -1255,10 +1256,14 @@ fn copyValue(dst: *Value, src: *const Value) void {
}
switch (src.*) {
.Vector, .Matrix, .Array => |src_slice| {
.Vector, .Matrix => |src_slice| {
const dst_slice = helpers.getDstSlice(dst);
helpers.copySlice(dst_slice.?, src_slice);
},
.Array => |a| {
const dst_slice = helpers.getDstSlice(dst);
helpers.copySlice(dst_slice.?, a.values);
},
.Structure => |s| {
const dst_slice = helpers.getDstSlice(dst);
helpers.copySlice(dst_slice.?, s.values);
@@ -1351,10 +1356,14 @@ fn opAccessChain(allocator: std.mem.Allocator, word_count: SpvWord, rt: *Runtime
}
switch (value_ptr.*) {
.Vector, .Matrix, .Array => |v| {
.Vector, .Matrix => |v| {
if (i.value.uint32 >= v.len) return RuntimeError.OutOfBounds;
value_ptr = &v[i.value.uint32];
},
.Array => |a| {
if (i.value.uint32 >= a.values.len) return RuntimeError.OutOfBounds;
value_ptr = &a.values[i.value.uint32];
},
.Structure => |s| {
if (i.value.uint32 >= s.values.len) return RuntimeError.OutOfBounds;
value_ptr = &s.values[i.value.uint32];