feat(recompiler): add WGSL with native cache compatibility #16391
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16391"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by SteelCrab on 2026-11-06T15:54:26Z.
What
Add a WGSL backend and
anyps5-wgsltools for WebGPU while preserving main's native cache keys, SPIR-V and disk-cache encoding. WGSL requests use distinct keys. Production compiler source-version stamps still change when compiler sources change.This is the WGSL prerequisite of #6879, replacing closed #9094. The relinker fix #10017 and Emscripten library portability #11341 have merged. Unsupported WGSL cases are recorded in
docs/dev/debt/changes/wgsl-native-cache.md. wasm-aot and runtime delivery remain separate follow-ups.Main
75b480e9c78ea1f13a7079f8f8457b990ea9f28dwas merged on 2026-12-01, preserving the reviewed commits and bringing in the upstream macOS replay fixdde92d5b17. The native target fields remain before the WGSL-only key suffix, with main's NaN-failure checks and native serialization. The existing fixture references passed on the refreshed main.The cache-key review is addressed by including all WGSL emission inputs in
WgslSource::Module's key. The key records input presence, compute workgroup and LDS sizes, pixel render-target modes and interpolation settings, and vertex embedded-fetch and clip-space settings. Float fields use their bit patterns. Existing specialization constant/binding keys are preserved, and requests with the same input values still reuse modules. This is confined to the WGSL module cache.Tested
Ubuntu 26.04.1 x86-64, GCC 15.2, Node 22.22.1 and Chromium 151.0.7922.34; baseline main
75b480e9c78ea1f13a7079f8f8457b990ea9f28d, tested head6f9c4ff1d06ea0704866c80a22742e9e8fb1d884.48938a5a32failed withinteger render target: reused stale WGSL modulewhen changing a pixel shader from float to integer output with identical constants and bindings. On the corrected head the tests pass for pixel render-target type, interpolation slot/mode/default and custom mask, vertex embedded fetch and clip-space transform (including +0/-0), compute workgroup dimensions and LDS size, missing/unsupported inputs, repeated identical inputs and restored inputs. Equal input values at different addresses also reuse the module.shader_native_snapshotpassed 1/1; the change'sshader_native_snapshotandwgsl_native_compatpassed 2/2. Three public compute fixtures produced 9/9 byte-identical native files: cache keys, SPIR-V and encoded artifacts. Native-to-WGSL-to-native cache reuse and separate target keys passed.shader_cache_file_read,shader_cache_native_pathsandrequest_serializertests: the four CTests passed 4/4 on each tree. Two Windows-only Python subcases skipped on each Linux run.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layerwith verbose CTest, on the same Mesa lavapipe / llvmpipe device (vendor10005, LLVM 21.1.8, Mesa26.0.8-1ubuntu0.3). Both native Vulkan logs confirm validation-layer insertion, with 0 VUID errors and no missing-layer diagnostic. The installed validation layer is 1.4.341, newer than pinned Vulkan headers 1.4.335. Snapshot and cache tests themselves are CPU-only.shader 0:. The checker selects Chromium's SwiftShader backend. The browser check used the four validation variables above; its log confirms layer insertion, without missing-layer or VUID diagnostics. Runtime format placeholders were set to representative values. This checks pipeline creation, not shader dispatch results.e71ac2f18epassed the full nativelibsbuild, including the production shader recompiler, AGC driver and NID patching, from recorded submodule source. Configuration: Release,BUILD_TESTING=ON,ANYPS5_USE_SYSTEM_DEPS=OFF,ANYPS5_ENABLE_SPIRV_TOOLS=OFF. That full project build also passedshader_cache_file_read,shader_cache_native_pathsandrequest_serializer3/3 with the four validation variables above; the same two Windows-only Python subcases skipped. This is not the complete product/runtime CTest suite.2125187a95. Full product runtime suites, title execution, vertex/pixel WGSL pipeline validation and physical GPU testing have not run.CI claim ownership:
native-compatibility-and-wgsllinuxandwindowsconventionsrelinker (macos-latest, clang++)The dedicated WGSL job tests the submitted head against its shared ancestor with main. The Build workflow tests the current merge. The external native Vulkan qualification is local evidence. The checker uses Node built-ins and Chromium with no new third-party source or Cargo packages.
The previous macOS relinker job failed
frame_capture_minimize_replaywhenkillpg(pid, 0)returnedEPERMduring process-group shutdown. The upstream fix retries that macOS condition within the existing timeout while still requiring the group to disappear. It adds regression tests covering both temporary and persistent errors. On Linux, the updated 22-case replay suite passed on main and prior head48938a5a32with 6 platform-specific cases skipped. On main's macOS runner, the replay test passed on the first attempt and the suite passed 1,026/1,026.On head
48938a5a32, the macOS relinker job passed 1,026/1,026. The previously failing replay test passed on the first attempt. The WGSL job, Conventions, Linux relinker and relinker ASan also passed. The automatic Windows build and tests and Windows relinker jobs passed. The automatic full Linux job was skipped and requires separate maintainer dispatch.Current head
6f9c4ff1d06passed local validation above and the WGSL backend job. Its log identifies the pinned baseline and exact candidate, passes the new pixel/vertex/compute cache regression, compares all nine native outputs, and creates 3/3 WebGPU compute pipelines. Conventions, macOS relinker, Linux relinker, Windows relinker and relinker ASan passed. The automatic Windows job passed. The full Linux job was skipped and requires maintainer dispatch.Landing order and overlap:
98b083ca99independently into main75b480e9c7and the WGSL head48938a5a32. With the default target in the three public fixtures, native keys, SPIR-V and artifacts matched 9/9 and both previews created 3/3 native Vulkan compute pipelines on the same llvmpipe device with the validation layer and zero VUID errors. The merged key appendscoherentBufferAtomicsbefore the WGSL-only suffix. #17611 head59203ed861still conflicts with this main in 12 files, so the two-prerequisite integration remains pending.tools/pr_overlap.py --branch review/wgsl-main-20261107 --base main --head-repo SteelCrab/AnyPS5scan against main1b8f79a5b5examined 2,147 open PRs and reports nine direct overlaps: #15548, #20130, #22690, #22703, #23242, #27811, #28102, #28295 and #28296. Another 70 PRs already conflict with main and could not be fully compared, including the unmerged prerequisites. The scan exits 2; this is not a compatibility pass. It checked merge commit5d564ffbff, before the reference-only test commite71ac2f18e; product sources are identical. The target-field, compiled-variant and artifact/result-size changes need integration review and combined testing after landing. Existing stacks (#17611 → #15548, #22690 → #22703 and #28102 → #28295/#28296) are preserved; no further author agreement is claimed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T11:02:23Z.
Review: COMMENTED
Reviewed — no blocking findings
Formal approval is not justified because the description identifies unresolved compatibility overlaps with active PRs, so their combined behavior remains unverified.
What I ran
2ad232555d9907fc9f11599ce3b32f9fa88ee615using the prepared diff andrepo_read.pyat the pinned head.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
manifest.json; no changed files were excluded by the manifest. Also readdescription.md,commits.md, and the relevant ranges ofdiff.patch. The review-folder README and the repositoryfiles.jsonwere not available through the reader.To get this to a good state
Nothing is required. Consider completing integration review after the overlapping PRs land; the description notes this remains outstanding.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T08:35:25Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this draft review; the documented limitations and pending full-build and hosted checks leave material uncertainty about merge readiness.
What I ran
Reviewed head
e71ac2f18ec7ff22c5e00368a62362e2e1db5cddusingrepo_read.pyagainst the prepared diff and targeted source ranges. No commands or tests were run by me.Results
Findings
Blocking
None.
Non-blocking
Not verified
The full native
libsbuild, hosted checks for this exact head, full runtime suites, title execution, physical GPU behavior, and vertex/pixel WGSL pipeline validation were not verified. I read the prepared description, commits, diff, manifest and all 20 changed-file paths listed by the manifest; nofiles/directory was available, so source ranges were read throughrepo_read.py. Files excluded by preparation rules were not reviewed, including lockfiles, minified files,dist/,build/, and SVG files, if any.To get this to a good state
Nothing is required. Optional: extend the browser checks to validate vertex and pixel WGSL pipelines and dispatch outputs.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-01T03:40:58Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: include every
inputInfovalue that affects WGSL output in the module cache key, or avoid reusing modules across different input info.What I ran
Reviewed head
48938a5a32f20438e51d8eb16b17f44987d6bc39using read-only source and diff inspection withrepo_read.pyand shell text searches. No build or tests were run.Results
Negative control
Not run; no test was executed to confirm that varying
inputInfoexposes the stale module.Findings
Blocking
WgslSource::Modulekeys cached modules using only specialization constants and bindings, but the emitter also usesinputInfoto generate WGSL. For example, pixel target output mode affects the generated output type, and vertex clip-space settings affect position output. A later request with the same constants and bindings but different input info can receive the earlier request's WGSL. Include all emission-relevant input info in the key or do not cache across it.core/shader/recompiler/WgslBackend/src/WgslEmitter.cpp:2286.Non-blocking
None.
Sources
Not verified
No build, tests, browser validation, or console/GPU execution was performed. The review bundle listed 20 changed files with none excluded by its file rules; 14 changed-file texts were fully inspected. The remaining six were not fully read:
core/shader/recompiler/tests/NativeSnapshot.cpp,core/shader/recompiler/tests/ShaderCompatibilityFixtures.hpp,core/shader/recompiler/tests/WgslTarget.cpp,core/shader/recompiler/tests/native_snapshot/CMakeLists.txt,docs/dev/debt/changes/wgsl-native-cache.md, andtools/wgsl-check/check.cjs.To get this to a good state
Include emission-relevant
inputInfoin the cache key or disable reuse across differing input info, and add a regression check that requests modules with identical constants and bindings but different input info.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T14:28:09Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed prepared diff and source context at head
6f9c4ff1d06ea0704866c80a22742e9e8fb1d884. No tests or builds were run; this was a static review usingrepo_read.pyand the prepared review files.Results
Findings
Blocking
None identified in the portions reviewed.
Non-blocking
None.
Sources
Not verified
Source context was read from 13 of the 20 changed paths: workflow, top-level and recompiler CMake files,
CacheKey.hpp,CompiledVariant.hpp,Recompiler.cpp,Recompiler.hpp,ShaderDiskCache.cpp,WgslEmitter.hpp,WgslEmitter.cpp,WgslTarget.cpp, tools CMake,WgslCompile.cpp, andWgslTarget.cpptests. Several were read only at changed hunks or targeted ranges. The full WGSL emitter and these changed files were not read:WgslTarget.hpp,NativeSnapshot.cpp,ShaderCompatibilityFixtures.hpp,native_snapshot/CMakeLists.txt,docs/dev/debt/changes/wgsl-native-cache.md, andtools/wgsl-check/check.cjs. The manifest lists 20 reviewed paths and no excluded paths. A complete review and independent test execution are not verified.To get this to a good state
Nothing is required. The review remains incomplete, so no approval decision is justified.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:37:27Z.
Review: COMMENTED
The trial merge onto
c1601e56d5was clean. I reviewed the native snapshot comparison and separate WGSL key. The workflow installsvulkan-validationlayersfrom the runner repository and checks that a layer was inserted, but it does not verify its version. Please enforce the repository’s minimum layer version for the Vulkan run. Also keep the host-only byte-for-byte snapshot result distinct from browser execution of the generated WGSL and ensure each native Vulkan case used for comparison runs on both arms.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.