core: cleanup sysgpu feature flag logic
* `@import("mach").core.gpu` has been renamed to `@import("mach").gpu`
* `pub const SYSGPUInterface` now has a default value (i.e. you do not need to write it in your main.zig, if you were.)
* You can now check `if (comptime mach.use_sysgpu)` for any conditional code you might have that should only run with sysgpu.
This (old):
```
pub const mach_core_options = core.ComptimeOptions{
.use_wgpu = false,
.use_sysgpu = true,
};
```
Has been replaced by this:
```
pub const use_sysgpu = true;
```
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
6a2358baf8
commit
7a1efdaa69
32 changed files with 85 additions and 132 deletions
|
|
@ -8,14 +8,16 @@ pub usingnamespace @import("app");
|
|||
const App = @import("app").App;
|
||||
|
||||
const std = @import("std");
|
||||
const core = @import("mach").core;
|
||||
|
||||
const mach = @import("mach");
|
||||
const core = mach.core;
|
||||
|
||||
pub usingnamespace if (!@hasDecl(App, "GPUInterface")) struct {
|
||||
pub const GPUInterface = core.wgpu.dawn.Interface;
|
||||
pub const GPUInterface = mach.wgpu.dawn.Interface;
|
||||
} else struct {};
|
||||
|
||||
pub usingnamespace if (!@hasDecl(App, "SYSGPUInterface")) extern struct {
|
||||
pub const SYSGPUInterface = core.sysgpu.Impl;
|
||||
pub const SYSGPUInterface = mach.sysgpu.Impl;
|
||||
} else struct {};
|
||||
|
||||
pub fn main() !void {
|
||||
|
|
@ -29,8 +31,8 @@ pub fn main() !void {
|
|||
core.allocator = gpa.allocator();
|
||||
|
||||
// Initialize GPU implementation
|
||||
if (comptime core.options.use_wgpu) try core.wgpu.Impl.init(core.allocator, .{});
|
||||
if (comptime core.options.use_sysgpu) try core.sysgpu.Impl.init(core.allocator, .{});
|
||||
if (comptime !mach.use_sysgpu) try mach.wgpu.Impl.init(core.allocator, .{});
|
||||
if (comptime mach.use_sysgpu) try mach.sysgpu.Impl.init(core.allocator, .{});
|
||||
|
||||
var app: App = undefined;
|
||||
try app.init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue