fix(gpu): add RTV/UAV format fallbacks and restrict format 67 promotion for placed views #2832
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!2832
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2832"
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?
@legayclightning22 on GitHub · 2026-11-25 21:40 UTC · original
legayclightning22:fix/placed-view-format-67→main· +251 −10 · 3 files · 6 commits · openWhy 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.)
@fuzeofficlal on GitHub · 2026-11-25 22:47 UTC · original
Tested
2f949b38on Windows 11 (RTX 5090 + WARP) and found a deterministic RTX 5090 test regression plus three format/view-compatibility issues:1. Deterministic RTX 5090 regression (
draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view)13f91ca, passes on commits06a1633and9445274, and passes on WARP, but fails 5/5 runs on RTX 5090 at HEAD2f949b38(including withVICTORY_D3D12_DEBUG=1):crates/victory-gpu/src/draw.rs:2396: round 0: one host texture left: false right: true.round 0registersobject(R32_UINT42,flags=4lazy) first, thenplaced_view(R9G9B9E5_SHAREDEXP67,flags=0) triggers.host()viaplaced_texture -> texture_at.shared_texturemergesobject'sUNORDEREDonto format67; on RTX 5090format_support(67)lacksTYPED_UNORDERED_ACCESS_VIEW, so2f949b38skips67 -> 26promotion and stripsUNORDERED(d.flags &= !UNORDERED) even thoughUNORDEREDcame from the castable siblingR32_UINT (42). Whenhost_copy(object)then callstakes(), the host texture lacksUNORDERED, forcing a secondHostTextureand breaking shared-texture aliasing.2. Silent cross-family & cross-bpp promotion breaks views and copies
d.formatinmake_texture(67 -> 26,86/115 -> 87) without updatingResource::desccauses:descriptor::host::fits()to reject views in the original format family as mismatched and null them out;CreateRenderTargetViewwith original format86/115/67against an87/26host resource to violate D3D12 format rules;86/115(16-bit, 2 B/px) ->87(32-bit, 4 B/px) to double bytes-per-pixel, breakingupload/alias_copy/read_backstrides.3.
HostTexture::takesregression (resource.rs:1305)t.castable.iter().any(|&c| family(c) == family(d.format))tot.castable.contains(&d.format)breaks typeless cross-family placed matches (e.g.27/90) becausecastable()excludes typeless formats.4. Minor
CheckFeatureSupportis called uncached on everymake_texture, andhost_texture_handles_unsupported_rtv_and_uav_formatsonly assertsmake_texture(...).is_some()without testing RTV/SRV/UAV creation or copies.@legayclightning22 on GitHub · 2026-11-26 01:05 UTC · original
Thank you both for the thorough review and RTX 5090 hardware verification!
@kotecompotek#2773,#2834, and#2442and confirming why handling unsupported RTV/UAV formats atmake_textureavoids#2834's family-members trap while keeping the!typelessguard scoped to standalone formats.#2442'shost_desc-side flag drop so format promotion vs. flag dropping stays consistent across the pipeline.@fuzeofficialThank you for catching the deterministic RTX 5090 failure and the three format/view-compatibility issues that WARP didn't surface:
shared_texture/UNORDEREDstripping regression (a_texture_written_in_one_format_reads_in_another_through_a_placed_view):shared_texturemergesUNORDEREDfrom a castable sibling (R32_UINT42) onto format67, skipping67 -> 26promotion and strippingUNORDERED(d.flags &= !UNORDERED) breaksHostTexture::takes()on subsequenthost_copycalls and forces a duplicateHostTexture, breaking shared-texture aliasing.67 -> 26,86/115 -> 87):d.formatinsidemake_texturewithout updatingResource::desccausesdescriptor::host::fits()to null out views in the original format family, violates D3D12 format rules onCreateRenderTargetView, and doubles bytes-per-pixel (86/11516-bit ->8732-bit), breakingupload/alias_copy/read_backstrides.HostTexture::takestypeless cross-family regression (resource.rs:1305):t.castable.iter().any(|&c| family(c) == family(d.format))tot.castable.contains(&d.format)rejects valid typeless cross-family placed matches (such as27/90) becausecastable()excludes typeless formats.CheckFeatureSupportrather than querying uncached permake_texture, and extending unit tests beyondmake_texture(...).is_some()to exercise actual RTV/SRV/UAV view creation and copies.I am updating
fix/placed-view-format-67to resolve these four items and coordinate cleanly with#2442.@Marvisak on GitHub · 2026-11-26 03:19 UTC · original
Automated triage for the maintainers.
Verdict: needs work. It merges cleanly, but the approach in
make_texture(crates/victory-gpu/src/resource.rs) changes data, not just flags. It swapsd.formatfor the host texture only.86/115are 2 bytes per texel and become87at 4 bytes, so uploads, alias copies and readbacks of title memory use the wrong stride.67(R9G9B9E5) becomes26(R11G11B10_FLOAT), which reads the same bits as a different encoding.Resource::desckeeps the old format, so views made in the original format no longer match the texture. Intakes,castable.contains(&d.format)rejects typeless placed matches that the family check accepted. fuzeofficlal also reportsdraw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_viewfailing 5/5 on an RTX 5090. The new test only checks thatmake_texturereturnsSome.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
@kotekompotek on GitHub · 2026-11-25 21:58 UTC · original · reviewed
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.
@legayclightning22 on GitHub · 2026-11-26 14:39 UTC · original
Updated
fix/placed-view-format-67(cfd2a4f):d.formatandclear_valueformat mutations (67 -> 26,86/115 -> 87, and sibling format swaps) soResource::descand texel strides remain unchanged.host_descto strip unsupported standaloneRENDER_TARGETandUNORDEREDflags on non-typeless textures via cachedHost::format_support(CheckFeatureSupport).shared_textureso placed views (format = 67) sharing memory with anUNORDEREDresource reuse the underlyingHostTexturewithout forcing unsupported flags onto format67.a_texture_written_in_one_format_reads_in_another_through_a_placed_view,host_texture_handles_unsupported_rtv_and_uav_formats,cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--features diagnostics), andcargo xtask policy.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.