From 48bc09ca93071f6fd2390e9401cb088bba4b0fd6 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sat, 30 Jul 2022 14:50:18 -0700 Subject: [PATCH] gpu: implement Dawn getProcAddress Signed-off-by: Stephen Gutekanst --- gpu/src/dawn_impl.zig | 7 ++++--- gpu/src/main.zig | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gpu/src/dawn_impl.zig b/gpu/src/dawn_impl.zig index 586b29b4..742fdb4c 100644 --- a/gpu/src/dawn_impl.zig +++ b/gpu/src/dawn_impl.zig @@ -21,9 +21,10 @@ pub const Interface = gpu.Interface(struct { } pub inline fn getProcAddress(device: *gpu.Device, proc_name: [*:0]const u8) ?gpu.Proc { - _ = device; - _ = proc_name; - unreachable; + return procs.getProcAddress.?( + @ptrCast(c.WGPUDevice, device), + proc_name, + ); } pub inline fn adapterCreateDevice(adapter: *gpu.Adapter, descriptor: ?*const gpu.Device.Descriptor) ?*gpu.Device { diff --git a/gpu/src/main.zig b/gpu/src/main.zig index decbd247..d7761e1d 100644 --- a/gpu/src/main.zig +++ b/gpu/src/main.zig @@ -50,8 +50,8 @@ const device = @import("device.zig"); const interface = @import("interface.zig"); /// Generic function pointer type, used for returning API function pointers. Must be -/// cast to a `fn (...) callconv(.C) T` before use. -pub const Proc = *anyopaque; +/// cast to the right `fn (...) callconv(.C) T` type before use. +pub const Proc = fn () callconv(.C) void; pub const ComputePassTimestampWrite = extern struct { query_set: *query_set.QuerySet,