Read placed R9G9B9E5 views from the R32_UINT texture itself (no alias copies) #107
No reviewers
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX!107
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-107"
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?
@SousaTrashBin on GitHub · 2026-11-26 03:32 UTC · original
SousaTrashBin:rdna4/alias-cast-rgb9e5→main· +552 −2 · 5 files · 1 commits · openPlaced R9G9B9E5 views read the R32_UINT texture the host writes, without a copy
Every texture alias in a gameplay frame had the same pair of formats: the title writes a texture as
R32_UINTthrough unordered access, and reads the same memory through a view it places there asR9G9B9E5_SHAREDEXP. That format can be neither an unordered-access view nor a render target, sotexture::aliascopied the texture into a buffer and back into the placed view's own texture, level by level. That was 87 copies a frame and 8.7 ms of the card's time (RX 9070 XT, timing run), on textures up to 2560×1440.With relaxed format casting (
D3D12_OPTIONS12.RelaxedFormatCastingSupported):R32_UINTtextures with unordered access are made withCreateCommittedResource3, listingR9G9B9E5_SHAREDEXPas a castable format, in the layout their legacy initial state corresponds to (COMMON, RENDER_TARGET or UNORDERED_ACCESS). They are tagged with private data, so a freed address that comes back can never be mistaken for one. If one cannot be made, it is made as before.alias_of) gets its descriptor on that texture, inR9G9B9E5_SHAREDEXP, and the draw moves that texture to a shader-resource state. No copy is made.VICTORY_ALIAS_CAST=0turns it off.Measured in the title: 1,060 such reads a frame now go to the texture itself and 10 copies a frame remain; the alias copies' time went from 8.7 ms to 0.1 ms a frame.
Tests
R32_UINTunder legacy barriers and read through anR9G9B9E5_SHAREDEXPview decodes exactly as the format's definition says; the same texture still reads asR32_UINT; a null view is no alias.cargo test -p victory-gpu --libpasses apart fromtimeline::report::tests::real_waits_are_recorded_with_who_ended_them, which fails the same way onmain.Not checked yet
I have not compared the picture with the copy path. The view now reads the texture as it is at the draw instead of at the last copy, so differences would point at a copy that used to be stale. Worth a look at HDR-heavy places (sky, emissive surfaces) before merging.
A first version crashed at start-up on null shader views (a null
Thisreachedresource()); that is fixed and covered by the test.🤖 Generated with Claude Code
@bordersky on GitHub · 2026-11-26 05:45 UTC · original
A regression report from Linux, in case the host matters here: with this PR the main characters lose their faces, and
VICTORY_ALIAS_CAST=0alone brings them back.Setup: RX 7900 XT, Mesa/RADV, Wine with vkd3d-proton master (which reports relaxed format casting),
b0cfe2b+ this PR + #98 + #108,play.ps1settings withVICTORY_RELAY=1 VICTORY_CARD_STEPS=0 VICTORY_LAND_ECHO=0,VICTORY_BVH_BUILDER=1.b0cfe2bwithout the three PRsVICTORY_ALIAS_CAST=0Every run started from a new game with the checkpoint save (
SARC0015) removed beforehand, so it is not the bad-save case of #67/#13. One run each, same scene (the prologue's cells), looked at by eye.So the R32_UINT-as-R9G9B9E5 read seems to give something the face shading or deformation cannot use on this host. I have not looked further into which view it is; if a log line or a capture of a slot would help, say which and I can run it.
Timing here did not move with the three PRs together (~155 ms a frame against ~150 ms at ~6,800 draws, builder on), so I cannot say anything about the speed side of this one on its own.
@pokces on GitHub · 2026-11-26 06:50 UTC · original · edited 2026-11-26 07:07 UTC
I reproduced a stale packed-texture read on Windows 11 build 26300 with an RX 9070 XT (driver 32.0.32029.2010) on this PR’s
d6b7fdf. The reproducer uses a generated 4×4 texture and a one-thread compute shader. Test-only commitThe test copies the SRV into a shader-visible table once, samples writer A, then replaces it with writer B at the same guest address and samples again through the original descriptor. With
VICTORY_ALIAS_CAST=1, B should return RGB(0.265625, 0.390625, 7.1875), but the shader still reads A’s(2, 2, 2). WithVICTORY_ALIAS_CAST=0, the same executable reads A, B, and the subsequent CPU upload correctly. A local variant that retains a separate texture for views whose writer can change also passes all three samples with casting enabled.To reproduce from a checkout of this repository:
This isolates a writer-lifetime case in the Windows D3D12 path. Whether it also explains the face rendering reported on Wine is still open.
The added regression test and this report were generated by GPT 6.2 Astra. The reported samples were read back on the RX 9070 XT.
@avatarmanz on GitHub · 2026-11-26 07:35 UTC · original
Left open: VICTORY_ALIAS_CAST is on by default wherever relaxed format casting exists (the 7900 XTX too); needs an in-game check there first.
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.