GPU: a texture is made in the uses its format takes #2773
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!2773
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2773"
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?
@kais7654 on GitHub · 2026-11-25 20:12 UTC · original
kais7654:gpu/formats-keep-the-uses-the-device-refuses→main· +210 −11 · 5 files · 2 commits · openFixes #2725 (group A — 14 of the 20 crashes; may also help #2719's group A).
What
The console makes any texture a render target or unordered storage. The host (D3D12) refuses resources with uses their format cannot take — on NVIDIA the 16-bit packed ones: B4G4R4A4 has no render-target support and neither B4G4R4A4 nor B5G5R5A1 supports typed UAVs. Until now the creation itself (and even a plain
GetResourceAllocationInfoof such a description) was an invalid call, which removed the device: the verbose log of #2725 reproduces one of these crashes 13 s after launch.Now a format's uses come from a cached
CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT)query, andhost_descleaves the refused uses away before anything reaches the device. The texture is created without them (its shader reads keep working).Host::rtv/Host::dsvreportNonefor a resource its view would not be valid on, andset_targets,ClearRenderTargetViewandClearDepthStencilViewleave such a target out, as they already do for a target without a recorded view — a dropped clear instead of a device removal.On formats that do take their uses (everything else), nothing changes.
Verified on hardware (RTX 5070, driver 616.87)
CheckFeatureSupportthere: B4G4R4A4 (115) — no RT, no UAV; B5G5R5A1 (86) — RT yes, UAV no — matching the report's debug-layer output.a_target_of_a_format_the_device_refuses_the_uses_of_is_made_without_them: the sanitized description agrees with the device's own answer for 86/115/87.cargo clippy --workspace --all-targets --locked -- -D warningsclean (standard and--all-features).cargo test -p victory-gpu --features diagnostics: 200 passed; the 2 failures are the heap-cap pair pre-existing on main on this machine (NVIDIA heap cap, #1943 family), unrelated to this diff.Not covered: the report's group B (DEVICE_HUNG in a mesh draw) and group C (feature level) are separate causes, and the 1M descriptor-heap cap of #2725's section 2 is its own fix; this PR takes the group that was 14/20 crashes.
AI-assisted: implemented with Mistral Vibe.
@fuzeofficlal on GitHub · 2026-11-25 20:27 UTC · original
Reviewed and tested
05d444c4(merged cleanly ontomain13f91ca) on Windows 11 (RTX 5090 + WARP).Blocking bug confirmed on both RTX 5090 and WARP:
format_usesstrips RT and UAV flags from allTYPELESSandsRGB + UNORDEREDtexturesIn
crates/victory-gpu/src/resource.rs:1131-1150,host_descfirst promotessRGB + UNORDEREDformats (29/91/93) toTYPELESS(27/90/92) and then queriesformat_uses(d.format)viaCheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT).In D3D12,
D3D12_FEATURE_FORMAT_SUPPORTreportsRENDER_TARGET = falseandTYPED_UNORDERED_ACCESS_VIEW = falsefor everyTYPELESSformat (views on a typeless resource supply the typed format, not the resource format itself). Probed directly on this branch on both RTX 5090 and WARP:format_uses(27 / R8G8B8A8_TYPELESS)->rt = false, uav = falseformat_uses(90 / B8G8R8A8_TYPELESS)->rt = false, uav = falseformat_uses(92 / B8G8R8X8_TYPELESS)->rt = false, uav = falsehost_descreturnsfmt = 27, flags = 0x0for bothR8G8B8A8_UNORM_SRGB (29) + RENDER_TARGET | UNORDEREDand title-createdR8G8B8A8_TYPELESS (27) + RENDER_TARGET | UNORDERED, stripping bothALLOW_RENDER_TARGETandALLOW_UNORDERED_ACCESS.B8G8R8X8_UNORM (88) + RENDER_TARGET | UNORDERED,format_uses(88)stripsALLOW_UNORDERED_ACCESSeven when a castableR32_UINT (42)UAV is valid on the resource.Skipping
TYPELESSformats informat_uses(or probing a representative typed format in the family) and preservingUNORDEREDfor formats castable to UAV-capable formats would avoid stripping legitimate RT/UAV flags.Verification & merge compatibility
--features diagnostics):resource::tests18/18 passed; full--test-threads=1197 passed, 2 failed (only the 2 pre-existing RTX 5090 >1M heap-cap baselines).VICTORY_D3D12_WARP=1,--features diagnostics --test-threads=1): 199 passed, 0 failed, 1 ignored.cargo clippy(default &diagnostics): 0 warnings;cargo xtask policy: 184 files ok.13f91ca,#2187,#2767(semantically mutually exclusive with#2767); conflicts with#2679inresource.rs.@oni-swr on GitHub · 2026-11-25 20:36 UTC · original
Independent verification of head
05d444c4(WARP/CPU): code looks right, but its test cannot catch the bug here.host_descdrops the render target / unordered use whenCheckFeatureSupportsays the format cannot take it.Host::rtvandHost::dsvreturnNonefor a resource without the flag, and the draw and clear paths skip such targets. This matches the described intent and is in scope. Tests:victory-gpu --lib196 pass, 0 fail (baseline 195). Clippy-D warningsis clean.host_descdisabled,a_target_of_a_format_the_device_refuses_the_uses_of_is_made_without_themstill passes. The test compareshost_descagainst the device's own report, and WARP takes all three formats, so it cannot fail there. It only catches the bug on a host that refuses a use, such as the NVIDIA case from #2725. Thertv/dsvNonepaths have no test at all. A device-free unit test of theNonepath, or a stubbed support table, would make this verifiable without that GPU.format_usescachestrue, truepermanently ifhost()is not yet available on its first call (!reported), so a later query is not redone.Method: WARP/CPU only (no physical GPU;
VICTORY_WARP=1,VICTORY_D3D12_WARP=1, Windows SDKdxil.dllon PATH, so DXIL validation ran),cargo test -p <crate> --lib --lockedandcargo clippy -p <crate> --all-targets --locked -- -D warnings, compared withorigin/main13f91cae. Nothing from the game was used.AI-assisted review (Claude Code / Claude Sonnet 5.5).
@kotekompotek on GitHub · 2026-11-25 20:38 UTC · original
Tightens the right seam: fits() now refuses any unordered view naming a format the device can't store - including the default view case (view==0 on a typed unstorable resource), which the old cast-only guard missed. Complements the creation-side work (making RTV/DSV fallible and skipping untaken uses keeps a dropped view from silently becoming device removal). Layers well with #2442's flag-drop: even where the flag survives, a bad view reads null instead of removing the device.
@kais7654 on GitHub · 2026-11-25 20:51 UTC · original
@fuzeofficlal Fixed in c1fcd74, on both points:
TYPELESS formats take their description's uses instead of the support report's (a typeless format names no view format itself, so the report is false-negative by construction) — the sRGB de-promoted targets keep theirs, and only the render target use is stripped at creation now, for a typed format the device refuses it on (the B4G4R4A4 of #2725). The unordered access use is no longer stripped at all: a creation the device refuses comes back a clean
E_INVALIDARG(probed on hardware), and what actually removed the device in #2725 was the view.So the removal's real spot is guarded where it happens:
fitsnow requires every typed unordered access view to name a format the device stores — own format and formats without a description included, which the oldtyped_storeguard only covered for cross-family casts. A UAV over B5G5R5A1/B4G4R4A4 reads null and drops its writes; a cast to a UAV-capable format (your R32_UINT case over B8G8R8X8) keeps working.New tests: the sanitized description of 86/115/87 agrees with the device on the render-target use and keeps the unordered one; typeless 27/90/92 and a sRGB promotion keep all uses;
typed_storeagrees with the device's report. Probed your exact sequences on hardware (RTX 5070, driver 616.87): typeless formats report rt=false/uav=false as you measured, and plainCreateCommittedResourcewithALLOW_UNORDERED_ACCESS+ B8G8R8X8 returns E_INVALIDARG without device removal. Clippy clean (default and diagnostics), the 2 remaining failures are the pre-existing heap-cap baselines on this machine. Thanks again for the catch.AI-assisted (Mistral Vibe).
@kais7654 on GitHub · 2026-11-25 20:52 UTC · original
@kotekompotek Thanks — the seam mattered: the creation side alone would have left a hole either way (keep the flag and the description's own view removes the device; drop the flag and every cast view dies with it), so the guard had to sit on the view. The default-view case (view==0 on a typed unstorable resource) was exactly the one that stayed open until this pass. Layering with #2442's flag-drop is the story of the whole fix: whatever survives the creation ends readable or bounded, never a removal.
AI-assisted (Mistral Vibe).
@fuzeofficlal on GitHub · 2026-11-25 21:31 UTC · original
Re-verified updated
c1fcd742on Windows 11 (RTX 5090 + WARP,--features diagnostics):TYPELESS(27/90/92) andsRGB + UNORDEREDflag-stripping issue is completely resolved:host_descno longer stripsUNORDEREDat resource creation,format_takes_render_targetpreserves all typeless families, anddescriptor::host::fits()now blocks unsupported typed-store UAVs on both default (view == 0) and explicit same-/cross-family views without device removal.cargo xtask policy: 184 files ok;cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default &--features diagnostics): 0 warnings.--features diagnostics,--test-threads=1): 198 passed, 2 failed (only the 2 pre-existing RTX 5090 >1M heap-limit testsdynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views), 1 ignored; both new tests pass.VICTORY_D3D12_WARP=1,--features diagnostics,--test-threads=1): 200 passed, 0 failed, 1 ignored.git merge-treeagainstorigin/main13f91ca(note: overlaps #2679 inresource.rsanddescriptor/host.rs).Non-blocking observations:
format_takes_render_targetis first called beforehost()is available (!reported),trueis cached permanently inKNOWN.Host::rtv/Host::dsvNoneskip paths do not yet have dedicated unit tests.Looks solid and ready from my side!
@artor410 on GitHub · 2026-11-25 21:53 UTC · original
Tested on RTX 3070 Ti, driver 610.88, Windows 11 26300, rustc 1.98.1. main
13f91ca. Merged into main cleanly (725d6f4).cargo test -p victory-gpu(main: 193 passed, 2 failed: the known heap-cap pairdynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views). With this PR: 195 passed, same 2 failed. Newan_unordered_view_names_a_format_the_device_storesanda_target_of_a_format_the_device_refuses_the_use_of_is_made_without_itpass.create_placedwith the UAV and/or RT flag, thendescriptor::host::make_view(View::Unordered(..))andHost::rtv(texture, None), thenGetDeviceRemovedReason, one process per case. On main: UAV view of 86 or 115 crashes the test process (0xc0000005 inside the driver); RTV of 115 removes the device (0x887A0001); 115 with RT|UAV gets no host texture.CheckFeatureSupporthere: 86 RT yes, typed UAV no; 115 RT no, typed UAV no.make_viewreturns no view; 115 with RT|UAV now gets a texture.Covers both formats and both uses, but by dropping them: draws to a 115 target and UAV writes to 86/115 are lost. #2767 makes the same cases work as R8G8B8A8.
(Claude Code, Claude Opus 5.5.)
@Marvisak on GitHub · 2026-11-25 23:22 UTC · original
Automated triage for the maintainers.
The current head strips the render-target flag in
resource::host_desc(via a newformat_takes_render_target) for formats the device refuses it on, and makesHost::rtv/Host::dsvreturnNonesodraw.rsset_targetsandlist.rsclear_rtv/clear_dsvskip such targets. A few things before this is mergeable:check) is failing on this head; please look at the job log and fix it.fits/typed_storeguard for unordered views described in the thread is already inmain(descriptor/host.rsfits, from #2462); this PR only adds a test for it, so the description should be updated to match what the diff does.format_takes_render_targetcachestruepermanently whenhost()is not yet available on its first call; it should not record an answer it did not get.rtv/dsvNonepaths also have no test.Generated by Claude Code
@zed6000 on GitHub · 2026-11-26 13:01 UTC · original
Merged onto current
main63bcca4(git merges it without a conflict),victory-gpu's tests don't compile:E0308 mismatched types. This PR makesHost::dsvandHost::rtvreturnOption<D3D12_CPU_DESCRIPTOR_HANDLE>, and two tests that landed onmainsince use the old form:crates/victory-gpu/src/pipeline/depth_bounds_test.rs(from #158):let dsv = host.dsv(&depth, None);crates/victory-gpu/src/queue.rs, a test'sClearRenderTargetView(host.rtv(&primary.texture, None), …)With
.expect("a depth buffer takes a depth view")and.expect("a render target takes a target view")on those two calls, it compiles, andcargo test -p victory-gpu --lib --locked -- --test-threads=1passes on an RX 7900 XTX (233 passed, 0 failed). Tested as part of a run of the GPU tests of open PRs on AMD hardware.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.