gpu: make texture states D3D12 refuses legal before they reach a barrier (0x80070057) #3487
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CubeB on 2026-11-29T23:50:57Z.
Branch:
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
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-30T05:14:41Z.
Review: APPROVED
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).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-30T05:49:57Z.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.