Files
SPIRV-Interpreter/test/ssbo.zig
Kbz-8 ad013d23fc
All checks were successful
Build / build (push) Successful in 56s
Test / build (push) Successful in 4m54s
ugly implementation of new runtime arrays management
2026-03-08 02:25:25 +01:00

61 lines
1.3 KiB
Zig

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 ssbo = [_]u32{0} ** 256;
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(&ssbo),
},
},
.expected_descriptor_sets = &.{
// Set 0
&.{
// Binding 0
std.mem.asBytes(&expected),
},
},
});
}