Repository navigation
fix(gpu): add RTV/UAV format fallbacks and restrict format 67 promotion for placed views - #2832
legayclightning22 wants to merge 3 commits into
Conversation
kotekompotek
left a comment
There was a problem hiding this comment.
Noting the overlap: this is the third concurrent take on the unsupported-RTV/UAV space (after #2773's view-side guard, #2834, and #2442's flag-drop in host_desc). Doing it in make_texture avoids #2834's family-members trap — the !typeless guard means only standalone formats reach the drop, where no cast path exists anyway; and the takes() narrowing to exact castable.contains is stricter and correct (a family member not in the creation's castable list is not a legal view format). The 67 promotion gate — promote only when RTV is needed, or UAV plus OTHER uses — is right: a UAV-only 67 texture can't be rescued by promotion since 26 lacks typed UAV there anyway, so it keeps its format and just loses the use. Query-failure->support=0 errs toward dropping uses rather than crashing creation, which is the safe direction given a NULL descriptor beats a removed device. LGTM; worth coordinating with #2442's host_desc-side drop so the two don't diverge on which formats get promoted vs flagged.
|
Tested 1. Deterministic RTX 5090 regression (
|
|
Thank you both for the thorough review and RTX 5090 hardware verification!
|
|
Automated triage for the maintainers. Verdict: needs work. It merges cleanly, but the approach in You said you are reworking this. Please also check #2442, #2626 and #2767, which handle the same formats. To change this verdict, a stand-in format needs matching conversion on upload and readback, plus tests that write through the view and read the data back. CI: passing. Generated by Claude Code |
Why This Change Is Needed & What It Improves
Prevents D3D12 resource creation failures, placed-view format mismatches, and GPU device hangs/TDRs when titles bind textures with formats that lack native RTV/UAV hardware support or alias placed SRVs over existing texture memory.
Specifically, this improves:
67,86, or115cleanly promote to hardware-supported D3D12 formats (26/87) instead of failing resource creation or triggering D3D12 validation errors.67textures keep their expected format unless RTV/UAV promotion is strictly required, preventing silent format mismatches during draw calls (including thedraw.rsformat67 -> 26placed-view failure).HostTextureallocations viat.castable, reducing redundant texture allocations and preventing incompatible view bindings.What Was Happening & Root Cause
67,86,115): Certain translated texture formats do not natively support RTV or UAV usage flags on D3D12 hardware. Previously,make_textureattempted to allocate these formats directly without checkingformat_support, leading to failed resource creation, invalid view bindings, and downstream device removal/TDRs during rendering passes.67Promotion on Placed Views: Promoting format67unconditionally to26broke placed SRV views that alias the underlying memory as format67, causing a format mismatch (67vs.26) at draw time.HostTexture::takeschecked exact format equality rather than checking whether the requested format was int.castable, rejecting valid placed-view aliases over compatible typeless/castable backing textures.Changes Made
crates/victory-gpu/src/resource.rs): Addedformat_supportqueries inmake_textureto promote unsupported RTV/UAV formats (67 -> 26,86 -> 87,115 -> 26) when required by resource usage flags.67Promotion: Restricted format67 -> 26promotion toneed_rtv || (need_uav && d.flags & !UNORDERED != 0)so placed SRVs do not get unexpectedly promoted to format26.HostTexture::takesto checkt.castable.contains(&d.format)for placed views.Verification
host_texture_handles_unsupported_rtv_and_uav_formatsincrates/victory-gpu/src/resource.rs.cargo test -p victory-gpu --lib --features diagnosticson WARP (199 passed; 0 failed) andcargo clippy -p victory-gpu --all-targets(0 errors; 0 warnings).(Split from #1799 into a single-topic PR as requested.)