Skip to content

feat(recompiler): add WGSL with native cache compatibility - #16391

Draft
SteelCrab wants to merge 6 commits into
boykopovar:mainfrom
SteelCrab:review/wgsl-main-20261107
Draft

SteelCrab wants to merge 6 commits into
boykopovar:mainfrom
SteelCrab:review/wgsl-main-20261107

Conversation

@SteelCrab

@SteelCrab SteelCrab commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What

Add a WGSL backend and anyps5-wgsl tools for WebGPU while keeping native shader cache keys, SPIR-V and encoded artifacts compatible with current main. WGSL requests use distinct cache keys. The production compiler source-version stamp still changes when compiler sources change.

This is the WGSL prerequisite of #6879 and replaces closed #9094. The relinker fix #10017 and Emscripten library portability #11341 have merged. Unsupported WGSL cases and host limitations are recorded in the shader debt file.

Tested

Ubuntu 26.04.1 x86-64, GCC 15.2, Node 26.12.0, Chromium 151.0.7922.34; main 399e7fb57e2e202e009227286212fc19a69d2eab, tested head 2125187a957e614bc4f4ba85e0f02fa71b7cf6b0.

  • Native shader-tools Release builds on main and the change passed. shader_native_snapshot: 1/1 passed on each; wgsl_native_compat: 1/1 passed on the change.
  • Three public compute fixtures produced 9/9 byte-identical native files between main and this head: cache keys, SPIR-V and encoded artifacts. Native-to-WGSL-to-native cache reuse and distinct target keys passed.
  • Browser WebGPU checked all three generated WGSL compute fixtures and created 3/3 compute pipelines on Chromium's SwiftShader Vulkan backend. Runtime format placeholders were set to representative values for this check. Five repeated browser checks passed; a malformed WGSL negative control was rejected.
  • Both verbose CTest runs used ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation on the same host; the native snapshot tests themselves are CPU-only. The browser pipeline check used the same variables with Chromium's SwiftShader Vulkan backend. Neither CTest log nor the pipeline log contained a missing-layer message, VUID- error or skipped case.
  • The full native library libs target built successfully on the change, including the production shader recompiler and NID patching.
  • Existing shader_cache_file_read and shader_cache_native_paths passed 2/2 on each tree, compiled from the respective sources through the same standalone CMake harness with the three Vulkan environment variables above. The change's full project build also ran those tests 2/2. In shader_cache_native_paths, two Windows-only Python cases were skipped on each Linux run.
  • Independent Windows report: contributor tested this head merged onto their main snapshot; the standalone shader tools built and the two CTests passed three times. This is not a full Windows build.
  • Local code and complete PR-template Conventions and git diff --check passed. Full product runtime suites, title execution and physical GPU tests have not run.

CI coverage: WGSL backend / native-compatibility-and-wgsl builds native main and the change, compares the nine native files, checks cache reuse, creates three Chromium WebGPU pipelines and rejects an invalid shader; it checks validation logs for missing layers, skipped cases and VUID- errors. Build / linux covers the full native library build and existing cache tests when a maintainer dispatches it; the automatic Linux job was skipped. Conventions / conventions checks repository and PR rules. Remote results for this updated head are pending. The earlier Naga/wgpu job passed on the previous head and is historical.

Draft work remaining: full product runtime tests, current-head hosted checks, and author coordination for the overlapping PRs below. The Chromium checker uses only Node built-ins and adds no third-party source or Cargo packages to the project.

Overlap review:

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Google SwiftShader software Vulkan via Chromium 151.0.7922.34, Ubuntu 26.04.1; no physical GPU tested
  • AI-assisted: yes

@JJenkx

JJenkx commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 2125187a95, merged onto main bfbb25cb72 (fde1deb30e, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. Configured as your workflow does: -DANYPS5_BUILD_SHADER_TOOLS=ON -DBUILD_TESTING=ON, in a separate build directory.

  • The standalone shader-tools configuration configures and builds cleanly with MinGW.
  • wgsl_native_compat and shader_native_snapshot pass in 3 of 3 runs.
  • Without -DBUILD_TESTING=ON that configuration registers no tests, because it returns before the usual test setup. Your workflow passes it explicitly, so that's only a note for anyone building it by hand.

Not covered here: the native-main snapshot comparison, the Rust wgsl-check tool, and the full emulator build with the changed Recompiler.cpp and ShaderDiskCache.cpp.

AI-assisted: yes.

@github-actions github-actions Bot added build shader core/shader docs ci .github labels Nov 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build ci .github docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants