Changed GpuProcess to use a definition

Now GpuProcess isnt limited to 2 in, 1 out but to anything.
This commit is contained in:
AdrienBouvais
2026-05-19 07:54:16 +02:00
parent 44d26feba5
commit 62b5224e6e
2 changed files with 116 additions and 51 deletions
+12 -2
View File
@@ -18,7 +18,17 @@ pub fn main(init: std.process.Init) !void {
const gloc = grena.gpuAllocator();
// 3. Load the WGSL compute pipeline
const add_process = try GpuProcess.init(device, @embedFile("shaders/add.wgsl"));
const add_process = try GpuProcess.init(
device,
@embedFile("shaders/add.wgsl"),
.{
.bindings = &.{
.{ .element_size = @sizeOf(f16) },
.{ .element_size = @sizeOf(f16) },
.{ .element_size = @sizeOf(f16) },
},
},
);
defer add_process.deinit();
// 4. Setup CPU data
@@ -49,7 +59,7 @@ pub fn main(init: std.process.Init) !void {
// 7. Dispatch the Compute Process
// We pass the data type (f16) to allow GpuProcess to calculate chunks correctly
try add_process.run(gloc, f16, buf_a, buf_b, buf_out);
try add_process.run(gloc, .{ buf_a, buf_b, buf_out });
// 8. Map and copy the resulting buffer back to the CPU
const out = try buf_out.read(allocator, f16);