build: fix sysgpu_backend build option (#1264)

This commit is contained in:
Jonathan Poole 2024-09-09 00:45:22 +01:00 committed by GitHub
parent 51bf4f40f2
commit 0a04a3c7c7
Failed to generate hash of commit

View file

@ -5,13 +5,20 @@ pub const sysgpu = @import("sysgpu/main.zig");
pub const shader = @import("shader.zig"); pub const shader = @import("shader.zig");
const utils = @import("utils.zig"); const utils = @import("utils.zig");
const backend_type: sysgpu.BackendType = const backend_type: sysgpu.BackendType = switch (build_options.sysgpu_backend) {
if (build_options.sysgpu_backend != .default) build_options.sysgpu_backend else switch (builtin.target.os.tag) { .webgpu => .webgpu,
.d3d12 => .d3d12,
.metal => .metal,
.vulkan => .vulkan,
.opengl => .opengl,
.default => switch (builtin.target.os.tag) {
.linux => .vulkan, .linux => .vulkan,
.macos, .ios => .metal, .macos, .ios => .metal,
.windows => .d3d12, .windows => .d3d12,
else => @compileError("unsupported platform"), else => @compileError("unsupported platform"),
},
}; };
const impl = switch (backend_type) { const impl = switch (backend_type) {
.d3d12 => @import("d3d12.zig"), .d3d12 => @import("d3d12.zig"),
.metal => @import("metal.zig"), .metal => @import("metal.zig"),