From 1540c6e85e971b407036bde2d457587d47de3c22 Mon Sep 17 00:00:00 2001 From: Foke Singh Date: Fri, 25 Oct 2024 10:20:04 +0000 Subject: [PATCH] =?UTF-8?q?Update=20loader=20example=20to=20demonstrate=20?= =?UTF-8?q?new=20HostBuffer=20helpers=20and=20type=E2=80=91inferred=20buff?= =?UTF-8?q?er=20loading.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/loader/main.zig | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/loader/main.zig b/examples/loader/main.zig index 0487f27..5b631e6 100644 --- a/examples/loader/main.zig +++ b/examples/loader/main.zig @@ -1,9 +1,8 @@ const std = @import("std"); + +const asynk = @import("async"); const stdx = @import("stdx"); const zml = @import("zml"); -const asynk = @import("async"); - -const asyncc = asynk.asyncc; pub fn main() !void { try asynk.AsyncThread.main(std.heap.c_allocator, asyncMain); @@ -39,9 +38,8 @@ pub fn asyncMain() !void { var buffers = try gpa.allocator().alloc(zml.Buffer, buffer_store.buffers.count()); defer { - for (buffers) |*buf| { - buf.deinit(); - } + // Note we don't pass an allocator to buf.deinit() cause its allocated on the device. + for (buffers) |*buf| buf.deinit(); gpa.allocator().free(buffers); } @@ -54,7 +52,7 @@ pub fn asyncMain() !void { while (it.next()) |entry| : (i += 1) { const host_buffer = entry.value_ptr.*; - total_bytes += host_buffer.data.len; + total_bytes += host_buffer.shape().byteSize(); std.debug.print("Buffer: {s} ({any} / {any})\n", .{ entry.key_ptr.*, i + 1, buffer_store.buffers.count() }); buffers[i] = try zml.Buffer.from(platform, host_buffer); }