adding builtin support
All checks were successful
Build / build (push) Successful in 1m41s
Test / build (push) Successful in 4m54s

This commit is contained in:
2026-02-17 02:20:28 +01:00
parent 2ea707ea57
commit 35686c3012
8 changed files with 176 additions and 181 deletions

View File

@@ -3,12 +3,8 @@ const spv = @import("spv");
const shader_source = @embedFile("shader.spv");
const Input = struct {
value: [4]i32 = [4]i32{ 0, 0, 0, 0 },
};
const Output = struct {
value: [4]i32 = [4]i32{ 0, 0, 0, 0 },
const SSBO = struct {
value: [256]i32 = [_]i32{0} ** 256,
};
pub fn main() !void {
@@ -28,19 +24,31 @@ pub fn main() !void {
const entry = try rt.getEntryPointByName("main");
var input: Input = .{};
var output: Output = .{};
var ssbo: SSBO = .{};
try rt.writeDescriptorSet(allocator, std.mem.asBytes(&input), 0, 0);
try rt.writeDescriptorSet(allocator, std.mem.asBytes(&output), 0, 1);
for (0..16) |i| {
for (0..16) |x| {
for (0..16) |y| {
const global_invocation_indices = [3]i32{
@as(i32, @intCast(i * 16 + x)),
@as(i32, @intCast(y)),
1,
};
try rt.callEntryPoint(allocator, entry);
try rt.writeBuiltIn(std.mem.asBytes(&global_invocation_indices), .GlobalInvocationId);
try rt.writeDescriptorSet(allocator, std.mem.asBytes(&ssbo), 0, 0);
rt.callEntryPoint(allocator, entry) catch |err| switch (err) {
spv.Runtime.RuntimeError.OutOfBounds => continue,
else => return err,
};
try rt.readDescriptorSet(std.mem.asBytes(&ssbo), 0, 0);
}
}
}
try rt.readDescriptorSet(std.mem.asBytes(&output), 0, 1);
std.log.info("Output: {any}", .{ssbo});
std.log.info("Output: {any}", .{output});
std.log.info("\nTotal memory used: {d:.3} KB\n", .{@as(f32, @floatFromInt(gpa.total_requested_bytes)) / 1000.0});
std.log.info("Total memory used: {d:.3} KB\n", .{@as(f32, @floatFromInt(gpa.total_requested_bytes)) / 1000.0});
}
std.log.info("Successfully executed", .{});
}