gpu: make Dawn source inclusion feature-oriented, not target-oriented
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
30c60162ae
commit
3f56f3f964
1 changed files with 104 additions and 122 deletions
|
|
@ -9,8 +9,8 @@ pub const LinuxWindowManager = enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
/// Only respected on Linux.
|
/// Defaults to X11 on Linux.
|
||||||
linux_window_manager: LinuxWindowManager = .X11,
|
linux_window_manager: ?LinuxWindowManager = null,
|
||||||
|
|
||||||
/// Defaults to true on Windows
|
/// Defaults to true on Windows
|
||||||
d3d12: ?bool = null,
|
d3d12: ?bool = null,
|
||||||
|
|
@ -36,6 +36,7 @@ pub const Options = struct {
|
||||||
const linux_desktop_like = !tag.isDarwin() and tag != .windows and tag != .fuchsia and tag != .emscripten and !target.isAndroid();
|
const linux_desktop_like = !tag.isDarwin() and tag != .windows and tag != .fuchsia and tag != .emscripten and !target.isAndroid();
|
||||||
|
|
||||||
var options = self;
|
var options = self;
|
||||||
|
if (options.linux_window_manager == null and linux_desktop_like) options.linux_window_manager = .X11;
|
||||||
if (options.d3d12 == null) options.d3d12 = tag == .windows;
|
if (options.d3d12 == null) options.d3d12 = tag == .windows;
|
||||||
if (options.metal == null) options.metal = tag.isDarwin();
|
if (options.metal == null) options.metal = tag.isDarwin();
|
||||||
if (options.vulkan == null) options.vulkan = tag == .fuchsia or linux_desktop_like;
|
if (options.vulkan == null) options.vulkan = tag == .fuchsia or linux_desktop_like;
|
||||||
|
|
@ -186,8 +187,6 @@ fn buildLibDawnNative(b: *Builder, step: *std.build.LibExeObjStep, options: Opti
|
||||||
lib.linkLibCpp();
|
lib.linkLibCpp();
|
||||||
system_sdk.include(b, lib, .{});
|
system_sdk.include(b, lib, .{});
|
||||||
|
|
||||||
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
|
||||||
|
|
||||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
appendDawnEnableBackendTypeFlags(&flags, options) catch unreachable;
|
appendDawnEnableBackendTypeFlags(&flags, options) catch unreachable;
|
||||||
flags.appendSlice(&.{
|
flags.appendSlice(&.{
|
||||||
|
|
@ -311,8 +310,6 @@ fn buildLibDawnNative(b: *Builder, step: *std.build.LibExeObjStep, options: Opti
|
||||||
// TODO(build-system): allow use_angle here. See src/dawn_native/BUILD.gn
|
// TODO(build-system): allow use_angle here. See src/dawn_native/BUILD.gn
|
||||||
// TODO(build-system): could allow use_swiftshader here. See src/dawn_native/BUILD.gn
|
// TODO(build-system): could allow use_swiftshader here. See src/dawn_native/BUILD.gn
|
||||||
|
|
||||||
switch (target.os.tag) {
|
|
||||||
.windows => {
|
|
||||||
// TODO(build-system): windows
|
// TODO(build-system): windows
|
||||||
// if (dawn_enable_d3d12) {
|
// if (dawn_enable_d3d12) {
|
||||||
// libs += [ "dxguid.lib" ]
|
// libs += [ "dxguid.lib" ]
|
||||||
|
|
@ -357,8 +354,6 @@ fn buildLibDawnNative(b: *Builder, step: *std.build.LibExeObjStep, options: Opti
|
||||||
// "d3d12/UtilsD3D12.cpp",
|
// "d3d12/UtilsD3D12.cpp",
|
||||||
// ]
|
// ]
|
||||||
// }
|
// }
|
||||||
},
|
|
||||||
.macos => {
|
|
||||||
if (options.metal.?) {
|
if (options.metal.?) {
|
||||||
lib.linkFramework("Metal");
|
lib.linkFramework("Metal");
|
||||||
lib.linkFramework("CoreGraphics");
|
lib.linkFramework("CoreGraphics");
|
||||||
|
|
@ -393,9 +388,8 @@ fn buildLibDawnNative(b: *Builder, step: *std.build.LibExeObjStep, options: Opti
|
||||||
lib.addCSourceFile(abs_path, flags.items);
|
lib.addCSourceFile(abs_path, flags.items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
else => {
|
if (options.linux_window_manager != null and options.linux_window_manager.? == .X11) {
|
||||||
if (options.linux_window_manager == .X11) {
|
|
||||||
lib.linkSystemLibrary("X11");
|
lib.linkSystemLibrary("X11");
|
||||||
for ([_][]const u8{
|
for ([_][]const u8{
|
||||||
"src/dawn_native/XlibXcbFunctions.cpp",
|
"src/dawn_native/XlibXcbFunctions.cpp",
|
||||||
|
|
@ -404,8 +398,6 @@ fn buildLibDawnNative(b: *Builder, step: *std.build.LibExeObjStep, options: Opti
|
||||||
lib.addCSourceFile(abs_path, flags.items);
|
lib.addCSourceFile(abs_path, flags.items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for ([_][]const u8{
|
for ([_][]const u8{
|
||||||
"src/dawn_native/null/DeviceNull.cpp",
|
"src/dawn_native/null/DeviceNull.cpp",
|
||||||
|
|
@ -1326,9 +1318,6 @@ fn buildLibDawnUtils(b: *Builder, step: *std.build.LibExeObjStep, options: Optio
|
||||||
lib.addCSourceFile(abs_path, flags.items);
|
lib.addCSourceFile(abs_path, flags.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
|
||||||
switch (target.os.tag) {
|
|
||||||
.windows => {
|
|
||||||
if (options.d3d12.?) {
|
if (options.d3d12.?) {
|
||||||
for ([_][]const u8{
|
for ([_][]const u8{
|
||||||
"src/utils/D3D12Binding.cpp",
|
"src/utils/D3D12Binding.cpp",
|
||||||
|
|
@ -1337,8 +1326,6 @@ fn buildLibDawnUtils(b: *Builder, step: *std.build.LibExeObjStep, options: Optio
|
||||||
lib.addCSourceFile(abs_path, flags.items);
|
lib.addCSourceFile(abs_path, flags.items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
.macos => {
|
|
||||||
if (options.metal.?) {
|
if (options.metal.?) {
|
||||||
for ([_][]const u8{
|
for ([_][]const u8{
|
||||||
"src/utils/MetalBinding.mm",
|
"src/utils/MetalBinding.mm",
|
||||||
|
|
@ -1347,11 +1334,6 @@ fn buildLibDawnUtils(b: *Builder, step: *std.build.LibExeObjStep, options: Optio
|
||||||
lib.addCSourceFile(abs_path, flags.items);
|
lib.addCSourceFile(abs_path, flags.items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
else => {
|
|
||||||
if (options.linux_window_manager == .X11) {}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(build-system): opengl
|
// TODO(build-system): opengl
|
||||||
// if (dawn_enable_opengl) {
|
// if (dawn_enable_opengl) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue