core: provide a default sysgpu interface implementation

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-04-29 11:57:54 -07:00 committed by Stephen Gutekanst
parent fc0ff2fffd
commit 44f950a7f3
3 changed files with 8 additions and 11 deletions

View file

@ -9,7 +9,10 @@ pub const Impl = blk: {
break :blk StubInterface;
} else {
const root = @import("root");
if (!@hasDecl(root, "SYSGPUInterface")) @compileError("expected to find `pub const SYSGPUInterface = T;` in root file");
// Default to standard implementation of sysgpu.Interface if none was specified.
if (!@hasDecl(root, "SYSGPUInterface")) break :blk Interface(@import("../main.zig").Impl);
_ = sysgpu.Interface(root.SYSGPUInterface); // verify the type
break :blk root.SYSGPUInterface;
}