adding SSBO unit test
All checks were successful
Build / build (push) Successful in 1m49s
Test / build (push) Successful in 4m36s

This commit is contained in:
2026-03-07 15:20:02 +01:00
parent 7bf671d974
commit 16eb184808
2 changed files with 78 additions and 1 deletions

58
test/ssbo.zig git.filemode.normal_file
View File

@@ -0,0 +1,58 @@
const std = @import("std");
const root = @import("root.zig");
const compileNzsl = root.compileNzsl;
const case = root.case;
test "Simple SSBO" {
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(16, 1, 1)]
\\ fn main()
\\ {
\\ for i in 0 -> 256
\\ {
\\ ssbo.data[i] = u32(i);
\\ }
\\ }
;
const code = try compileNzsl(allocator, shader);
defer allocator.free(code);
var expected = [_]u32{0} ** 256;
for (expected[0..], 0..) |*val, i| {
val.* = @intCast(i);
}
try case.expect(.{
.source = code,
.descriptor_sets = &.{
// Set 0
&.{
// Binding 0
std.mem.asBytes(&[_]u32{0} ** 256),
},
},
.expected_descriptor_sets = &.{
// Set 0
&.{
// Binding 0
std.mem.asBytes(&expected),
},
},
});
}