Repository navigation
startup: hash slot 57 pixel entry records in gfx2hlsl request keys - #3448
Merged
tedin7 merged 1 commit intoNov 29, 2026
Merged
Conversation
The runtime and the native request reader fold req_<key>.ps57in into a slot 57 pipeline's key (71844ba). gfx2hlsl did not, so it refused every such request with "shader request source key mismatch". pipeline_key now hashes the record's 12 bytes as stored, after .ia. load_request reads and validates the record and refuses a request that has both .psin and .ps57in. The translation does not read the record's values. startup_shader_cache_key covers the new identity with known answers from the C++ reader. It also runs in the Linux Python job now.
Ammmae0x
added a commit
to Ammmae0x/Xbox2Windows
that referenced
this pull request
Nov 29, 2026
…the remaining gaps R0Y00#3448 already hashes .ps57in into pipeline_key (read_slot57_entry / slot57_entry) and R0Y00#3449 already made the launcher default to X2W_NATIVE_SHADERS_ONLY=1, so this branch drops its duplicate read_ps57_inputs and its run.ps1 edits and keeps only what main lacks: request_ps_inputs takes the pixel input masks from the entry and validates its layout, translate_request writes no .psdep for an entry, shader_cache_rekey carries .ps57in, and cached_translation reuses a cached plain-key translation outside native-shaders-only mode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Since #3094 (71844ba), a native-shader runtime build with
X2W_NATIVE_SHADERSset folds a slot 57 pipeline's pixel entry record into the graphics request key. It also publishes the record asreq_<key>.ps57in(PSI1followed by 8 bytes of fixed graphics state).src/shader_compute_request.cpp(read_graphics_request) checks that same key.tools/startup/gfx2hlsl.pywas not updated:pipeline_keyhashed.psinmasks but not.ps57in, sotranslate_requestrefused every such request withshader request source key mismatch. When the native path also refused one of these pipelines, nothing could ever be published for its key, and its draws were skipped.This change makes gfx2hlsl compute the key the way the runtime and the C++ reader do:
pipeline_key(..., slot57_entry=b'')hashes the record's 12 bytes as stored, last (after the optional.ia), likecached_translationandgraphics_request_key. Without a record the key is unchanged.read_slot57_entryreadsreq_<key>.ps57in. A record that is not 12 bytes or does not start withPSI1is refused asinvalid slot-57 pixel entry record.load_requestincludes the record in the base and RTV-source key checks. It refuses a request that has both.psinand.ps57inwithconflicting stream and slot-57 pixel entry records, the C++ reader's wording.The runtime is not changed. The native path needs PSI1 in the key, because
direct_compute_cache.cppreads the record's two words. Dropping the record from the runtime key would give pipelines that differ only in that state the same key, and the native reader would then refuse every slot 57 request as stale.Cache effect. Results that a cache holds under keys computed without the record (for example, from before #3094) are not used for these pipelines. Each such pipeline translates once more under its current key. This PR does not cause that; the runtime has used these keys since #3094. With
X2W_SKIP_FAILED=1, a cache in which gfx2hlsl already wrote a.failfor one of these keys keeps skipping it until that.failis removed.Refs #3094
Verification
Commit ea68a60 = main f1236fd + this change. All checks ran on a Debian Linux 6.12 host. I don't have MSVC or a Windows machine.
python -B tests/startup_shader_cache_key_check.pyslot 57 entry:lines, last linestartup shader cache key checks: passedwindows.ymlruns it (python -B tools/run_checks_parallel.py --from-dir tests/checks/python-linux ...), which now includestests/checks/python-linux/startup_shader_cache_key.txtall 261 checks passed, exit 0python -B tests/startup_tools_lint_check.py tools/startupstartup_archive_requests_cli,startup_gfx2hlsl_buffer_store,startup_gfx2hlsl_export_mask,startup_gfx2hlsl_fract,startup_mesh86_cache_cli,startup_shader_cache_rekey_clinative_compile_dxil_rekey,native_rtv_variant,native_startup_request_cache,startup_indirect_mesh_cache,startup_mrt,startup_rect_gapctest --preset dev --no-tests=error -R '^startup_shader_cache_key$' -VMutations. Each was applied to a byte copy of
gfx2hlsl.py, run against the key check, and restored (sha256 verified):load_requestignores.ps57in(the behaviour on main)unsupported: shader request source key mismatchon the first slot 57 caseread_slot57_entryaccepts any recordok)pixel input description names another pipelineinstead of the conflict diagnosticpipeline_keyignoresslot57_entry.psinmasksThe new known answers (
0x9ffda271506f7dc6,0x06315afc32bae986) come fromx2w::graphics_request_key, run in a separate driver built with g++ 14.2 againstsrc/shader_compute_request.cpp. The same driver reproduces the existing plain and.iaanswers (a837b162afd547ce,6d5c0b7786182e0e). Itsread_graphics_requestaccepts the keyed synthetic request and refuses the unkeyed one and the short, long, mistagged and empty records, as gfx2hlsl now does.Evidence and follow-up
The fixture uses the test's existing source-built VS/PS/root blobs and synthetic records. It needs no GPU, compiler or game files (
X2W_FXC='', manifest only).Local data from a console executable (SHA-256
e95020b2fa4a721d…). These are Wine results only: Proton Experimental 11.0-20261123b with vkd3d-proton 30b0eb9b on an NVIDIA GeForce RTX 4070 Ti SUPER, driver 550.163.01, no debug layer, no Windows build. Nothing here was measured on Windows..ps57inthat a run on main refused: main's gfx2hlsl (f1236fd) gives 9 ×shader request source key mismatch. With this change: 9ok, 0.fail. The HLSL equals what the cache held for the same stages under keys without the record (18/18 files). The manifests match too (9/9, key names normalised, line endings ignored).--render --translatefrom a fresh copy of the same starting cache. At about 3 minutes,translate.txthas 9 ×ok(exactly the 9 keys above), 0 key mismatches, andpipelines translated 11 / missing 0. At 4800 executes there were 90495 translated draws and 6134 not drawn, and the not-drawn count stopped growing after about 2100 executes. The runtime still logs the 9 native refusals; the gfx2hlsl results load after them through the manifest retry. The presented surface's mean level went from 0.00 to 91.82 after about frame 2370.pipelines translated 2 / missing 9, with 9 key mismatches and 8400 translated / 167263 not drawn at 8400 executes. The mean level stayed at 0.00. Between 1a0120b and f1236fd neithergfx2hlsl.pynorshader_compute_request.cppchanged, and thed3d12_draw.inlchanges don't touch request keys. I did not run f1236fd without this change.Not covered:
tools/startup/shader_cache_rekey.pyneither hashes nor copies.ps57in, so it does not handle these requests correctly. That is the same on main and would be a separate change.Checklist
AI-assisted