Skip to content

D3D12.X: forward RSSetShadingRate to ID3D12GraphicsCommandList5 - #1944

Open
fixgep wants to merge 1 commit into
xcl-dev:mainfrom
fixgep:feat/d3d12x-rs-set-shading-rate
Open

fixgep wants to merge 1 commit into
xcl-dev:mainfrom
fixgep:feat/d3d12x-rs-set-shading-rate

Conversation

@fixgep

@fixgep fixgep commented Nov 24, 2026

Copy link
Copy Markdown

The console command list's RSSetShadingRate sits at #124 on the base console layout and at #126 on the newer layout. main already remapped the base slot straight to the PC's ID3D12GraphicsCommandList5::RSSetShadingRate (PC #77), while the newer slot #126 was unrouted and fell into the console-extension stub (ID3D12GraphicsCommandList10::#126 (not on PC)). Both slots now route through a single capability-gated handler. Part of #505.

What is in it

  • crates/xcl/src/hle/d3d12x/device_x.rs: probe and cache D3D12_FEATURE_DATA_D3D12_OPTIONS6 (VariableShadingRateTier, AdditionalShadingRatesSupported) on the underlying PC ID3D12Device at creation and log it once (probe_vrs, vrs).
  • crates/xcl/src/hle/d3d12x/list_x.rs: add rs_set_shading_rate_x — clean no-op without host VRS; otherwise sanitize the base rate (clamp unsupported axes to 2X/4X per AdditionalShadingRatesSupported) and combiners (unknown combiners -> PASSTHROUGH, unreadable combiners pointer -> NULL defaults) before forwarding to ID3D12GraphicsCommandList5::RSSetShadingRate, and record/re-apply the state across KickoffX and mid-list splits (restore_bindings).
  • crates/xcl/src/hle/d3d12x/real.rs: route console #124 through rs_set_shading_rate_x instead of the bare PC remap and map newer-layout #126 to #124 in NEWER_LIST_SLOTS (title_list wrappers inherit this through the extended vtable).
  • Tests (device_x.rs / list_x.rs / real.rs): slot-routing table assertions, rate/combiner sanitization unit tests, null-list no-op test, and an isolated child-process D3D12 debug-layer forwarding test.

Tested

  • NVIDIA GeForce RTX 3060 (driver 32.0.15.9144), AMD Ryzen 5 7500F 6-Core Processor, Windows 11 Pro x64 (build 26200), rustc 1.100.0 (0ef1bc386 2026-11-09); debug and release
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 979 passed, 1 failed, 45 ignored (xcl --lib: 930 passed, 1 failed, 25 ignored; 16 xcl integration targets: 49 passed, 0 failed, 20 ignored; xcl bin / xcl-testtitle / doc-tests: 0 tests). SKIPPED GPU tests: 21 in gpu::recomp (no wave64 / unsupported wave32 per-lane V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32), 1 in shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode required to disable driver cache), and 1 in gpu_compute_e2e::heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows). The single failure (gpu::recomp::tests::gpu_clamp_and_omod_per_instruction, v_pk_add_i16 clamp) is pre-existing on main on this GPU/driver.
  • cargo test -p xcl --test '*' -- --test-threads=4: 49 passed, 0 failed, 20 ignored (1 SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows)
  • Newer-layout retail title (title: 3c290c16, 60 s release scripts/smoke.ps1): main (689f2db) logged [STUB] d3d12_xs.dll!ID3D12GraphicsCommandList10::#126 (not on PC) (1061 frames); 30862ad logged D3D12.X: variable shading rate (OPTIONS6): tier 2, additional rates true, cleared the #126 stub warning, and reached 1099 frames with 0 crashes / 0 device removals.

Regression run
main:

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 3060
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1061 (PresentX 1062)
presents per 2 s (last 3): 59 58 61
device removals: 0
crashes: 0
peak commit: 15366 MB

PR:

xcl-smoke v1
commit: 30862ad39c530455cd7c7072213b0a522d425b55
gpu: NVIDIA GeForce RTX 3060
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1099 (PresentX 1100)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15364 MB

Not tested

  • Rasterization output (SV_ShadingRate readback draw) from the forwarded shading rate
  • Tier 1 VRS hardware and adapters without VRS (the no-op path is covered by unit logic only); AMD / Intel GPUs
  • Newer-layout #126 identity on other titles: Glyph-cache menu text loses letters; black blocks on the brightness HUD (newer retail title) #1049 decodes #126 as a stencil-ref setter on another runtime; while a title passes zeroed arguments this sanitized forward acts as default rate/combiners (flagged for review)
  • RSSetShadingRateImage (console #125 / newer #127) is out of scope

AI use

  • ZCode (GLM-5.4): wrote the implementation and unit/GPU tests in 30862ad and ran the xcl-smoke runs.
  • Antigravity (Gemini 4 Hydrogen): verified the full workspace test suite, reviewed the diff and retail title run logs, validated the PR description with scripts/pr_check.py, and finalized this PR description.

The console command list's RSSetShadingRate sits at xcl-dev#124 on the base layout
(previously remapped straight to PC xcl-dev#77) and at xcl-dev#126 on the newer layout,
which was unrouted and fell into the console-extension stub. Route both
through list_x::rs_set_shading_rate_x: without variable-rate shading on the
host (D3D12_FEATURE_D3D12_OPTIONS6, probed once at device creation and
cached) a clean no-op, otherwise a sanitized forward to
ID3D12GraphicsCommandList5::RSSetShadingRate. Unsupported rate axes are
clamped to what the adapter supports and unknown combiner values act as
PASSTHROUGH (the D3D12 ApplyCombiner default arm); an unreadable combiners
pointer is treated as NULL (the PC defaults). The rate is recorded with the
other Reset-cleared state and re-applied after KickoffX and a deferred
mid-list split.

Assisted-by: ZCode (GLM-5.4)
@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 30862ad (on its base 689f2db).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::dxil::fuzz_tests: 970 passed, 0 failed, 43 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: sanitize_shading_rate_clamps_to_what_the_adapter_supports, rs_set_shading_rate_x_without_a_list_is_a_no_op, rs_set_shading_rate_x_forwards_without_debug_layer_errors, rs_set_shading_rate_x_debug_layer_child, shading_rate_slots_run_the_handler.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 979 passed, 0 failed, 45 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 62265d3 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651) and the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@raylitebull

Copy link
Copy Markdown
Member

Code review on 30862ad:

  • Probing D3D12_FEATURE_DATA_D3D12_OPTIONS6 (device_x::probe_vrs / vrs()), routing console RSSetShadingRate (#124 and NEWER_LIST_SLOTS #126) through list_x::rs_set_shading_rate_x, clamping unsupported axes via sanitize_shading_rate, preserving shading rate across restore_bindings, and subprocess-testing debug-layer safety (rs_set_shading_rate_x_forwards_without_debug_layer_errors) is very thorough.
  • Diff audited and CI workflow approved (running).

Remaining before merge: Build and test finishing green plus AMD verification on 30862ad.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine + vkd3d-proton) + NVIDIA test of 30862ad on its base 689f2db with #684 merged in: in 100 s of a retail title the #126 stub was called 0 times with it (2 of 2 runs) and 1,446 to 1,662 times without (3 runs), and the screens were the same. One run on native Windows also made 0 calls of the stub.

Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b, RTX 4070 12 GB (driver 615.71.09), Ryzen 9 9950X3D, 62 GB RAM; release, cross-compiled to x86_64-pc-windows-gnu (rustc 1.98.0), XCL_PSO_PRELOAD=0. Windows: Windows 11 Pro 26300, RTX 5070 Ti 16 GB (driver 621.24), Ryzen 7 9800X3D, 32 GB RAM, rustc 1.99.1, release. Retail title 1.0.2.1, the first-run screens completed once and no story progress, A pressed on the account screen.

Tested

100 s on Linux without (3 runs) with 30862ad (2 runs)
ID3D12GraphicsCommandList10::#126 (not on PC) stub calls 1474, 1446, 1662 0, 0
variable shading rate (OPTIONS6) line – tier 2, additional rates true
frames 1465, 1428, 1617 1736, 1391
last 2 s with a present 82.6, 84.1, 96.1 s 98.3, 82.1 s
faults, device removals, NVIDIA kernel messages 0 0
  • The third run without it started beside another job on the machine and pressed A twice; the stub count is the comparison, not the frames.
  • Kept frames of one run of each tree show the same screens (intro film, logo, both loading pictures).
  • Windows, 1 run of 120 s with it: 0 calls of the stub, the same OPTIONS6 line, no fault. A run of 689f2db alone 2 h 45 min earlier logged 1,262 calls; it is not a pair.
  • Of the five shading_rate tests, the three without a device passed under Wine; the debug-layer pair passed by skipping (SKIPPED … no InfoQueue), so no test checked the forward here.

Read

  • list_x.rs:537 (sanitize_shading_rate): each axis is clamped by itself, so 0x2 and 0x8 (1x4 and 4x1) pass unchanged with the additional rates, and D3D12_SHADING_RATE has no such value. Does the console accept those two, and what does the PC do with them?

Not tested: that each call reaches the PC's RSSetShadingRate (the handler logs nothing per call); a 3D scene; which rate and combiners the title passes; an adapter without variable-rate shading; a matched pair on Windows; AMD and Intel.

AI use: Claude Code (Claude Fable 5.2) read the diff, built the trees, ran the title and the tests, compared the frames and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@JJAutoCompare

Copy link
Copy Markdown

PR #1944 compatibility verification

Commit 30862ad39c530455cd7c7072213b0a522d425b55

Tested

  • STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175, DoublePrecisionFloatShaderOps=0, wave size 8–32). Rust 1.100.0 (0ef1bc386 2026-11-09), DXC/DXIL 1.9.2609.5, debug/test profiles with debug info disabled, XCL_ADAPTER=A770. The D3D12 debug-layer DLL is absent.
  • cargo build --workspace and cargo test --workspace --no-run succeeded.
  • cargo test -p xcl shading_rate -- --nocapture reported 5 passed, 0 failed, 0 ignored. The checks cover rate and combiner sanitization, a null command list, and wiring for console slots 124/126. The forwarding wrapper's short --exact filter matched 0 tests, and the child returns immediately in an ordinary run.
  • Reran the child by its fully qualified name with XCL_SHADING_RATE_DEBUG_CHILD=1 under the Arc lock. It emitted SKIPPED … no InfoQueue and returned before recording any shading-rate command. This skip is outside the workspace totals. Workspace logs confirmed the OPTIONS6 probe reported VRS tier 2 with additional rates.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under the shared Arc lock. Across 20 result blocks, libtest reported 955 passed, 25 failed, 45 ignored. The log contains 22 SKIPPED lines. Those lines include skipped subcases and do not count as coverage.
  • Failures comprised 20 GPU compute pipeline creation errors (0x80070057), four shader result mismatches (FMA, mip sampling, packed FP16, wave reduction), and one synthetic-title failure in dynamic depth bias (RSSetDepthBiasX).
  • Skip lines comprised 17 for unavailable wave64, three for refused per-lane DXIL forms, one for unavailable driver-cache control, and one for unavailable heap windows.

Not tested

Live CL5 shading-rate forwarding and restoration after command-list splits, the VRS-unsupported path on hardware, and other adapters. No retail-title smoke run or main baseline was run, so the suite failures cannot be attributed to this PR from these results.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1944-suite.log and published this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants