Moved all f32 out of GpuXxxx to all be in Vec
This commit is contained in:
parent
8e137c8f33
commit
d2b0735540
@ -66,12 +66,13 @@ pub fn unmap(self: @This()) void {
|
||||
/// CPU to GPU.
|
||||
pub fn load(
|
||||
self: @This(),
|
||||
data: []const f16,
|
||||
T: type,
|
||||
data: []const T,
|
||||
) !void {
|
||||
c.wgpuQueueWriteBuffer(self.gloc.device.queue, self.raw, 0, data.ptr, self.size);
|
||||
}
|
||||
|
||||
pub fn read(self: @This(), alloc: std.mem.Allocator, T: type) ![]f16 {
|
||||
pub fn read(self: @This(), alloc: std.mem.Allocator, T: type) ![]T {
|
||||
const out = try alloc.alloc(T, @divExact(self.size, @sizeOf(T)));
|
||||
|
||||
const staging = try init(
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
/// GpuProcess is just a pipeline with 2 inpout and 1 output
|
||||
/// for now, to see if I make it a bit more generic
|
||||
///
|
||||
const std = @import("std");
|
||||
const c = @import("utils.zig").c;
|
||||
const sv = @import("utils.zig").sv;
|
||||
@ -40,6 +43,7 @@ fn onMapped(
|
||||
pub fn run(
|
||||
self: @This(),
|
||||
gloc: GpuAllocator,
|
||||
T: type,
|
||||
buf_a: GpuBuffer,
|
||||
buf_b: GpuBuffer,
|
||||
buf_out: GpuBuffer,
|
||||
@ -50,7 +54,7 @@ pub fn run(
|
||||
var offset: u64 = 0;
|
||||
while (offset < bytes) {
|
||||
const current_chunk_bytes = @min(max_chunk_bytes, bytes - offset);
|
||||
const current_chunk_elements: u32 = @intCast(current_chunk_bytes / @sizeOf(f16));
|
||||
const current_chunk_elements: u32 = @intCast(current_chunk_bytes / @sizeOf(T));
|
||||
|
||||
const info_buf = try GpuBuffer.init(
|
||||
gloc,
|
||||
|
||||
@ -34,7 +34,7 @@ pub fn deinit(self: Vec) void {
|
||||
|
||||
/// CPU to GPU.
|
||||
pub fn load(self: Vec, data: []const f16) !void {
|
||||
try self.buf.load(data);
|
||||
try self.buf.load(f16, data);
|
||||
}
|
||||
|
||||
pub fn byteSize(self: Vec) u64 {
|
||||
@ -48,7 +48,7 @@ pub fn run(self: Vec, gloc: GpuAllocator, other: Vec, process: GpuProcess) !Vec
|
||||
const result = try Vec.initZero(gloc, self.len);
|
||||
errdefer result.deinit();
|
||||
|
||||
try process.run(gloc, self.buf, other.buf, result.buf);
|
||||
try process.run(gloc, f32, self.buf, other.buf, result.buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -2,4 +2,4 @@ pub const GpuAllocator = @import("GpuAllocator.zig");
|
||||
pub const GpuArena = @import("GpuArena.zig");
|
||||
pub const GpuBuffer = @import("GpuBuffer.zig");
|
||||
pub const GpuDevice = @import("GpuDevice.zig");
|
||||
pub const GpuPipeline = @import("GpuPipeline.zig");
|
||||
pub const GpuProcess = @import("GpuProcess.zig");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user