From 3c44baa863f3b2a88398e24b5221d8aad1727832 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 11 Mar 2022 13:23:47 -0700 Subject: [PATCH] gpu: add ExternalTexture.destroy Signed-off-by: Stephen Gutekanst --- gpu/src/ExternalTexture.zig | 8 ++++++-- gpu/src/NativeInstance.zig | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gpu/src/ExternalTexture.zig b/gpu/src/ExternalTexture.zig index 27632fd9..0db0ca8a 100644 --- a/gpu/src/ExternalTexture.zig +++ b/gpu/src/ExternalTexture.zig @@ -8,8 +8,7 @@ vtable: *const VTable, pub const VTable = struct { reference: fn (ptr: *anyopaque) void, release: fn (ptr: *anyopaque) void, - // TODO: - // WGPU_EXPORT void wgpuExternalTextureDestroy(WGPUExternalTexture externalTexture); + destroy: fn (ptr: *anyopaque) void, setLabel: fn (ptr: *anyopaque, label: [:0]const u8) void, }; @@ -25,8 +24,13 @@ pub inline fn setLabel(texture: ExternalTexture, label: [:0]const u8) void { texture.vtable.setLabel(texture.ptr, label); } +pub inline fn destroy(texture: ExternalTexture) void { + texture.vtable.destroy(texture.ptr); +} + test "syntax" { _ = VTable; _ = reference; _ = release; + _ = destroy; } diff --git a/gpu/src/NativeInstance.zig b/gpu/src/NativeInstance.zig index 59bfc40f..61159ed9 100644 --- a/gpu/src/NativeInstance.zig +++ b/gpu/src/NativeInstance.zig @@ -379,7 +379,7 @@ const device_vtable = Device.VTable{ }).nativeCreateSwapChain, .destroy = (struct { pub fn destroy(ptr: *anyopaque) void { - c.wgpuDeviceDestroy(@ptrCast(c.WGPUDestroy, ptr)); + c.wgpuDeviceDestroy(@ptrCast(c.WGPUDevice, ptr)); } }).destroy, }; @@ -766,6 +766,11 @@ const external_texture_vtable = ExternalTexture.VTable{ c.wgpuExternalTextureSetLabel(@ptrCast(c.WGPUExternalTexture, ptr), label); } }).setLabel, + .destroy = (struct { + pub fn destroy(ptr: *anyopaque) void { + c.wgpuExternalTextureDestroy(@ptrCast(c.WGPUExternalTexture, ptr)); + } + }).destroy, }; fn wrapBindGroup(group: c.WGPUBindGroup) BindGroup { @@ -843,7 +848,7 @@ const buffer_vtable = Buffer.VTable{ }).setLabel, .destroy = (struct { pub fn destroy(ptr: *anyopaque) void { - c.wgpuBufferDestroy(@ptrCast(c.WGPUDestroy, ptr)); + c.wgpuBufferDestroy(@ptrCast(c.WGPUBuffer, ptr)); } }).destroy, };