Changed GpuProcess to use a definition
Now GpuProcess isnt limited to 2 in, 1 out but to anything.
This commit is contained in:
+12
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user