GPU: ignore clear values on non-target textures and avoid caching failed host textures in PLACED_TEXTURES #1422
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!1422
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1422"
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?
@ESAT586 on GitHub · 2026-11-24 17:55 UTC · original
ESAT586:gpu/resource-clear-value-and-placed-cache→main· +84 −7 · 1 files · 1 commits · openSummary
Fixes two resource-creation bugs tracked in #1242 (
VIC-BT-022andVIC-BT-027) incrates/victory-gpu/src/resource.rs:Optimized clear value on non-target textures (
VIC-BT-022):CreateCommittedResourcerejects a non-nullpOptimizedClearValueunlessD3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGETorD3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCILis set.host_texture()now ignoresclearwheneverd.flags & (1 | 2) == 0.Failed host textures cached in
PLACED_TEXTURES(VIC-BT-027):texture_at()previously insertedoutintoPLACED_TEXTURESbefore checkingresource(out).host.is_some(). If host texture creation failed, the first call returnedNonewhile leaking theResourcebox, and every subsequent lookup for that(address, desc)returnedSome(r)withhost == None.texture_at()now checksresource(out).host.is_none()first, releasesoutviaobject::release_boxed::<Resource>(out), and returnsNonewithout poisoningPLACED_TEXTURES.Verification
Tested locally on Windows 11 with NVIDIA GeForce RTX 3060 Ti (
Driver 32.0.16.1656), Rust1.98.1MSVC:cargo clippy --workspace --all-targets --locked -- -D warnings— 0 warningscargo clippy --workspace --all-targets --all-features --locked -- -D warnings— 0 warningscargo test -p victory-gpu --all-features --locked— 54 passed, 0 failed, 1 ignored (includingnon_target_texture_ignores_clear_value_and_placed_cache_skips_failureson RTX 3060 Ti)cargo xtask policy— 154 files ok@wbkepler on GitHub · 2026-11-24 20:56 UTC · original
Interaction note: the VIC-BT-027 half of this PR matches the
texture_athunk in #1353. Both releaseoutbefore inserting intoPLACED_TEXTURESand returnNone.object::release_boxed::<Resource>is exactly whatresource_releasedoes, so the two versions behave the same. Releasing while holding thePLACED_TEXTURESlock is also safe:Drop for Resourceonly touchestexture::forget,descriptor::forgetandshadow, never that map. Only one of the two needs to land.The VIC-BT-022 half is only in this PR and looks right. The check runs after
d.flags &= PC_FLAGS, so the RT (1) and DS (2) bits it tests are the ones the host will actually see.AI-assisted review (Claude Code); checked on Windows 11 / RTX 5090.
@acetonahard-code on GitHub · 2026-11-24 21:08 UTC · original
Partial overlap: #1353 also stops
texture_atfrom caching a placed texture whose host texture failed, as part of a larger change. The two conflict inresource.rs.Tested on Windows 11, RTX 4070 SUPER (driver 621.14), with the repo toolchain, merged into current
main(ffe310e):cargo test -p victory-gpumainmain+ this PRmain,--all-featuresmain+ this PR,--all-featurescargo clippy --all-targets -- -D warnings, with and without--all-features: clean.cargo fmt --checkwould rewrap 2 blocks this PR adds (resource.rs).mainisn't rustfmt-clean either, so take it or leave it.I didn't test with game data.
Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.
@Marvisak on GitHub · 2026-11-25 03:27 UTC · original · edited 2026-11-25 16:44 UTC
Automated triage for the maintainers.
Needs work.
The clear-value half looks right. In
make_texture(crates/victory-gpu/src/resource.rs), the PR drops the optimized clear value unless the host flags include render target or depth-stencil. D3D12 rejects a clear value on any other texture.The
texture_athalf changes behaviour, and the stated reason does not match main. On main, a resource whose host texture failed is not leaked. It stays inPLACED_TEXTURES, andResource::hostcaches the failure asSome(None). So later lookups get the same resource without another attempt, and callers such asplaced_texturealready handle a resource with no host copy. With this PR, every lookup for such memory runscreate_at_addressand a failing host texture creation again. That is a repeated failing D3D12 call on each descriptor write. The PR also creates the resource before inserting it, so concurrent callers now each build one and all but one are thrown away.To move forward, either drop the
texture_atchange and keep the clear-value fix, or show a case where retrying succeeds (for example a transient budget failure) and limit how often it retries.CI (
check) passes on this head.Generated by Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 02:38 UTC · original
I tested the clear-value half separately in response to the review. 14f1028 is a fast-forward from your exact HEAD
4e3e669. It keeps your clear-value guard and restores the previoustexture_atbehavior.The same synthetic Windows/WARP test calls
create_committedand fetches the D3D12 resource. On upstream63bcca4, the sampled and UAV textures given a clear value have no host resource. With the narrowed change both get one. The sampled texture given a null clear value and the render-target and depth-stencil controls succeed in both builds. Six paired runs gave the same result, and the fixture verifies the flags of each returned resource.The fork commit passed 199 GPU tests with one ignored. Its clean merge with
63bcca4matches the source used for the current-main test, which passed 247 GPU tests with one ignored. Strict GPU Clippy and the asset policy passed.Please retain the Git author if you cherry-pick the follow-up. If you fold the test or other changes from this commit into yours, please include:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted with Codex. Synthetic resources only.
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.