From 8453b0d2a6fd6d5ec752be9244d8ef3d93fe6ea0 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Mon, 25 Jul 2022 21:40:37 -0700 Subject: [PATCH] gpu: add Adapter.release Signed-off-by: Stephen Gutekanst --- gpu/TODO-webgpu.h | 11 ----------- gpu/src/adapter.zig | 4 ++++ gpu/src/interface.zig | 11 ++++++++++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/gpu/TODO-webgpu.h b/gpu/TODO-webgpu.h index 9a8ac421..cd618002 100644 --- a/gpu/TODO-webgpu.h +++ b/gpu/TODO-webgpu.h @@ -1,14 +1,3 @@ -// WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter); -export fn wgpuAdapterRelease(adapter: gpu.Adapter) void { - impl.adapterRelease(adapter); -} -pub inline fn adapterRelease(adapter: gpu.Adapter) void { - _ = adapter; -} -pub inline fn release(adapter: Adapter) void { - impl.adapterRelease(adapter); -} - // WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label); export fn wgpuBindGroupSetLabel(bind_group: gpu.BindGroup, label: [*:0]const u8) void { diff --git a/gpu/src/adapter.zig b/gpu/src/adapter.zig index 0ec64a6b..f9b5ae24 100644 --- a/gpu/src/adapter.zig +++ b/gpu/src/adapter.zig @@ -36,6 +36,10 @@ pub const Adapter = *opaque { pub inline fn reference(adapter: Adapter) void { impl.adapterReference(adapter); } + + pub inline fn release(adapter: Adapter) void { + impl.adapterRelease(adapter); + } }; pub const RequestDeviceCallback = fn ( diff --git a/gpu/src/interface.zig b/gpu/src/interface.zig index 25d1f2f3..cf725148 100644 --- a/gpu/src/interface.zig +++ b/gpu/src/interface.zig @@ -26,7 +26,7 @@ pub fn Interface(comptime Impl: type) type { assertDecl(Impl, "adapterHasFeature", fn (adapter: gpu.Adapter, feature: gpu.FeatureName) callconv(.Inline) bool); assertDecl(Impl, "adapterRequestDevice", fn (adapter: gpu.Adapter, descriptor: ?*const gpu.DeviceDescriptor, callback: gpu.RequestDeviceCallback, userdata: *anyopaque) callconv(.Inline) void); assertDecl(Impl, "adapterReference", fn (adapter: gpu.Adapter) callconv(.Inline) void); - // assertDecl(Impl, "adapterRelease", fn (adapter: gpu.Adapter) callconv(.Inline) void); + assertDecl(Impl, "adapterRelease", fn (adapter: gpu.Adapter) callconv(.Inline) void); // assertDecl(Impl, "bindGroupSetLabel", fn (bind_group: gpu.BindGroup, label: [*:0]const u8) callconv(.Inline) void); // assertDecl(Impl, "bindGroupReference", fn (bind_group: gpu.BindGroup) callconv(.Inline) void); // assertDecl(Impl, "bindGroupRelease", fn (bind_group: gpu.BindGroup) callconv(.Inline) void); @@ -276,6 +276,11 @@ pub fn Export(comptime Impl: type) type { export fn wgpuAdapterReference(adapter: gpu.Adapter) void { Impl.adapterReference(adapter); } + + // WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter); + export fn wgpuAdapterRelease(adapter: gpu.Adapter) void { + Impl.adapterRelease(adapter); + } }; } @@ -331,6 +336,10 @@ pub const NullInterface = Interface(struct { pub inline fn adapterReference(adapter: gpu.Adapter) void { _ = adapter; } + + pub inline fn adapterRelease(adapter: gpu.Adapter) void { + _ = adapter; + } }); test "null" {