gpu-dawn: update README to reflect Dawn-specific package

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-12-22 17:08:48 -07:00 committed by Stephen Gutekanst
parent 7af784bee7
commit 162a9825e8

View file

@ -1,57 +1,21 @@
# 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-dawn, the easiest way to build Dawn <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.)
`mach/gpu-dawn` is the easiest way to build [Dawn](https://dawn.googlesource.com/dawn/) (Google's WebGPU implementation), requiring nothing more than `zig` and `git` to build and cross-compile static Dawn libraries for every OS.
![](https://user-images.githubusercontent.com/3173176/137646296-72ba698e-c710-4daf-aa75-222f8d717d00.png)
This repository is a separate copy of the same library in the [main Mach repository](https://github.com/hexops/mach), and is automatically kept in sync, so that anyone can use this library in their own project / engine if they like!
## Warning: Under heavy development!
Not everything stated in this README is yet achieved. We're working on it! Of particular note, we are missing:
This package is still under heavy development, Linux and macOS are working but Windows is not yet.
* 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
## Zero fuss installation, cross compilation, and more
## Features
[Just as with Mach](https://github.com/hexops/mach#zero-fuss-installation--cross-compilation), you get zero fuss installation & cross compilation using these GLFW bindings. **only `zig` and `git` are needed to build from any OS and produce binaries for every OS.** No system dependencies at all.
* 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
## Zig Dawn/WebGPU interface
**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.
This package implements the [the `mach/gpu` Zig interface](https://github.com/hexops/mach/tree/main/gpu) which, for Zig developers, allows swapping between WebGPU implementations seamlessly similar to the `std.mem.Allocator` interface.
## A different approach to graphics API abstraction
## Generated code
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:
![](https://user-images.githubusercontent.com/3173176/137647342-abf2bde6-a8bb-4276-b072-95c279c5d92f.png)
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)
Dawn itself relies on a fairly large amount of dependencies, generated code, etc. To avoid having any dependency on Google build tools, code generation, etc. we maintain [a minor fork of Dawn which has generated code and third-party dependencies comitted.](https://github.com/hexops/dawn/tree/main/mach)