Mirror of zig-gamedev/zgpu upstream
  • C++ 34.7%
  • Zig 32.4%
  • C 30.2%
  • Shell 1.9%
  • Objective-C 0.7%
  • Other 0.1%
Find a file
2026-09-22 11:34:37 +00:00
.forgejo/workflows Isolate Dawn patching per build target 2026-09-22 11:34:37 +00:00
compat/linux/include/xcb Build egpu and Dawn from pinned source mirrors 2026-09-22 10:19:22 +00:00
libs/dawn/include files from monorepo @ 613d847104a072fc1d4442f58d5f50b3f9c3f27c 2024-11-03 22:10:31 +00:00
patches/dawn Build egpu and Dawn from pinned source mirrors 2026-09-22 10:19:22 +00:00
src Updated to zig 0.15.1 (#20) 2025-10-20 19:30:21 +01:00
tools Isolate Dawn patching per build target 2026-09-22 11:34:37 +00:00
vendor Build egpu and Dawn from pinned source mirrors 2026-09-22 10:19:22 +00:00
.gitignore Build egpu and Dawn from pinned source mirrors 2026-09-22 10:19:22 +00:00
.gitmodules Build egpu and Dawn from pinned source mirrors 2026-09-22 10:19:22 +00:00
build.zig Isolate Dawn patching per build target 2026-09-22 11:34:37 +00:00
build.zig.zon Build egpu and Dawn from pinned source mirrors 2026-09-22 10:19:22 +00:00
LICENSE files from monorepo @ 613d847104a072fc1d4442f58d5f50b3f9c3f27c 2024-11-03 22:10:31 +00:00
README.md Isolate Dawn patching per build target 2026-09-22 11:34:37 +00:00
SOURCE_LOCK.md Build egpu and Dawn from pinned source mirrors 2026-09-22 10:19:22 +00:00

egpu

egpu is WetGrape's source-first fork of zig-gamedev/zgpu. It keeps the public Zig API while replacing downloaded prebuilt Dawn archives with a reproducible build from pinned sources.

What is different

  • No webgpu_dawn-*-prebuilt dependency exists in build.zig.zon.
  • Dawn C/C++ is compiled by Zig 0.16.0 (zig cc / zig c++).
  • Dawn, zpool and system SDK inputs are pinned source mirrors under git.wetgrape.su/mirrors.
  • zig build builds Dawn first and combines its static libraries with zig ar; the install contains sibling zdawn and dawn archives (never a nested archive).
  • CI builds and packages all supported cross targets; tag builds publish artifacts.
  • A deterministic source bundle contains expanded submodules, so the actual build can run without network access.

No upstream prebuilt Dawn archive is used as an input or fallback.

Supported targets

  • x86_64-linux-gnu
  • aarch64-linux-gnu
  • x86_64-windows-gnu
  • x86_64-macos.12.0.0-none
  • aarch64-macos.12.0.0-none

Prerequisites

  • Zig 0.16.0
  • CMake 3.10.2 or newer
  • Ninja
  • Python 3 (Dawn's source generators)
  • git, tar, sha256sum, and zstd
  • Linux native build: X11, XCB, XRandR, Xinerama, XCursor, Xi, Wayland and xkbcommon development headers

On Ubuntu 24.04:

apt-get install cmake ninja-build python3 pkg-config zstd binutils \
  libx11-dev libx11-xcb-dev libxrandr-dev libxinerama-dev \
  libxcursor-dev libxi-dev libwayland-dev wayland-protocols libxkbcommon-dev

Connected source checkout, then offline build

The bootstrap step downloads sources only and pins every checkout:

git clone https://git.wetgrape.su/WetGrape/egpu.git
cd egpu
./tools/bootstrap-sources.sh

After bootstrap, disconnect the network. These commands do not fetch anything:

zig build -Doptimize=ReleaseFast
zig build test -Doptimize=ReleaseFast

Cross-build examples:

zig build -Dtarget=aarch64-linux-gnu -Doptimize=ReleaseFast
zig build -Dtarget=x86_64-windows-gnu -Doptimize=ReleaseFast
zig build -Dtarget=aarch64-macos.12.0.0-none -Doptimize=ReleaseFast

Fully expanded offline source bundle

On a connected machine:

./tools/bootstrap-sources.sh
./tools/make-source-bundle.sh dist/egpu-source.tar.zst
sha256sum -c dist/egpu-source.tar.zst.sha256

Move only the .tar.zst and checksum to the offline builder, then:

sha256sum -c egpu-source.tar.zst.sha256
tar --zstd -xf egpu-source.tar.zst
cd egpu-source
zig build -Dtarget=x86_64-linux-gnu -Doptimize=ReleaseFast

The source bundle is not a binary build artifact: it contains source code, generated source checked into Dawn, headers, and text linker stubs only. Unused system_sdk binaries (libX11.so, dxguid.lib, CoreImage.metallib) are explicitly excluded; Linux/Windows linkage comes from the target system and Zig's source-built MinGW runtime.

Consumer build.zig

pub fn build(b: *std.Build) void {
    const exe = b.addExecutable(.{ ... });
    const egpu = b.dependency("egpu", .{});

    exe.root_module.addImport("zgpu", egpu.module("root"));
    exe.linkLibrary(egpu.artifact("zdawn"));

    // Propagates the generated source-built Dawn archive path.
    @import("egpu").addLibraryPathsTo(exe);
}

Source and patch policy

  • Upstream zgpu history is retained.
  • Source mirrors are read-only pull mirrors in the mirrors organization.
  • WetGrape-specific changes live only in WetGrape/egpu.
  • patches/dawn/ contains small, reviewable compatibility patches applied to a private build-cache copy of the pinned Dawn checkout; builds never modify vendor/dawn.
  • The same patch path works in expanded bundles without Git metadata, and independent target builds cannot race on shared source files.
  • CI and local builds fail if a required source directory is absent; there is no prebuilt fallback.

See SOURCE_LOCK.md for exact revisions and provenance.

License

The original zgpu code is MIT licensed; see LICENSE. Vendored/mirrored dependencies retain their own license files.