Repository navigation
startup: apply .ps57in pixel masks, carry .ps57in through rekey, and reuse cached plain-key translations - #3410
Conversation
…ations With X2W_NATIVE_SHADERS set, cached_translation appended the PSI1 slot 57 entry to every ordinary graphics key, so a translation already cached under the plain key never hit and the Python fallback refused the suffixed request because it never read .ps57in. Read the 12-byte slot 57 pixel entry in the fallback, validate it against the suffixed key, and apply its address as both pixel input masks; carry the entry unchanged through cache rekeying; reuse an already published plain-key translation in cached_translation; and restore X2W_NATIVE_SHADERS when run.ps1 exits so later runs without -NativeShaders are not polluted. Fixes R0Y00#3385
|
Reviewed
A start-up run with Point 1 should be fixed before merge; 2-4 at the author's choice. |
|
Addressed in
Windows verification ( AI-assisted. |
Leyukaka
left a comment
There was a problem hiding this comment.
Re-read 24755d1f by its diff (ec57297d...24755d1f, 3 files) and the full diff against the merge base.
- Fixed.
cached_translationskips the plain-key reuse whennative_shaders_only()(d3d12_draw.inl:665), so the entry stays in the key and in the request in that mode, as on main. Pinned by source text with the mutantnative-shaders-only guard removed. read_ps57_inputsnow refuses anything but address 2 or0x8002with 1 to 7 interpolants. The native path additionally checks the count against the reflected pixel interface's attribute count and the address against its reflected input address (src/direct_compute_cache.cpp:723-728). The Python reader has no reflected interface, so that part stays native-only, as the body says. No change requested.- Stated in the body.
- All three covered: no
.psdepfor the RTV variant of a suffixed request, the(pixel_entry.empty() ||pin with the mutantpublish gated on the wrong entry, and the 13-byte entry refused asinvalid slot-57 pixel entry record.
Not covered: the cached_translation change is checked by source text only, and startup_gfx2hlsl_ps57in is not in the pr test preset, so on this PR CI runs it in the Linux Python job only (tests/checks/python-linux/); the Windows results are the ones reported in the body. No -NativeShaders run comparing main and this head on a warmed cache.
Approving 24755d1f.
|
#3448 ( What main still lacks from this branch:
Could you rebase onto main's |
|
Review of MUST
SHOULD (for the cut-down version)
AI-assisted. |
…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.
|
Rebased onto
AI-assisted. |
|
Re-review of What it still adds after #3448
Measured on a local warmed cache. A runtime that left the slot-57 entry out of the key built this cache. After #3448, a
So the reuse would have hit all 12 at pipeline creation. That part is inference: I did not run it. The rekey part would not have changed this cache. Without the reuse, the run skipped those pipelines' draws until the background translator landed them, and 3 had not landed by exit. Tests:
CI on SHOULD
NIT
AI-assisted. |
Fixes #3385
With
-NativeShaders, ordinary direct graphics pipelines stopped translating:cached_translationappended thePSI1slot 57 entry to every graphics key, so a translation already cached under the plain key never hit, and the Python fallback refused the suffixed request because it never read.ps57in(shader request source key mismatch).#3448 (
ea68a605) already landed the key half of that onmain:read_slot57_entryandpipeline_key(..., slot57_entry=...)hash the entry bytes into the key, and the request reader refuses a malformed entry. #3449 already made the launcher default to native-shaders-only mode. This PR mergesorigin/main(5de0b114, merge commit1fdd1f7f, no force-push) and is cut down to the three piecesmainstill lacks:tools/startup/gfx2hlsl.py(request_ps_inputs+.psdepguard): takes the pixel input masks from the entry throughmain'sread_slot57_entry— the entry's address is both masks, as the native fixed entry builds them — refuses a request with both.psinand.ps57in, validates the entry's layout (address 2 or0x8002with 1 to 7 interpolants, as inprepare_direct_graphics), and verifies the suffixed key. No.psdepis recorded for a slot 57 entry, since its bytes are part of the key. The native path additionally bounds the interpolant count by the pixel interface's attribute count, which the Python fallback cannot know; that bound stays native-only.tools/startup/shader_cache_rekey.py: carries.ps57ininPARTS/OPTIONALand passesslot57_entry=entrytopipeline_keyincurrent_key(), so a rekeyed slot 57 request is written under its suffixed key with the entry copied unchanged instead of under the plain key with no entry. A request with both records is refused.src/startup_stubs/d3d12_draw.inl(cached_translation): when a translation is already published under the plain key, reuse it instead of suffixing the key. Only a cold pipeline keeps the entry in its key. The reuse is skipped whennative_shaders_only()is true.What each piece does on the default launcher path vs
-Translate(@JohnConnorNPC SHOULD #1): since #3449,run.ps1/run.shsetX2W_NATIVE_SHADERS_ONLY=1unless-Translateis given. In that mode thecached_translationplain-key reuse is skipped (!native_shaders_only() && cache_path(...)), andload_translationnever reads a.txtmanifest, so the masks and the reuse only change-Translateruns. The.ps57inentry itself is built only whenX2W_NATIVE_SHADERSis set; on a-Translaterun that variable comes either from-NativeShadersor from what a previous run in the same PowerShell session left behind.tools/startup/run.ps1is untouched by this PR (zero diff againstmain).Tests:
tests/startup_gfx2hlsl_ps57in_check.py(new, CTeststartup_gfx2hlsl_ps57in): suffixed-key known answer, suffixed request translates and applies the entry masks, plain request still translates without them, address 2 and 7-interpolant entries translate, RTV variant of a suffixed request translates, rekey copies the entry, and negative controls (bad-layout addresses, 0 and 8 interpolants, bad prefix, short and 13-byte entries, both records, entry under the plain key, wide address, bad rekey). Mesh57 native requests still translate. The check also pins thecached_translationguard with in-test mutants.tests/startup_shader_cache_key_check.py: the slot 57 block's "translation does not read the record's values" case is replaced — an address outside the fixed entry's layout (address 3) under its own key is now refused asinvalid slot-57 pixel entry layout, sincerequest_ps_inputsreads the address and count. The key still hashes the record as stored, and a key-mismatched entry is refused byload_requestasshader request source key mismatch.Checks run on Linux (this host cannot run Windows CTest or
compile_dxil):python -B tools/run_checks_parallel.py --from-dir tests/checks/python-linuxwith the affected checks — all 61 checks passedpython -B tests/startup_translator_check.py— 0 failedpython -B tests/startup_gfx2hlsl_watch_check.py— passedpython -B tests/startup_gfx2hlsl_refusals_check.py— passedpython -B tests/startup_archive_requests_check.py— passedpython -B tests/startup_flat_param_check.py— passedpython -B tests/startup_mesh57_skeleton_check.py— passedpython -B tests/run_checks_parallel_check.py— okpython -B tests/form_coverage_check.py— passed (throwaway venv, needsiced-x86)python -B tests/docs_links_check.py— passed (175 Markdown files, 711 links)python -B tests/bidi_controls_check.py— passed (2670 files)py_compileon the touched Python files — okgit merge-tree --write-tree origin/main HEAD— exits 0;git diff --check— cleanSpot mutations (on sandbox copies outside the repo, each restored after), each made the new check fail as expected: dropping the layout validation in
request_ps_inputs(bad-layout entries then translate); dropping the.ps57infile check from the.psdepguard (the suffixed request then writes a.psdepand is no longer complete); dropping the entry branch from rekeycurrent_key(the entry is not copied under the suffixed key); removing!native_shaders_only() &&from the plain-key reuse guard; and dropping the mutual-exclusion check inrequest_ps_inputs(both records are then accepted there;load_requeststill refuses them).Not verified here: Windows CTest,
compile_dxil, and the native graphics draw path; those are for the WIN-VERIFY run.Review feedback addressed (@Leyukaka, @JohnConnorNPC):
main'sread_slot57_entry/slot57_entry(startup: hash slot 57 pixel entry records in gfx2hlsl request keys #3448) and kept only the three gaps above; the duplicateread_ps57_inputsand therun.ps1edits are dropped, andrun.ps1has zero diff againstmain. The layout check (address 2 or0x8002, 1 to 7 interpolants) lives inrequest_ps_inputs, as asked.mainare resolved by merge (no force-push); the PR builds onmain's reader, with no second reader. SHOULD Run the native wave64 BVH fixture on a supported Windows GPU #1: the default-path vs-Translatebehaviour is stated above. SHOULD Check the first build from a fresh Windows checkout #2: theshader_cache_rekey.pypart is kept as its own piece, as above.X2W_NATIVE_SHADERS_ONLY=1keep the.ps57inentry in the key.Windows Verification
1fdd1f7fb1e3261df9780a82c298fb0e1c00639cdev:ctest --preset dev --no-tests=error -R '^(startup_gfx2hlsl_ps57in|startup_shader_cache_key|startup_tools_lint)$' --output-on-failure->3 passed, 0 failed(2.27s); also^(startup_shader_cache_rekey|startup_translator|startup_run_ps1)$->3 passed, 0 failed(40.91s)release:ctest --preset release --no-tests=error -R '^(startup_gfx2hlsl_ps57in|startup_shader_cache_key|startup_tools_lint)$' --output-on-failure->3 passed, 0 failed(1.97s)form_coverage_check.py,docs_links_check.py(175 Markdown files, 711 links), andbidi_controls_check.py(2666 files) passed.AI-assisted.