GPU: revalidate bound depth state after compute reads #4549
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!4549
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4548"
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?
@d8ahazard on GitHub · 2026-11-30 22:17 UTC · original
d8ahazard:codex/depth-state-transition→main· +1185 −852 · 35 files · 14 commits · closed without mergingWhat it changes
An intervening compute SRV, copy, or internal pass can change a bound depth texture's state without changing the DSV. The next graphics draw currently skips its transition when its desired state equals
State::last_depth_state, even though that cache no longer describes the resource. This leaves a read-only depth draw using a texture in shader-read state and produces D3D12 message 538.Always revalidate the computed depth state through the command list's existing tracker, which already deduplicates actual no-op transitions. Preserve the combined
DEPTH_READ | SHADER_RESOURCEstate for a draw that also samples its depth texture. Depth preparation is factored into a private method so the regression exercises the production path.The opt-in native regression uses authored 4×4 resources and shaders. It covers read-only depth → compute SRV → the same read-only depth, simultaneous depth/SRV reads, and a writable-depth control. It checks the actual compute result, 16 rasterized samples, depth readback, device completion, and the debug InfoQueue. A separate legacy-gate control reproduces the validation error while recording and never submits the invalid command list. The test-only
victory-coredependency keeps its output outside the repository.How it was tested
GPU/profile: Windows, NVIDIA RTX PRO 5000 Blackwell; Series X, native 2560×1440, DLAA, 2× DLSS frame generation. The game's RT passes without a structure builder remain omitted.
Before: the legacy desired-state gate reproduces D3D12 error 538 while recording; that invalid command list is never submitted.
After: the corrected native controls return the expected GPU values with zero error-level debug messages.
Shader wave sizes: not applicable; no shader or translator change.
Native D3D12 regression and legacy control pass with the device LUID matched to its DXGI hardware adapter. All three corrected controls return the expected GPU values with zero error-level debug messages.
cargo check --workspace --all-targets --all-features --lockedpasses.All 14
draw::testspass.Staged asset policy passes for all five changed files;
git diff --cached --checkpasses.An optimized local integration build completed a 15-minute in-world smoke check at native 1440p with DLAA and 2× DLSS frame generation, including character appearance and wardrobe operations, and remained responsive. The clean PR source was separately validated with the native regression.
Strict workspace Clippy remains blocked by inherited
Lowered::loop_caps/Shadow::rangeddead-code errors and the existingseed % 3test lint inhost.rs. Whole-tree policy reports the unchanged 560-character run invictory-shader/src/native.rs. These are outside this change; no lint or policy is suppressed. The full touched-crate/workspace test suites were not rerun; the selected draw tests and native regression are the completed test coverage.Checked for overlap
@IRennie74 on GitHub · 2026-11-30 22:39 UTC · original
This and #4512 change the same lines in
State::prepare_targets(thelast_depth_stategate), so only one of them can go in as is. #4512 also fixesmirror_light(colourmoved to 0xC0, not 0x80), which this PR does not touch and which would be worth carrying over.With the gate gone,
State::last_depth_state(draw.rs:676 on main) is only ever written outside tests: the gate was its one read in the library, and the remaining reads are in#[cfg(test)]code. That should give a newfield is never readwarning in the non-test build, which-D warningsturns into an error. It is hidden for now by the dead-code errors already on main. Either drop the field (and its resets at thereset/set_*sites) or keep it as the cache below.On cost: dropping the gate means one
ensure_stateper draw with a depth target (ahost_copylookup plus the list'sstatesmutex) even when nothing changed. That runs on the list-recording threads, not the submitting thread. Still, on a 6-core CPU (Ryzen 5 5600X, RTX 3060) the submit head waits about 6 ms a frame for lists still being recorded, at 4,500-5,000 draws a frame. The extra cost is probably small next to the rest of a draw. A cheaper equivalent would keep the gate and clearlast_depth_statewherever a dispatch, copy or internal pass on the same list can moveself.depth, as #4512 already does for dispatches.@trustno1-coder on GitHub · 2026-12-01 18:37 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed