adding SSBO unit test
This commit is contained in:
58
test/ssbo.zig
git.filemode.normal_file
58
test/ssbo.zig
git.filemode.normal_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),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user