Renamed GpuProcess to GpuCompute

This commit is contained in:
adrien
2026-05-19 21:15:31 +02:00
parent fb2f454c1c
commit e467539f6e
5 changed files with 18 additions and 15 deletions
+4 -4
View File
@@ -3,7 +3,7 @@ const gpu = @import("gpu");
const GpuDevice = gpu.GpuDevice;
const GpuArena = gpu.GpuArena;
const GpuBuffer = gpu.GpuBuffer;
const GpuProcess = gpu.GpuProcess;
const GpuCompute = gpu.GpuCompute;
pub fn main(init: std.process.Init) !void {
const allocator = init.gpa;
@@ -18,7 +18,7 @@ pub fn main(init: std.process.Init) !void {
const gloc = grena.gpuAllocator();
// 3. Load the WGSL compute pipeline
const add_process = try GpuProcess.init(
const add_cp = try GpuCompute.init(
device,
@embedFile("shaders/add.wgsl"),
.{ .bindings = &.{
@@ -27,7 +27,7 @@ pub fn main(init: std.process.Init) !void {
.{ .element_size = @sizeOf(f16) },
} },
);
defer add_process.deinit();
defer add_cp.deinit();
// 4. Setup CPU data
const len: usize = 16;
@@ -55,7 +55,7 @@ pub fn main(init: std.process.Init) !void {
try buf_b.load(f16, data_b);
// 7. Dispatch the Compute Process
try add_process.run(gloc, .{ buf_a, buf_b, buf_out });
try add_cp.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);
+8 -4
View File
@@ -4,7 +4,7 @@ const GpuDevice = gpu.GpuDevice;
const GpuArena = gpu.GpuArena;
const GpuAllocator = gpu.GpuAllocator;
const GpuBuffer = gpu.GpuBuffer;
const GpuProcess = gpu.GpuProcess;
const GpuCompute = gpu.GpuCompute;
/// Minimal implementation of a f16 Vector
const Vec = struct {
@@ -40,13 +40,13 @@ const Vec = struct {
}
// Changed: gloc is passed by value instead of *GpuAllocator
pub fn run(self: Vec, gloc: GpuAllocator, other: Vec, process: GpuProcess) !Vec {
pub fn run(self: Vec, gloc: GpuAllocator, other: Vec, process: GpuCompute) !Vec {
std.debug.assert(self.len == other.len);
const result = try Vec.initZero(gloc, self.len);
errdefer result.deinit();
try process.run(gloc, f16, self.buf, other.buf, result.buf);
try process.run(gloc, .{ self.buf, other.buf, result.buf });
return result;
}
@@ -65,7 +65,11 @@ pub fn main(init: std.process.Init) !void {
const gloc = grena.gpuAllocator();
const add_pip = try GpuProcess.init(device, @embedFile("shaders/add.wgsl"));
const add_pip = try GpuCompute.init(device, @embedFile("shaders/add.wgsl"), .{ .bindings = &.{
.{ .element_size = @sizeOf(f16) },
.{ .element_size = @sizeOf(f16) },
.{ .element_size = @sizeOf(f16) },
} });
defer add_pip.deinit();
const allocator = init.gpa;