Moved c.gpuQueuWriteBuffer to GpuBuffer

This commit is contained in:
adrien 2026-05-18 14:16:01 +02:00
parent 7ce6b9cd1d
commit 2673aef0fd
2 changed files with 10 additions and 5 deletions

View File

@ -68,3 +68,11 @@ pub fn getConstMappedRange(self: @This(), offset: u64, size: u64) ?*const anyopa
pub fn unmap(self: @This()) void {
c.wgpuBufferUnmap(self.raw);
}
/// CPU to GPU.
pub fn load(
self: @This(),
data: []const f16,
) !void {
c.wgpuQueueWriteBuffer(self.gloc.device.queue, self.raw, 0, data.ptr, self.size);
}

View File

@ -26,7 +26,7 @@ pub fn initZero(gloc: GpuAllocator, len: usize) !Vec {
// Changed: gloc is passed by value
pub fn initLoad(gloc: GpuAllocator, data: []const f16) !Vec {
var self = try initZero(gloc, data.len);
try self.load(gloc.device, data); // Direct access via the interface copy
try self.load(data); // Direct access via the interface copy
return self;
}
@ -37,12 +37,9 @@ pub fn deinit(self: Vec) void {
/// CPU to GPU.
pub fn load(
self: Vec,
device: GpuDevice,
data: []const f16,
) !void {
std.debug.assert(data.len == self.len);
const bytes = self.byteSize();
c.wgpuQueueWriteBuffer(device.queue, self.buf.raw, 0, data.ptr, bytes);
try self.buf.load(data);
}
pub fn byteSize(self: Vec) u64 {