D3D12.X: remap newer-layout RSSetShadingRate (#126) and RSSetShadingRateImage (#127) #1213

Closed
github-bot wants to merge 1 commit from gh-pr/1213/head into gh-pr/1213/base
Owner

@⁠shzyjbr06-dev on GitHub · 2026-11-24 13:18 UTC · original
shzyjbr06-dev:fix/newer-list-shading-rate → main · +19 −4 · 1 files · 1 commits · closed without merging

Forwards RSSetShadingRate (#126 -> PC #77) and RSSetShadingRateImage (#127 -> PC #78) on QUEUE_SHIFTED newer-layout console command lists instead of dropping them into the (not on PC) stub path. Part of #505.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: adds NEWER_LIST_REMAP: [(usize, usize); 2] = [(126, 77), (127, 78)] and chains those shifted PC-forwarded slots into make_layout_split inside class_for alongside NEWER_LIST_SLOTS.
  • crates/xcl/src/hle/d3d12x/real.rs: adds unit test queue_tests::newer_list_remap_covers_shifted_shading_rate_slots asserting alignment with console_remap(Kind::CommandList).

Tested

  • NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2124), AMD Ryzen 7 7800X3D, Windows 11 26300, rustc 1.100.0 (0ef1bc386 2026-11-09), debug (tests) and release (smoke).
  • cargo build --workspace && cargo build --release -p xcl succeeded.
  • cargo test --workspace -- --test-threads=4: 742 passed, 0 failed, 41 ignored (xcl lib: 699 passed, 0 failed, 21 ignored; 2 runtime SKIPPED wave64 tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask and gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware, reason: no wave64; integration targets: bcpack_parity 1, console_dlls_e2e 13, console_shaders 3 passed / 4 ignored, disasm_e2e 1, e2e 3, gpu_compute_e2e 2, gpu_pso_e2e 7, heap_probe 0 passed / 4 ignored, low_va 1, pls_quota 1, predication_e2e 1, rpf_e2e 2, sparse_reinit 1, texture_states 1, xg_oracle 6 passed / 12 ignored).
  • Retail title 1.0.2.1 live check: ID3D12GraphicsCommandList10::#126 (not on PC) in called_stubs dropped from 713 calls on main to 0 calls with this patch.
  • XCL_D3D12_DEBUG=1 15 s smoke run (exit: 0x0, 258 frames shown, 0 device removals, 0 crashes, zero D3D12 debug layer errors related to RSSetShadingRate).

Regression run

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3c290c16
seconds: 45
exit: 0x0
frames shown: 712 (PresentX 712)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15343 MB
xcl-smoke v1
commit: f5675c7db86beee3b71febe52ec8b246c39aeb25
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3c290c16
seconds: 45
exit: 0x0
frames shown: 1174 (PresentX 1174)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 14497 MB

Not tested

  • RSSetShadingRateImage (#127 -> PC #78) was not called during the 45 s retail run; it matches console_remap in queue_tests and is unverified live.
  • AMD / Intel GPUs, native wave64 hardware (2 wave64 tests skipped on RTX 5070 Ti), Wine, and other newer-layout retail titles.

AI use

  • Antigravity (Gemini) traced the unpatched #126 vtable slot, wrote the 2-entry NEWER_LIST_REMAP change and unit test, and helped format the description. All builds, tests, and live GPU runs were executed locally on the hardware listed above.
**@⁠shzyjbr06-dev** on GitHub · 2026-11-24 13:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/1213) `shzyjbr06-dev:fix/newer-list-shading-rate` → `main` · +19 −4 · 1 files · 1 commits · closed without merging Forwards `RSSetShadingRate` (`#126` -> PC `#77`) and `RSSetShadingRateImage` (`#127` -> PC `#78`) on `QUEUE_SHIFTED` newer-layout console command lists instead of dropping them into the `(not on PC)` stub path. Part of #505. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: adds `NEWER_LIST_REMAP: [(usize, usize); 2] = [(126, 77), (127, 78)]` and chains those shifted PC-forwarded slots into `make_layout_split` inside `class_for` alongside `NEWER_LIST_SLOTS`. - `crates/xcl/src/hle/d3d12x/real.rs`: adds unit test `queue_tests::newer_list_remap_covers_shifted_shading_rate_slots` asserting alignment with `console_remap(Kind::CommandList)`. **Tested** - NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2124), AMD Ryzen 7 7800X3D, Windows 11 26300, `rustc 1.100.0 (0ef1bc386 2026-11-09)`, debug (tests) and release (smoke). - `cargo build --workspace && cargo build --release -p xcl` succeeded. - `cargo test --workspace -- --test-threads=4`: 742 passed, 0 failed, 41 ignored (`xcl` lib: 699 passed, 0 failed, 21 ignored; 2 runtime `SKIPPED` wave64 tests: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`, reason: `no wave64`; integration targets: `bcpack_parity` 1, `console_dlls_e2e` 13, `console_shaders` 3 passed / 4 ignored, `disasm_e2e` 1, `e2e` 3, `gpu_compute_e2e` 2, `gpu_pso_e2e` 7, `heap_probe` 0 passed / 4 ignored, `low_va` 1, `pls_quota` 1, `predication_e2e` 1, `rpf_e2e` 2, `sparse_reinit` 1, `texture_states` 1, `xg_oracle` 6 passed / 12 ignored). - Retail title 1.0.2.1 live check: `ID3D12GraphicsCommandList10::#126 (not on PC)` in `called_stubs` dropped from 713 calls on `main` to 0 calls with this patch. - `XCL_D3D12_DEBUG=1` 15 s smoke run (`exit: 0x0`, 258 frames shown, 0 device removals, 0 crashes, zero D3D12 debug layer errors related to `RSSetShadingRate`). **Regression run** ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 5070 Ti title: 3c290c16 seconds: 45 exit: 0x0 frames shown: 712 (PresentX 712) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15343 MB ``` ``` xcl-smoke v1 commit: f5675c7db86beee3b71febe52ec8b246c39aeb25 gpu: NVIDIA GeForce RTX 5070 Ti title: 3c290c16 seconds: 45 exit: 0x0 frames shown: 1174 (PresentX 1174) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 14497 MB ``` **Not tested** - `RSSetShadingRateImage` (`#127` -> PC `#78`) was not called during the 45 s retail run; it matches `console_remap` in `queue_tests` and is unverified live. - AMD / Intel GPUs, native wave64 hardware (`2` wave64 tests skipped on RTX 5070 Ti), Wine, and other newer-layout retail titles. **AI use** - Antigravity (Gemini) traced the unpatched `#126` vtable slot, wrote the 2-entry `NEWER_LIST_REMAP` change and unit test, and helped format the description. All builds, tests, and live GPU runs were executed locally on the hardware listed above.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:47:19 +00:00
github-bot closed this pull request 2026-11-26 04:47:19 +00:00
Author
Owner

@⁠celian-hamon on GitHub · 2026-11-24 13:37 UTC · original

lgtm

**@⁠celian-hamon** on GitHub · 2026-11-24 13:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1213#issuecomment-7133087358) lgtm
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 13:47 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib shading_rate test: 1 passed (see note), 0 failed.

Note: the full d3d12x lib filter currently aborts with 0xc0000005 on unmodified main too (pre-existing, unrelated to this PR); the PR's own tests were run by name and pass.

**@⁠DavidM1911** on GitHub · 2026-11-24 13:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/1213#issuecomment-7133332544) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl --lib shading_rate test: 1 passed (see note), 0 failed. Note: the full `d3d12x` lib filter currently aborts with 0xc0000005 on unmodified `main` too (pre-existing, unrelated to this PR); the PR's own tests were run by name and pass.
Author
Owner

@⁠Chrysana on GitHub · 2026-11-24 15:23 UTC · original

AMD run of f5675c7, plus a point about what the retail title passes through slot #126.

Setup: AMD Radeon RX 9070 XT 16 GB (RDNA4), driver 32.0.32015.2008, Ryzen 7 9800X3D, Windows 11 26200.9974, rustc 1.100.0 MSVC, release. Retail title 1.0.2.1, the same saved state for every run, XCL_NETWORK=0 XCL_PRESS_A_AT=20,25,30. This PR's head sits directly on main 47efa2e.

Tested

  • cargo test -p xcl --lib newer_list_remap: 1 passed (newer_list_remap_covers_shifted_shading_rate_slots).
  • scripts/smoke.ps1 -Seconds 60, alternating: PR 1165, main 1162, PR 1160 frames. Every run: 60 60 60, 0 crashes, 0 device removals. Peak commit 17255 / 17258 / 19479 MB; the last one is an outlier I didn't chase. No regression on this card in what these runs reach.

What the title passes through #126. Local diagnostic, not part of this PR: a shim on the PC RSSetShadingRate this PR forwards to, logging each distinct argument set.

  • One 240 s run into the world load: the title called #126 1,024–2,047 times before its stop at +0x23cf683. Every call was baseRate 0 with 8 zero bytes behind the combiner pointer, so 1X1 with PASSTHROUGH / PASSTHROUGH. That's why the forward is harmless so far.
  • The only call site is +0x32638 (call [rax+0x3f0]), the one AallynReed decoded in #1049. I read it in my copy and agree with their reading:
    • it loads one 32-bit state word;
    • it calls only when bits 0–23 differ from a cached copy;
    • it passes state & 0xFF as the second argument;
    • and a pointer to two dwords, (state >> 8) & 0xFF and (state >> 16) & 0xFF (the shift and mask constants are 8, 16 and 0xFF, 0xFF in .rdata).
  • That is a stencil ref plus read and write masks, not a shading rate plus combiners. With this PR, a stencil ref of 1, 4 or 5 would turn on coarse shading. A ref like 2 or 3, or masks like 0xFF, would be invalid D3D12_SHADING_RATE / D3D12_SHADING_RATE_COMBINER values. Our runs never got past state 0, so I haven't seen that happen.
  • AallynReed has #126 wired to OMSetStencilRef on a branch: https://github.com/AallynReed/xcl/tree/glyph-cache-gpu-writes

Not tested

  • #127: the title never called it in these runs.
  • Gameplay, where nonzero stencil states would show up: the world load stops at +0x23cf683 first (#534).
  • Other GPUs.

AI use

  • Claude Code (Claude Opus 5.5) built the trees and the local diagnostic, ran the runs, read the call site and drafted this comment. I checked it before posting.
**@⁠Chrysana** on GitHub · 2026-11-24 15:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/1213#issuecomment-7135958099) AMD run of `f5675c7`, plus a point about what the retail title passes through slot #126. **Setup:** AMD Radeon RX 9070 XT 16 GB (RDNA4), driver 32.0.32015.2008, Ryzen 7 9800X3D, Windows 11 26200.9974, rustc 1.100.0 MSVC, release. Retail title 1.0.2.1, the same saved state for every run, `XCL_NETWORK=0 XCL_PRESS_A_AT=20,25,30`. This PR's head sits directly on `main` `47efa2e`. **Tested** - `cargo test -p xcl --lib newer_list_remap`: 1 passed (`newer_list_remap_covers_shifted_shading_rate_slots`). - `scripts/smoke.ps1 -Seconds 60`, alternating: PR 1165, `main` 1162, PR 1160 frames. Every run: `60 60 60`, 0 crashes, 0 device removals. Peak commit 17255 / 17258 / 19479 MB; the last one is an outlier I didn't chase. No regression on this card in what these runs reach. **What the title passes through #126.** Local diagnostic, not part of this PR: a shim on the PC `RSSetShadingRate` this PR forwards to, logging each distinct argument set. - One 240 s run into the world load: the title called #126 1,024–2,047 times before its stop at `+0x23cf683`. Every call was `baseRate 0` with 8 zero bytes behind the combiner pointer, so `1X1` with `PASSTHROUGH` / `PASSTHROUGH`. That's why the forward is harmless so far. - The only call site is `+0x32638` (`call [rax+0x3f0]`), the one AallynReed decoded in #1049. I read it in my copy and agree with their reading: - it loads one 32-bit state word; - it calls only when bits 0–23 differ from a cached copy; - it passes `state & 0xFF` as the second argument; - and a pointer to two dwords, `(state >> 8) & 0xFF` and `(state >> 16) & 0xFF` (the shift and mask constants are `8, 16` and `0xFF, 0xFF` in `.rdata`). - That is a stencil ref plus read and write masks, not a shading rate plus combiners. With this PR, a stencil ref of 1, 4 or 5 would turn on coarse shading. A ref like 2 or 3, or masks like `0xFF`, would be invalid `D3D12_SHADING_RATE` / `D3D12_SHADING_RATE_COMBINER` values. Our runs never got past state 0, so I haven't seen that happen. - AallynReed has #126 wired to `OMSetStencilRef` on a branch: https://github.com/AallynReed/xcl/tree/glyph-cache-gpu-writes **Not tested** - #127: the title never called it in these runs. - Gameplay, where nonzero stencil states would show up: the world load stops at `+0x23cf683` first (#534). - Other GPUs. **AI use** - Claude Code (Claude Opus 5.5) built the trees and the local diagnostic, ran the runs, read the call site and drafted this comment. I checked it before posting.
Author
Owner

@⁠shzyjbr06-dev on GitHub · 2026-11-24 15:43 UTC · original

Thank you for running the RDNA4 test and tracing +0x32638! That makes total sense — I derived (126, 77) / (127, 78) by shifting console_remap's older #124/#125 entries by +2, and because the title only passed zeroed state in the menus, forwarding to RSSetShadingRate happened to act as a harmless no-op.

Since #126 is actually stencil ref + masks and AallynReed already has it wired to OMSetStencilRef on their branch for #1049, I'll close this PR to avoid misleading or duplicate work. Thanks again for the thorough check!

**@⁠shzyjbr06-dev** on GitHub · 2026-11-24 15:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/1213#issuecomment-7136503741) Thank you for running the RDNA4 test and tracing `+0x32638`! That makes total sense — I derived `(126, 77)` / `(127, 78)` by shifting `console_remap`'s older `#124`/`#125` entries by `+2`, and because the title only passed zeroed state in the menus, forwarding to `RSSetShadingRate` happened to act as a harmless no-op. Since `#126` is actually stencil ref + masks and AallynReed already has it wired to `OMSetStencilRef` on their branch for #1049, I'll close this PR to avoid misleading or duplicate work. Thanks again for the thorough check!
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 04:05 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 04:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1213#issuecomment-7182284166) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.