gpu: make texture states D3D12 refuses legal before they reach a barrier (0x80070057) #3487
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3487
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3487"
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?
@CubeB on GitHub · 2026-11-29 23:50 UTC · original
CubeB:close/state-sanitiser→main· +157 −3 · 1 files · 1 commits · openBranch:
CubeB:close/state-sanitiser(one commit onmainat41adb551).Problem
One invalid command makes
ID3D12GraphicsCommandList::Closereturn0x80070057for the whole host list:"a host command list did not close: a command recorded into it was invalid". D3D12 does not say which command.
In #2914 the debug layer named one (
CopyTextureRegion, BC7_TYPELESS to BC6H_TYPELESS; #3043 addresses it), butthat is one of several commands that fail the same way.
To find the others we measured them: one command recorded into a fresh list, then
Close. 278 cases gave thesame answer on an RTX 5070 Ti and on WARP; the set later grew to 466 cases on WARP (263 refused), kept as a test
in the companion branch
close/guard-stack. Among the refused commands are transitions to texture states theconsole accepts and the PC does not:
COPY_DEST|PIXEL_SHADER_RESOURCE,UNORDERED_ACCESS|PIXEL_SHADER_RESOURCE,RENDER_TARGET|PIXEL_SHADER_RESOURCE,RENDER_TARGET|UNORDERED_ACCESS,DEPTH_WRITE|DEPTH_READ,DEPTH_WRITE|PIXEL_SHADER_RESOURCE,RESOLVE_DEST|COPY_DEST,RESOLVE_DEST|PIXEL_SHADER_RESOURCE;texture_state()already removes the buffer-only bits and the console's bits from 25 up, andlegal_for()thestates a host texture's flags forbid. Nothing removed the cases above. The title's after-state reaches barriers
and texture creation through these two functions.
Whether the title ever sends such a state is not known; the log line below answers that in a play log.
What the commit does
legal_for()(crates/victory-gpu/src/host.rs) now ends insane_state():0x01003CFC);destination), after the flags have removed what the texture cannot be in.
Which state to keep from a mix is a choice, not a measurement.
Switch
VICTORY_STATE_SANITISE: on by default;=0passes states on as before.Log
state sanitiser: a texture state D3D12 refuses was made legal (Close would fail with 0x80070057)withasked,made,what(bits that are no texture state/a write state mixed with another) andcount. First 16 ofeach kind, then every 4096th.
Cost
A state that is already legal takes the old path plus two compares and returns. The rest is
#[cold]. Noallocation, no lock. Not measured in ns separately.
Tests
New module
host::state_tests, five tests, no GPU needed:every_state_comes_out_as_one_close_takes: all 2^16 low-bit combinations x 5 sets of high bits x 7 flag sets;the result must satisfy the measured rule.
a_write_state_stands_alone,bits_that_are_no_texture_state_go,states_d3d12_takes_stay_as_they_are,a_forbidden_write_state_leaves_the_read_statespin the measured cases.Adapted from the original commit: the exhaustive test compared against
crate::checked::judge(the close guard,in
close/guard-stack). That module is not inmain, so here the test carries the measured texture-state ruleitself as
close_takes(). Nothing outside the test module and two comments differs.On this branch (Windows, stable toolchain):
cargo build --release --locked -p victory: builds.cargo test -p victory-gpu --lib -- --test-threads=1: 926 passed, 1 failed, 60 ignored. The failure isshader_cache::tests::every_switch_of_the_translator_is_in_the_key("VICTORY_SCALAR_SPLITS is not read by thetranslator any more"); it fails the same way on
mainat41adb551without this commit.cargo xtask policy: only the existingcrates/victory-loader/src/heap_sites/frame_users.rshit, as onmain.Not yet play-tested
Nothing here has been run against the game. The rules come from the one-command measurements and the tests.
Relation to the other branch
Independent of #3043 and of
close/guard-stack; either can land first. With both, the guard no longer has todrop a transition to one of these states (a dropped transition leaves the tracked state ahead of the real one).
🤖 Generated with Claude Code
The console lets the title name texture states the PC refuses, and one transition to such a state makes Close fail for the whole host list (0x80070057, "a host command list did not close"). texture_state() already took the buffer-only bits and the console's bits from 25 up, and legal_for() the states a host texture's flags forbid; nothing took a write state mixed with another state, nor the remaining bits that are no texture state. The title's after-state reaches barriers and texture creation through exactly these two functions. Measured (one transition into a fresh list, RTX 5070 Ti and WARP alike, and asked of WARP again by crate::checked's oracle test): Close refuses COPY_DEST|PSR, UAV|PSR, RT|PSR, RT|UAV, DEPTH_WRITE|DEPTH_READ, DEPTH_WRITE|PSR, RESOLVE_DEST|COPY_DEST, RESOLVE_DEST|PSR, and on a texture the bits 0x4000, 0x8000 and 0x10000 to 0x400000; bit 0x800000 passes only alone. legal_for() now ends in sane_state(): the state is masked to the eleven texture states D3D12 knows (0x01003CFC), and a mix keeps its lowest write state (render target, unordered access, depth write, copy destination, resolve destination), after the flags have taken what the texture cannot be in. Legal states take the old path plus two compares. What was changed is counted by kind and logged ("state sanitiser: a texture state D3D12 refuses was made legal", first 16 of each kind, then every 4096th, with the state asked and made). Switch: VICTORY_STATE_SANITISE, on by default; =0 passes states on as before (the close guard then drops the transition instead). Tests: every_state_comes_out_as_one_close_takes runs all 2^16 low-bit combinations with five sets of high bits on seven kinds of texture through the guard's judge; four tests pin the measured cases. victory-gpu lib: 946 passed. Adapted for upstream main: every_state_comes_out_as_one_close_takes held the result against crate::checked::judge, which is not in this tree (it comes with the close guard). The test now carries the measured texture state rule itself as close_takes(); two comments no longer name crate::checked. No change outside the test module and comments. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01JzsiBtxAuHxjYfCpTzVV3h (cherry picked from commit 4893b97deb3263b04088ed3343f90c4ec579917e)@Dukestar69 on GitHub · 2026-11-30 05:14 UTC · original · approved these changes
Tested locally merged onto
main(41adb551).crates/victory-gpu/src/host.rs.a_write_state_stands_alone,every_state_comes_out_as_one_close_takes,a_forbidden_write_state_leaves_the_read_states).cargo test -p victory-gpu --lib host::tests::andlist::(20 passed; 0 failed) passed.Strong, hardware-verified defense against
E_INVALIDARG (0x80070057)command-listClose()failures from illegal D3D12 texture barrier state combinations. LGTM.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@dyshay on GitHub · 2026-11-30 05:49 UTC · original
Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch
janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with--profile diag --features diagnostics, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.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.