GPU: variable-rate shading (RSSetShadingRate) reaches the host #3511
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3511
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3511"
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?
@alexandruiulian201-bot on GitHub · 2026-11-27 11:56 UTC · original
alexandruiulian201-bot:feat/variable-rate-shading→main· +722 −15 · 5 files · 1 commits · open## Summary
Forwards the title's
RSSetShadingRatecommand (console command-list slot124:0x3e0in the older layout,0x3f0in the newer layout vianewer_slot) to host D3D12 (ID3D12GraphicsCommandList5::RSSetShadingRate), following the same capability-query and state-replay structure as depth bounds (#158).Changes
crates/victory-gpu/src/host.rs:D3D12_FEATURE_D3D12_OPTIONS6(VariableShadingRateTierandAdditionalShadingRatesSupported) during host device creation.Option<ID3D12GraphicsCommandList5>ontoHostListwhenVariableShadingRateTier != NOT_SUPPORTED.crates/victory-gpu/src/list.rs:sanitize_shading_rate:None(no host call).1x1,1x2,2x1,2x2): forwarded directly.2x4,4x2,4x4): forwarded whenAdditionalShadingRatesSupportedis true, clamped conservatively to2x2otherwise.1x1(0x0) and flag a one-time warning.None(D3D12 Tier 1 forbids non-passthrough combiners).0..=4(PASSTHROUGH..=SUM), falling back toPASSTHROUGH(0) on out-of-range values with a one-time warning.extern "system" fn shading_rateand wires slot124in both layouts (0x3e0/0x3f0).crates/victory-gpu/src/draw.rs:shading_rate: Option<(u32, Option<[u32; 2]>)>ondraw::State(reset toNoneonState::reset).set_shading_rate, replays it across segment splits inState::cut(), and reapplies it after graphicsSetPipelineStateinState::bind()(covering indirect-clamp pipeline invalidation andhost_state_lost).crates/victory-gpu/src/pipeline/shading_rate_test.rs&crates/victory-gpu/src/pipeline.rs:D3DCompile, no game assets) exercising title command-list entry points (0x3e0/0x3f0,0xb0,0x60,0x50) across fresh1x1,2x2,2x1,1x2([PASSTHROUGH, PASSTHROUGH]), non-passthrough combiner[PASSTHROUGH, MAX], invalid base rate0x7 -> 1x1,4x4(0xA) whenAdditionalShadingRatesSupportedis true, Tier 0 fallback, andResetrestoring1x1.Out of scope
RSSetShadingRateImageis intentionally left unmapped until its console vtable slot is confirmed.Verification
All tests use synthetic shaders and targets only (no game files).
cargo test --locked -p victory-gpu --lib -- shading_rate --nocapture --test-threads=1on NVIDIA GeForce GTX 1070 (tier=0, additional=false): 3 passed, 0 failed (verifies clean Tier 0 fallback).VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test --locked -p victory-gpu --features diagnostics --lib -- shading_rate --nocapture --test-threads=1on Microsoft Basic Render Driver (WARP) (tier=1, additional=true): 3 passed, 0 failed with zero D3D12 debug layer errors (verifies real2x2,2x1,1x2,4x4coarse rasterization, Tier 1 combiner stripping, invalid-rate fallback, andResetrestoring1x1).cargo clippy --workspace --all-targets --locked -- -D warnings: passcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passcargo run -p xtask --locked -- policy:asset policy: 192 files oklist::tests::sanitize_shading_rate_enforces_tier_and_validates_inputs.Disclosure
This PR was developed with AI assistance and manually reviewed and verified against live D3D12 (GTX 1070 + WARP with the D3D12 Debug Layer) using synthetic tests only.
@andrewpozdnakov7-jpg on GitHub · 2026-11-27 12:44 UTC · original
Tier 2 and the additional-rate flag still leave
SUMconditional onD3D12_OPTIONS10.VariableRateShadingSumCombinerSupported. The sanitizer on5ad4a02accepts[MAX, SUM]for any Tier 2 host. D3D12 capability definitionFollow-up
3a9b480reads OPTIONS10 once at host creation and passes the capability to the draw-state sanitizer. If the query fails or the capability is false, eachSUMuses the existingPASSTHROUGHfallback. The CPU regression covers both combiner positions, both capability values, and independent additional-rate support.All four shading-rate tests pass on the final commit. App-local WARP 1.0.22 with Agility 1.620.2 reports Tier 2, additional rates and SUM support. The GPU readback includes
[PASSTHROUGH, SUM]and shows the four pixels sharing the requested 2x2 rate. Strict Clippy passes both configurations and the asset policy check passes.One other result from this WARP build is worth checking on hardware. I cleared the same target and tested both the guest entry point and a direct native
RSSetShadingRatecall. Both paths wrote 4/4 pixels with[PASSTHROUGH, SUM],[PASSTHROUGH, MAX]and[PASSTHROUGH, PASSTHROUGH]. Both left the clear value in all four positions whenSUMoccupied the first combiner. A physical Tier 2 run with the capability reported by OPTIONS10 would clarify that result.Please retain the Git author if taking the commit. If folding it into another commit, please add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.AI-assisted with OpenAI Codex. Synthetic targets and shaders.
@UncommonDLL on GitHub · 2026-11-27 13:39 UTC · original
We tested your
3a9b480follow-up on a physical RTX 5070 Ti with driver 621.40. The device reported VRS Tier 2 and OPTIONS10 SUM support. With SUM in either combiner position, both the guest setter and nativeRSSetShadingRatewrote[1, 1, 0, 1]to all four pixels. The pixel outside the draw kept its clear value. The MAX and passthrough controls matched. A second process reproduced the result, with no skips.First-position SUM drew on this setup. The other rate inputs were at their defaults, so the result leaves SUM arithmetic open. OpenAI Codex helped extend and run the synthetic fixture. Claude Sonnet 5.5 reviewed the interpretation.
@ColorMeBoom on GitHub · 2026-11-27 15:03 UTC · original
Tier 0 host: RX 5700 XT (RDNA1, no variable-rate shading), driver 32.0.21045.29003, Windows 11 26200, Rust 1.98.1. Head
5ad4a02merged ontomain63bcca4, native adapter, no game files. The run above is a Tier 2 card, so this covers the other branch ofshading_rate_controls_coarse_pixel_rasterization.shading rate on AMD Radeon RX 5700 XT: tier=0, additional=falseand passes on the Tier 0 path. With a 2x2 rate set, the quadrants still rasterize at 1x1 (distinct X and Y per pixel), and the reset and invalid-rate passes match.HostListgets noID3D12GraphicsCommandList5there, and the guest'sRSSetShadingRateis dropped without error.sanitize_shading_rate_enforces_tier_and_validates_inputsandshading_rate_slot_is_wired_in_both_layoutspass.victory-gpulib suite: 234 passed, 0 failed, 1 ignored.I didn't run @andrewpozdnakov7-jpg's
3a9b480follow-up. It only changes the Tier 2 SUM-combiner check, which this card never reaches.AI use: Claude Code (Claude Opus 5.5).
@passerbyyhx on GitHub · 2026-11-27 18:56 UTC · original
Windows synthetic verification at
5ad4a021e58ff28539aa76713ca1f22c04af7d62.I checked the command-list boundaries with a 4×4 position-color render target on RTX 4090 Laptop (621.14, Tier 2, 16-pixel tiles, additional rates and OPTIONS10 SUM supported), with a WARP comparison. On the 4090 the cut retained horizontal 2×1 shading. Forcing native 1×1 after the cut gave 16 distinct pixels without rebinding; replaying the production bind restored the 2×2 pattern. A guest Reset returned to 16 distinct 1×1 pixels. The parent
63bcca43c6a00a758510398fa43096ce7e4f7df0returned distinct pixels.With default 1×1 secondary inputs the two MIN positions gave 1×1, and MAX produced 2×2. The SUM cases cover this SUM-capable adapter only. Head render cases 3/3 on both adapters. A separate known descriptor-heap size probe emitted diagnostic 645 during 4090 setup and fell back successfully. The subsequent measured VRS operations had zero debug errors.
Reproducible fixture. GTA-VI-3/EIGHT-20261127. AI-assisted with Codex.
@passerbyyhx on GitHub · 2026-11-27 19:10 UTC · original
Follow-up to the command-list tests on
5ad4a021e58ff28539aa76713ca1f22c04af7d62. The earlier fixture used default 1×1 secondary inputs. This run supplies 2×1 per primitive from the vertex shader and 1×2 from a single R8_UINT shading-rate tile, with a 1×1 base rate. The guest sets the combiners. The tile is bound through the native D3D12 list; the guest shading-rate image entry point is outside this test.All five draws matched the expected grouping for all 16 pixels of the 4×4 position-color target. RTX 4090 Laptop, driver 621.14, Tier 2, tile size 16, LUID
00000000:0001c903. The debug layer reported zero draw errors; the previously recorded descriptor-heap setup probe 645 was counted separately.Fixture and reproduction command. AU-20261127-08X. AI-assisted with Codex.
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.