core: provide a default sysgpu interface implementation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
fc0ff2fffd
commit
44f950a7f3
3 changed files with 8 additions and 11 deletions
|
|
@ -137,11 +137,8 @@ pub fn init(
|
||||||
input: *Frequency,
|
input: *Frequency,
|
||||||
options: Options,
|
options: Options,
|
||||||
) !void {
|
) !void {
|
||||||
if (!@import("builtin").is_test and !mach.use_sysgpu) _ = mach.wgpu.Export(blk: {
|
if (!@import("builtin").is_test and !mach.use_sysgpu) _ = mach.wgpu.Export(mach.wgpu.Impl);
|
||||||
if (@hasDecl(@import("root"), "GPUInterface")) break :blk @import("root").GPUInterface;
|
if (!@import("builtin").is_test and mach.use_sysgpu) _ = mach.sysgpu.sysgpu.Export(mach.sysgpu.Impl);
|
||||||
break :blk mach.wgpu.dawn.Interface;
|
|
||||||
});
|
|
||||||
if (!@import("builtin").is_test and mach.use_sysgpu) _ = mach.sysgpu.sysgpu.Export(@import("root").SYSGPUInterface);
|
|
||||||
|
|
||||||
const backend_type = try detectBackendType(allocator);
|
const backend_type = try detectBackendType(allocator);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -300,11 +300,8 @@ pub fn init(
|
||||||
input: *Frequency,
|
input: *Frequency,
|
||||||
options: Options,
|
options: Options,
|
||||||
) !void {
|
) !void {
|
||||||
if (!@import("builtin").is_test and !mach.use_sysgpu) _ = mach.wgpu.Export(blk: {
|
if (!@import("builtin").is_test and !mach.use_sysgpu) _ = mach.wgpu.Export(mach.wgpu.Impl);
|
||||||
if (@hasDecl(@import("root"), "GPUInterface")) break :blk @import("root").GPUInterface;
|
if (!@import("builtin").is_test and mach.use_sysgpu) _ = mach.sysgpu.sysgpu.Export(mach.sysgpu.Impl);
|
||||||
break :blk mach.wgpu.dawn.Interface;
|
|
||||||
});
|
|
||||||
if (!@import("builtin").is_test and mach.use_sysgpu) _ = mach.sysgpu.sysgpu.Export(@import("root").SYSGPUInterface);
|
|
||||||
|
|
||||||
const libx11 = try LibX11.load();
|
const libx11 = try LibX11.load();
|
||||||
const libxcursor: ?LibXCursor = LibXCursor.load() catch |err| switch (err) {
|
const libxcursor: ?LibXCursor = LibXCursor.load() catch |err| switch (err) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,10 @@ pub const Impl = blk: {
|
||||||
break :blk StubInterface;
|
break :blk StubInterface;
|
||||||
} else {
|
} else {
|
||||||
const root = @import("root");
|
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
|
_ = sysgpu.Interface(root.SYSGPUInterface); // verify the type
|
||||||
break :blk root.SYSGPUInterface;
|
break :blk root.SYSGPUInterface;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue