rename mach/gpu to mach/gpu-dawn
See https://github.com/hexops/mach/issues/133#issuecomment-999940767 Helps #109 Helps #133 Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
7ec7fb7af0
commit
7af784bee7
28 changed files with 0 additions and 1 deletions
57
gpu-dawn/README.md
Normal file
57
gpu-dawn/README.md
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# mach/gpu, truly cross-platform graphics for Zig <a href="https://hexops.com"><img align="right" alt="Hexops logo" src="https://raw.githubusercontent.com/hexops/media/master/readme.svg"></img></a>
|
||||
|
||||
`mach/gpu` is a truly cross-platform graphics API (desktop, mobile, and web) providing a unified low-level graphics API over Vulkan, Metal, D3D12, and OpenGL (as a best-effort fallback.)
|
||||
|
||||

|
||||
|
||||
## Warning: Under heavy development!
|
||||
|
||||
Not everything stated in this README is yet achieved. We're working on it! Of particular note, we are missing:
|
||||
|
||||
* You'll need a version of Zig which includes ObjC++ support: https://github.com/ziglang/zig/pull/10096
|
||||
* Cross compilation support
|
||||
* Windows support
|
||||
* Linux support
|
||||
* Android support
|
||||
* iOS support
|
||||
* Browser support
|
||||
* Idiomatic WebGPU wrapper
|
||||
|
||||
## Features
|
||||
|
||||
* Desktop, mobile, and web support.
|
||||
* Cross-compilation & no fuss installation, using `zig build`, as with all Mach libraries.
|
||||
* A modern graphics API similar to Metal, Vulkan, and DirectX 12.
|
||||
* Compute shaders
|
||||
* Advanced GPU features where hardware support is available:
|
||||
* Depth buffer clipping control
|
||||
* Depth buffer format control
|
||||
* Texture compression (BC, ETC2, and ASTC)
|
||||
* Timestamp querying (for GPU profiling)
|
||||
* Indirect draw support
|
||||
|
||||
**Note:** Absolute bleeding edge features which have not truly stabilized, such as DirectX 12 Mesh Shaders (which has limited hardware support, does not work across both AMD and NVIDIA cards in Vulkan, etc.) are not supported. You can however always choose to drop down to the underlying native Vulkan/Metal/D3D12 API in conjunction with this abstraction if needed.
|
||||
|
||||
## A different approach to graphics API abstraction
|
||||
|
||||
Most engines today (Unreal, Unity) maintain their own GPU abstraction layer over native graphics APIs at great expense, requiring many years of development and ongoing maintenance.
|
||||
|
||||
Many are attempting graphics abstraction layers on their own including Godot (and their custom shading language), [SDL's recently announced GPU abstraction layer](https://news.ycombinator.com/item?id=29203534), [sokol_gfx](https://github.com/floooh/sokol), and others including Blender3D which target varying native graphics APIs. These are admirable efforts, but come at great development costs.
|
||||
|
||||
Vulkan, the alleged cross-platform graphics API, in practice requires abstraction layers like MoltenVK on Apple hardware and is often in practice too verbose for use without at least one higher level abstraction layer (often the engine's rendering layer.) With a simpler API like Metal or D3D, however, one could stay closer to the underlying API without introducing secondary and third abstraction layers on top and make smarter choices as a result.
|
||||
|
||||
With Mach, we'd rather focus on building great games than yet-another-abstraction-layer, and as it turns out some of the best minds in computer graphics (including the Rust community, Mozilla, Google, Microsoft, Intel, and Apple) have made serious multi-year investments with several full-time engineers into creating a solid abstraction layer for us - we're just being smart and adopting it for our own purpose!
|
||||
|
||||
## Behind the scenes
|
||||
|
||||
`mach/gpu` is an idiomatic Zig interface to [the next-generation WebGPU API](https://www.w3.org/TR/webgpu/), which supersedes WebGL and exposes the common denominator between the latest low-level graphics APIs (Vulkan, Metal, D3D12) in the web.
|
||||
|
||||
Despite its name, [WebGPU was also built with native support in mind](http://kvark.github.io/web/gpu/native/2020/05/03/point-of-webgpu-native.html) and has substantial investment from Mozilla, Google, Microsoft, Intel, and, critically, Apple:
|
||||
|
||||

|
||||
|
||||
When targeting WebAssembly, `mach/gpu` merely calls into the browser's native WebGPU implementation.
|
||||
|
||||
When building native Zig binaries, it builds and directly invokes Google Chrome's native WebGPU implementation, [Dawn](https://dawn.googlesource.com/dawn), bypassing the client-server sandboxing model - and using `zig build` (plus a lot of hand-holding) to support zero-fuss cross compilation & installation without any third-party Google tools, libraries, etc. Just `zig` and `git` needed, nothing else.
|
||||
|
||||
[Read more about why we believe WebGPU may be the future of graphics here](https://devlog.hexops.com/2021/mach-engine-the-future-of-graphics-with-zig#truly-cross-platform-graphics-api)
|
||||
38
gpu-dawn/build.zig
Normal file
38
gpu-dawn/build.zig
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
const Builder = @import("std").build.Builder;
|
||||
const dawn = @import("build_dawn.zig");
|
||||
|
||||
const glfw = @import("libs/mach-glfw/build.zig");
|
||||
|
||||
pub fn build(b: *Builder) void {
|
||||
const mode = b.standardReleaseOptions();
|
||||
const target = b.standardTargetOptions(.{});
|
||||
|
||||
const lib = b.addStaticLibrary("gpu", "src/main.zig");
|
||||
lib.setBuildMode(mode);
|
||||
lib.setTarget(target);
|
||||
lib.install();
|
||||
dawn.link(b, lib, .{});
|
||||
|
||||
const main_tests = b.addTest("src/main.zig");
|
||||
main_tests.setBuildMode(mode);
|
||||
|
||||
const test_step = b.step("test", "Run library tests");
|
||||
test_step.dependOn(&main_tests.step);
|
||||
|
||||
const dawn_example = b.addExecutable("dawn-example", "src/dawn/hello_triangle.zig");
|
||||
dawn_example.setBuildMode(mode);
|
||||
dawn_example.setTarget(target);
|
||||
dawn.link(b, dawn_example, .{});
|
||||
glfw.link(b, dawn_example, .{ .system_sdk = .{ .set_sysroot = false } });
|
||||
dawn_example.addPackagePath("glfw", "libs/mach-glfw/src/main.zig");
|
||||
dawn_example.addIncludeDir("libs/dawn/out/Debug/gen/src/include");
|
||||
dawn_example.addIncludeDir("libs/dawn/out/Debug/gen/src");
|
||||
dawn_example.addIncludeDir("libs/dawn/src/include");
|
||||
dawn_example.addIncludeDir("src/dawn");
|
||||
dawn_example.install();
|
||||
|
||||
const dawn_example_run_cmd = dawn_example.run();
|
||||
dawn_example_run_cmd.step.dependOn(b.getInstallStep());
|
||||
const dawn_example_run_step = b.step("run-dawn-example", "Run the dawn example");
|
||||
dawn_example_run_step.dependOn(&dawn_example_run_cmd.step);
|
||||
}
|
||||
887
gpu-dawn/build_dawn.zig
Normal file
887
gpu-dawn/build_dawn.zig
Normal file
|
|
@ -0,0 +1,887 @@
|
|||
const std = @import("std");
|
||||
const Builder = std.build.Builder;
|
||||
const glfw = @import("libs/mach-glfw/build.zig");
|
||||
const system_sdk = @import("libs/mach-glfw/system_sdk.zig");
|
||||
|
||||
pub const LinuxWindowManager = enum {
|
||||
X11,
|
||||
Wayland,
|
||||
};
|
||||
|
||||
pub const Options = struct {
|
||||
/// Defaults to X11 on Linux.
|
||||
linux_window_manager: ?LinuxWindowManager = null,
|
||||
|
||||
/// Defaults to true on Windows
|
||||
d3d12: ?bool = null,
|
||||
|
||||
/// Defaults to true on Darwin
|
||||
metal: ?bool = null,
|
||||
|
||||
/// Defaults to true on Linux, Fuchsia
|
||||
// TODO(build-system): enable on Windows if we can cross compile Vulkan
|
||||
vulkan: ?bool = null,
|
||||
|
||||
/// Defaults to true on Windows, Linux
|
||||
// TODO(build-system): not respected at all currently
|
||||
desktop_gl: ?bool = null,
|
||||
|
||||
/// Defaults to true on Android, Linux, Windows, Emscripten
|
||||
// TODO(build-system): not respected at all currently
|
||||
opengl_es: ?bool = null,
|
||||
|
||||
/// Whether or not minimal debug symbols should be emitted. This is -g1 in most cases, enough to
|
||||
/// produce stack traces but omitting debug symbols for locals. For spirv-tools and tint in
|
||||
/// specific, -g0 will be used (no debug symbols at all) to save an additional ~39M.
|
||||
///
|
||||
/// When enabled, a debug build of the static library goes from ~947M to just ~53M.
|
||||
minimal_debug_symbols: bool = true,
|
||||
|
||||
/// Detects the default options to use for the given target.
|
||||
pub fn detectDefaults(self: Options, target: std.Target) Options {
|
||||
const tag = target.os.tag;
|
||||
const linux_desktop_like = isLinuxDesktopLike(target);
|
||||
|
||||
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.metal == null) options.metal = tag.isDarwin();
|
||||
if (options.vulkan == null) options.vulkan = tag == .fuchsia or linux_desktop_like;
|
||||
|
||||
// TODO(build-system): respect these options / defaults
|
||||
if (options.desktop_gl == null) options.desktop_gl = linux_desktop_like; // TODO(build-system): add windows
|
||||
options.opengl_es = false;
|
||||
// if (options.opengl_es == null) options.opengl_es = tag == .windows or tag == .emscripten or target.isAndroid() or linux_desktop_like;
|
||||
return options;
|
||||
}
|
||||
|
||||
pub fn appendFlags(self: Options, flags: *std.ArrayList([]const u8), zero_debug_symbols: bool) !void {
|
||||
if (self.minimal_debug_symbols) {
|
||||
if (zero_debug_symbols) try flags.append("-g0") else try flags.append("-g1");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {
|
||||
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
||||
const opt = options.detectDefaults(target);
|
||||
|
||||
const lib_mach_dawn_native = buildLibMachDawnNative(b, step, opt);
|
||||
step.linkLibrary(lib_mach_dawn_native);
|
||||
|
||||
const lib_dawn_common = buildLibDawnCommon(b, step, opt);
|
||||
step.linkLibrary(lib_dawn_common);
|
||||
|
||||
const lib_dawn_platform = buildLibDawnPlatform(b, step, opt);
|
||||
step.linkLibrary(lib_dawn_platform);
|
||||
|
||||
// dawn-native
|
||||
const lib_abseil_cpp = buildLibAbseilCpp(b, step, opt);
|
||||
step.linkLibrary(lib_abseil_cpp);
|
||||
const lib_dawn_native = buildLibDawnNative(b, step, opt);
|
||||
step.linkLibrary(lib_dawn_native);
|
||||
|
||||
const lib_dawn_wire = buildLibDawnWire(b, step, opt);
|
||||
step.linkLibrary(lib_dawn_wire);
|
||||
|
||||
const lib_dawn_utils = buildLibDawnUtils(b, step, opt);
|
||||
step.linkLibrary(lib_dawn_utils);
|
||||
|
||||
const lib_spirv_tools = buildLibSPIRVTools(b, step, opt);
|
||||
step.linkLibrary(lib_spirv_tools);
|
||||
|
||||
const lib_tint = buildLibTint(b, step, opt);
|
||||
step.linkLibrary(lib_tint);
|
||||
}
|
||||
|
||||
fn isLinuxDesktopLike(target: std.Target) bool {
|
||||
const tag = target.os.tag;
|
||||
return !tag.isDarwin() and tag != .windows and tag != .fuchsia and tag != .emscripten and !target.isAndroid();
|
||||
}
|
||||
|
||||
fn buildLibMachDawnNative(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
|
||||
var main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/dawn/dummy.zig" }) catch unreachable;
|
||||
const lib = b.addStaticLibrary("dawn-native-mach", main_abs);
|
||||
lib.install();
|
||||
lib.setBuildMode(step.build_mode);
|
||||
lib.setTarget(step.target);
|
||||
lib.linkLibCpp();
|
||||
|
||||
// TODO(build-system): pass system SDK options through
|
||||
glfw.link(b, lib, .{ .system_sdk = .{ .set_sysroot = false } });
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
options.appendFlags(&flags, false) catch unreachable;
|
||||
appendDawnEnableBackendTypeFlags(&flags, options) catch unreachable;
|
||||
flags.appendSlice(&.{
|
||||
include("libs/mach-glfw/upstream/glfw/include"),
|
||||
include("libs/dawn/out/Debug/gen/src/include"),
|
||||
include("libs/dawn/out/Debug/gen/src"),
|
||||
include("libs/dawn/src/include"),
|
||||
include("libs/dawn/src"),
|
||||
}) catch unreachable;
|
||||
|
||||
lib.addCSourceFile("src/dawn/dawn_native_mach.cpp", flags.items);
|
||||
return lib;
|
||||
}
|
||||
|
||||
// Builds common sources; derived from src/common/BUILD.gn
|
||||
fn buildLibDawnCommon(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
|
||||
var main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/dawn/dummy.zig" }) catch unreachable;
|
||||
const lib = b.addStaticLibrary("dawn-common", main_abs);
|
||||
lib.setBuildMode(step.build_mode);
|
||||
lib.setTarget(step.target);
|
||||
lib.linkLibCpp();
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
options.appendFlags(&flags, false) catch unreachable;
|
||||
flags.append(include("libs/dawn/src")) catch unreachable;
|
||||
|
||||
var sources = std.ArrayList([]const u8).init(b.allocator);
|
||||
for ([_][]const u8{
|
||||
"src/common/Assert.cpp",
|
||||
"src/common/DynamicLib.cpp",
|
||||
"src/common/GPUInfo.cpp",
|
||||
"src/common/Log.cpp",
|
||||
"src/common/Math.cpp",
|
||||
"src/common/RefCounted.cpp",
|
||||
"src/common/Result.cpp",
|
||||
"src/common/SlabAllocator.cpp",
|
||||
"src/common/SystemUtils.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
|
||||
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
||||
if (target.os.tag == .macos) {
|
||||
// TODO(build-system): pass system SDK options through
|
||||
system_sdk.include(b, lib, .{});
|
||||
lib.linkFramework("Foundation");
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn/src/common/SystemUtils_mac.mm" }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
lib.addCSourceFiles(sources.items, flags.items);
|
||||
return lib;
|
||||
}
|
||||
|
||||
// Build dawn platform sources; derived from src/dawn_platform/BUILD.gn
|
||||
fn buildLibDawnPlatform(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
|
||||
var main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/dawn/dummy.zig" }) catch unreachable;
|
||||
const lib = b.addStaticLibrary("dawn-platform", main_abs);
|
||||
lib.install();
|
||||
lib.setBuildMode(step.build_mode);
|
||||
lib.setTarget(step.target);
|
||||
lib.linkLibCpp();
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
options.appendFlags(&flags, false) catch unreachable;
|
||||
flags.appendSlice(&.{
|
||||
include("libs/dawn/src"),
|
||||
include("libs/dawn/src/include"),
|
||||
|
||||
include("libs/dawn/out/Debug/gen/src/include"),
|
||||
}) catch unreachable;
|
||||
|
||||
var sources = std.ArrayList([]const u8).init(b.allocator);
|
||||
for ([_][]const u8{
|
||||
"src/dawn_platform/DawnPlatform.cpp",
|
||||
"src/dawn_platform/WorkerThread.cpp",
|
||||
"src/dawn_platform/tracing/EventTracer.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
lib.addCSourceFiles(sources.items, flags.items);
|
||||
return lib;
|
||||
}
|
||||
|
||||
fn appendDawnEnableBackendTypeFlags(flags: *std.ArrayList([]const u8), options: Options) !void {
|
||||
const d3d12 = "-DDAWN_ENABLE_BACKEND_D3D12";
|
||||
const metal = "-DDAWN_ENABLE_BACKEND_METAL";
|
||||
const vulkan = "-DDAWN_ENABLE_BACKEND_VULKAN";
|
||||
const opengl = "-DDAWN_ENABLE_BACKEND_OPENGL";
|
||||
const desktop_gl = "-DDAWN_ENABLE_BACKEND_DESKTOP_GL";
|
||||
const opengl_es = "-DDAWN_ENABLE_BACKEND_OPENGLES";
|
||||
const backend_null = "-DDAWN_ENABLE_BACKEND_NULL";
|
||||
|
||||
try flags.append(backend_null);
|
||||
if (options.d3d12.?) try flags.append(d3d12);
|
||||
if (options.metal.?) try flags.append(metal);
|
||||
if (options.vulkan.?) try flags.append(vulkan);
|
||||
if (options.desktop_gl.?) try flags.appendSlice(&.{ opengl, desktop_gl });
|
||||
if (options.opengl_es.?) try flags.appendSlice(&.{ opengl, opengl_es });
|
||||
}
|
||||
|
||||
// Builds dawn native sources; derived from src/dawn_native/BUILD.gn
|
||||
fn buildLibDawnNative(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
|
||||
var main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/dawn/dummy.zig" }) catch unreachable;
|
||||
const lib = b.addStaticLibrary("dawn-native", main_abs);
|
||||
lib.install();
|
||||
lib.setBuildMode(step.build_mode);
|
||||
lib.setTarget(step.target);
|
||||
lib.linkLibCpp();
|
||||
system_sdk.include(b, lib, .{});
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
options.appendFlags(&flags, false) catch unreachable;
|
||||
appendDawnEnableBackendTypeFlags(&flags, options) catch unreachable;
|
||||
if (options.desktop_gl.?) {
|
||||
// OpenGL requires spriv-cross until Dawn moves OpenGL shader generation to Tint.
|
||||
flags.append(include("libs/dawn/third_party/vulkan-deps/spirv-cross/src")) catch unreachable;
|
||||
|
||||
const lib_spirv_cross = buildLibSPIRVCross(b, step, options);
|
||||
step.linkLibrary(lib_spirv_cross);
|
||||
}
|
||||
flags.appendSlice(&.{
|
||||
include("libs/dawn"),
|
||||
include("libs/dawn/src"),
|
||||
include("libs/dawn/src/include"),
|
||||
include("libs/dawn/third_party/vulkan-deps/spirv-tools/src/include"),
|
||||
include("libs/dawn/third_party/abseil-cpp"),
|
||||
include("libs/dawn/third_party/khronos"),
|
||||
|
||||
// TODO(build-system): make these optional
|
||||
"-DTINT_BUILD_SPV_READER=1",
|
||||
"-DTINT_BUILD_SPV_WRITER=1",
|
||||
"-DTINT_BUILD_WGSL_READER=1",
|
||||
"-DTINT_BUILD_WGSL_WRITER=1",
|
||||
"-DTINT_BUILD_MSL_WRITER=1",
|
||||
"-DTINT_BUILD_HLSL_WRITER=1",
|
||||
include("libs/dawn/third_party/tint"),
|
||||
include("libs/dawn/third_party/tint/include"),
|
||||
|
||||
include("libs/dawn/out/Debug/gen/src/include"),
|
||||
include("libs/dawn/out/Debug/gen/src"),
|
||||
}) catch unreachable;
|
||||
|
||||
var sources = std.ArrayList([]const u8).init(b.allocator);
|
||||
sources.appendSlice(&.{
|
||||
thisDir() ++ "/src/dawn/sources/dawn_native.cpp",
|
||||
thisDir() ++ "/libs/dawn/out/Debug/gen/src/dawn/dawn_proc.c",
|
||||
}) catch unreachable;
|
||||
|
||||
// dawn_native_utils_gen
|
||||
sources.append(thisDir() ++ "/src/dawn/sources/dawn_native_utils_gen.cpp") catch unreachable;
|
||||
|
||||
// TODO(build-system): could allow enable_vulkan_validation_layers 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
|
||||
|
||||
if (options.d3d12.?) {
|
||||
// TODO(build-system): windows
|
||||
// libs += [ "dxguid.lib" ]
|
||||
// TODO(build-system): reduce build units
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/d3d12/AdapterD3D12.cpp",
|
||||
"src/dawn_native/d3d12/BackendD3D12.cpp",
|
||||
"src/dawn_native/d3d12/BindGroupD3D12.cpp",
|
||||
"src/dawn_native/d3d12/BindGroupLayoutD3D12.cpp",
|
||||
"src/dawn_native/d3d12/BufferD3D12.cpp",
|
||||
"src/dawn_native/d3d12/CPUDescriptorHeapAllocationD3D12.cpp",
|
||||
"src/dawn_native/d3d12/CommandAllocatorManager.cpp",
|
||||
"src/dawn_native/d3d12/CommandBufferD3D12.cpp",
|
||||
"src/dawn_native/d3d12/CommandRecordingContext.cpp",
|
||||
"src/dawn_native/d3d12/ComputePipelineD3D12.cpp",
|
||||
"src/dawn_native/d3d12/D3D11on12Util.cpp",
|
||||
"src/dawn_native/d3d12/D3D12Error.cpp",
|
||||
"src/dawn_native/d3d12/D3D12Info.cpp",
|
||||
"src/dawn_native/d3d12/DeviceD3D12.cpp",
|
||||
"src/dawn_native/d3d12/GPUDescriptorHeapAllocationD3D12.cpp",
|
||||
"src/dawn_native/d3d12/HeapAllocatorD3D12.cpp",
|
||||
"src/dawn_native/d3d12/HeapD3D12.cpp",
|
||||
"src/dawn_native/d3d12/NativeSwapChainImplD3D12.cpp",
|
||||
"src/dawn_native/d3d12/PageableD3D12.cpp",
|
||||
"src/dawn_native/d3d12/PipelineLayoutD3D12.cpp",
|
||||
"src/dawn_native/d3d12/PlatformFunctions.cpp",
|
||||
"src/dawn_native/d3d12/QuerySetD3D12.cpp",
|
||||
"src/dawn_native/d3d12/QueueD3D12.cpp",
|
||||
"src/dawn_native/d3d12/RenderPassBuilderD3D12.cpp",
|
||||
"src/dawn_native/d3d12/RenderPipelineD3D12.cpp",
|
||||
"src/dawn_native/d3d12/ResidencyManagerD3D12.cpp",
|
||||
"src/dawn_native/d3d12/ResourceAllocatorManagerD3D12.cpp",
|
||||
"src/dawn_native/d3d12/ResourceHeapAllocationD3D12.cpp",
|
||||
"src/dawn_native/d3d12/SamplerD3D12.cpp",
|
||||
"src/dawn_native/d3d12/SamplerHeapCacheD3D12.cpp",
|
||||
"src/dawn_native/d3d12/ShaderModuleD3D12.cpp",
|
||||
"src/dawn_native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp",
|
||||
"src/dawn_native/d3d12/StagingBufferD3D12.cpp",
|
||||
"src/dawn_native/d3d12/StagingDescriptorAllocatorD3D12.cpp",
|
||||
"src/dawn_native/d3d12/SwapChainD3D12.cpp",
|
||||
"src/dawn_native/d3d12/TextureCopySplitter.cpp",
|
||||
"src/dawn_native/d3d12/TextureD3D12.cpp",
|
||||
"src/dawn_native/d3d12/UtilsD3D12.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
lib.addCSourceFile(abs_path, flags.items);
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
}
|
||||
if (options.metal.?) {
|
||||
lib.linkFramework("Metal");
|
||||
lib.linkFramework("CoreGraphics");
|
||||
lib.linkFramework("Foundation");
|
||||
lib.linkFramework("IOKit");
|
||||
lib.linkFramework("IOSurface");
|
||||
lib.linkFramework("QuartzCore");
|
||||
|
||||
sources.appendSlice(&.{
|
||||
thisDir() ++ "/src/dawn/sources/dawn_native_metal.mm",
|
||||
thisDir() ++ "/libs/dawn/src/dawn_native/metal/BackendMTL.mm",
|
||||
}) catch unreachable;
|
||||
}
|
||||
|
||||
if (options.linux_window_manager != null and options.linux_window_manager.? == .X11) {
|
||||
lib.linkSystemLibrary("X11");
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/XlibXcbFunctions.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/null/DeviceNull.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
|
||||
if (options.desktop_gl.? or options.vulkan.?) {
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/SpirvValidation.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.desktop_gl.?) {
|
||||
for ([_][]const u8{
|
||||
"out/Debug/gen/src/dawn_native/opengl/OpenGLFunctionsBase_autogen.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
|
||||
// TODO(build-system): reduce build units
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/opengl/BackendGL.cpp",
|
||||
"src/dawn_native/opengl/BindGroupGL.cpp",
|
||||
"src/dawn_native/opengl/BindGroupLayoutGL.cpp",
|
||||
"src/dawn_native/opengl/BufferGL.cpp",
|
||||
"src/dawn_native/opengl/CommandBufferGL.cpp",
|
||||
"src/dawn_native/opengl/ComputePipelineGL.cpp",
|
||||
"src/dawn_native/opengl/DeviceGL.cpp",
|
||||
"src/dawn_native/opengl/GLFormat.cpp",
|
||||
"src/dawn_native/opengl/NativeSwapChainImplGL.cpp",
|
||||
"src/dawn_native/opengl/OpenGLFunctions.cpp",
|
||||
"src/dawn_native/opengl/OpenGLVersion.cpp",
|
||||
"src/dawn_native/opengl/PersistentPipelineStateGL.cpp",
|
||||
"src/dawn_native/opengl/PipelineGL.cpp",
|
||||
"src/dawn_native/opengl/PipelineLayoutGL.cpp",
|
||||
"src/dawn_native/opengl/QuerySetGL.cpp",
|
||||
"src/dawn_native/opengl/QueueGL.cpp",
|
||||
"src/dawn_native/opengl/RenderPipelineGL.cpp",
|
||||
"src/dawn_native/opengl/SamplerGL.cpp",
|
||||
"src/dawn_native/opengl/ShaderModuleGL.cpp",
|
||||
"src/dawn_native/opengl/SpirvUtils.cpp",
|
||||
"src/dawn_native/opengl/SwapChainGL.cpp",
|
||||
"src/dawn_native/opengl/TextureGL.cpp",
|
||||
"src/dawn_native/opengl/UtilsGL.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
||||
if (options.vulkan.?) {
|
||||
// TODO(build-system): reduce build units
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/vulkan/AdapterVk.cpp",
|
||||
"src/dawn_native/vulkan/BackendVk.cpp",
|
||||
"src/dawn_native/vulkan/BindGroupLayoutVk.cpp",
|
||||
"src/dawn_native/vulkan/BindGroupVk.cpp",
|
||||
"src/dawn_native/vulkan/BufferVk.cpp",
|
||||
"src/dawn_native/vulkan/CommandBufferVk.cpp",
|
||||
"src/dawn_native/vulkan/ComputePipelineVk.cpp",
|
||||
"src/dawn_native/vulkan/DescriptorSetAllocator.cpp",
|
||||
"src/dawn_native/vulkan/DeviceVk.cpp",
|
||||
"src/dawn_native/vulkan/FencedDeleter.cpp",
|
||||
"src/dawn_native/vulkan/NativeSwapChainImplVk.cpp",
|
||||
"src/dawn_native/vulkan/PipelineLayoutVk.cpp",
|
||||
"src/dawn_native/vulkan/QuerySetVk.cpp",
|
||||
"src/dawn_native/vulkan/QueueVk.cpp",
|
||||
"src/dawn_native/vulkan/RenderPassCache.cpp",
|
||||
"src/dawn_native/vulkan/RenderPipelineVk.cpp",
|
||||
"src/dawn_native/vulkan/ResourceHeapVk.cpp",
|
||||
"src/dawn_native/vulkan/ResourceMemoryAllocatorVk.cpp",
|
||||
"src/dawn_native/vulkan/SamplerVk.cpp",
|
||||
"src/dawn_native/vulkan/ShaderModuleVk.cpp",
|
||||
"src/dawn_native/vulkan/StagingBufferVk.cpp",
|
||||
"src/dawn_native/vulkan/SwapChainVk.cpp",
|
||||
"src/dawn_native/vulkan/TextureVk.cpp",
|
||||
"src/dawn_native/vulkan/UtilsVulkan.cpp",
|
||||
"src/dawn_native/vulkan/VulkanError.cpp",
|
||||
"src/dawn_native/vulkan/VulkanExtensions.cpp",
|
||||
"src/dawn_native/vulkan/VulkanFunctions.cpp",
|
||||
"src/dawn_native/vulkan/VulkanInfo.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
|
||||
if (isLinuxDesktopLike(target)) {
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/vulkan/external_memory/MemoryServiceOpaqueFD.cpp",
|
||||
"src/dawn_native/vulkan/external_semaphore/SemaphoreServiceFD.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
lib.addCSourceFile(abs_path, flags.items);
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
} else if (target.os.tag == .fuchsia) {
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/vulkan/external_memory/MemoryServiceZirconHandle.cpp",
|
||||
"src/dawn_native/vulkan/external_semaphore/SemaphoreServiceZirconHandle.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
} else {
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/vulkan/external_memory/MemoryServiceNull.cpp",
|
||||
"src/dawn_native/vulkan/external_semaphore/SemaphoreServiceNull.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(build-system): fuchsia: add is_fuchsia here from upstream source file
|
||||
|
||||
if (options.vulkan.?) {
|
||||
// TODO(build-system): vulkan
|
||||
// if (enable_vulkan_validation_layers) {
|
||||
// defines += [
|
||||
// "DAWN_ENABLE_VULKAN_VALIDATION_LAYERS",
|
||||
// "DAWN_VK_DATA_DIR=\"$vulkan_data_subdir\"",
|
||||
// ]
|
||||
// }
|
||||
// if (enable_vulkan_loader) {
|
||||
// data_deps += [ "${dawn_vulkan_loader_dir}:libvulkan" ]
|
||||
// defines += [ "DAWN_ENABLE_VULKAN_LOADER" ]
|
||||
// }
|
||||
}
|
||||
// TODO(build-system): swiftshader
|
||||
// if (use_swiftshader) {
|
||||
// data_deps += [
|
||||
// "${dawn_swiftshader_dir}/src/Vulkan:icd_file",
|
||||
// "${dawn_swiftshader_dir}/src/Vulkan:swiftshader_libvulkan",
|
||||
// ]
|
||||
// defines += [
|
||||
// "DAWN_ENABLE_SWIFTSHADER",
|
||||
// "DAWN_SWIFTSHADER_VK_ICD_JSON=\"${swiftshader_icd_file_name}\"",
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
|
||||
if (options.opengl_es.?) {
|
||||
// TODO(build-system): gles
|
||||
// if (use_angle) {
|
||||
// data_deps += [
|
||||
// "${dawn_angle_dir}:libEGL",
|
||||
// "${dawn_angle_dir}:libGLESv2",
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/DawnNative.cpp",
|
||||
"src/dawn_native/null/NullBackend.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
|
||||
if (options.d3d12.?) {
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/d3d12/D3D12Backend.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
}
|
||||
if (options.desktop_gl.?) {
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/opengl/OpenGLBackend.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
}
|
||||
if (options.vulkan.?) {
|
||||
for ([_][]const u8{
|
||||
"src/dawn_native/vulkan/VulkanBackend.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
// TODO(build-system): vulkan
|
||||
// if (enable_vulkan_validation_layers) {
|
||||
// data_deps =
|
||||
// [ "${dawn_vulkan_validation_layers_dir}:vulkan_validation_layers" ]
|
||||
// if (!is_android) {
|
||||
// data_deps +=
|
||||
// [ "${dawn_vulkan_validation_layers_dir}:vulkan_gen_json_files" ]
|
||||
// }
|
||||
// }
|
||||
}
|
||||
lib.addCSourceFiles(sources.items, flags.items);
|
||||
return lib;
|
||||
}
|
||||
|
||||
// Builds third party tint sources; derived from third_party/tint/src/BUILD.gn
|
||||
fn buildLibTint(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
|
||||
var main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/dawn/dummy.zig" }) catch unreachable;
|
||||
const lib = b.addStaticLibrary("tint", main_abs);
|
||||
lib.install();
|
||||
lib.setBuildMode(step.build_mode);
|
||||
lib.setTarget(step.target);
|
||||
lib.linkLibCpp();
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
options.appendFlags(&flags, true) catch unreachable;
|
||||
flags.appendSlice(&.{
|
||||
// TODO(build-system): make these optional
|
||||
"-DTINT_BUILD_SPV_READER=1",
|
||||
"-DTINT_BUILD_SPV_WRITER=1",
|
||||
"-DTINT_BUILD_WGSL_READER=1",
|
||||
"-DTINT_BUILD_WGSL_WRITER=1",
|
||||
"-DTINT_BUILD_MSL_WRITER=1",
|
||||
"-DTINT_BUILD_HLSL_WRITER=1",
|
||||
"-DTINT_BUILD_GLSL_WRITER=1",
|
||||
|
||||
include("libs/dawn"),
|
||||
include("libs/dawn/third_party/tint"),
|
||||
include("libs/dawn/third_party/tint/include"),
|
||||
|
||||
// Required for TINT_BUILD_SPV_READER=1 and TINT_BUILD_SPV_WRITER=1, if specified
|
||||
include("libs/dawn/third_party/vulkan-deps"),
|
||||
include("libs/dawn/third_party/vulkan-deps/spirv-tools/src"),
|
||||
include("libs/dawn/third_party/vulkan-deps/spirv-tools/src/include"),
|
||||
include("libs/dawn/third_party/vulkan-deps/spirv-headers/src/include"),
|
||||
include("libs/dawn/out/Debug/gen/third_party/vulkan-deps/spirv-tools/src"),
|
||||
include("libs/dawn/out/Debug/gen/third_party/vulkan-deps/spirv-tools/src/include"),
|
||||
}) catch unreachable;
|
||||
|
||||
// libtint_core_all_src
|
||||
var sources = std.ArrayList([]const u8).init(b.allocator);
|
||||
sources.appendSlice(&.{
|
||||
thisDir() ++ "/src/dawn/sources/tint_core_all_src.cc",
|
||||
thisDir() ++ "/src/dawn/sources/tint_core_all_src_2.cc",
|
||||
thisDir() ++ "/libs/dawn/third_party/tint/src/ast/node.cc",
|
||||
thisDir() ++ "/libs/dawn/third_party/tint/src/ast/texture.cc",
|
||||
}) catch unreachable;
|
||||
|
||||
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
||||
switch (target.os.tag) {
|
||||
.windows => sources.append(thisDir() ++ "/libs/dawn/third_party/tint/src/diagnostic/printer_windows.cc") catch unreachable,
|
||||
.linux => sources.append(thisDir() ++ "/libs/dawn/third_party/tint/src/diagnostic/printer_linux.cc") catch unreachable,
|
||||
else => sources.append(thisDir() ++ "/libs/dawn/third_party/tint/src/diagnostic/printer_other.cc") catch unreachable,
|
||||
}
|
||||
|
||||
// libtint_sem_src
|
||||
sources.appendSlice(&.{
|
||||
thisDir() ++ "/src/dawn/sources/tint_sem_src.cc",
|
||||
thisDir() ++ "/src/dawn/sources/tint_sem_src_2.cc",
|
||||
thisDir() ++ "/libs/dawn/third_party/tint/src/sem/node.cc",
|
||||
thisDir() ++ "/libs/dawn/third_party/tint/src/sem/texture_type.cc",
|
||||
}) catch unreachable;
|
||||
|
||||
// libtint_spv_reader_src
|
||||
sources.append(thisDir() ++ "/src/dawn/sources/tint_spv_reader_src.cc") catch unreachable;
|
||||
|
||||
// libtint_spv_writer_src
|
||||
sources.append(thisDir() ++ "/src/dawn/sources/tint_spv_writer_src.cc") catch unreachable;
|
||||
|
||||
// TODO(build-system): make optional
|
||||
// libtint_wgsl_reader_src
|
||||
for ([_][]const u8{
|
||||
"third_party/tint/src/reader/wgsl/lexer.cc",
|
||||
"third_party/tint/src/reader/wgsl/parser.cc",
|
||||
"third_party/tint/src/reader/wgsl/parser_impl.cc",
|
||||
"third_party/tint/src/reader/wgsl/token.cc",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
|
||||
// TODO(build-system): make optional
|
||||
// libtint_wgsl_writer_src
|
||||
for ([_][]const u8{
|
||||
"third_party/tint/src/writer/wgsl/generator.cc",
|
||||
"third_party/tint/src/writer/wgsl/generator_impl.cc",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
|
||||
// TODO(build-system): make optional
|
||||
// libtint_msl_writer_src
|
||||
for ([_][]const u8{
|
||||
"third_party/tint/src/writer/msl/generator.cc",
|
||||
"third_party/tint/src/writer/msl/generator_impl.cc",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
|
||||
// TODO(build-system): make optional
|
||||
// libtint_hlsl_writer_src
|
||||
for ([_][]const u8{
|
||||
"third_party/tint/src/writer/hlsl/generator.cc",
|
||||
"third_party/tint/src/writer/hlsl/generator_impl.cc",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
|
||||
// TODO(build-system): make optional
|
||||
// libtint_glsl_writer_src
|
||||
for ([_][]const u8{
|
||||
"third_party/tint/src/transform/glsl.cc",
|
||||
"third_party/tint/src/writer/glsl/generator.cc",
|
||||
"third_party/tint/src/writer/glsl/generator_impl.cc",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
lib.addCSourceFiles(sources.items, flags.items);
|
||||
return lib;
|
||||
}
|
||||
|
||||
// Builds third_party/vulkan-deps/spirv-tools sources; derived from third_party/vulkan-deps/spirv-tools/src/BUILD.gn
|
||||
fn buildLibSPIRVTools(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
|
||||
var main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/dawn/dummy.zig" }) catch unreachable;
|
||||
const lib = b.addStaticLibrary("spirv-tools", main_abs);
|
||||
lib.install();
|
||||
lib.setBuildMode(step.build_mode);
|
||||
lib.setTarget(step.target);
|
||||
lib.linkLibCpp();
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
options.appendFlags(&flags, true) catch unreachable;
|
||||
flags.appendSlice(&.{
|
||||
include("libs/dawn"),
|
||||
include("libs/dawn/third_party/vulkan-deps/spirv-tools/src"),
|
||||
include("libs/dawn/third_party/vulkan-deps/spirv-tools/src/include"),
|
||||
include("libs/dawn/third_party/vulkan-deps/spirv-headers/src/include"),
|
||||
include("libs/dawn/out/Debug/gen/third_party/vulkan-deps/spirv-tools/src"),
|
||||
include("libs/dawn/out/Debug/gen/third_party/vulkan-deps/spirv-tools/src/include"),
|
||||
}) catch unreachable;
|
||||
|
||||
// spvtools
|
||||
var sources = std.ArrayList([]const u8).init(b.allocator);
|
||||
sources.appendSlice(&.{
|
||||
thisDir() ++ "/src/dawn/sources/spirv_tools.cpp",
|
||||
thisDir() ++ "/libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/operand.cpp",
|
||||
thisDir() ++ "/libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/spirv_reducer_options.cpp",
|
||||
}) catch unreachable;
|
||||
|
||||
// spvtools_val
|
||||
sources.append(thisDir() ++ "/src/dawn/sources/spirv_tools_val.cpp") catch unreachable;
|
||||
|
||||
// spvtools_opt
|
||||
sources.appendSlice(&.{
|
||||
thisDir() ++ "/src/dawn/sources/spirv_tools_opt.cpp",
|
||||
thisDir() ++ "/src/dawn/sources/spirv_tools_opt_2.cpp",
|
||||
thisDir() ++ "/libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/opt/local_single_store_elim_pass.cpp",
|
||||
thisDir() ++ "/libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/opt/loop_unswitch_pass.cpp",
|
||||
thisDir() ++ "/libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/opt/mem_pass.cpp",
|
||||
thisDir() ++ "/libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/opt/ssa_rewrite_pass.cpp",
|
||||
thisDir() ++ "/libs/dawn/third_party/vulkan-deps/spirv-tools/src/source/opt/vector_dce.cpp",
|
||||
}) catch unreachable;
|
||||
|
||||
// spvtools_link
|
||||
for ([_][]const u8{
|
||||
"third_party/vulkan-deps/spirv-tools/src/source/link/linker.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
lib.addCSourceFiles(sources.items, flags.items);
|
||||
return lib;
|
||||
}
|
||||
|
||||
// Builds third_party/vulkan-deps/spirv-tools sources; derived from third_party/vulkan-deps/spirv-tools/src/BUILD.gn
|
||||
fn buildLibSPIRVCross(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
|
||||
var main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/dawn/dummy.zig" }) catch unreachable;
|
||||
const lib = b.addStaticLibrary("spirv-cross", main_abs);
|
||||
lib.install();
|
||||
lib.setBuildMode(step.build_mode);
|
||||
lib.setTarget(step.target);
|
||||
lib.linkLibCpp();
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
options.appendFlags(&flags, false) catch unreachable;
|
||||
flags.appendSlice(&.{
|
||||
"-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS",
|
||||
include("libs/dawn/third_party/vulkan-deps/spirv-cross/src"),
|
||||
include("libs/dawn"),
|
||||
"-Wno-extra-semi",
|
||||
"-Wno-ignored-qualifiers",
|
||||
"-Wno-implicit-fallthrough",
|
||||
"-Wno-inconsistent-missing-override",
|
||||
"-Wno-missing-field-initializers",
|
||||
"-Wno-newline-eof",
|
||||
"-Wno-sign-compare",
|
||||
"-Wno-unused-variable",
|
||||
}) catch unreachable;
|
||||
|
||||
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
||||
if (target.os.tag != .windows) flags.append("-fno-exceptions") catch unreachable;
|
||||
|
||||
// spvtools_link
|
||||
lib.addCSourceFile(thisDir() ++ "/src/dawn/sources/spirv_cross.cpp", flags.items);
|
||||
return lib;
|
||||
}
|
||||
|
||||
// Builds third_party/abseil sources; derived from:
|
||||
//
|
||||
// ```
|
||||
// $ find third_party/abseil-cpp/absl | grep '\.cc' | grep -v 'test' | grep -v 'benchmark' | grep -v gaussian_distribution_gentables | grep -v print_hash_of | grep -v chi_square
|
||||
// ```
|
||||
//
|
||||
fn buildLibAbseilCpp(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
|
||||
var main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/dawn/dummy.zig" }) catch unreachable;
|
||||
const lib = b.addStaticLibrary("abseil-cpp", main_abs);
|
||||
lib.install();
|
||||
lib.setBuildMode(step.build_mode);
|
||||
lib.setTarget(step.target);
|
||||
lib.linkLibCpp();
|
||||
system_sdk.include(b, lib, .{});
|
||||
|
||||
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
||||
if (target.os.tag == .macos) lib.linkFramework("CoreFoundation");
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
options.appendFlags(&flags, false) catch unreachable;
|
||||
flags.appendSlice(&.{
|
||||
include("libs/dawn"),
|
||||
include("libs/dawn/third_party/abseil-cpp"),
|
||||
}) catch unreachable;
|
||||
|
||||
// absl
|
||||
lib.addCSourceFiles(&.{
|
||||
thisDir() ++ "/src/dawn/sources/abseil.cc",
|
||||
thisDir() ++ "/libs/dawn/third_party/abseil-cpp/absl/strings/numbers.cc",
|
||||
thisDir() ++ "/libs/dawn/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc",
|
||||
thisDir() ++ "/libs/dawn/third_party/abseil-cpp/absl/time/format.cc",
|
||||
thisDir() ++ "/libs/dawn/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc",
|
||||
}, flags.items);
|
||||
return lib;
|
||||
}
|
||||
|
||||
// Buids dawn wire sources; derived from src/dawn_wire/BUILD.gn
|
||||
fn buildLibDawnWire(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
|
||||
var main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/dawn/dummy.zig" }) catch unreachable;
|
||||
const lib = b.addStaticLibrary("dawn-wire", main_abs);
|
||||
lib.install();
|
||||
lib.setBuildMode(step.build_mode);
|
||||
lib.setTarget(step.target);
|
||||
lib.linkLibCpp();
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
options.appendFlags(&flags, false) catch unreachable;
|
||||
flags.appendSlice(&.{
|
||||
include("libs/dawn"),
|
||||
include("libs/dawn/src"),
|
||||
include("libs/dawn/src/include"),
|
||||
include("libs/dawn/out/Debug/gen/src/include"),
|
||||
include("libs/dawn/out/Debug/gen/src"),
|
||||
}) catch unreachable;
|
||||
|
||||
lib.addCSourceFile(thisDir() ++ "/src/dawn/sources/dawn_wire_gen.cpp", flags.items);
|
||||
return lib;
|
||||
}
|
||||
|
||||
// Builds dawn utils sources; derived from src/utils/BUILD.gn
|
||||
fn buildLibDawnUtils(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
|
||||
var main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/dawn/dummy.zig" }) catch unreachable;
|
||||
const lib = b.addStaticLibrary("dawn-utils", main_abs);
|
||||
lib.install();
|
||||
lib.setBuildMode(step.build_mode);
|
||||
lib.setTarget(step.target);
|
||||
lib.linkLibCpp();
|
||||
|
||||
glfw.link(b, lib, .{ .system_sdk = .{ .set_sysroot = false } });
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
options.appendFlags(&flags, false) catch unreachable;
|
||||
appendDawnEnableBackendTypeFlags(&flags, options) catch unreachable;
|
||||
flags.appendSlice(&.{
|
||||
include("libs/mach-glfw/upstream/glfw/include"),
|
||||
include("libs/dawn/src"),
|
||||
include("libs/dawn/src/include"),
|
||||
include("libs/dawn/out/Debug/gen/src/include"),
|
||||
}) catch unreachable;
|
||||
|
||||
var sources = std.ArrayList([]const u8).init(b.allocator);
|
||||
for ([_][]const u8{
|
||||
"src/utils/BackendBinding.cpp",
|
||||
"src/utils/NullBinding.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
|
||||
if (options.d3d12.?) {
|
||||
for ([_][]const u8{
|
||||
"src/utils/D3D12Binding.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
}
|
||||
if (options.metal.?) {
|
||||
for ([_][]const u8{
|
||||
"src/utils/MetalBinding.mm",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.desktop_gl.?) {
|
||||
for ([_][]const u8{
|
||||
"src/utils/OpenGLBinding.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.vulkan.?) {
|
||||
for ([_][]const u8{
|
||||
"src/utils/VulkanBinding.cpp",
|
||||
}) |path| {
|
||||
var abs_path = std.fs.path.join(b.allocator, &.{ thisDir(), "libs/dawn", path }) catch unreachable;
|
||||
sources.append(abs_path) catch unreachable;
|
||||
}
|
||||
}
|
||||
lib.addCSourceFiles(sources.items, flags.items);
|
||||
return lib;
|
||||
}
|
||||
|
||||
fn include(comptime rel: []const u8) []const u8 {
|
||||
return "-I" ++ thisDir() ++ "/" ++ rel;
|
||||
}
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
1
gpu-dawn/libs/mach-glfw
Symbolic link
1
gpu-dawn/libs/mach-glfw
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../glfw
|
||||
5
gpu-dawn/src/dawn/c.zig
Normal file
5
gpu-dawn/src/dawn/c.zig
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
pub const c = @cImport({
|
||||
@cInclude("dawn/webgpu.h");
|
||||
@cInclude("dawn/dawn_proc.h");
|
||||
@cInclude("dawn_native_mach.h");
|
||||
});
|
||||
274
gpu-dawn/src/dawn/dawn_native_mach.cpp
Normal file
274
gpu-dawn/src/dawn/dawn_native_mach.cpp
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
#include <dawn_native/DawnNative.h>
|
||||
#include <dawn_native/wgpu_structs_autogen.h>
|
||||
#include "utils/BackendBinding.h"
|
||||
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||
#include <dawn_native/OpenGLBackend.h>
|
||||
#endif
|
||||
#include "dawn_native_mach.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// wgpu::AdapterProperties wrappers
|
||||
MACH_EXPORT void machDawnNativeAdapterProperties_deinit(MachDawnNativeAdapterProperties properties) {
|
||||
auto self = reinterpret_cast<wgpu::AdapterProperties*>(properties);
|
||||
delete self;
|
||||
}
|
||||
MACH_EXPORT uint32_t machDawnNativeAdapterProperties_getVendorID(MachDawnNativeAdapterProperties properties) {
|
||||
auto self = reinterpret_cast<wgpu::AdapterProperties*>(properties);
|
||||
return self->vendorID;
|
||||
}
|
||||
MACH_EXPORT uint32_t machDawnNativeAdapterProperties_getDeviceID(MachDawnNativeAdapterProperties properties) {
|
||||
auto self = reinterpret_cast<wgpu::AdapterProperties*>(properties);
|
||||
return self->deviceID;
|
||||
}
|
||||
MACH_EXPORT char const* machDawnNativeAdapterProperties_getName(MachDawnNativeAdapterProperties properties) {
|
||||
auto self = reinterpret_cast<wgpu::AdapterProperties*>(properties);
|
||||
return self->name;
|
||||
}
|
||||
MACH_EXPORT char const* machDawnNativeAdapterProperties_getDriverDescription(MachDawnNativeAdapterProperties properties) {
|
||||
auto self = reinterpret_cast<wgpu::AdapterProperties*>(properties);
|
||||
return self->driverDescription;
|
||||
}
|
||||
MACH_EXPORT WGPUAdapterType machDawnNativeAdapterProperties_getAdapterType(MachDawnNativeAdapterProperties properties) {
|
||||
auto self = reinterpret_cast<wgpu::AdapterProperties*>(properties);
|
||||
switch (self->adapterType) {
|
||||
case wgpu::AdapterType::DiscreteGPU: return WGPUAdapterType_DiscreteGPU;
|
||||
case wgpu::AdapterType::IntegratedGPU: return WGPUAdapterType_IntegratedGPU;
|
||||
case wgpu::AdapterType::CPU: return WGPUAdapterType_CPU;
|
||||
case wgpu::AdapterType::Unknown: return WGPUAdapterType_Unknown;
|
||||
}
|
||||
}
|
||||
MACH_EXPORT WGPUBackendType machDawnNativeAdapterProperties_getBackendType(MachDawnNativeAdapterProperties properties) {
|
||||
auto self = reinterpret_cast<wgpu::AdapterProperties*>(properties);
|
||||
switch (self->backendType) {
|
||||
case wgpu::BackendType::WebGPU: return WGPUBackendType_WebGPU;
|
||||
case wgpu::BackendType::D3D11: return WGPUBackendType_D3D11;
|
||||
case wgpu::BackendType::D3D12: return WGPUBackendType_D3D12;
|
||||
case wgpu::BackendType::Metal: return WGPUBackendType_Metal;
|
||||
case wgpu::BackendType::Null: return WGPUBackendType_Null;
|
||||
case wgpu::BackendType::OpenGL: return WGPUBackendType_OpenGL;
|
||||
case wgpu::BackendType::OpenGLES: return WGPUBackendType_OpenGLES;
|
||||
case wgpu::BackendType::Vulkan: return WGPUBackendType_Vulkan;
|
||||
}
|
||||
}
|
||||
|
||||
// dawn_native::Adapter wrappers
|
||||
MACH_EXPORT MachDawnNativeAdapterProperties machDawnNativeAdapter_getProperties(MachDawnNativeAdapter adapter) {
|
||||
auto self = reinterpret_cast<dawn_native::Adapter*>(adapter);
|
||||
auto cppProperties = new wgpu::AdapterProperties();
|
||||
self->GetProperties(cppProperties);
|
||||
return reinterpret_cast<MachDawnNativeAdapterProperties>(cppProperties);
|
||||
}
|
||||
// TODO(dawn-native-mach):
|
||||
// std::vector<const char*> GetSupportedExtensions() const;
|
||||
// WGPUDeviceProperties GetAdapterProperties() const;
|
||||
// bool GetLimits(WGPUSupportedLimits* limits) const;
|
||||
// void SetUseTieredLimits(bool useTieredLimits);
|
||||
// // Check that the Adapter is able to support importing external images. This is necessary
|
||||
// // to implement the swapchain and interop APIs in Chromium.
|
||||
// bool SupportsExternalImages() const;
|
||||
// explicit operator bool() const;
|
||||
|
||||
// TODO(dawn-native-mach): These API* methods correlate to the new API (which is unified between Dawn
|
||||
// and wgpu-native?), e.g. dawn_native::Instance::APIRequestAdapter corresponds to wgpuInstanceRequestAdapter
|
||||
// These are not implemented in Dawn yet according to austineng, but we should switch to this API once they do:
|
||||
//
|
||||
// "fyi, the requestAdapter/requestedDevice stuff isn't implemented right now. We just added the interface for it, but still working on the implementation. Today, it'll always fail the callback."
|
||||
//
|
||||
//
|
||||
// bool APIGetLimits(SupportedLimits* limits) const;
|
||||
// void APIGetProperties(AdapterProperties* properties) const;
|
||||
// bool APIHasFeature(wgpu::FeatureName feature) const;
|
||||
// uint32_t APIEnumerateFeatures(wgpu::FeatureName* features) const;
|
||||
// void APIRequestDevice(const DeviceDescriptor* descriptor,
|
||||
// WGPURequestDeviceCallback callback,
|
||||
// void* userdata);
|
||||
//
|
||||
MACH_EXPORT WGPUDevice machDawnNativeAdapter_createDevice(MachDawnNativeAdapter adapter, MachDawnNativeDawnDeviceDescriptor* deviceDescriptor) {
|
||||
auto self = reinterpret_cast<dawn_native::Adapter*>(adapter);
|
||||
|
||||
if (deviceDescriptor == nullptr) {
|
||||
return self->CreateDevice(nullptr);
|
||||
}
|
||||
|
||||
std::vector<const char*> cppRequiredExtensions;
|
||||
for (int i = 0; i < deviceDescriptor->requiredFeaturesLength; i++)
|
||||
cppRequiredExtensions.push_back(deviceDescriptor->requiredFeatures[i]);
|
||||
|
||||
std::vector<const char*> cppForceEnabledToggles;
|
||||
for (int i = 0; i < deviceDescriptor->forceEnabledTogglesLength; i++)
|
||||
cppForceEnabledToggles.push_back(deviceDescriptor->forceEnabledToggles[i]);
|
||||
|
||||
std::vector<const char*> cppForceDisabledToggles;
|
||||
for (int i = 0; i < deviceDescriptor->forceDisabledTogglesLength; i++)
|
||||
cppForceDisabledToggles.push_back(deviceDescriptor->forceDisabledToggles[i]);
|
||||
|
||||
auto cppDeviceDescriptor = dawn_native::DawnDeviceDescriptor{
|
||||
.requiredFeatures = cppRequiredExtensions,
|
||||
.forceEnabledToggles = cppForceEnabledToggles,
|
||||
.forceDisabledToggles = cppForceDisabledToggles,
|
||||
.requiredLimits = deviceDescriptor->requiredLimits,
|
||||
};
|
||||
return self->CreateDevice(&cppDeviceDescriptor);
|
||||
}
|
||||
|
||||
// TODO(dawn-native-mach):
|
||||
// // Create a device on this adapter, note that the interface will change to include at least
|
||||
// // a device descriptor and a pointer to backend specific options.
|
||||
// // On an error, nullptr is returned.
|
||||
// WGPUDevice CreateDevice(const DeviceDescriptor* deviceDescriptor = nullptr);
|
||||
|
||||
// TODO(dawn-native-mach):
|
||||
// void RequestDevice(const DeviceDescriptor* descriptor,
|
||||
// WGPURequestDeviceCallback callback,
|
||||
// void* userdata);
|
||||
|
||||
// TODO(dawn-native-mach):
|
||||
// // Reset the backend device object for testing purposes.
|
||||
// void ResetInternalDeviceForTesting();
|
||||
|
||||
// std::vector<Adapter> wrapper
|
||||
typedef struct MachDawnNativeAdaptersImpl* MachDawnNativeAdapters;
|
||||
MACH_EXPORT MachDawnNativeAdapter machDawnNativeAdapters_index(MachDawnNativeAdapters adapters, uintptr_t index) {
|
||||
auto self = reinterpret_cast<std::vector<dawn_native::Adapter>*>(adapters);
|
||||
return reinterpret_cast<MachDawnNativeAdapter>(&(*self)[index]);
|
||||
}
|
||||
MACH_EXPORT uintptr_t machDawnNativeAdapters_length(MachDawnNativeAdapters adapters) {
|
||||
auto self = reinterpret_cast<std::vector<dawn_native::Adapter>*>(adapters);
|
||||
return self->size();
|
||||
};
|
||||
|
||||
// dawn_native::Instance wrappers
|
||||
MACH_EXPORT MachDawnNativeInstance machDawnNativeInstance_init(void) {
|
||||
return reinterpret_cast<MachDawnNativeInstance>(new dawn_native::Instance());
|
||||
}
|
||||
MACH_EXPORT void machDawnNativeInstance_deinit(MachDawnNativeInstance instance) {
|
||||
delete reinterpret_cast<dawn_native::Instance*>(instance);
|
||||
}
|
||||
// TODO(dawn-native-mach): These API* methods correlate to the new API (which is unified between Dawn
|
||||
// and wgpu-native?), e.g. dawn_native::Instance::APIRequestAdapter corresponds to wgpuInstanceRequestAdapter
|
||||
// These are not implemented in Dawn yet according to austineng, but we should switch to this API once they do:
|
||||
//
|
||||
// "fyi, the requestAdapter/requestedDevice stuff isn't implemented right now. We just added the interface for it, but still working on the implementation. Today, it'll always fail the callback."
|
||||
//
|
||||
// void APIRequestAdapter(const RequestAdapterOptions* options,
|
||||
// WGPURequestAdapterCallback callback,
|
||||
// void* userdata);
|
||||
MACH_EXPORT void machDawnNativeInstance_discoverDefaultAdapters(MachDawnNativeInstance instance) {
|
||||
dawn_native::Instance* self = reinterpret_cast<dawn_native::Instance*>(instance);
|
||||
self->DiscoverDefaultAdapters();
|
||||
}
|
||||
MACH_EXPORT bool machDawnNativeInstance_discoverAdapters(MachDawnNativeInstance instance, WGPUBackendType backendType, const void* options) {
|
||||
dawn_native::Instance* self = reinterpret_cast<dawn_native::Instance*>(instance);
|
||||
switch (backendType) {
|
||||
case WGPUBackendType_OpenGL:
|
||||
#if defined(DAWN_ENABLE_BACKEND_DESKTOP_GL)
|
||||
{
|
||||
auto opt = reinterpret_cast<const MachDawnNativeAdapterDiscoveryOptions_OpenGL*>(options);
|
||||
dawn_native::opengl::AdapterDiscoveryOptions adapterOptions = dawn_native::opengl::AdapterDiscoveryOptions();
|
||||
adapterOptions.getProc = opt->getProc;
|
||||
return self->DiscoverAdapters(&adapterOptions);
|
||||
}
|
||||
#endif
|
||||
case WGPUBackendType_OpenGLES:
|
||||
#if defined(DAWN_ENABLE_BACKEND_OPENGLES)
|
||||
{
|
||||
auto opt = reinterpret_cast<const MachDawnNativeAdapterDiscoveryOptions_OpenGLES*>(options);
|
||||
dawn_native::opengl::AdapterDiscoveryOptionsES adapterOptions;
|
||||
adapterOptions.getProc = opt->getProc;
|
||||
return self->DiscoverAdapters(&adapterOptions);
|
||||
}
|
||||
#endif
|
||||
case WGPUBackendType_WebGPU:
|
||||
case WGPUBackendType_D3D11:
|
||||
case WGPUBackendType_D3D12:
|
||||
case WGPUBackendType_Metal:
|
||||
case WGPUBackendType_Null:
|
||||
case WGPUBackendType_Vulkan:
|
||||
case WGPUBackendType_Force32:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
MACH_EXPORT MachDawnNativeAdapters machDawnNativeInstance_getAdapters(MachDawnNativeInstance instance) {
|
||||
dawn_native::Instance* self = reinterpret_cast<dawn_native::Instance*>(instance);
|
||||
auto cppAdapters = self->GetAdapters();
|
||||
auto heapAllocated = new std::vector<dawn_native::Adapter>();
|
||||
for (int i=0; i<cppAdapters.size(); i++) heapAllocated->push_back(cppAdapters[i]);
|
||||
return reinterpret_cast<MachDawnNativeAdapters>(heapAllocated);
|
||||
}
|
||||
|
||||
MACH_EXPORT const DawnProcTable* machDawnNativeGetProcs() {
|
||||
return &dawn_native::GetProcs();
|
||||
}
|
||||
|
||||
// TODO(dawn-native-mach):
|
||||
// const ToggleInfo* GetToggleInfo(const char* toggleName);
|
||||
|
||||
// TODO(dawn-native-mach):
|
||||
// // Enables backend validation layers
|
||||
// void EnableBackendValidation(bool enableBackendValidation);
|
||||
// void SetBackendValidationLevel(BackendValidationLevel validationLevel);
|
||||
|
||||
// TODO(dawn-native-mach):
|
||||
// // Enable debug capture on Dawn startup
|
||||
// void EnableBeginCaptureOnStartup(bool beginCaptureOnStartup);
|
||||
|
||||
// TODO(dawn-native-mach):
|
||||
// void SetPlatform(dawn_platform::Platform* platform);
|
||||
|
||||
// TODO(dawn-native-mach):
|
||||
// // Returns the underlying WGPUInstance object.
|
||||
// WGPUInstance Get() const;
|
||||
|
||||
|
||||
// typedef struct MachUtilsBackendBindingImpl* MachUtilsBackendBinding;
|
||||
MACH_EXPORT MachUtilsBackendBinding machUtilsCreateBinding(WGPUBackendType backendType, GLFWwindow* window, WGPUDevice device) {
|
||||
wgpu::BackendType cppBackendType;
|
||||
switch (backendType) {
|
||||
case WGPUBackendType_WebGPU:
|
||||
cppBackendType = wgpu::BackendType::WebGPU;
|
||||
break;
|
||||
case WGPUBackendType_D3D11:
|
||||
cppBackendType = wgpu::BackendType::D3D11;
|
||||
break;
|
||||
case WGPUBackendType_D3D12:
|
||||
cppBackendType = wgpu::BackendType::D3D12;
|
||||
break;
|
||||
case WGPUBackendType_Metal:
|
||||
cppBackendType = wgpu::BackendType::Metal;
|
||||
break;
|
||||
case WGPUBackendType_Null:
|
||||
cppBackendType = wgpu::BackendType::Null;
|
||||
break;
|
||||
case WGPUBackendType_OpenGL:
|
||||
cppBackendType = wgpu::BackendType::OpenGL;
|
||||
break;
|
||||
case WGPUBackendType_OpenGLES:
|
||||
cppBackendType = wgpu::BackendType::OpenGLES;
|
||||
break;
|
||||
case WGPUBackendType_Vulkan:
|
||||
cppBackendType = wgpu::BackendType::Vulkan;
|
||||
break;
|
||||
case WGPUBackendType_Force32:
|
||||
// Force32 is just to force the size of the C enum type to 32-bits, so this is technically
|
||||
// an illegal input.
|
||||
cppBackendType = wgpu::BackendType::Null;
|
||||
break;
|
||||
}
|
||||
return reinterpret_cast<MachUtilsBackendBinding>(utils::CreateBinding(cppBackendType, window, device));
|
||||
}
|
||||
|
||||
MACH_EXPORT uint64_t machUtilsBackendBinding_getSwapChainImplementation(MachUtilsBackendBinding binding) {
|
||||
auto self = reinterpret_cast<utils::BackendBinding*>(binding);
|
||||
return self->GetSwapChainImplementation();
|
||||
}
|
||||
MACH_EXPORT WGPUTextureFormat machUtilsBackendBinding_getPreferredSwapChainTextureFormat(MachUtilsBackendBinding binding) {
|
||||
auto self = reinterpret_cast<utils::BackendBinding*>(binding);
|
||||
return self->GetPreferredSwapChainTextureFormat();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
116
gpu-dawn/src/dawn/dawn_native_mach.h
Normal file
116
gpu-dawn/src/dawn/dawn_native_mach.h
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
#ifndef MACH_DAWNNATIVE_C_H_
|
||||
#define MACH_DAWNNATIVE_C_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(MACH_DAWNNATIVE_C_SHARED_LIBRARY)
|
||||
# if defined(_WIN32)
|
||||
# if defined(MACH_DAWNNATIVE_C_IMPLEMENTATION)
|
||||
# define MACH_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define MACH_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
# else // defined(_WIN32)
|
||||
# if defined(MACH_DAWNNATIVE_C_IMPLEMENTATION)
|
||||
# define MACH_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
# define MACH_EXPORT
|
||||
# endif
|
||||
# endif // defined(_WIN32)
|
||||
#else // defined(MACH_DAWNNATIVE_C_SHARED_LIBRARY)
|
||||
# define MACH_EXPORT
|
||||
#endif // defined(MACH_DAWNNATIVE_C_SHARED_LIBRARY)
|
||||
|
||||
#include <dawn/webgpu.h>
|
||||
#include <dawn/dawn_proc_table.h>
|
||||
|
||||
// TODO(slimsag): future: Dawn authors want dawn_native::AdapterProperties to eventually be in webgpu.h,
|
||||
// and there is a corresponding WGPUAdapterProperties struct today, but there aren't corresponding methods
|
||||
// to actually use / work with it today.
|
||||
typedef struct MachDawnNativeAdapterPropertiesImpl* MachDawnNativeAdapterProperties;
|
||||
|
||||
MACH_EXPORT void machDawnNativeAdapterProperties_deinit(MachDawnNativeAdapterProperties properties);
|
||||
MACH_EXPORT uint32_t machDawnNativeAdapterProperties_getVendorID(MachDawnNativeAdapterProperties properties);
|
||||
MACH_EXPORT uint32_t machDawnNativeAdapterProperties_getDeviceID(MachDawnNativeAdapterProperties properties);
|
||||
MACH_EXPORT char const* machDawnNativeAdapterProperties_getName(MachDawnNativeAdapterProperties properties);
|
||||
MACH_EXPORT char const* machDawnNativeAdapterProperties_getDriverDescription(MachDawnNativeAdapterProperties properties);
|
||||
MACH_EXPORT WGPUAdapterType machDawnNativeAdapterProperties_getAdapterType(MachDawnNativeAdapterProperties properties);
|
||||
MACH_EXPORT WGPUBackendType machDawnNativeAdapterProperties_getBackendType(MachDawnNativeAdapterProperties properties);
|
||||
|
||||
// An adapter is an object that represent on possibility of creating devices in the system.
|
||||
// Most of the time it will represent a combination of a physical GPU and an API. Not that the
|
||||
// same GPU can be represented by multiple adapters but on different APIs.
|
||||
//
|
||||
// The underlying Dawn adapter is owned by the Dawn instance so this is just a reference to an
|
||||
// underlying adapter.
|
||||
typedef struct MachDawnNativeAdapterImpl* MachDawnNativeAdapter;
|
||||
|
||||
MACH_EXPORT MachDawnNativeAdapterProperties machDawnNativeAdapter_getProperties(MachDawnNativeAdapter adapter);
|
||||
|
||||
// An optional parameter of Adapter::CreateDevice() to send additional information when creating
|
||||
// a Device. For example, we can use it to enable a workaround, optimization or feature.
|
||||
typedef struct MachDawnNativeDawnDeviceDescriptor {
|
||||
char** requiredFeatures;
|
||||
uintptr_t requiredFeaturesLength;
|
||||
|
||||
char** forceEnabledToggles;
|
||||
uintptr_t forceEnabledTogglesLength;
|
||||
|
||||
char** forceDisabledToggles;
|
||||
uintptr_t forceDisabledTogglesLength;
|
||||
|
||||
// default null
|
||||
WGPURequiredLimits* requiredLimits;
|
||||
} MachDawnNativeDawnDeviceDescriptor;
|
||||
MACH_EXPORT WGPUDevice machDawnNativeAdapter_createDevice(MachDawnNativeAdapter adapter, MachDawnNativeDawnDeviceDescriptor* deviceDescriptor);
|
||||
|
||||
typedef struct MachDawnNativeAdaptersImpl* MachDawnNativeAdapters;
|
||||
MACH_EXPORT MachDawnNativeAdapter machDawnNativeAdapters_index(MachDawnNativeAdapters adapters, uintptr_t index);
|
||||
MACH_EXPORT uintptr_t machDawnNativeAdapters_length(MachDawnNativeAdapters adapters);
|
||||
|
||||
// Represents a connection to dawn_native and is used for dependency injection, discovering
|
||||
// system adapters and injecting custom adapters (like a Swiftshader Vulkan adapter).
|
||||
//
|
||||
// This can be initialized via machDawnNativeInstanceInit and destroyed via
|
||||
// machDawnNativeInstanceDeinit. The instance controls the lifetime of all adapters for the
|
||||
// instance.
|
||||
typedef struct MachDawnNativeInstanceImpl* MachDawnNativeInstance;
|
||||
|
||||
MACH_EXPORT MachDawnNativeInstance machDawnNativeInstance_init(void);
|
||||
MACH_EXPORT void machDawnNativeInstance_deinit(MachDawnNativeInstance);
|
||||
MACH_EXPORT void machDawnNativeInstance_discoverDefaultAdapters(MachDawnNativeInstance);
|
||||
|
||||
// Adds adapters that can be discovered with the options provided (like a getProcAddress).
|
||||
// You must specify a valid backend type corresponding to the type of MachDawnNativeAdapterDiscoveryOptions_
|
||||
// struct pointer you pass as options.
|
||||
// Returns true on success.
|
||||
MACH_EXPORT bool machDawnNativeInstance_discoverAdapters(MachDawnNativeInstance instance, WGPUBackendType backendType, const void* options);
|
||||
|
||||
MACH_EXPORT MachDawnNativeAdapters machDawnNativeInstance_getAdapters(MachDawnNativeInstance instance);
|
||||
|
||||
// Backend-agnostic API for dawn_native
|
||||
MACH_EXPORT const DawnProcTable* machDawnNativeGetProcs();
|
||||
|
||||
// Backend-specific options which can be passed to discoverAdapters
|
||||
typedef struct MachDawnNativeAdapterDiscoveryOptions_OpenGL {
|
||||
void* (*getProc)(const char*);
|
||||
} MachDawnNativeAdapterDiscoveryOptions_OpenGL;
|
||||
typedef struct MachDawnNativeAdapterDiscoveryOptions_OpenGLES {
|
||||
void* (*getProc)(const char*);
|
||||
} MachDawnNativeAdapterDiscoveryOptions_OpenGLES;
|
||||
|
||||
// utils
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
typedef struct MachUtilsBackendBindingImpl* MachUtilsBackendBinding;
|
||||
MACH_EXPORT MachUtilsBackendBinding machUtilsCreateBinding(WGPUBackendType backendType, GLFWwindow* window, WGPUDevice device);
|
||||
MACH_EXPORT uint64_t machUtilsBackendBinding_getSwapChainImplementation(MachUtilsBackendBinding binding);
|
||||
MACH_EXPORT WGPUTextureFormat machUtilsBackendBinding_getPreferredSwapChainTextureFormat(MachUtilsBackendBinding binding);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // MACH_DAWNNATIVE_C_H_
|
||||
0
gpu-dawn/src/dawn/dummy.zig
Normal file
0
gpu-dawn/src/dawn/dummy.zig
Normal file
178
gpu-dawn/src/dawn/hello_triangle.zig
Normal file
178
gpu-dawn/src/dawn/hello_triangle.zig
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
const std = @import("std");
|
||||
const sample_utils = @import("sample_utils.zig");
|
||||
const c = @import("c.zig").c;
|
||||
const glfw = @import("glfw");
|
||||
|
||||
// #include "utils/SystemUtils.h"
|
||||
// #include "utils/WGPUHelpers.h"
|
||||
|
||||
// WGPUSwapChain swapchain;
|
||||
// WGPURenderPipeline pipeline;
|
||||
|
||||
// WGPUTextureFormat swapChainFormat;
|
||||
|
||||
pub fn main() !void {
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
var allocator = gpa.allocator();
|
||||
|
||||
const setup = try sample_utils.setup();
|
||||
const queue = c.wgpuDeviceGetQueue(setup.device);
|
||||
|
||||
var descriptor = std.mem.zeroes(c.WGPUSwapChainDescriptor);
|
||||
descriptor.implementation = c.machUtilsBackendBinding_getSwapChainImplementation(setup.binding);
|
||||
const swap_chain = c.wgpuDeviceCreateSwapChain(setup.device, null, &descriptor);
|
||||
|
||||
const swap_chain_format = c.machUtilsBackendBinding_getPreferredSwapChainTextureFormat(setup.binding);
|
||||
c.wgpuSwapChainConfigure(swap_chain, swap_chain_format, c.WGPUTextureUsage_RenderAttachment, 640, 480);
|
||||
|
||||
const vs =
|
||||
\\ [[stage(vertex)]] fn main(
|
||||
\\ [[builtin(vertex_index)]] VertexIndex : u32
|
||||
\\ ) -> [[builtin(position)]] vec4<f32> {
|
||||
\\ var pos = array<vec2<f32>, 3>(
|
||||
\\ vec2<f32>( 0.0, 0.5),
|
||||
\\ vec2<f32>(-0.5, -0.5),
|
||||
\\ vec2<f32>( 0.5, -0.5)
|
||||
\\ );
|
||||
\\ return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||
\\ }
|
||||
;
|
||||
var vs_wgsl_descriptor = try allocator.create(c.WGPUShaderModuleWGSLDescriptor);
|
||||
vs_wgsl_descriptor.chain.next = null;
|
||||
vs_wgsl_descriptor.chain.sType = c.WGPUSType_ShaderModuleWGSLDescriptor;
|
||||
vs_wgsl_descriptor.source = vs;
|
||||
const vs_shader_descriptor = c.WGPUShaderModuleDescriptor{
|
||||
.nextInChain = @ptrCast(*const c.WGPUChainedStruct, vs_wgsl_descriptor),
|
||||
.label = "my vertex shader",
|
||||
};
|
||||
const vs_module = c.wgpuDeviceCreateShaderModule(setup.device, &vs_shader_descriptor);
|
||||
|
||||
const fs =
|
||||
\\ [[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
\\ return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
\\ }
|
||||
;
|
||||
var fs_wgsl_descriptor = try allocator.create(c.WGPUShaderModuleWGSLDescriptor);
|
||||
fs_wgsl_descriptor.chain.next = null;
|
||||
fs_wgsl_descriptor.chain.sType = c.WGPUSType_ShaderModuleWGSLDescriptor;
|
||||
fs_wgsl_descriptor.source = fs;
|
||||
const fs_shader_descriptor = c.WGPUShaderModuleDescriptor{
|
||||
.nextInChain = @ptrCast(*const c.WGPUChainedStruct, fs_wgsl_descriptor),
|
||||
.label = "my fragment shader",
|
||||
};
|
||||
const fs_module = c.wgpuDeviceCreateShaderModule(setup.device, &fs_shader_descriptor);
|
||||
|
||||
// Fragment state
|
||||
var blend = std.mem.zeroes(c.WGPUBlendState);
|
||||
blend.color.operation = c.WGPUBlendOperation_Add;
|
||||
blend.color.srcFactor = c.WGPUBlendFactor_One;
|
||||
blend.color.dstFactor = c.WGPUBlendFactor_One;
|
||||
blend.alpha.operation = c.WGPUBlendOperation_Add;
|
||||
blend.alpha.srcFactor = c.WGPUBlendFactor_One;
|
||||
blend.alpha.dstFactor = c.WGPUBlendFactor_One;
|
||||
|
||||
var color_target = std.mem.zeroes(c.WGPUColorTargetState);
|
||||
color_target.format = swap_chain_format;
|
||||
color_target.blend = &blend;
|
||||
color_target.writeMask = c.WGPUColorWriteMask_All;
|
||||
|
||||
var fragment = std.mem.zeroes(c.WGPUFragmentState);
|
||||
fragment.module = fs_module;
|
||||
fragment.entryPoint = "main";
|
||||
fragment.targetCount = 1;
|
||||
fragment.targets = &color_target;
|
||||
|
||||
var pipeline_descriptor = std.mem.zeroes(c.WGPURenderPipelineDescriptor);
|
||||
pipeline_descriptor.fragment = &fragment;
|
||||
|
||||
// Other state
|
||||
pipeline_descriptor.layout = null;
|
||||
pipeline_descriptor.depthStencil = null;
|
||||
|
||||
pipeline_descriptor.vertex.module = vs_module;
|
||||
pipeline_descriptor.vertex.entryPoint = "main";
|
||||
pipeline_descriptor.vertex.bufferCount = 0;
|
||||
pipeline_descriptor.vertex.buffers = null;
|
||||
|
||||
pipeline_descriptor.multisample.count = 1;
|
||||
pipeline_descriptor.multisample.mask = 0xFFFFFFFF;
|
||||
pipeline_descriptor.multisample.alphaToCoverageEnabled = false;
|
||||
|
||||
pipeline_descriptor.primitive.frontFace = c.WGPUFrontFace_CCW;
|
||||
pipeline_descriptor.primitive.cullMode = c.WGPUCullMode_None;
|
||||
pipeline_descriptor.primitive.topology = c.WGPUPrimitiveTopology_TriangleList;
|
||||
pipeline_descriptor.primitive.stripIndexFormat = c.WGPUIndexFormat_Undefined;
|
||||
|
||||
const pipeline = c.wgpuDeviceCreateRenderPipeline(setup.device, &pipeline_descriptor);
|
||||
|
||||
c.wgpuShaderModuleRelease(vs_module);
|
||||
c.wgpuShaderModuleRelease(fs_module);
|
||||
|
||||
// Reconfigure the swap chain with the new framebuffer width/height, otherwise e.g. the Vulkan
|
||||
// device would be lost after a resize.
|
||||
const CallbackPayload = struct {
|
||||
swap_chain: c.WGPUSwapChain,
|
||||
swap_chain_format: c.WGPUTextureFormat,
|
||||
};
|
||||
setup.window.setUserPointer(CallbackPayload, &.{ .swap_chain = swap_chain, .swap_chain_format = swap_chain_format });
|
||||
setup.window.setFramebufferSizeCallback((struct {
|
||||
fn callback(window: glfw.Window, width: u32, height: u32) void {
|
||||
const pl = window.getUserPointer(*CallbackPayload);
|
||||
c.wgpuSwapChainConfigure(pl.?.swap_chain, pl.?.swap_chain_format, c.WGPUTextureUsage_RenderAttachment, @intCast(u32, width), @intCast(u32, height));
|
||||
}
|
||||
}).callback);
|
||||
|
||||
while (!setup.window.shouldClose()) {
|
||||
try frame(.{
|
||||
.device = setup.device,
|
||||
.swap_chain = swap_chain,
|
||||
.pipeline = pipeline,
|
||||
.queue = queue,
|
||||
});
|
||||
std.time.sleep(16 * std.time.ns_per_ms);
|
||||
}
|
||||
}
|
||||
|
||||
const FrameParams = struct {
|
||||
device: c.WGPUDevice,
|
||||
swap_chain: c.WGPUSwapChain,
|
||||
pipeline: c.WGPURenderPipeline,
|
||||
queue: c.WGPUQueue,
|
||||
};
|
||||
|
||||
fn frame(params: FrameParams) !void {
|
||||
const back_buffer_view = c.wgpuSwapChainGetCurrentTextureView(params.swap_chain);
|
||||
var render_pass_info = std.mem.zeroes(c.WGPURenderPassDescriptor);
|
||||
var color_attachment = std.mem.zeroes(c.WGPURenderPassColorAttachment);
|
||||
color_attachment.view = back_buffer_view;
|
||||
color_attachment.resolveTarget = null;
|
||||
color_attachment.clearColor = c.WGPUColor{ .r = 0.0, .g = 0.0, .b = 0.0, .a = 0.0 };
|
||||
color_attachment.loadOp = c.WGPULoadOp_Clear;
|
||||
color_attachment.storeOp = c.WGPUStoreOp_Store;
|
||||
render_pass_info.colorAttachmentCount = 1;
|
||||
render_pass_info.colorAttachments = &color_attachment;
|
||||
render_pass_info.depthStencilAttachment = null;
|
||||
|
||||
const encoder = c.wgpuDeviceCreateCommandEncoder(params.device, null);
|
||||
const pass = c.wgpuCommandEncoderBeginRenderPass(encoder, &render_pass_info);
|
||||
c.wgpuRenderPassEncoderSetPipeline(pass, params.pipeline);
|
||||
c.wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0);
|
||||
c.wgpuRenderPassEncoderEndPass(pass);
|
||||
c.wgpuRenderPassEncoderRelease(pass);
|
||||
|
||||
const commands = c.wgpuCommandEncoderFinish(encoder, null);
|
||||
c.wgpuCommandEncoderRelease(encoder);
|
||||
|
||||
c.wgpuQueueSubmit(params.queue, 1, &commands);
|
||||
c.wgpuCommandBufferRelease(commands);
|
||||
c.wgpuSwapChainPresent(params.swap_chain);
|
||||
c.wgpuTextureViewRelease(back_buffer_view);
|
||||
|
||||
// if (cmdBufType == CmdBufType::Terrible) {
|
||||
// bool c2sSuccess = c2sBuf->Flush();
|
||||
// bool s2cSuccess = s2cBuf->Flush();
|
||||
|
||||
// ASSERT(c2sSuccess && s2cSuccess);
|
||||
// }
|
||||
try glfw.pollEvents();
|
||||
}
|
||||
282
gpu-dawn/src/dawn/sample_utils.zig
Normal file
282
gpu-dawn/src/dawn/sample_utils.zig
Normal file
|
|
@ -0,0 +1,282 @@
|
|||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const glfw = @import("glfw");
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
// #include "SampleUtils.h"
|
||||
|
||||
// #include "common/Assert.h"
|
||||
// #include "common/Log.h"
|
||||
// #include "common/Platform.h"
|
||||
// #include "common/SystemUtils.h"
|
||||
// #include "utils/BackendBinding.h"
|
||||
// #include "utils/GLFWUtils.h"
|
||||
// #include "utils/TerribleCommandBuffer.h"
|
||||
|
||||
// #include <dawn/dawn_proc.h>
|
||||
// #include <dawn/dawn_wsi.h>
|
||||
// #include <dawn_native/DawnNative.h>
|
||||
// #include <dawn_wire/WireClient.h>
|
||||
// #include <dawn_wire/WireServer.h>
|
||||
// #include "GLFW/glfw3.h"
|
||||
|
||||
// #include <algorithm>
|
||||
// #include <cstring>
|
||||
|
||||
fn printDeviceError(error_type: c.WGPUErrorType, message: [*c]const u8, _: ?*anyopaque) callconv(.C) void {
|
||||
switch (error_type) {
|
||||
c.WGPUErrorType_Validation => std.debug.print("dawn: validation error: {s}\n", .{message}),
|
||||
c.WGPUErrorType_OutOfMemory => std.debug.print("dawn: out of memory: {s}\n", .{message}),
|
||||
c.WGPUErrorType_Unknown => std.debug.print("dawn: unknown error: {s}\n", .{message}),
|
||||
c.WGPUErrorType_DeviceLost => std.debug.print("dawn: device lost: {s}\n", .{message}),
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
||||
const CmdBufType = enum { none, terrible };
|
||||
|
||||
// static std::unique_ptr<dawn_native::Instance> instance;
|
||||
// static utils::BackendBinding* binding = nullptr;
|
||||
|
||||
// static GLFWwindow* window = nullptr;
|
||||
|
||||
// static dawn_wire::WireServer* wireServer = nullptr;
|
||||
// static dawn_wire::WireClient* wireClient = nullptr;
|
||||
// static utils::TerribleCommandBuffer* c2sBuf = nullptr;
|
||||
// static utils::TerribleCommandBuffer* s2cBuf = nullptr;
|
||||
|
||||
const Setup = struct {
|
||||
device: c.WGPUDevice,
|
||||
binding: c.MachUtilsBackendBinding,
|
||||
window: glfw.Window,
|
||||
};
|
||||
|
||||
fn detectBackendType() c.WGPUBackendType {
|
||||
if (std.os.getenv("WGPU_BACKEND")) |backend| {
|
||||
if (std.ascii.eqlIgnoreCase(backend, "opengl")) return c.WGPUBackendType_OpenGL;
|
||||
if (std.ascii.eqlIgnoreCase(backend, "opengles")) return c.WGPUBackendType_OpenGLES;
|
||||
if (std.ascii.eqlIgnoreCase(backend, "d3d11")) return c.WGPUBackendType_D3D11;
|
||||
if (std.ascii.eqlIgnoreCase(backend, "d3d12")) return c.WGPUBackendType_D3D12;
|
||||
if (std.ascii.eqlIgnoreCase(backend, "metal")) return c.WGPUBackendType_Metal;
|
||||
if (std.ascii.eqlIgnoreCase(backend, "null")) return c.WGPUBackendType_Null;
|
||||
if (std.ascii.eqlIgnoreCase(backend, "vulkan")) return c.WGPUBackendType_Vulkan;
|
||||
@panic("unknown BACKEND type");
|
||||
}
|
||||
|
||||
const target = @import("builtin").target;
|
||||
if (target.isDarwin()) return c.WGPUBackendType_Metal;
|
||||
if (target.os.tag == .windows) return c.WGPUBackendType_D3D12;
|
||||
return c.WGPUBackendType_Vulkan;
|
||||
}
|
||||
|
||||
fn backendTypeString(t: c.WGPUBackendType) []const u8 {
|
||||
return switch (t) {
|
||||
c.WGPUBackendType_OpenGL => "OpenGL",
|
||||
c.WGPUBackendType_OpenGLES => "OpenGLES",
|
||||
c.WGPUBackendType_D3D11 => "D3D11",
|
||||
c.WGPUBackendType_D3D12 => "D3D12",
|
||||
c.WGPUBackendType_Metal => "Metal",
|
||||
c.WGPUBackendType_Null => "Null",
|
||||
c.WGPUBackendType_Vulkan => "Vulkan",
|
||||
else => unreachable,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn setup() !Setup {
|
||||
const backend_type = detectBackendType();
|
||||
const cmd_buf_type = CmdBufType.none;
|
||||
|
||||
try glfw.init(.{});
|
||||
|
||||
// Create the test window and discover adapters using it (esp. for OpenGL)
|
||||
var hints = glfwWindowHintsForBackend(backend_type);
|
||||
hints.cocoa_retina_framebuffer = false;
|
||||
const window = try glfw.Window.create(640, 480, "Dawn window", null, null, hints);
|
||||
|
||||
const instance = c.machDawnNativeInstance_init();
|
||||
try discoverAdapter(instance, window, backend_type);
|
||||
|
||||
const adapters = c.machDawnNativeInstance_getAdapters(instance);
|
||||
var backend_adapter: ?c.MachDawnNativeAdapter = null;
|
||||
var i: usize = 0;
|
||||
while (i < c.machDawnNativeAdapters_length(adapters)) : (i += 1) {
|
||||
const adapter = c.machDawnNativeAdapters_index(adapters, i);
|
||||
const properties = c.machDawnNativeAdapter_getProperties(adapter);
|
||||
if (c.machDawnNativeAdapterProperties_getBackendType(properties) == backend_type) {
|
||||
const name = c.machDawnNativeAdapterProperties_getName(properties);
|
||||
const driver_description = c.machDawnNativeAdapterProperties_getDriverDescription(properties);
|
||||
std.debug.print("found {s} adapter: {s}, {s}\n", .{ backendTypeString(backend_type), name, driver_description });
|
||||
backend_adapter = adapter;
|
||||
}
|
||||
}
|
||||
assert(backend_adapter != null);
|
||||
|
||||
const backend_device = c.machDawnNativeAdapter_createDevice(backend_adapter.?, null);
|
||||
const backend_procs = c.machDawnNativeGetProcs();
|
||||
|
||||
const binding = c.machUtilsCreateBinding(backend_type, @ptrCast(*c.GLFWwindow, window.handle), backend_device);
|
||||
if (binding == null) {
|
||||
@panic("failed to create binding");
|
||||
}
|
||||
|
||||
// Choose whether to use the backend procs and devices directly, or set up the wire.
|
||||
var procs: ?*const c.DawnProcTable = null;
|
||||
var c_device: ?c.WGPUDevice = null;
|
||||
switch (cmd_buf_type) {
|
||||
CmdBufType.none => {
|
||||
procs = backend_procs;
|
||||
c_device = backend_device;
|
||||
},
|
||||
CmdBufType.terrible => {
|
||||
// TODO(slimsag):
|
||||
@panic("not implemented");
|
||||
// c2sBuf = new utils::TerribleCommandBuffer();
|
||||
// s2cBuf = new utils::TerribleCommandBuffer();
|
||||
|
||||
// dawn_wire::WireServerDescriptor serverDesc = {};
|
||||
// serverDesc.procs = &backendProcs;
|
||||
// serverDesc.serializer = s2cBuf;
|
||||
|
||||
// wireServer = new dawn_wire::WireServer(serverDesc);
|
||||
// c2sBuf->SetHandler(wireServer);
|
||||
|
||||
// dawn_wire::WireClientDescriptor clientDesc = {};
|
||||
// clientDesc.serializer = c2sBuf;
|
||||
|
||||
// wireClient = new dawn_wire::WireClient(clientDesc);
|
||||
// procs = dawn_wire::client::GetProcs();
|
||||
// s2cBuf->SetHandler(wireClient);
|
||||
|
||||
// auto deviceReservation = wireClient->ReserveDevice();
|
||||
// wireServer->InjectDevice(backendDevice, deviceReservation.id,
|
||||
// deviceReservation.generation);
|
||||
|
||||
// cDevice = deviceReservation.device;
|
||||
},
|
||||
}
|
||||
|
||||
c.dawnProcSetProcs(procs.?);
|
||||
procs.?.deviceSetUncapturedErrorCallback.?(c_device.?, printDeviceError, null);
|
||||
return Setup{
|
||||
.device = c_device.?,
|
||||
.binding = binding,
|
||||
.window = window,
|
||||
};
|
||||
}
|
||||
|
||||
fn glfwWindowHintsForBackend(backend: c.WGPUBackendType) glfw.Window.Hints {
|
||||
return switch (backend) {
|
||||
c.WGPUBackendType_OpenGL => .{
|
||||
// Ask for OpenGL 4.4 which is what the GL backend requires for compute shaders and
|
||||
// texture views.
|
||||
.context_version_major = 4,
|
||||
.context_version_minor = 4,
|
||||
.opengl_forward_compat = true,
|
||||
.opengl_profile = .opengl_core_profile,
|
||||
},
|
||||
c.WGPUBackendType_OpenGLES => .{
|
||||
.context_version_major = 3,
|
||||
.context_version_minor = 1,
|
||||
.client_api = .opengl_es_api,
|
||||
.context_creation_api = .egl_context_api,
|
||||
},
|
||||
else => .{
|
||||
// Without this GLFW will initialize a GL context on the window, which prevents using
|
||||
// the window with other APIs (by crashing in weird ways).
|
||||
.client_api = .no_api,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
fn discoverAdapter(instance: c.MachDawnNativeInstance, window: glfw.Window, typ: c.WGPUBackendType) !void {
|
||||
if (typ == c.WGPUBackendType_OpenGL) {
|
||||
try glfw.makeContextCurrent(window);
|
||||
const adapter_options = c.MachDawnNativeAdapterDiscoveryOptions_OpenGL{
|
||||
.getProc = @ptrCast(fn ([*c]const u8) callconv(.C) ?*anyopaque, glfw.getProcAddress),
|
||||
};
|
||||
_ = c.machDawnNativeInstance_discoverAdapters(instance, typ, &adapter_options);
|
||||
} else if (typ == c.WGPUBackendType_OpenGLES) {
|
||||
try glfw.makeContextCurrent(window);
|
||||
const adapter_options = c.MachDawnNativeAdapterDiscoveryOptions_OpenGLES{
|
||||
.getProc = @ptrCast(fn ([*c]const u8) callconv(.C) ?*anyopaque, glfw.getProcAddress),
|
||||
};
|
||||
_ = c.machDawnNativeInstance_discoverAdapters(instance, typ, &adapter_options);
|
||||
} else {
|
||||
c.machDawnNativeInstance_discoverDefaultAdapters(instance);
|
||||
}
|
||||
}
|
||||
|
||||
// wgpu::TextureFormat GetPreferredSwapChainTextureFormat() {
|
||||
// DoFlush();
|
||||
// return static_cast<wgpu::TextureFormat>(binding->GetPreferredSwapChainTextureFormat());
|
||||
// }
|
||||
|
||||
// wgpu::TextureView CreateDefaultDepthStencilView(const wgpu::Device& device) {
|
||||
// wgpu::TextureDescriptor descriptor;
|
||||
// descriptor.dimension = wgpu::TextureDimension::e2D;
|
||||
// descriptor.size.width = 640;
|
||||
// descriptor.size.height = 480;
|
||||
// descriptor.size.depthOrArrayLayers = 1;
|
||||
// descriptor.sampleCount = 1;
|
||||
// descriptor.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||
// descriptor.mipLevelCount = 1;
|
||||
// descriptor.usage = wgpu::TextureUsage::RenderAttachment;
|
||||
// auto depthStencilTexture = device.CreateTexture(&descriptor);
|
||||
// return depthStencilTexture.CreateView();
|
||||
// }
|
||||
|
||||
// bool InitSample(int argc, const char** argv) {
|
||||
// for (int i = 1; i < argc; i++) {
|
||||
// if (std::string("-b") == argv[i] || std::string("--backend") == argv[i]) {
|
||||
// i++;
|
||||
// if (i < argc && std::string("d3d12") == argv[i]) {
|
||||
// backendType = wgpu::BackendType::D3D12;
|
||||
// continue;
|
||||
// }
|
||||
// if (i < argc && std::string("metal") == argv[i]) {
|
||||
// backendType = wgpu::BackendType::Metal;
|
||||
// continue;
|
||||
// }
|
||||
// if (i < argc && std::string("null") == argv[i]) {
|
||||
// backendType = wgpu::BackendType::Null;
|
||||
// continue;
|
||||
// }
|
||||
// if (i < argc && std::string("opengl") == argv[i]) {
|
||||
// backendType = wgpu::BackendType::OpenGL;
|
||||
// continue;
|
||||
// }
|
||||
// if (i < argc && std::string("opengles") == argv[i]) {
|
||||
// backendType = wgpu::BackendType::OpenGLES;
|
||||
// continue;
|
||||
// }
|
||||
// if (i < argc && std::string("vulkan") == argv[i]) {
|
||||
// backendType = wgpu::BackendType::Vulkan;
|
||||
// continue;
|
||||
// }
|
||||
// fprintf(stderr,
|
||||
// "--backend expects a backend name (opengl, opengles, metal, d3d12, null, "
|
||||
// "vulkan)\n");
|
||||
// return false;
|
||||
// }
|
||||
// if (std::string("-c") == argv[i] || std::string("--command-buffer") == argv[i]) {
|
||||
// i++;
|
||||
// if (i < argc && std::string("none") == argv[i]) {
|
||||
// cmdBufType = CmdBufType::None;
|
||||
// continue;
|
||||
// }
|
||||
// if (i < argc && std::string("terrible") == argv[i]) {
|
||||
// cmdBufType = CmdBufType::Terrible;
|
||||
// continue;
|
||||
// }
|
||||
// fprintf(stderr, "--command-buffer expects a command buffer name (none, terrible)\n");
|
||||
// return false;
|
||||
// }
|
||||
// if (std::string("-h") == argv[i] || std::string("--help") == argv[i]) {
|
||||
// printf("Usage: %s [-b BACKEND] [-c COMMAND_BUFFER]\n", argv[0]);
|
||||
// printf(" BACKEND is one of: d3d12, metal, null, opengl, opengles, vulkan\n");
|
||||
// printf(" COMMAND_BUFFER is one of: none, terrible\n");
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
114
gpu-dawn/src/dawn/sources/abseil.cc
Normal file
114
gpu-dawn/src/dawn/sources/abseil.cc
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
#include "third_party/abseil-cpp/absl/strings/match.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/cord_rep_btree_reader.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/cordz_info.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/cord_internal.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/cordz_sample_token.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/cord_rep_consume.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/str_format/output.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/cordz_handle.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/memutil.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/ostringstream.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/pow10_helper.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/utf8.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/cordz_functions.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/cord_rep_btree_navigator.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/escaping.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/string_view.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/str_cat.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/cord.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/ascii.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/charconv.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/str_split.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/substitute.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/escaping.cc"
|
||||
#include "third_party/abseil-cpp/absl/strings/str_replace.cc"
|
||||
#include "third_party/abseil-cpp/absl/types/bad_any_cast.cc"
|
||||
#include "third_party/abseil-cpp/absl/types/bad_optional_access.cc"
|
||||
#include "third_party/abseil-cpp/absl/types/bad_variant_access.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/parse.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/usage.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/internal/private_handle_accessor.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/internal/usage.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/internal/program_name.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/internal/flag.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/reflection.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/usage_config.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/flag.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/marshalling.cc"
|
||||
#include "third_party/abseil-cpp/absl/flags/commandlineflag.cc"
|
||||
#include "third_party/abseil-cpp/absl/synchronization/blocking_counter.cc"
|
||||
#include "third_party/abseil-cpp/absl/synchronization/mutex.cc"
|
||||
#include "third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc"
|
||||
#include "third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc"
|
||||
#include "third_party/abseil-cpp/absl/synchronization/internal/waiter.cc"
|
||||
#include "third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc"
|
||||
#include "third_party/abseil-cpp/absl/synchronization/barrier.cc"
|
||||
#include "third_party/abseil-cpp/absl/synchronization/notification.cc"
|
||||
#include "third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc"
|
||||
#include "third_party/abseil-cpp/absl/hash/internal/hash.cc"
|
||||
#include "third_party/abseil-cpp/absl/hash/internal/city.cc"
|
||||
#include "third_party/abseil-cpp/absl/debugging/symbolize.cc"
|
||||
#include "third_party/abseil-cpp/absl/debugging/failure_signal_handler.cc"
|
||||
#include "third_party/abseil-cpp/absl/debugging/leak_check_disable.cc"
|
||||
#include "third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc"
|
||||
#include "third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc"
|
||||
#include "third_party/abseil-cpp/absl/debugging/internal/stack_consumption.cc"
|
||||
#include "third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc"
|
||||
#include "third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc"
|
||||
#include "third_party/abseil-cpp/absl/debugging/internal/demangle.cc"
|
||||
#include "third_party/abseil-cpp/absl/debugging/leak_check.cc"
|
||||
#include "third_party/abseil-cpp/absl/debugging/stacktrace.cc"
|
||||
#include "third_party/abseil-cpp/absl/status/status_payload_printer.cc"
|
||||
#include "third_party/abseil-cpp/absl/status/status.cc"
|
||||
#include "third_party/abseil-cpp/absl/status/statusor.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/clock.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/duration.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/civil_time.cc"
|
||||
#include "third_party/abseil-cpp/absl/time/time.cc"
|
||||
#include "third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc"
|
||||
#include "third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc"
|
||||
#include "third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc"
|
||||
#include "third_party/abseil-cpp/absl/numeric/int128.cc"
|
||||
#include "third_party/abseil-cpp/absl/random/gaussian_distribution.cc"
|
||||
#include "third_party/abseil-cpp/absl/random/discrete_distribution.cc"
|
||||
#include "third_party/abseil-cpp/absl/random/seed_gen_exception.cc"
|
||||
#include "third_party/abseil-cpp/absl/random/internal/seed_material.cc"
|
||||
#include "third_party/abseil-cpp/absl/random/internal/randen_slow.cc"
|
||||
#include "third_party/abseil-cpp/absl/random/internal/randen.cc"
|
||||
#include "third_party/abseil-cpp/absl/random/internal/randen_detect.cc"
|
||||
#include "third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc"
|
||||
#include "third_party/abseil-cpp/absl/random/internal/pool_urbg.cc"
|
||||
#include "third_party/abseil-cpp/absl/random/seed_sequences.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/periodic_sampler.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/cycleclock.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/spinlock.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/scoped_set_env.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/sysinfo.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/raw_logging.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/throw_delegate.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/strerror.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/thread_identity.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/exponential_biased.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc"
|
||||
#include "third_party/abseil-cpp/absl/base/log_severity.cc"
|
||||
72
gpu-dawn/src/dawn/sources/dawn_native.cpp
Normal file
72
gpu-dawn/src/dawn/sources/dawn_native.cpp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#include "out/Debug/gen/src/dawn/dawn_thread_dispatch_proc.cpp"
|
||||
#include "out/Debug/gen/src/dawn/webgpu_cpp.cpp"
|
||||
|
||||
#include "src/dawn_native/Adapter.cpp"
|
||||
#include "src/dawn_native/AsyncTask.cpp"
|
||||
#include "src/dawn_native/AttachmentState.cpp"
|
||||
#include "src/dawn_native/BackendConnection.cpp"
|
||||
#include "src/dawn_native/BindGroup.cpp"
|
||||
#include "src/dawn_native/BindGroupLayout.cpp"
|
||||
#include "src/dawn_native/BindingInfo.cpp"
|
||||
#include "src/dawn_native/BuddyAllocator.cpp"
|
||||
#include "src/dawn_native/BuddyMemoryAllocator.cpp"
|
||||
#include "src/dawn_native/Buffer.cpp"
|
||||
#include "src/dawn_native/CachedObject.cpp"
|
||||
#include "src/dawn_native/CallbackTaskManager.cpp"
|
||||
#include "src/dawn_native/CommandAllocator.cpp"
|
||||
#include "src/dawn_native/CommandBuffer.cpp"
|
||||
#include "src/dawn_native/CommandBufferStateTracker.cpp"
|
||||
#include "src/dawn_native/CommandEncoder.cpp"
|
||||
#include "src/dawn_native/CommandValidation.cpp"
|
||||
#include "src/dawn_native/Commands.cpp"
|
||||
#include "src/dawn_native/CompilationMessages.cpp"
|
||||
#include "src/dawn_native/ComputePassEncoder.cpp"
|
||||
#include "src/dawn_native/ComputePipeline.cpp"
|
||||
#include "src/dawn_native/CopyTextureForBrowserHelper.cpp"
|
||||
#include "src/dawn_native/CreatePipelineAsyncTask.cpp"
|
||||
#include "src/dawn_native/Device.cpp"
|
||||
#include "src/dawn_native/DynamicUploader.cpp"
|
||||
#include "src/dawn_native/EncodingContext.cpp"
|
||||
#include "src/dawn_native/Error.cpp"
|
||||
#include "src/dawn_native/ErrorData.cpp"
|
||||
#include "src/dawn_native/ErrorInjector.cpp"
|
||||
#include "src/dawn_native/ErrorScope.cpp"
|
||||
#include "src/dawn_native/ExternalTexture.cpp"
|
||||
#include "src/dawn_native/Features.cpp"
|
||||
#include "src/dawn_native/Format.cpp"
|
||||
#include "src/dawn_native/IndirectDrawMetadata.cpp"
|
||||
#include "src/dawn_native/IndirectDrawValidationEncoder.cpp"
|
||||
#include "src/dawn_native/Instance.cpp"
|
||||
#include "src/dawn_native/InternalPipelineStore.cpp"
|
||||
#include "src/dawn_native/Limits.cpp"
|
||||
#include "src/dawn_native/ObjectBase.cpp"
|
||||
#include "src/dawn_native/ObjectContentHasher.cpp"
|
||||
#include "src/dawn_native/PassResourceUsageTracker.cpp"
|
||||
#include "src/dawn_native/PerStage.cpp"
|
||||
#include "src/dawn_native/PersistentCache.cpp"
|
||||
#include "src/dawn_native/Pipeline.cpp"
|
||||
#include "src/dawn_native/PipelineLayout.cpp"
|
||||
#include "src/dawn_native/PooledResourceMemoryAllocator.cpp"
|
||||
#include "src/dawn_native/ProgrammableEncoder.cpp"
|
||||
#include "src/dawn_native/QueryHelper.cpp"
|
||||
#include "src/dawn_native/QuerySet.cpp"
|
||||
#include "src/dawn_native/Queue.cpp"
|
||||
#include "src/dawn_native/RenderBundle.cpp"
|
||||
#include "src/dawn_native/RenderBundleEncoder.cpp"
|
||||
#include "src/dawn_native/RenderEncoderBase.cpp"
|
||||
#include "src/dawn_native/RenderPassEncoder.cpp"
|
||||
#include "src/dawn_native/RenderPipeline.cpp"
|
||||
#include "src/dawn_native/ResourceMemoryAllocation.cpp"
|
||||
#include "src/dawn_native/RingBufferAllocator.cpp"
|
||||
#include "src/dawn_native/Sampler.cpp"
|
||||
#include "src/dawn_native/ScratchBuffer.cpp"
|
||||
#include "src/dawn_native/ShaderModule.cpp"
|
||||
#include "src/dawn_native/StagingBuffer.cpp"
|
||||
#include "src/dawn_native/Subresource.cpp"
|
||||
#include "src/dawn_native/Surface.cpp"
|
||||
#include "src/dawn_native/SwapChain.cpp"
|
||||
#include "src/dawn_native/Texture.cpp"
|
||||
#include "src/dawn_native/TintUtils.cpp"
|
||||
#include "src/dawn_native/Toggles.cpp"
|
||||
#include "src/dawn_native/VertexFormat.cpp"
|
||||
#include "src/dawn_native/utils/WGPUHelpers.cpp"
|
||||
19
gpu-dawn/src/dawn/sources/dawn_native_metal.mm
Normal file
19
gpu-dawn/src/dawn/sources/dawn_native_metal.mm
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#include "src/dawn_native/metal/MetalBackend.mm"
|
||||
#include "src/dawn_native/Surface_metal.mm"
|
||||
#include "src/dawn_native/metal/BindGroupLayoutMTL.mm"
|
||||
#include "src/dawn_native/metal/BindGroupMTL.mm"
|
||||
#include "src/dawn_native/metal/BufferMTL.mm"
|
||||
#include "src/dawn_native/metal/CommandBufferMTL.mm"
|
||||
#include "src/dawn_native/metal/CommandRecordingContext.mm"
|
||||
#include "src/dawn_native/metal/ComputePipelineMTL.mm"
|
||||
#include "src/dawn_native/metal/DeviceMTL.mm"
|
||||
#include "src/dawn_native/metal/PipelineLayoutMTL.mm"
|
||||
#include "src/dawn_native/metal/QuerySetMTL.mm"
|
||||
#include "src/dawn_native/metal/QueueMTL.mm"
|
||||
#include "src/dawn_native/metal/RenderPipelineMTL.mm"
|
||||
#include "src/dawn_native/metal/SamplerMTL.mm"
|
||||
#include "src/dawn_native/metal/ShaderModuleMTL.mm"
|
||||
#include "src/dawn_native/metal/StagingBufferMTL.mm"
|
||||
#include "src/dawn_native/metal/SwapChainMTL.mm"
|
||||
#include "src/dawn_native/metal/TextureMTL.mm"
|
||||
#include "src/dawn_native/metal/UtilsMetal.mm"
|
||||
6
gpu-dawn/src/dawn/sources/dawn_native_utils_gen.cpp
Normal file
6
gpu-dawn/src/dawn/sources/dawn_native_utils_gen.cpp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#include "out/Debug/gen/src/dawn_native/ChainUtils_autogen.cpp"
|
||||
#include "out/Debug/gen/src/dawn_native/ProcTable.cpp"
|
||||
#include "out/Debug/gen/src/dawn_native/wgpu_structs_autogen.cpp"
|
||||
#include "out/Debug/gen/src/dawn_native/ValidationUtils_autogen.cpp"
|
||||
#include "out/Debug/gen/src/dawn_native/webgpu_absl_format_autogen.cpp"
|
||||
#include "out/Debug/gen/src/dawn_native/ObjectType_autogen.cpp"
|
||||
31
gpu-dawn/src/dawn/sources/dawn_wire_gen.cpp
Normal file
31
gpu-dawn/src/dawn/sources/dawn_wire_gen.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "out/Debug/gen/src/dawn_wire/WireCmd_autogen.cpp"
|
||||
#include "out/Debug/gen/src/dawn_wire/client/ApiProcs_autogen.cpp"
|
||||
#include "out/Debug/gen/src/dawn_wire/client/ClientHandlers_autogen.cpp"
|
||||
#include "out/Debug/gen/src/dawn_wire/server/ServerDoers_autogen.cpp"
|
||||
#include "out/Debug/gen/src/dawn_wire/server/ServerHandlers_autogen.cpp"
|
||||
|
||||
#include "src/dawn_wire/ChunkedCommandHandler.cpp"
|
||||
#include "src/dawn_wire/ChunkedCommandSerializer.cpp"
|
||||
#include "src/dawn_wire/SupportedFeatures.cpp"
|
||||
#include "src/dawn_wire/Wire.cpp"
|
||||
#include "src/dawn_wire/WireClient.cpp"
|
||||
#include "src/dawn_wire/WireDeserializeAllocator.cpp"
|
||||
#include "src/dawn_wire/WireServer.cpp"
|
||||
#include "src/dawn_wire/client/Adapter.cpp"
|
||||
#include "src/dawn_wire/client/Buffer.cpp"
|
||||
#include "src/dawn_wire/client/Client.cpp"
|
||||
#include "src/dawn_wire/client/ClientDoers.cpp"
|
||||
#include "src/dawn_wire/client/ClientInlineMemoryTransferService.cpp"
|
||||
#include "src/dawn_wire/client/Device.cpp"
|
||||
#include "src/dawn_wire/client/Instance.cpp"
|
||||
#include "src/dawn_wire/client/LimitsAndFeatures.cpp"
|
||||
#include "src/dawn_wire/client/Queue.cpp"
|
||||
#include "src/dawn_wire/client/ShaderModule.cpp"
|
||||
#include "src/dawn_wire/server/Server.cpp"
|
||||
#include "src/dawn_wire/server/ServerAdapter.cpp"
|
||||
#include "src/dawn_wire/server/ServerBuffer.cpp"
|
||||
#include "src/dawn_wire/server/ServerDevice.cpp"
|
||||
#include "src/dawn_wire/server/ServerInlineMemoryTransferService.cpp"
|
||||
#include "src/dawn_wire/server/ServerInstance.cpp"
|
||||
#include "src/dawn_wire/server/ServerQueue.cpp"
|
||||
#include "src/dawn_wire/server/ServerShaderModule.cpp"
|
||||
9
gpu-dawn/src/dawn/sources/spirv_cross.cpp
Normal file
9
gpu-dawn/src/dawn/sources/spirv_cross.cpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include "third_party/vulkan-deps/spirv-cross/src/spirv_cfg.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-cross/src/spirv_cross.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-cross/src/spirv_cross_parsed_ir.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-cross/src/spirv_cross_util.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-cross/src/spirv_glsl.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-cross/src/spirv_hlsl.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-cross/src/spirv_msl.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-cross/src/spirv_parser.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-cross/src/spirv_reflect.cpp"
|
||||
24
gpu-dawn/src/dawn/sources/spirv_tools.cpp
Normal file
24
gpu-dawn/src/dawn/sources/spirv_tools.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "third_party/vulkan-deps/spirv-tools/src/source/assembly_grammar.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/binary.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/diagnostic.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/disassemble.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/enum_string_mapping.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/ext_inst.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/extensions.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/libspirv.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/name_mapper.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opcode.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/parsed_operand.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/print.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/spirv_endian.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/spirv_fuzzer_options.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/spirv_optimizer_options.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/spirv_target_env.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/spirv_validator_options.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/table.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/text.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/text_handler.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/util/bit_vector.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/util/parse_number.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/util/string_utils.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/util/timer.cpp"
|
||||
89
gpu-dawn/src/dawn/sources/spirv_tools_opt.cpp
Normal file
89
gpu-dawn/src/dawn/sources/spirv_tools_opt.cpp
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/aggressive_dead_code_elim_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/amd_ext_to_khr.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/block_merge_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/block_merge_util.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/build_module.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/ccp_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/cfg.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/cfg_cleanup_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/code_sink.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/combine_access_chains.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/compact_ids_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/composite.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/const_folding_rules.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/constants.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/control_dependence.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/convert_to_sampled_image_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/convert_to_half_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/dataflow.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/dead_branch_elim_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/dead_insert_elim_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/dead_variable_elimination.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/debug_info_manager.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/decoration_manager.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/def_use_manager.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/desc_sroa.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/dominator_analysis.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/dominator_tree.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/eliminate_dead_constant_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/eliminate_dead_functions_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/eliminate_dead_functions_util.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/eliminate_dead_members_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/feature_manager.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/fix_storage_class.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/flatten_decoration_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/fold.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/fold_spec_constant_op_and_composite_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/freeze_spec_constant_value_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/function.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/graphics_robust_access_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/if_conversion.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/inline_exhaustive_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/inline_opaque_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/inline_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/inst_bindless_check_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/inst_buff_addr_check_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/inst_debug_printf_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/instruction.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/instruction_list.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/instrument_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/interp_fixup_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/ir_loader.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/licm_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/local_redundancy_elimination.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/local_single_block_elim_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/loop_dependence.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/loop_dependence_helpers.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/loop_descriptor.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/loop_fission.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/loop_fusion.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/loop_fusion_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/loop_peeling.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/loop_unroller.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/loop_utils.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/merge_return_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/module.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/optimizer.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/pass_manager.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/private_to_local_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/propagator.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/reduce_load_size.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/redundancy_elimination.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/register_pressure.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/relax_float_ops_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/remove_duplicates_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/replace_invalid_opc.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/scalar_analysis.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/scalar_analysis_simplification.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/simplification_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/strength_reduction_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/strip_debug_info_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/strip_reflect_info_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/struct_cfg_analysis.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/type_manager.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/types.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/unify_const_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/upgrade_memory_model.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/value_number_table.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/workaround1209.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/wrap_opkill.cpp"
|
||||
9
gpu-dawn/src/dawn/sources/spirv_tools_opt_2.cpp
Normal file
9
gpu-dawn/src/dawn/sources/spirv_tools_opt_2.cpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/basic_block.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/copy_prop_arrays.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/folding_rules.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/ir_context.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/local_access_chain_convert_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/remove_unused_interface_variables_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/scalar_replacement_pass.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/opt/set_spec_constant_default_value_pass.cpp"
|
||||
40
gpu-dawn/src/dawn/sources/spirv_tools_val.cpp
Normal file
40
gpu-dawn/src/dawn/sources/spirv_tools_val.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/basic_block.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/construct.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/function.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/instruction.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_adjacency.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_annotation.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_arithmetics.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_atomics.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_barriers.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_bitwise.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_builtins.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_capability.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_cfg.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_composites.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_constants.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_conversion.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_debug.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_decorations.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_derivatives.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_execution_limitations.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_extensions.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_function.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_id.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_image.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_instruction.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_interfaces.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_layout.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_literals.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_logicals.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_memory.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_memory_semantics.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_misc.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_mode_setting.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_non_uniform.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_primitives.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_scopes.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_small_type_uses.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validate_type.cpp"
|
||||
#include "third_party/vulkan-deps/spirv-tools/src/source/val/validation_state.cpp"
|
||||
132
gpu-dawn/src/dawn/sources/tint_core_all_src.cc
Normal file
132
gpu-dawn/src/dawn/sources/tint_core_all_src.cc
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
#include "third_party/tint/src/ast/access.cc"
|
||||
#include "third_party/tint/src/ast/alias.cc"
|
||||
#include "third_party/tint/src/ast/array.cc"
|
||||
#include "third_party/tint/src/ast/assignment_statement.cc"
|
||||
#include "third_party/tint/src/ast/atomic.cc"
|
||||
#include "third_party/tint/src/ast/binary_expression.cc"
|
||||
#include "third_party/tint/src/ast/binding_decoration.cc"
|
||||
#include "third_party/tint/src/ast/bitcast_expression.cc"
|
||||
#include "third_party/tint/src/ast/block_statement.cc"
|
||||
#include "third_party/tint/src/ast/bool.cc"
|
||||
#include "third_party/tint/src/ast/bool_literal_expression.cc"
|
||||
#include "third_party/tint/src/ast/break_statement.cc"
|
||||
#include "third_party/tint/src/ast/builtin.cc"
|
||||
#include "third_party/tint/src/ast/builtin_decoration.cc"
|
||||
#include "third_party/tint/src/ast/call_expression.cc"
|
||||
#include "third_party/tint/src/ast/call_statement.cc"
|
||||
#include "third_party/tint/src/ast/case_statement.cc"
|
||||
#include "third_party/tint/src/ast/continue_statement.cc"
|
||||
#include "third_party/tint/src/ast/depth_multisampled_texture.cc"
|
||||
#include "third_party/tint/src/ast/disable_validation_decoration.cc"
|
||||
#include "third_party/tint/src/ast/discard_statement.cc"
|
||||
#include "third_party/tint/src/ast/else_statement.cc"
|
||||
#include "third_party/tint/src/ast/external_texture.cc"
|
||||
#include "third_party/tint/src/ast/f32.cc"
|
||||
#include "third_party/tint/src/ast/fallthrough_statement.cc"
|
||||
#include "third_party/tint/src/ast/float_literal_expression.cc"
|
||||
#include "third_party/tint/src/ast/for_loop_statement.cc"
|
||||
#include "third_party/tint/src/ast/function.cc"
|
||||
#include "third_party/tint/src/ast/group_decoration.cc"
|
||||
#include "third_party/tint/src/ast/i32.cc"
|
||||
#include "third_party/tint/src/ast/identifier_expression.cc"
|
||||
#include "third_party/tint/src/ast/if_statement.cc"
|
||||
#include "third_party/tint/src/ast/index_accessor_expression.cc"
|
||||
#include "third_party/tint/src/ast/int_literal_expression.cc"
|
||||
#include "third_party/tint/src/ast/interpolate_decoration.cc"
|
||||
#include "third_party/tint/src/ast/invariant_decoration.cc"
|
||||
#include "third_party/tint/src/ast/location_decoration.cc"
|
||||
#include "third_party/tint/src/ast/loop_statement.cc"
|
||||
#include "third_party/tint/src/ast/matrix.cc"
|
||||
#include "third_party/tint/src/ast/member_accessor_expression.cc"
|
||||
#include "third_party/tint/src/ast/module.cc"
|
||||
#include "third_party/tint/src/ast/multisampled_texture.cc"
|
||||
#include "third_party/tint/src/ast/override_decoration.cc"
|
||||
#include "third_party/tint/src/ast/phony_expression.cc"
|
||||
#include "third_party/tint/src/ast/pipeline_stage.cc"
|
||||
#include "third_party/tint/src/ast/pointer.cc"
|
||||
#include "third_party/tint/src/ast/return_statement.cc"
|
||||
#include "third_party/tint/src/ast/sampled_texture.cc"
|
||||
#include "third_party/tint/src/ast/sampler.cc"
|
||||
#include "third_party/tint/src/ast/sint_literal_expression.cc"
|
||||
#include "third_party/tint/src/ast/stage_decoration.cc"
|
||||
#include "third_party/tint/src/ast/storage_class.cc"
|
||||
#include "third_party/tint/src/ast/storage_texture.cc"
|
||||
#include "third_party/tint/src/ast/stride_decoration.cc"
|
||||
#include "third_party/tint/src/ast/struct.cc"
|
||||
#include "third_party/tint/src/ast/struct_block_decoration.cc"
|
||||
#include "third_party/tint/src/ast/struct_member.cc"
|
||||
#include "third_party/tint/src/ast/struct_member_align_decoration.cc"
|
||||
#include "third_party/tint/src/ast/struct_member_offset_decoration.cc"
|
||||
#include "third_party/tint/src/ast/struct_member_size_decoration.cc"
|
||||
#include "third_party/tint/src/ast/switch_statement.cc"
|
||||
#include "third_party/tint/src/ast/type_name.cc"
|
||||
#include "third_party/tint/src/ast/u32.cc"
|
||||
#include "third_party/tint/src/ast/uint_literal_expression.cc"
|
||||
#include "third_party/tint/src/ast/unary_op.cc"
|
||||
#include "third_party/tint/src/ast/unary_op_expression.cc"
|
||||
#include "third_party/tint/src/ast/variable.cc"
|
||||
#include "third_party/tint/src/ast/variable_decl_statement.cc"
|
||||
#include "third_party/tint/src/ast/vector.cc"
|
||||
#include "third_party/tint/src/ast/void.cc"
|
||||
#include "third_party/tint/src/ast/workgroup_decoration.cc"
|
||||
#include "third_party/tint/src/castable.cc"
|
||||
#include "third_party/tint/src/clone_context.cc"
|
||||
#include "third_party/tint/src/debug.cc"
|
||||
#include "third_party/tint/src/demangler.cc"
|
||||
#include "third_party/tint/src/diagnostic/diagnostic.cc"
|
||||
#include "third_party/tint/src/diagnostic/formatter.cc"
|
||||
#include "third_party/tint/src/diagnostic/printer.cc"
|
||||
#include "third_party/tint/src/inspector/entry_point.cc"
|
||||
#include "third_party/tint/src/inspector/inspector.cc"
|
||||
#include "third_party/tint/src/inspector/resource_binding.cc"
|
||||
#include "third_party/tint/src/inspector/scalar.cc"
|
||||
#include "third_party/tint/src/intrinsic_table.cc"
|
||||
#include "third_party/tint/src/program.cc"
|
||||
#include "third_party/tint/src/program_builder.cc"
|
||||
#include "third_party/tint/src/program_id.cc"
|
||||
#include "third_party/tint/src/reader/reader.cc"
|
||||
#include "third_party/tint/src/resolver/dependency_graph.cc"
|
||||
#include "third_party/tint/src/resolver/resolver.cc"
|
||||
#include "third_party/tint/src/resolver/resolver_constants.cc"
|
||||
#include "third_party/tint/src/resolver/resolver_validation.cc"
|
||||
#include "third_party/tint/src/source.cc"
|
||||
#include "third_party/tint/src/symbol.cc"
|
||||
#include "third_party/tint/src/symbol_table.cc"
|
||||
#include "third_party/tint/src/transform/add_empty_entry_point.cc"
|
||||
#include "third_party/tint/src/transform/add_spirv_block_decoration.cc"
|
||||
#include "third_party/tint/src/transform/array_length_from_uniform.cc"
|
||||
#include "third_party/tint/src/transform/binding_remapper.cc"
|
||||
#include "third_party/tint/src/transform/calculate_array_length.cc"
|
||||
#include "third_party/tint/src/transform/canonicalize_entry_point_io.cc"
|
||||
#include "third_party/tint/src/transform/decompose_memory_access.cc"
|
||||
#include "third_party/tint/src/transform/decompose_strided_matrix.cc"
|
||||
#include "third_party/tint/src/transform/external_texture_transform.cc"
|
||||
#include "third_party/tint/src/transform/first_index_offset.cc"
|
||||
#include "third_party/tint/src/transform/fold_constants.cc"
|
||||
#include "third_party/tint/src/transform/fold_trivial_single_use_lets.cc"
|
||||
#include "third_party/tint/src/transform/for_loop_to_loop.cc"
|
||||
#include "third_party/tint/src/transform/localize_struct_array_assignment.cc"
|
||||
#include "third_party/tint/src/transform/loop_to_for_loop.cc"
|
||||
#include "third_party/tint/src/transform/manager.cc"
|
||||
#include "third_party/tint/src/transform/module_scope_var_to_entry_point_param.cc"
|
||||
#include "third_party/tint/src/transform/multiplanar_external_texture.cc"
|
||||
#include "third_party/tint/src/transform/num_workgroups_from_uniform.cc"
|
||||
#include "third_party/tint/src/transform/pad_array_elements.cc"
|
||||
#include "third_party/tint/src/transform/promote_initializers_to_const_var.cc"
|
||||
#include "third_party/tint/src/transform/remove_phonies.cc"
|
||||
#include "third_party/tint/src/transform/remove_unreachable_statements.cc"
|
||||
#include "third_party/tint/src/transform/renamer.cc"
|
||||
#include "third_party/tint/src/transform/robustness.cc"
|
||||
#include "third_party/tint/src/transform/simplify_pointers.cc"
|
||||
#include "third_party/tint/src/transform/single_entry_point.cc"
|
||||
#include "third_party/tint/src/transform/unshadow.cc"
|
||||
#include "third_party/tint/src/transform/vectorize_scalar_matrix_constructors.cc"
|
||||
#include "third_party/tint/src/transform/vertex_pulling.cc"
|
||||
#include "third_party/tint/src/transform/wrap_arrays_in_structs.cc"
|
||||
#include "third_party/tint/src/transform/zero_init_workgroup_memory.cc"
|
||||
#include "third_party/tint/src/writer/append_vector.cc"
|
||||
#include "third_party/tint/src/writer/array_length_from_uniform_options.cc"
|
||||
#include "third_party/tint/src/writer/float_to_string.cc"
|
||||
#include "third_party/tint/src/writer/text.cc"
|
||||
#include "third_party/tint/src/writer/text_generator.cc"
|
||||
#include "third_party/tint/src/writer/writer.cc"
|
||||
9
gpu-dawn/src/dawn/sources/tint_core_all_src_2.cc
Normal file
9
gpu-dawn/src/dawn/sources/tint_core_all_src_2.cc
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include "third_party/tint/src/ast/ast_type.cc"
|
||||
#include "third_party/tint/src/ast/decoration.cc"
|
||||
#include "third_party/tint/src/ast/depth_texture.cc"
|
||||
#include "third_party/tint/src/ast/expression.cc"
|
||||
#include "third_party/tint/src/ast/internal_decoration.cc"
|
||||
#include "third_party/tint/src/ast/literal_expression.cc"
|
||||
#include "third_party/tint/src/ast/statement.cc"
|
||||
#include "third_party/tint/src/ast/type_decl.cc"
|
||||
#include "third_party/tint/src/transform/transform.cc"
|
||||
37
gpu-dawn/src/dawn/sources/tint_sem_src.cc
Normal file
37
gpu-dawn/src/dawn/sources/tint_sem_src.cc
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "third_party/tint/src/sem/array.cc"
|
||||
#include "third_party/tint/src/sem/atomic_type.cc"
|
||||
#include "third_party/tint/src/sem/behavior.cc"
|
||||
#include "third_party/tint/src/sem/block_statement.cc"
|
||||
#include "third_party/tint/src/sem/bool_type.cc"
|
||||
#include "third_party/tint/src/sem/call.cc"
|
||||
#include "third_party/tint/src/sem/call_target.cc"
|
||||
#include "third_party/tint/src/sem/constant.cc"
|
||||
#include "third_party/tint/src/sem/depth_multisampled_texture_type.cc"
|
||||
#include "third_party/tint/src/sem/external_texture_type.cc"
|
||||
#include "third_party/tint/src/sem/f32_type.cc"
|
||||
#include "third_party/tint/src/sem/for_loop_statement.cc"
|
||||
#include "third_party/tint/src/sem/function.cc"
|
||||
#include "third_party/tint/src/sem/i32_type.cc"
|
||||
#include "third_party/tint/src/sem/if_statement.cc"
|
||||
#include "third_party/tint/src/sem/info.cc"
|
||||
#include "third_party/tint/src/sem/intrinsic.cc"
|
||||
#include "third_party/tint/src/sem/intrinsic_type.cc"
|
||||
#include "third_party/tint/src/sem/loop_statement.cc"
|
||||
#include "third_party/tint/src/sem/matrix_type.cc"
|
||||
#include "third_party/tint/src/sem/member_accessor_expression.cc"
|
||||
#include "third_party/tint/src/sem/multisampled_texture_type.cc"
|
||||
#include "third_party/tint/src/sem/parameter_usage.cc"
|
||||
#include "third_party/tint/src/sem/pointer_type.cc"
|
||||
#include "third_party/tint/src/sem/reference_type.cc"
|
||||
#include "third_party/tint/src/sem/sampled_texture_type.cc"
|
||||
#include "third_party/tint/src/sem/sampler_type.cc"
|
||||
#include "third_party/tint/src/sem/storage_texture_type.cc"
|
||||
#include "third_party/tint/src/sem/struct.cc"
|
||||
#include "third_party/tint/src/sem/switch_statement.cc"
|
||||
#include "third_party/tint/src/sem/type_constructor.cc"
|
||||
#include "third_party/tint/src/sem/type_conversion.cc"
|
||||
#include "third_party/tint/src/sem/type_manager.cc"
|
||||
#include "third_party/tint/src/sem/u32_type.cc"
|
||||
#include "third_party/tint/src/sem/variable.cc"
|
||||
#include "third_party/tint/src/sem/vector_type.cc"
|
||||
#include "third_party/tint/src/sem/void_type.cc"
|
||||
4
gpu-dawn/src/dawn/sources/tint_sem_src_2.cc
Normal file
4
gpu-dawn/src/dawn/sources/tint_sem_src_2.cc
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#include "third_party/tint/src/sem/depth_texture_type.cc"
|
||||
#include "third_party/tint/src/sem/expression.cc"
|
||||
#include "third_party/tint/src/sem/statement.cc"
|
||||
#include "third_party/tint/src/sem/type.cc"
|
||||
9
gpu-dawn/src/dawn/sources/tint_spv_reader_src.cc
Normal file
9
gpu-dawn/src/dawn/sources/tint_spv_reader_src.cc
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include "third_party/tint/src/reader/spirv/construct.cc"
|
||||
#include "third_party/tint/src/reader/spirv/entry_point_info.cc"
|
||||
#include "third_party/tint/src/reader/spirv/enum_converter.cc"
|
||||
#include "third_party/tint/src/reader/spirv/function.cc"
|
||||
#include "third_party/tint/src/reader/spirv/namer.cc"
|
||||
#include "third_party/tint/src/reader/spirv/parser.cc"
|
||||
#include "third_party/tint/src/reader/spirv/parser_impl.cc"
|
||||
#include "third_party/tint/src/reader/spirv/parser_type.cc"
|
||||
#include "third_party/tint/src/reader/spirv/usage.cc"
|
||||
6
gpu-dawn/src/dawn/sources/tint_spv_writer_src.cc
Normal file
6
gpu-dawn/src/dawn/sources/tint_spv_writer_src.cc
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#include "third_party/tint/src/writer/spirv/binary_writer.cc"
|
||||
#include "third_party/tint/src/writer/spirv/builder.cc"
|
||||
#include "third_party/tint/src/writer/spirv/function.cc"
|
||||
#include "third_party/tint/src/writer/spirv/generator.cc"
|
||||
#include "third_party/tint/src/writer/spirv/instruction.cc"
|
||||
#include "third_party/tint/src/writer/spirv/operand.cc"
|
||||
10
gpu-dawn/src/main.zig
Normal file
10
gpu-dawn/src/main.zig
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
|
||||
export fn add(a: i32, b: i32) i32 {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
test "basic add functionality" {
|
||||
try testing.expect(add(3, 7) == 10);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue