gpu: implement Surface.reference, Surface.release
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
368f53ece1
commit
d32be19c8b
1 changed files with 13 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
//! A native WebGPU surface
|
//! A native WebGPU surface
|
||||||
|
|
||||||
|
const Surface = @This();
|
||||||
|
|
||||||
// The type erased pointer to the Surface implementation
|
// The type erased pointer to the Surface implementation
|
||||||
ptr: *anyopaque,
|
ptr: *anyopaque,
|
||||||
vtable: *const VTable,
|
vtable: *const VTable,
|
||||||
|
|
@ -9,6 +11,14 @@ pub const VTable = struct {
|
||||||
release: fn (ptr: *anyopaque) void,
|
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 {
|
pub const DescriptorTag = enum {
|
||||||
metal_layer,
|
metal_layer,
|
||||||
windows_hwnd,
|
windows_hwnd,
|
||||||
|
|
@ -48,6 +58,9 @@ pub const Descriptor = union(DescriptorTag) {
|
||||||
};
|
};
|
||||||
|
|
||||||
test "syntax" {
|
test "syntax" {
|
||||||
|
_ = VTable;
|
||||||
|
_ = reference;
|
||||||
|
_ = release;
|
||||||
_ = DescriptorTag;
|
_ = DescriptorTag;
|
||||||
_ = Descriptor;
|
_ = Descriptor;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue