From 3670af8b517634325a71a66c28bb9f19f72db0f7 Mon Sep 17 00:00:00 2001 From: c1 Date: Thu, 26 Nov 2026 12:29:32 +0100 Subject: [PATCH 1/3] feat: warn when the shader cache and the translator come from different revisions The runtime writes its graphics, compute and mesh57 key revisions to /revision.txt before its first request. run.ps1 and run.sh compare it with the gfx2hlsl.py they start (tools/startup/shader_cache_revision.py) and print one warning with both revisions and the fixes; a cache with requests and no revision.txt warns too. -FreshShaderCache / --fresh-shader-cache moves a cache that is not empty aside. Fixes #2815. --- .github/workflows/windows.yml | 1 + CMakeLists.txt | 3 + docs/startup-runtime.md | 11 +- src/startup_stubs/d3d12_draw.inl | 46 ++++-- tests/startup_compute_request_check.py | 17 ++- tests/startup_indirect_draw_indexed.cpp | 3 +- tests/startup_run_ps1_check.py | 24 +++- tests/startup_run_sh_check.py | 39 ++++- tests/startup_shader_cache_revision_check.py | 110 ++++++++++++++ tools/startup/run.ps1 | 23 ++- tools/startup/run.sh | 31 +++- tools/startup/shader_cache_revision.py | 143 +++++++++++++++++++ 12 files changed, 433 insertions(+), 18 deletions(-) create mode 100644 tests/startup_shader_cache_revision_check.py create mode 100644 tools/startup/shader_cache_revision.py diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 5c25411c74..bf4eaa8353 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -302,6 +302,7 @@ jobs: tests/startup_compute_request_offline_check.py \ tests/compute_container_index_check.py \ tests/startup_shader_cache_rekey_check.py \ + tests/startup_shader_cache_revision_check.py \ tests/startup_gfx2hlsl_scalar_m0_check.py \ tests/startup_gfx2hlsl_waitcnt_depctr_check.py \ tests/startup_mesh57_skeleton_check.py \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 25c7f646c2..37e3fff815 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4908,6 +4908,9 @@ if(EXISTS "${INTAKE_PYTHON}") "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_shader_cache_rekey_check.py") add_test(NAME runtime_shader_cache_rekey_cli_check COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_shader_cache_rekey_cli_check.py") + # The launchers' warning when the shader cache and the translator come from different revisions (#2815). + add_test(NAME startup_shader_cache_revision COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_shader_cache_revision_check.py") # Partial colour exports carry their channel mask to the manifest; compressed exports of whole pairs lower (#1674). add_test(NAME startup_gfx2hlsl_export_mask COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_export_mask_check.py") diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index eb04947379..5ca10640fc 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -1514,7 +1514,16 @@ handle returns `0x80004005`. The startup shader cache key includes the translator revision. After updating from an earlier translation revision, run the recording build once to emit requests, run `python tools/startup/gfx2hlsl.py --pending `, -then start the build again. The new key keeps the former bytecode and manifest +then start the build again. +The first request of a process also writes the runtime's revisions to `/revision.txt` +(`graphics`, `compute` and `mesh57` lines). With `-Render -Translate` (`--render --translate`), +`run.ps1` and `run.sh` compare that file with the `gfx2hlsl.py` they start +(`tools/startup/shader_cache_revision.py`) and print one warning naming both revisions when they differ, +or when the cache holds requests but no `revision.txt`: every cached request would be refused as a key +mismatch. The warning comes before the watcher starts, or after the run when the run's own stand-ins +wrote the first `revision.txt`. Rebuild the stand-ins from the same checkout, or start with an empty cache: +`-FreshShaderCache` (`--fresh-shader-cache`) moves a cache that is not empty to `.old--