startup: hash slot 57 pixel entry records in gfx2hlsl request keys #3448
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3448"
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 R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T10:25:40Z.
Change
Since #3094 (
71844ba0), a native-shader runtime build withX2W_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
ea68a605= mainf1236fd3+ 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 (f1236fd3) 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).ea68a605(runtime identical tof1236fd3), run with--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.1a0120bareadpipelines translated 2 / missing 9, with 9 key mismatches and 8400 translated / 167263 not drawn at 8400 executes. The mean level stayed at 0.00. Between1a0120baandf1236fd3neithergfx2hlsl.pynorshader_compute_request.cppchanged, and thed3d12_draw.inlchanges don't touch request keys. I did not runf1236fd3without 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