gpu: implement Surface.reference, Surface.release

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-06 21:29:47 -07:00 committed by Stephen Gutekanst
parent 368f53ece1
commit d32be19c8b

View file

@ -1,5 +1,7 @@
//! A native WebGPU surface
const Surface = @This();
// The type erased pointer to the Surface implementation
ptr: *anyopaque,
vtable: *const VTable,
@ -9,6 +11,14 @@ pub const VTable = struct {
release: fn (ptr: *anyopaque) void,
};
pub inline fn reference(surface: Surface) void {
surface.vtable.reference(surface.ptr);
}
pub inline fn release(surface: Surface) void {
surface.vtable.release(surface.ptr);
}
pub const DescriptorTag = enum {
metal_layer,
windows_hwnd,
@ -48,6 +58,9 @@ pub const Descriptor = union(DescriptorTag) {
};
test "syntax" {
_ = VTable;
_ = reference;
_ = release;
_ = DescriptorTag;
_ = Descriptor;
}