gpu: correct implementation initialization
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
a468c51ad4
commit
2a39ff8f7e
2 changed files with 5 additions and 6 deletions
|
|
@ -10,10 +10,9 @@ var procs: c.DawnProcTable = undefined;
|
||||||
/// A Dawn implementation of the gpu.Interface, which merely directs calls to the Dawn proc table.
|
/// A Dawn implementation of the gpu.Interface, which merely directs calls to the Dawn proc table.
|
||||||
///
|
///
|
||||||
/// Before use, it must be `.init()`ialized in order to set the global proc table.
|
/// Before use, it must be `.init()`ialized in order to set the global proc table.
|
||||||
pub const Interface = gpu.Interface(struct {
|
pub const Interface = struct {
|
||||||
pub fn init() @This() {
|
pub fn init() void {
|
||||||
procs = c.machDawnGetProcTable();
|
procs = c.machDawnGetProcTable();
|
||||||
return @This(){};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createInstance(descriptor: ?*const gpu.Instance.Descriptor) ?*gpu.Instance {
|
pub inline fn createInstance(descriptor: ?*const gpu.Instance.Descriptor) ?*gpu.Instance {
|
||||||
|
|
@ -1200,7 +1199,7 @@ pub const Interface = gpu.Interface(struct {
|
||||||
pub inline fn textureViewRelease(texture_view: *gpu.TextureView) void {
|
pub inline fn textureViewRelease(texture_view: *gpu.TextureView) void {
|
||||||
procs.textureViewRelease.?(@ptrCast(c.WGPUTextureView, texture_view));
|
procs.textureViewRelease.?(@ptrCast(c.WGPUTextureView, texture_view));
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
test "dawn_impl" {
|
test "dawn_impl" {
|
||||||
_ = gpu.Export(Interface);
|
_ = gpu.Export(Interface);
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ pub const Impl = blk: {
|
||||||
break :blk StubInterface;
|
break :blk StubInterface;
|
||||||
} else {
|
} else {
|
||||||
const root = @import("root");
|
const root = @import("root");
|
||||||
if (!@hasField(root, "GPUInterface")) @compileError("expected to find `pub const GPUInterface = T;` in root file");
|
if (!@hasDecl(root, "GPUInterface")) @compileError("expected to find `pub const GPUInterface = T;` in root file");
|
||||||
_ = gpu.Interface(@TypeOf(root.GPUInterface)); // verify the type
|
_ = gpu.Interface(root.GPUInterface); // verify the type
|
||||||
break :blk root.GPUInterface;
|
break :blk root.GPUInterface;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue