tooling: stage shader patches from a patch manifest #3878
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3878
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3876"
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?
@Ammmae0x on GitHub · 2026-12-02 17:07 UTC · original
Ammmae0x:tooling/shader-patch-stage→main· +797 −0 · 5 files · 1 commits · openPer-key shader-cache override consumer for
kind = "shader"manifests (docs/experiments/patch-manifests.md).What landed — single commit on
tooling/shader-patch-stage, offorigin/main8121ca99, pushed to the fork with no force-push. 5 new files only, +0/-0 elsewhere:tools/shader_patch.py— CLI (manifest,input,cache_dir,--report,--runtime-root) + library API (runtime_revisions(root),stage(...)). Reusespatch_manifest.loadfor the manifest schema and[target] input_sha256gate. Reads the runtime's current key revisions from the runtime sources, refuses a patch whose revision is not the current one, and validates every shader patch completely (revision + every replacement file's SHA-256, over the bytes read in memory and staged verbatim, never re-read) before writing a single file. Memory patches in a combined manifest are left untouched; a manifest with no shader patches is refused. Staged files are written atomically (tempfile incache_dir+os.replace) ascache_dir/<key><ext>, blobs first and the manifest marker (.txt/.mesh86.txt) last, matching the runtime cache publication order. Symlinkcache_dir, symlink destinations and symlink/non-regular replacement files are refused. Report is{manifest_sha256, input_sha256, patch_ids, staged_files}to--reportor stdout; validation/IO failures exit 1 with a conciseshader patch: ...message and no traceback.tests/shader_patch_check.py(14 tests),tests/cmake/shader_patch.cmake(shader_patch_controls),tests/checks/python-linux/shader_patch.txt,docs/experiments/shader-patches.md.tools/patch_manifest.py,tools/exe_aot.pyandtools/cpu_stdio_exe_aot.pyare untouched, so this stays disjoint from the memory-patch work onexe_aot.Spec note (flagged, not silently followed): the task text said the compute revision comes from
src/startup_stubs/d3d12_compute_dispatch.inl. It does not: that file contains no revision literal at all (and no mention ofcompute_revision). It consumestr.key, seeded insrc/startup_stubs/d3d12_draw.inlfromshader_cache::compute_revision(fnv_bytes(shader_cache::compute_revision, ...)), which is where the compute literal lives, beside the graphics one. The tool reads both files (refusing a dispatch literal that disagrees with draw's) and the check pins this, so a future move of the literal is caught instead of silently reading a stale value. Current revisions on this checkout: graphicsx2w-startup-shader-29, computex2w-startup-shader-29cs, mesh86x2w-startup-mesh-86-1.Tests — all three pipelines with and without their optional file (graphics ±
.gs.cso, compute ±.cs.hlsl, mesh86 ±.ps.cso) using the real current revisions; combined memory+shader manifest stages only the shader override; wrong input/file hashes with no partial apply (bad 2nd patch leaves the cache completely empty); stale revisions; missing/symlinked replacement files; symlink destination/cache_dir; memory-only manifest refused; CLI report to stdout and to--report; two mutations (revision guard dropped, SHA-256 guard dropped) each let their bad input through, proving the refusal tests pin the guards.Linux (this host,
/tmp/pe-env/bin/python, Python 3.12.3, pefile 2024.8.26):tests/shader_patch_check.py: 14 tests, all passedtests/patch_manifest_check.py: 9 tests, all passedtests/form_coverage_check.py: passedtests/docs_links_check.py: 252 Markdown files, 961 links, passedtests/bidi_controls_check.py: 2992 tracked files, no bidirectional controlsgit diff --check origin/main...HEAD: cleangit merge-tree --write-tree origin/main HEAD: exits 0Full-repo Python suite not run locally per instructions; GitHub Actions runs it on push. No mingw/MSVC on this host, so no Windows compile check; Windows execution awaits WIN-VERIFY.
Refs #3037, #3119.
Windows verification (MSVC
dev+releaseon98809240):ctest --preset dev --no-tests=error -R '^(shader_patch|patch_manifest)' -V: 2/2 passed (patch_manifest_controls9/9,shader_patch_controls14/14, 2.76s)ctest --preset release --no-tests=error -R '^(shader_patch|patch_manifest)' -V: 2/2 passed (patch_manifest_controls9/9,shader_patch_controls14/14, 2.61s)tests/form_coverage_check.py,tests/docs_links_check.py(252 files, 961 links),tests/bidi_controls_check.py(2992 files),git diff --check upstream/main...HEAD: passedWIN-VERIFY: passed | sha=9880924080031b2a0c319d588592f52c746250ef | ctest=^(shader_patch|patch_manifest) | release=true
AI-assisted.
@R0Y00 on GitHub · 2026-12-02 22:30 UTC · original · requested changes
On
98809240, both Python suites passed independently on Windows (tests/shader_patch_check.py14/14 andtests/patch_manifest_check.py9/9). I also tested replacing a populated cache using the existing synthetic graphics fixture. With a write failure injected at.ps.cso,stagereturned an error after changing.vs.cso. The cache was left with the old.txtmarker, the new VS, and the old PS. Since a marker was already present, writing the new marker last does not prevent a reader from seeing a mixed pair. Please define and enforce the populated-cache contract. Refusing replacement before writes and directing callers to stage into a fresh cache would be one small way to keep the published pair intact. If in-place replacement is required, protect the old pair through the failure path and add a seeded-cache I/O failure control.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.