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
+49 -1
View File
@@ -3,7 +3,7 @@ const root = @import("root.zig");
const compileNzsl = root.compileNzsl;
const case = root.case;
test "Simple SSBO" {
test "SSBO read" {
const allocator = std.testing.allocator;
const shader =
\\ [nzsl_version("1.1")]
@@ -58,3 +58,51 @@ test "Simple SSBO" {
},
});
}
test "SSBO write" {
const allocator = std.testing.allocator;
const shader =
\\ [nzsl_version("1.1")]
\\ module;
\\
\\ [layout(std430)]
\\ struct SSBO
\\ {
\\ data: dyn_array[u32]
\\ }
\\
\\ external
\\ {
\\ [set(0), binding(0)] ssbo: storage[SSBO],
\\ }
\\
\\ [entry(compute)]
\\ [workgroup(1, 1, 1)]
\\ fn main()
\\ {
\\ for i in u32(2) -> u32(8)
\\ {
\\ ssbo.data[i] = ssbo.data[i - u32(1)] + ssbo.data[i - u32(2)];
\\ }
\\ }
;
const code = try compileNzsl(allocator, shader);
defer allocator.free(code);
var ssbo = [_]u32{ 1, 1, 0, 0, 0, 0, 0, 0 };
const expected = [_]u32{ 1, 1, 2, 3, 5, 8, 13, 21 };
try case.expect(.{
.source = code,
.descriptor_sets = &.{
&.{
std.mem.asBytes(&ssbo),
},
},
.expected_descriptor_sets = &.{
&.{
std.mem.asBytes(&expected),
},
},
});
}