diff --git a/.github/workflows/build-dawn.yml b/.github/workflows/build-dawn.yml index 81d83cb75..7b07bdcca 100644 --- a/.github/workflows/build-dawn.yml +++ b/.github/workflows/build-dawn.yml @@ -18,28 +18,39 @@ jobs: - name: Checkout repository uses: actions/checkout@v6.0.2 - - name: Determine Dawn branch metadata + - name: Determine Dawn version metadata id: dawn_meta run: | set -eo pipefail - branch=$(git config -f .gitmodules submodule.externals/dawn.branch) - if [ -z "$branch" ]; then - echo "Could not determine Dawn branch from .gitmodules" >&2 + version=$(node -p "require('./packages/webgpu/package.json').dawn") + commit=$(node -p "require('./packages/webgpu/package.json').dawnCommit") + if [ -z "$version" ] || [ "$version" = "undefined" ]; then + echo "Could not determine Dawn version from package.json ('dawn' field)" >&2 exit 1 fi - slug=${branch//\//-} - echo "branch=$branch" >> "$GITHUB_OUTPUT" + if [ -z "$commit" ] || [ "$commit" = "undefined" ]; then + echo "Could not determine Dawn commit from package.json ('dawnCommit' field)" >&2 + exit 1 + fi + gitlink=$(git ls-tree HEAD externals/dawn | awk '{print $3}') + if [ "$gitlink" != "$commit" ]; then + echo "Submodule gitlink ($gitlink) does not match package.json dawnCommit ($commit)." >&2 + echo "Update the externals/dawn submodule and the dawnCommit field together." >&2 + exit 1 + fi + slug=${version//\//-} + echo "branch=$version" >> "$GITHUB_OUTPUT" echo "branch_slug=$slug" >> "$GITHUB_OUTPUT" - name: Compute release metadata id: release_meta run: | - tag="dawn-${DAWN_BRANCH_SLUG}" + tag="dawn-${DAWN_VERSION_SLUG}" echo "tag_name=$tag" >> "$GITHUB_OUTPUT" - echo "release_name=Dawn ${DAWN_BRANCH}" >> "$GITHUB_OUTPUT" + echo "release_name=Dawn ${DAWN_VERSION}" >> "$GITHUB_OUTPUT" env: - DAWN_BRANCH: ${{ steps.dawn_meta.outputs.branch }} - DAWN_BRANCH_SLUG: ${{ steps.dawn_meta.outputs.branch_slug }} + DAWN_VERSION: ${{ steps.dawn_meta.outputs.branch }} + DAWN_VERSION_SLUG: ${{ steps.dawn_meta.outputs.branch_slug }} - name: Create GitHub release id: create_release @@ -49,7 +60,7 @@ jobs: with: tag_name: ${{ steps.release_meta.outputs.tag_name }} name: ${{ steps.release_meta.outputs.release_name }} - body: "Dawn prebuilt binaries for version ${{ steps.dawn_meta.outputs.branch }}" + body: "Dawn prebuilt binaries for ${{ steps.dawn_meta.outputs.branch }} (Dawn commit pinned in package.json dawnCommit)" draft: false prerelease: true generate_release_notes: false diff --git a/.gitmodules b/.gitmodules index 609c52db0..81c45037a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "externals/dawn"] path = externals/dawn url = https://dawn.googlesource.com/dawn - branch = chromium/7849 + branch = main diff --git a/externals/dawn b/externals/dawn index cbfe412bf..63f25feec 160000 --- a/externals/dawn +++ b/externals/dawn @@ -1 +1 @@ -Subproject commit cbfe412bf6c88a23f6936b7219e1129d7d0a1620 +Subproject commit 63f25feec51e9351fb25222b6d5de1af791d7c4f diff --git a/packages/webgpu/CONTRIBUTING.md b/packages/webgpu/CONTRIBUTING.md index c3368aab5..b98847007 100644 --- a/packages/webgpu/CONTRIBUTING.md +++ b/packages/webgpu/CONTRIBUTING.md @@ -23,28 +23,31 @@ The Expo config plugin lives in `plugin/src` and is compiled to `plugin/build` b ## Upgrading Dawn -The Dawn version is pinned in two places that must stay in sync: +The Dawn version tracks the one shipped by `@shopify/react-native-skia` Graphite builds: the pin is the exact Dawn commit from the Skia milestone's DEPS file (`third_party/externals/dawn` in Skia's DEPS). It is recorded in two places that must stay in sync: -- `.gitmodules` → `submodule.externals/dawn.branch` (e.g. `chromium/7849`) -- `packages/webgpu/package.json` → the `"dawn"` field (same value, e.g. `chromium/7849`) +- the `externals/dawn` submodule gitlink (the commit the submodule points at) +- `packages/webgpu/package.json` → `"dawn"` (a human-readable label, e.g. `chrome-m150`; Skia milestones mirror Chrome milestones) and `"dawnCommit"` (the exact commit hash) -`yarn install-dawn` downloads **prebuilt** binaries from a GitHub release tagged `dawn-` (e.g. `dawn-chromium-7849`); the release host is configured at the top of `scripts/install-dawn.ts`. `yarn build-dawn` builds the same binaries from the submodule source instead. +The **Build Dawn** workflow verifies the gitlink matches `dawnCommit` and fails otherwise. -Steps to bump to a new Dawn version (`chromium/`): +`yarn install-dawn` downloads **prebuilt** binaries from a GitHub release on this repo tagged `dawn-` (e.g. `dawn-chrome-m150`). `yarn build-dawn` builds the same binaries from the submodule source instead. -1. **Point the submodule at the new branch.** Update both `.gitmodules` and the `"dawn"` field in `package.json` to `chromium/`, then move the submodule to the new tip: +Steps to bump to a new Dawn version (new Skia milestone `m`): + +1. **Find the Dawn commit** in the Skia milestone's `DEPS` file (`third_party/externals/dawn` entry). + +2. **Point the submodule at that commit** and update `package.json` (`"dawn": "chrome-m"`, `"dawnCommit": ""`): ```sh - git submodule set-branch --branch chromium/ externals/dawn - git submodule update --remote externals/dawn + cd externals/dawn && git fetch origin && git checkout && cd ../.. ``` -2. **Publish prebuilt binaries.** Trigger the **Build Dawn** workflow (`.github/workflows/build-dawn.yml`, `workflow_dispatch`). It reads the branch from `.gitmodules`, builds Android + Apple, and creates the `dawn-chromium-` release with the headers, the Android `.so`s, and the Apple `.xcframework`. (To build locally instead, run `yarn build-dawn`; this requires the Android NDK and Xcode toolchains.) +3. **Publish prebuilt binaries.** Trigger the **Build Dawn** workflow (`.github/workflows/build-dawn.yml`, `workflow_dispatch`). It builds Android + Apple from the submodule and creates the `dawn-chrome-m` release with the headers, the Android `.so`s, and the Apple `.xcframework`. (To build locally instead, run `yarn build-dawn`; this requires the Android NDK and Xcode toolchains.) -3. **Pull the new binaries** once the release exists: +4. **Pull the new binaries** once the release exists: ```sh cd packages/webgpu && yarn install-dawn ``` -4. **Verify and commit.** Build and run the example app, then commit the submodule bump together with the updated `.gitmodules` and `package.json`. \ No newline at end of file +5. **Verify and commit.** Build and run the example app, then commit the submodule bump together with the updated `package.json`. \ No newline at end of file diff --git a/packages/webgpu/package.json b/packages/webgpu/package.json index d58fd6b80..f3b2b765f 100644 --- a/packages/webgpu/package.json +++ b/packages/webgpu/package.json @@ -22,7 +22,8 @@ "app.plugin.js", "plugin/build/**" ], - "dawn": "chromium/7849", + "dawn": "chrome-m150", + "dawnCommit": "63f25feec51e9351fb25222b6d5de1af791d7c4f", "scripts": { "test": "NODE_OPTIONS='--experimental-require-module' jest -i", "test:ref": "REFERENCE=true NODE_OPTIONS='--experimental-require-module' jest -i", diff --git a/packages/webgpu/scripts/install-dawn.ts b/packages/webgpu/scripts/install-dawn.ts index e6d827756..345f6a3b6 100644 --- a/packages/webgpu/scripts/install-dawn.ts +++ b/packages/webgpu/scripts/install-dawn.ts @@ -75,7 +75,7 @@ if (!dawnVersion) { } // Parse the dawn version to construct the release tag -// Format: "chromium/7472" -> "dawn-chromium-7472" +// Format: "chrome-m150" -> "dawn-chrome-m150" const releaseTag = `dawn-${dawnVersion.replace("/", "-")}`; const releaseUrl = `https://github.com/wcandillon/react-native-webgpu/releases/tag/${releaseTag}`; @@ -171,7 +171,7 @@ const assetNames: { [key: string]: string } = { }; for (const [index, asset] of assets.entries()) { - const assetUrl = `https://github.com/Shopify/react-native-skia/releases/download/${releaseTag}/${asset.name}`; + const assetUrl = `https://github.com/wcandillon/react-native-webgpu/releases/download/${releaseTag}/${asset.name}`; const tarPath = join(libsDir, asset.name); const displayName = assetNames[asset.name] || asset.name;