Shaders: apply the console's pixel shader export patches #3209
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3209"
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 ivall/xcl. Originally posted by Eterst on 2026-11-28T20:08:37Z.
A pixel shader's render-target exports are stored for one export format, the compiler's default FP16 (
v_cvt_pkrtz_f16_f32and a compressedexp). The console patches them at pipeline creation for each target'sSPI_SHADER_COL_FORMAT, from a table in the PS stage data. XCL never applied that table, so a target of 32 bits a channel got the FP16 conversion of its value. In a retail title, a packedR32_UINTlighting target heldf16(asfloat(bits))(0x7BFFwhere the packed value was large) instead of its bits; on screen that showed as a blue-white glow on skin and lit surfaces. This applies the table: every target gets the 32_ABGR variant, so the channels leave the shader unconverted and the PC target converts them. Part of #505.How this relates to #3200 (merged 2026-11-29, after this PR was opened; it fixes the same symptom)
rt32_maskfrom the PSO), when its liveness check allows it (it declines when an aliased conversion destination stays live after theexpor reaches a branch or join).main(now0fe06eb0) joins the two cache-name changes: a pixel shader's translated-cache file name carries this PR's export mode and #3200's_rt32_<mask>(in that order, so #3200's test is unchanged).What is in it (one commit)
crates/xcl/src/gpu/xbox.rs:patch_ps_exports, called fromanalyze_fssmfor FSSMs whose code region comes from the header (version 0x101). Per render target it copies the 32_ABGR variant over the stored export code. A table that is implausible (no PS record, a patch size of 0 or over ten dwords, a patch past the end of the code, an empty variant) changes nothing.XCL_PS_EXPORT_PATCH=0keeps the stored exports. Two tests: the patch lands on the right dwords and nothing around them changes; each kind of implausible table leaves the buffer byte for byte the same.crates/xcl/src/gpu/recomp/pso.rs: a pixel shader's entry in the translated-shader cache names its export mode (translated::exports_mode), so a warm cache does not hand one mode's translation to the other; older unlabelled pixel entries are not read. Found and fixed by @andrewDoing in review; the cache-name test asserts it.README.md: one note on the patches and the switch.THIRD_PARTY.md: the table layout (record at payload + 0x30, stage data at record + 0x54, size at + 0x148, eight entries from + 0x14C, ten variants of ten dwords) is as VIctory documents it invictory-shader/src/native.rs(GPL-3.0). The code here is written independently; VIctory's row says so.gpu/xbox.rsis one of the translator's sources, so the translation cache identity changes with this PR.Tested
bb0679fbonmain3b6a91ed. The head is now710a5f4f, the same commit rebased ontomain0fe06eb0to pick upmain's test fixes:main's geometry tests failed CI at3b6a91edand were fixed in468190c2, and CI on601481ed(onbc2cbb72) failed in the fourpipeline_library/warm_librarytests of #3180, which #3221 (2c003dd6) fixes. On710a5f4f,cargo test -p xcl --lib -- recomp::pso xbox:: rt32 ps_32bit_rt_export pipeline_library warm_library pipeline_cap_tests --test-threads=4: 72 passed, 0 failed, 1 ignored, no SKIPPED. RTX 4070 SUPER 12 GB (driver 621.40), Ryzen 7 5700X, 32 GB RAM, Windows 10 19045, Rust 1.100.0; tests in debug, the title in release; all runs with a cache directory of their own (XCL_DXIL_CACHE).cargo test -p xcl --lib -- recomp::pso xbox:: rt32 ps_32bit_rt_export: 57 passed, 0 failed, 1 ignored (this PR's tests and #3200's).cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: the integration harnesses 138 passed, 1 failed, 20 ignored. The failure,e2e::test_title_runs_and_game_folder_is_untouched("a texture in title memory (XG layout, #44) follows CPU writes: subresource 2 row 0 differs"), passed 2 of 2 runs on its own on both this head andmain3b6a91ed. The library harness ended early, with exit code0x80004005after "sparse upload preparation still failed after bounded retries – the title is stopped before its GPU submission" (prepare_title_submission→end_title), as it does onmain(reported before on this PR).--test-threads=1) in parts, on this head and onmain3b6a91ed:list_x::tests: 104 passed, 0 failed on both;sparse::tests: 140 passed, 0 failed, 1 ignored on both. (A full single-threaded run ended with the abort above inside these groups, atsparse::tests::a_buffer_over_a_remapped_tile_reads_the_new_page, which passes on its own on both.)--skip list_x::tests --skip sparse::tests): on both, the run ended with the same abort at the same test,texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays. Up to there: this PR 1,585 passed, 4 failed;main1,583 passed and the same 4 failed (the 2 more are this PR's tests). The 4 aremain's own geometry tests:geometry_tests::gpu_geometry_msg_gs_done_records,geometry_tests::msg_gs_done_emits_in_dxil,lower_geom::tests::gpu_epilogue_filters_oob_triangles_and_no_store_emits,lower_mem::stage_guard_tests::geometry_export_rejected.e8782653onmain10d27297) the whole library ran single-threaded: 2,012 passed, 7 failed, 28 ignored, againstmain's 2,010 / 7 / 28, the failuresmain's own.SKIPPEDon this adapter, 26 lines, the same on both: 22 "no wave64", 3 per-lane f16 refusals ("its #1426 semantics differ from the console's"), 1 "no heap windows (opt-in: XCL_HEAP_WINDOWS=1)". None is a test of this PR.Regression run
scripts/smoke.ps1, 200 s, the same title, no input,XCL_PREPARE=0on both (both build in game what they use), each run with its tree's ownscripts/smoke.ps1and with a cache directory of its own.main:
this PR's head:
Not tested
UINT16/SINT16formats): not by me; @andrewDoing checked them on an RTX 5070 in review (in-range values preserved on both shader paths).AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by jessenic on 2026-11-28T20:50:46Z.
A test report from another card and another tree: the blue-white skin is gone with this patch.
Tested
e8782653cherry-picked onto my lab line (jessenic/xcllab/two-pass-batch,bdac3b84; the two doc files conflicted and I kept mine,xbox.rsapplied cleanly). Not this PR's own head onmain.cargo test --release -p xcl --lib ps_export_patch: 2 passed, 0 failed.XCL_DEBUG_MAGENTA=42a7d936b37ac3e1(TL_PS_PBR_MATERIAL_SKIN) had shown earlier that this program's output is what goes wrong on the head (#505, 7242576967), which fits the cause given here.One thing I had to add on my line, which may matter here too: the patch changes the code a pixel program is translated from, not the blob the title hands over. Where the translated cache is keyed by that blob's hash, a translation cached before the patch is served as it was. I gave the cache identity a salt when the patches are on (every shader is translated again once, about 5 more minutes to the world on the first launch). I did not check how
mainkeys it.Not tested
main; AMD; other scenes than the cell.AI use: Claude Code with Claude Fable 5.2 cherry-picked the commit, ran the tests and the runs on this machine, and wrote this report. No frame posted.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T21:04:05Z.
I checked the 16-bit integer render-target case listed under “Not tested” on exact head
e87826532e98a43353e255665ff19bf2bd93106c, RTX 5070 / NVIDIA 616.92. In both tested cases the patched export preserved the intended in-range integer, with identical results through HLSL + DXC and direct DXIL.The synthetic v0x101 FSSM had a header-located pixel program, a stored
V_CVT_PKRTZ_F16_F32and compressed export, and a 32_ABGR variant exporting the source VGPR directly. I used the productionanalyze_fssmpath, asserted the switch actually changed the code, translated that code with the corresponding signed or unsigned output signature, drew to a native 4×4 target, and read back each 16-bit texel after a fence.All eight shaded texels per draw matched the value shown. The eight texels outside the scissor retained the clear value
0011in every draw. Four fresh switch/format processes exercised both translators, for eight native draws and zero skips.This establishes the PC output for these two representable values in a one-target synthetic shader. It does not compare against a console capture, cover out-of-range conversion, or establish whether a retail title uses these formats.
AI use: OpenAI Codex built the test-only FSSM and typed render-target fixture, ran the controls, and wrote this report.
Imported from ivall/xcl. Originally posted by BBareth on 2026-11-28T21:57:27Z.
A test report from GTA 6's intro cutscene (#505): with this patch the night, sunset and daylight shots are exposed far closer to correct.
Tested
e8782653cherry-picked (same patch-id) onto our test tree: nvidia-dev54225f58+ a port of #2799 + #3094 + KDenKC's sampler-prelude rule + #3179 + #2956, plus a local logging-only commit. README conflict only.cargo test -p xcl --lib ps_export: 2 passed, 0 failed, 0 ignored.XCL_ALIAS_COPY=1 XCL_DRED=1 XCL_PLACE_RETIRE=0. One warm-up run first, because the patch changes the translation cache identity. Then a measured run, A at 300 s, 800 s long. Compared with the same tree and env without this PR (earlier run, A at 300 s, 750 s).Seen, same shots, without the PR → with it
Not fixed / not attributable to this PR
AI use: test run and report by Claude Code, Claude Opus 5.5.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T22:34:00Z.
A warm translated-shader cache can mask
XCL_PS_EXPORT_PATCHin either direction one8782653. I ran four fresh Windows processes through the productionpso::console_to_dxil_inpixel caller, using the same synthetic v0x101 Xbox pixel container, a real uint SV_Target output signature and a valid 32_ABGR table. Each process also independently parsed the container and asserted that the actual export instructions matched its switch setting.5ad4c1e3259a2aa95ad4c1e3259a2aa99be258cbc57a259c9be258cbc57a259cThe two cold translations differ as expected. In both warm processes the decoded instructions switched, but the returned DXIL still matched the first process. The translated cache uses the original Xbox container and translator build identity; toggling a runtime switch changes neither. A narrowly scoped correction is to bypass translated pixel cache reads and writes when the export patch is effectively disabled, leaving the default cache available. An explicitly mode-keyed pixel cache is another option. Until then, separate
XCL_DXIL_CACHEdirectories give a valid A/B control. This measured returned DXIL bytes, without drawing or making a retail performance claim.AI assistance: OpenAI Codex traced the production path, assembled the synthetic fixture, ran the four controls and drafted this comment.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T22:47:49Z.
I tested a small candidate on
e8782653. It uses the parser's process-wide effective switch for both the success and error disk paths. Unset and explicit1share the patched entry;0has its own entry. Neither mode reads an old unlabelled pixel entry, whose origin cannot be inferred. The in-process translation key can stay unchanged because the parser freezes the setting on first use.Fresh processes calling
console_to_dxil_inon the same synthetic Xbox pixel container returned these DXIL hashes:5ad4c1e3259a2aa9→9be258cbc57a259c→5ad4c1e3259a2aa99be258cbc57a259c→5ad4c1e3259a2aa9→9be258cbc57a259cI also seeded a third cache with only a valid stored-mode entry under the old filename, using the candidate's exact translator identity and shader blob. An unset launch returned the patched hash and wrote a separate patched entry. This checks migration even when a build fingerprint change cannot hide stale entries. The patch preserves non-pixel filenames; as usual, changing a translator source can invalidate the build fingerprint. No retail or GPU run for this cache-only follow-up.
Apply-checked against the pristine PR head. The following is the entire production patch.
AI assistance: OpenAI Codex implemented the candidate, ran the fresh-process controls, and wrote this report.
Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-29T00:18:00Z.
Review: APPROVED
Approving on a merge-check run on an RTX 3060 Ti 8 GB (driver 32.0.16.1714, i5-10400, Windows 11 Pro 26200, Rust 1.100.0).
e87826532e98a43353e255665ff19bf2bd93106cmerged cleanly ontomain7db2f391, and the workspace builds.cargo test --workspace --no-fail-fast -- --test-threads=4, with--skipfor threeuma_drivertests that can end the library harness on this PC on plainmaintoo: 2,593 passed, 0 failed, 49 ignored, 28 SKIPPED (21 of them no wave64).mainwith the same skips: 2,591 passed, 0 failed. Both new tests pass.scripts/smoke.ps1world run (scripted confirm presses, Series S profile,XCL_PREPARE=0, a private shader cache) gave 3,529 frames and a peak commit of 22,048 MB with this change, against 3,463 frames and 23,115 MB onmain. No device removal and no crash on either. Both stop presenting after about 240 s with some 83,000 pipelines in the build-ahead backlog, so that stall ismain's. One run a side.main, no device removal, no crash.xbox.rsread in full, no blocking finding. Not checked here: the picture itself; no frames were dumped on this card.Build and testrun on this head failed in one timing test,hle::kernelx::tests::fine_timer_makes_short_sleeps_short, which this change does not touch.AI use: Claude Code ran the builds, tests and game runs on Prime's PC and wrote this text. Approving is Prime's decision.
I use a temporary Discord to coordinate my work. Anyone helping test XCL or compare results is welcome. Test coordination on Discord
Imported from ivall/xcl. Originally posted by Eterst on 2026-11-29T00:41:07Z.
@andrewDoing thank you, both points taken.
6931baaf, credited in its message). The mode suffix comes from a small helper,translated::exports_mode(stage, patched), so the test can check both modes in one process.translated_namespace_tracks_every_request_inputnow also asserts that a pixel shader's entry names its mode, that the two modes differ, and that vertex and compute entries keep their old names. Run here against a cache of its own:cargo test -p xcl --lib -- recomp::pso xbox::52 passed, 0 failed, 1 ignored.The regression block in the description is rerun on the new head.
Thanks also to @jessenic and @BBareth for the runs on their trees.
AI use: Claude Code (Claude Opus 5.5) applied the change, ran the tests and the regression run, and wrote this reply.
Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-29T01:44:49Z.
Review: APPROVED
Approving again on the updated head, after a rerun on the same RTX 3060 Ti 8 GB (driver 32.0.16.1714).
6931baaf92e3693f0e48b023a5b368da27b713afmerged cleanly ontomain7db2f391, and the workspace builds.cargo test --workspace --no-fail-fast -- --test-threads=4with the same threeuma_drivertests skipped: 2,593 passed, 0 failed, 49 ignored, 28 SKIPPED. Same counts as on the previous head.scripts/smoke.ps1withXCL_PREPARE=0: 1,420 frames against 1,385 onmain, peak commit 15,283 MB against 15,626 MB, no device removal, no crash.e8782653and was not repeated: the patch code is the same, and this update only adds the export mode to the translated-cache file name.AI use: Claude Code ran the builds, tests and game runs on Prime's PC and wrote this text. Approving is Prime's decision.
I use a temporary Discord to coordinate my work. Anyone helping test XCL or compare results is welcome. Test coordination on Discord
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T01:49:43Z.
Confirmed the squashed cache fix on
6931baaf. Seven fresh Windows processes called the production console_to_dxil_in path with the same synthetic Xbox pixel shader. With one shared cache, unset → 0 → 1 returned patched → stored → patched DXIL. With a second cache, 0 → unset → 0 returned stored → patched → stored. The hashes were 5ad4c1e3259a2aa9 (patched) and 9be258cbc57a259c (stored).For the seventh launch I seeded a third cache with only the valid stored entry under the old unlabelled filename, in the current translator identity directory. Unset produced the patched hash and created its labelled entry alongside the legacy one. This closes my disk-cache finding on the author's implementation. Synthetic translation only; no new title or GPU run. OpenAI Codex prepared the test overlay, ran the controls and drafted this comment.
Imported from ivall/xcl. Originally posted by Eterst on 2026-11-29T15:04:13Z.
Rebased onto
main3b6a91ed(headbb0679fb) and marked ready for review.#3200 was merged in the meantime and fixes the same symptom from the other side: it rewrites the FP16 export epilogue during translation for pipelines with 32-bit render targets, behind a liveness check. This PR applies the console's own export patch table while the FSSM is parsed, for every target and format. The two coexist; the only conflict was the translated-cache file name, which now carries both this PR's export mode and #3200's
_rt32_<mask>(#3200's test is unchanged). The description has a section on the difference, the suite counts on the new head (compared withmain3b6a91edpart by part, since the library harness ends early on both at the same test), and a new regression pair: 5,787 frames againstmain's 5,662, peak commit 15,377 MB against 15,231 MB, no removals or crashes.AI use: Claude Code (Claude Opus 5.5) did the rebase, ran the tests and the regression runs, and wrote this comment.
Imported from ivall/xcl. Originally posted by Eterst on 2026-11-29T15:53:00Z.
CI on
bb0679fbfailed on six tests, none of them in this change: two geometry tests that failed onmain3b6a91editself (geometry_tests::msg_gs_done_emits_in_dxil,lower_mem::stage_guard_tests::geometry_export_rejected; fixed onmainin468190c2), and fourshaders::pipeline_library/warm_librarytests, the group listed in #3180 as failing on unrelated PRs (they pass here, 10 of 10, twice). Rebased ontomainbc2cbb72(head601481ed): the two geometry tests pass, and the regression block in the description is of the new head.AI use: Claude Code (Claude Opus 5.5) read the CI log, rebased, reran the tests and the regression run, and wrote this comment.
Imported from ivall/xcl. Originally posted by Eterst on 2026-11-29T21:53:51Z.
The PR is now at
710a5f4f, onmain0fe06eb0, with every check green. The merge queue (#3041) counts test reports and merge checks only on the current head. The reports and approvals here are one8782653and6931baaf, so it no longer lists this PR.What changed since
6931baaf(git range-diff):crates/xcl/src/gpu/recomp/pso.rs: the conflict with #3200 is resolved.translated::file_fortakes #3200'srt32_mask, and a pixel shader's cache file name now carries both suffixes, this PR's export mode first and then_rt32_<mask>. #3200's test is unchanged;translated_namespace_tracks_every_request_inputasserts both.3b6a91edand then0fe06eb0, to pick upmain's fixes for the geometry tests and for thepipeline_librarytests of #3180. Nothing else in the diff changed.@Prime1997 @andrewDoing, if you have time, a rerun on
710a5f4fe38763a8f901e70eeff212c32544e3d1would count for the queue: suite counts, or anxcl-smokeblock, naming that commit, or a merge check in #3041's format. Thank you for the earlier runs.AI use: Claude Code (Claude Opus 5.5) compared the heads and wrote this comment.
Imported from ivall/xcl. Originally posted by claudetools-gh on 2026-12-01T00:05:29Z.
A data point for this PR, from an RTX 5070 Ti (driver 621.40). We tested a local port of the same idea, not this PR's code.
Our tree is an older base that already has #3200. On top of it we apply the console's export patch table first: the 32_ABGR slot, for the render targets #3200's
rt32_masknames. What the table does not cover falls back to #3200's pattern. In one run, 287 pixel shaders were patched from the table, and none were left for the pattern.Result in the prologue cell, compared with #3200 alone, at the same shot:
The difference showed up after we fixed the tile lighting's material-class plane, which is described in #505. Since that fix, skin and cloth tiles go through the R32_UINT subsurface path. With #3200's pattern alone, some of those shaders still wrote the FP16 form. We have not narrowed down which ones, or which of #3200's liveness declines they hit.
This is one run (360 s, no device removal), with the same switches as our earlier runs. Untested: AMD, and this PR's own code on
main, since the PR currently conflicts.AI-assisted.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:39:12Z.
Review (head
710a5f4f, diff read, not a merge-check; conflicts with main, a textual conflict next tobranch_targetsingpu/xbox.rs):record == 0xB0, or using the PS record's code, would settle it.patch_ps_exportsdirectly, so the gate inanalyze_fssm(xbox.rs~339) that decides whether a title's shaders get patched isn't tested.XCL_PS_EXPORT_PATCHis an env switch in the same PR, and the extra cache-naming code exists only for it. CONTRIBUTING puts switches in their own PR.e + 0x148(~421) isn't overflow-checked. A malformed record wraps in release and can patch arbitrary words;checked_addwould match the surrounding reads.Fine:
native.rs, credited inTHIRD_PARTY.md: payload+0x30 is the PS slot, other stages hold 0xDEADBEEF, the table is at +0x148 / +0x14C, and variant 9 is 32_ABGR.It is on by default and runs in
xbox::parsefor every v0x101 FSSM, so it changes every retail pixel shader. After the rebase, a full suite run and a smoke pair on the new head matter. Related: #3200 (merged, same symptom at translation) and #3273 (integer render targets).AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:44:20Z.
Triage (#1607) – head
710a5f4Main already handles 32-bit render targets per pipeline (
ps_rt32_mask/recomp::patch_ps_32bit_exports, which rewrites compressed exports for R32 targets); this PR instead applies the console's own export patch table (32_ABGR variant) to every pixel shader inxbox::analyze_fssm, so the two coexist (the rt32 pass skips exports that are no longer compressed).The same patch table is also applied on the
amd-devbranch (recomp::patch_ps_exportsin commit8942a5b, part of the open amd-dev merge PRs), with a different implementation; whichever lands second should drop its copy.The translated-cache key gains an export-mode suffix for pixel shaders only, so existing pixel entries are rebuilt once.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.