adding lots of unit tests, improving image sampling, adding image sampling deref
Build / build (push) Successful in 1m24s
Test / build (push) Successful in 9m42s

This commit is contained in:
2026-06-12 23:05:16 +02:00
parent 089a33981c
commit c7320325fd
18 changed files with 1714 additions and 147 deletions
+39
View File
@@ -33,3 +33,42 @@ test "Simple array" {
},
});
}
test "Array fold" {
const allocator = std.testing.allocator;
const shader =
\\ [nzsl_version("1.1")]
\\ module;
\\
\\ struct FragOut
\\ {
\\ [location(0)] color: vec4[f32]
\\ }
\\
\\ [entry(frag)]
\\ fn main() -> FragOut
\\ {
\\ let values = array[f32](1.0, 2.0, 3.0, 4.0);
\\ let sum = 0.0;
\\ let weighted = 0.0;
\\ for i in u32(0) -> values.Size()
\\ {
\\ sum += values[i];
\\ weighted += values[i] * f32(i + 1);
\\ }
\\
\\ let output: FragOut;
\\ output.color = vec4[f32](sum, weighted, values[2], f32(values.Size()));
\\ return output;
\\ }
;
const code = try compileNzsl(allocator, shader);
defer allocator.free(code);
try case.expect(.{
.source = code,
.expected_outputs = &.{
std.mem.asBytes(&[_]f32{ 10.0, 30.0, 3.0, 4.0 }),
},
});
}