Repository navigation
D3D12.X: XCL_PIXEL_HISTORY (which draw writes a pixel) and XCL_SKIP_PS (leave out draws by pixel shader) - #3509
CharlyRien wants to merge 1 commit into
Conversation
…S (draws of named console pixel shaders left out) PIX and Nsight captures do not replay a title under XCL. XCL_PIXEL_HISTORY=<x>,<y>[,<s>[,<frames>]] (+ _ALSO, _SPACE, _CROP, _SLOTS): in the frames chosen, each draw on a direct list copies the texel at the point of each bound render target before and after itself (1x1 CopyTextureRegion between RENDER_TARGET <-> COPY_SOURCE transitions) into a readback buffer; a few presents later the changes are logged with the draw's console VS / PS, the target, the values decoded and the slot's blend state, and changes between two draws of a list with the dispatches in between. With _CROP a second round writes crops of the draws that changed the point. XCL_SKIP_PS=<hash>,...: draws (direct and indirect) whose translated pipeline's console PS is listed are skipped as XCL_SKIP_CS skips dispatches, counted in the log. Unset, each costs a draw one cached check. Documented in the README's diagnostics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Ran the pixel-history and pixel-shader skip tests at System
Results
What this adds Not tested AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
Only AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
Two diagnostic switches to find which draw writes a wrong pixel. PIX and Nsight frame captures do not replay a title running under XCL, so we could not use their pixel history. These switches do the same job inside the process. Both are off by default. Unset, each one costs a draw one cached check.
What is in it
XCL_PIXEL_HISTORY=<x>,<y>[,<s>[,<frames>]](d3d12x/pixel_history.rs, new).sseconds (default 0) or more after the first one, and followsframesframes (default 1, at most 8).x,yof the presented picture in each bound render target that has the picture's shape. Each copy is a 1×1CopyTextureRegionbetween a RENDER_TARGET → COPY_SOURCE transition and its way back.XCL_PIXEL_HISTORY_SPACE=<w>x<h>: the size of the picture thatx,yare given in (default 3840x2160).XCL_PIXEL_HISTORY_ALSO=<x>,<y>[;<x>,<y>]: up to 3 more points.XCL_PIXEL_HISTORY_CROP=<w>,<h>[,<n>]: a second round of as many frames. In it, only the draws whose pipeline changed a point in the first round also copy aw×hcrop around the point after themselves. The crops of the draws that change the point are written as BMPs (pixel-history/<frame>_<event>_<ps>_p<point>rt<slot>.bmpnext toxcl.log, at mostna frame, default 200).XCL_PIXEL_HISTORY_SLOTS: the readback slots of a round (default 131072 slots of 512 bytes).XCL_SKIP_PS=<hash>,<hash>: leaves out the draws (direct and indirect) whose console pixel shader has one of these hashes, the wayXCL_SKIP_CSleaves out dispatches, and counts them in the log. Use it to confirm that the draw the history found is the one at fault.bind.rs(draw, indexed draw, ExecuteIndirect, dispatch),real.rs(RTV mip / slice, the pipeline's blend state, console VS / PS hashes kept while either switch is set),present.rs(one call at each present).Reading the output (
grep -a "pixel history" xcl.log)XCL_PIXEL_HISTORY: points [...] of a WxH present, N frames from S s after the first present, ...: the settings, read once.pixel history r1: point 0 (x, y) -> target 0x… sub S WxH format F at (tx, ty): once per target. It shows where the point landed in that target.pixel history r1: f<frame> ev <seq> list 0x… #<i> [indirect ]draw vs <hash> ps <hash> pso 0x… p<k> rt<n> WxH fmt F at (tx, ty): (before) [raw] -> (after) [raw]; <blend state of that slot>: one line per draw that changed the texel. The values are decoded (RGBA8 / BGRA8, RGBA16 float, R11G11B10, R10G10B10A2, R32 float), with the raw bytes in brackets. Read the lines in (frame, list,#i) order. The last change before the present, on the scene's target, tells which draw wrote the final value, and the blend state tells how.pixel history r1: f… list 0x… p<k> rt<n> …: changed BETWEEN draws #a (ev …) and #b (ev …): … -> …; dispatches between: #i cs <hash>, …: the texel changed between two draws of one list. This means a compute pass (named by itscs), a clear, a copy or a resolve wrote it.pixel history r1 done: … events (… draws), … slots used; … changes by draws, … between draws, … copies not done (list not run yet); targets not followed: … by shape, … by format, … multisampled, … other; … slots full, … crops full; … crops written: the round's summary. "Copies not done" are copies whose list had not run by the readout (their slots still hold a 0xA5 sentinel). They are counted, not read._CROP, anr2round follows with the same lines, and its crops are written.Measured use. On the retail title, a pose in front of a window where one diagonal half of the glass turns black. One run with two points (one on the dark half, one control) and one frame per round, plus 64×64 crops. The history named the depth-of-field composite, an indirect draw blending SRC_ALPHA / INV_SRC_ALPHA, as the draw that set the texel to RGB 0. It also showed the DoF downsample writing RGB 0 at every watched point.
XCL_SKIP_PSon the composite's pixel shader then gave a clean window. That led to #3281's case: a R9G9B9E5 view placed over an R32_UINT texture. Report: #3281 (comment). That run used an earlier form of this tool, in which the start could also be counted from a busy-draws heuristic. This PR keeps only seconds after the first present, which does not depend on the title.Numbers from that run (RTX 3090):
Cost
XCL_SKIP_PS; a dispatch's hook loads the same atomic. The hooks at pipeline creation, RTV creation and present check cached values only. Nothing is allocated. A test checks that the hooks do not even look at the command list when the switch is unset.Tested
maind52ff48 + this commit (8952390).cargo test --release -p xcl --lib -- pixel_history:: skip_ps_tests::: 6 passed, 0 failed, 0 ignored. The 6 tests are:pixel_history_settings_parse: the switches' parsing, including rejected values.unset_pixel_history_changes_nothing: unset, no round, no session, no map, and a draw's hooks do not touch the list (a dangling pointer in the test).points_map_by_each_targets_own_size: mapping a point to full, half, quarter and 2560x1440 targets; other shapes refused; crop placement at the edges.followed_formats_decode_and_others_fail_closed.skip_ps_hashes_parse_and_unset_skips_nothing.gpu_a_targets_texel_is_read_before_and_after_a_draw: on the default adapter, else WARP. A texel copied before and after a "draw" (a clear) between the same barriers reads back as both values; an unreached slot still holds the sentinel; a crop around the point holds the new value and turns into a BMP.mainwithout other changes than the start time, the doc comments and the log text.Regression run
Same machine as under Tested, same title, 60 s each (the
scripts/smoke.ps1default), both throughmaind52ff48'sscripts/smoke.ps1,XCL_PREPARE=0, the same scripted A presses (XCL_PRESS_A_AT),XCL_PIXEL_HISTORYandXCL_SKIP_PSunset. Each run started from its own copy of the same shader cache, made by anothermaincommit, so cold for both.maind52ff48:this head
8952390(maind52ff48+ this commit):main's 517 (107.2 %; the check wants at least 80 %), peak commit 16,424 MB against 15,968 MB (102.9 %; at most 125 %). Last three 2 s slices: head 61 61 60,main61 60 61 presents. 60 s covers the start of the title, not a long stay in its world.Not tested
DispatchMesh) and draws on bundles are not followed, andXCL_SKIP_PSdoes not apply to them.AI use
AI use: the tool, its tests, the in-game run, the smoke runs and this description were done with Claude Code (Claude Opus 5.5), checked and posted by me.
🤖 Generated with Claude Code