GPU: the console's packed 4-bit colour target stands in as B5G5R5A1 #2332
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!2332
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2332"
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?
@fiestorra on GitHub · 2026-11-25 10:47 UTC · original
fiestorra:gpu/b4g4r4a4-stands-in→main· +180 −10 · 2 files · 4 commits · openThe console's packed 4-bit colour target has no PC render target on NVIDIA; it stands in as the same two bytes
Format 115 (
B4G4R4A4_UNORM) is what the title asks for its 2560×1440 target, and NVIDIA reports it as a render target and then refuses the view — an illegal call that removes the device (issue #1952, with the debug layer naming it).pc_formatmaps the console's 16-bit depth formats (118/119/120) to PC ones and leaves everything else alone, so 115 reached the host as itself.Change:
pc_format(115) = 86(B5G5R5A1_UNORM), and the choice is not aesthetic:R8G8B8A8_UNORM(28), would double the resource and every copy of it;host_desc,view_format, the descriptor tables, the twin path, the pipeline's render-target formats — because they all callpc_format, so the stand-in cannot be applied to the resource but not to a view of it (which would move the illegal call to the sampling view instead of removing it).The cost, stated plainly: the title writes 4-4-4-4 and reads 5-5-5-1, so colours through that target are reinterpreted. A shifted picture instead of no picture, and the step to take before
R8G8B8A8precision would be needed. If 86 ever turns out to be refused on another vendor, 85 (B5G6R5_UNORM) is the next two-byte candidate.Measured (RTX 4090,
32.0.16.2124, diag build with the debug layer, session 1, empty cache, 330 s, this change with #1630 + #1832 + #1778):So the target is created, the illegal call is gone, and the run survives to 8,192 frames. What is not verified: that the world now draws. The run stayed on the setup screens (no keys scripted), and "the world is no longer black" is a claim I am not making — it needs a run that reaches the world, which is the next measurement.
No game data is involved: format numbers, counts and log text.
Written with an AI assistant.
@JAEdotUK on GitHub · 2026-11-25 11:02 UTC · original
Tested on Windows 11 with an AMD RX 9070 XT — cargo test --workspace (including victory-gpu and victory-shader) compiled cleanly and passed with 0 failures!
@steven-seagull27 on GitHub · 2026-11-25 11:10 UTC · original
Tested the format-86 fallback on an RTX 5080 (621.40) and built-in Microsoft WARP (10.0.26100.10068), Windows 11 build 26300.10075. On
0e350ab1both adapters created the 5-5-5-1 render target, cleared a 4×4 grid to 16 known colors, and read all 16 pixels back through a shader. The D3D12 debug layer reported no errors in that test.940d32f6, upload the packed words and sample format 115Alpha changed in 10/16 pixels on each adapter in both format-86 cases. The distinction between uploaded bytes and rendered colors is visible on
0xFF00. The original word was opaque red. Reinterpreting it on the PR gave(1, 0.7765, 0, 1)on RTX and(1, 0.7742, 0, 1)on WARP. Clearing the fallback target to opaque red still produced exact red on both.For anyone adding a test, all 16 cleared pixels on WARP matched the 5-bit RGB code divided by 31. The RTX readbacks matched expanding each 5-bit code to 8 bits with
(n << 3) | (n >> 2)and dividing by 255. That small precision difference is separate from the channel and alpha changes above. This was a synthetic grid. Whether gameplay reaches and displays the world remains open.@Marvisak on GitHub · 2026-11-25 15:23 UTC · original · edited 2026-11-26 03:20 UTC
Automated triage for the maintainers.
Thanks for the rebase. Reviewed at
44638a8, which merges cleanly. CI: passing.The change maps format 115 (
B4G4R4A4_UNORM) to 86 (B5G5R5A1_UNORM) inresource.rspc_format, for every resource, view and pipeline on every adapter. The testers' runs confirm it stops the render-target-view device removal on NVIDIA. Thanks, @Bladureau and @KainanP. But:B5G5R5A1is no typed-UAV format there either. So the stand-in does not fully fix the crash it targets.R8G8B8A8where the host cannot use the format (#2626, #2767, #2936).To move forward, gate the stand-in on the host's format support (render target and typed UAV), and show it beats widening. Otherwise, consider joining one of the widening PRs.
Verdict: needs work. CI: passing.
Generated by Claude Code
@Bladureau on GitHub · 2026-11-25 16:20 UTC · original
RTX 4060 Laptop: in the world, this removes the format-115 device removal (render-target path only; colours not checked)
Machine: RTX 4060 Laptop 8 GB (driver 617.14, 32-lane waves), i7-13650HX, 32 GB RAM, Windows 11 26300. Series X mode, title 1.0.2.1. Diagnostics build, shader cache filled with
translate --cachefirst.Tree:
main940d32f+ #2121 (40bd210) + #1763 (50d91b1) + #1630 (3c036f7) + #2176 (3feadc6) + #579 (rebased, from the patch in its thread). That is the tree from #965 that shows a lit world on this GPU model. Then this PR (0e350ab) on top.VICTORY_SKIP_WAVE64=mesh,compute,VICTORY_D3D12_DEBUG=1(except run 1),VICTORY_D3D12_DRED=1.0x887A0001), 39 s after world entry (run 1); before world entry (run 2)ID3D12Device::CreateRenderTargetView: The format (0x73, B4G4R4A4_UNORM) cannot be used with a RenderTarget view because this particular graphics implementation doesn't support this format.ERRORlinesThe message also stayed at 0 in five more runs with this PR that reached the world with other wave64 settings. Those runs ended for other reasons: once on a hang in the BVH builder, once stopped by hand, three times on the title's watchdog (#1118).
The other debug-layer messages in the run with this PR come from elsewhere: ID 527 (497 times, buffer states, see #334), ID 971 (pipeline library misses), and a few IDs 538, 599, 645, 679, 680, 820 and 1419.
What this does not show:
RENDER_TARGETfor format 115 and then the view is refused. If that holds on this card too, a gate onCheckFeatureSupportalone would not trigger on NVIDIA. I have not measured the query on this card.Happy to run a narrowed version (render targets only, or a colour-keeping stand-in) on this card in the same world scene.
One run per configuration. Counts and messages only, no game data. AI-assisted (Claude Code).
@KainanP on GitHub · 2026-11-25 19:36 UTC · original
RTX 4060 Laptop (610.47), merged onto main
13f91cae(adjacent-line conflict inpc_format): B4G4R4A4 target half renders (as B5G5R5A1, with the bits reinterpreted), B5G5R5A1 UAV half still removes the device; your own test fails on main, which now maps 118 to 20 rather than 45. Note: this RTX reports RENDER_TARGET = no for 115 (it does not report support and then refuse). Details and the side-by-side table with the other #1753 PRs: #1753. Tested with the help of an AI assistant (Claude Code).44638a89b5to31848207ff@catminou4 on GitHub · 2026-11-25 10:54 UTC · original · reviewed
B4G4R4A4_UNORM stands in as B5G5R5A1_UNORM on hosts where NVIDIA's view creation removes the device (#1952); colors shift rather than vanish. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Same #1952 cluster as #2305/#2319.
@fiestorra on GitHub · 2026-11-26 12:22 UTC · original
The stand-in is now conditional on the host, and it carries the view guard with it
Head
31848207, rebased onto63bcca43. The three points are answered, and the second one is why this branch now also contains what was #2305.pc_formatmaps nothing for 115 again. The choice lives where the host is known:stand_in_for(115)asks the adapter (host.vendor, plusCheckFeatureSupportfor the format and forB5G5R5A1_UNORM) and returns the stand-in only when the host refusesB4G4R4A4_UNORMand takesB5G5R5A1. A host that renders to 4-4-4-4 keeps its colours; an adapter that takes neither keeps the format and gets a null view (below) instead of a removed device.stand_in_decisionis the pure part and its four cases are pinned in the test.Host::rtvkeeps a view of a format the host refuses off entirely — vendor refused, or the support query says no — with onewarn!and a null descriptor, so the UAV path that still removes the device on an RTX 4060 no longer does it through a render target. I am not claiming that fixes the UAV half;#1763refusing the UAV view is the fix there.R8G8B8A8changes the element from 2 to 4 bytes: every ladder step, placed footprint and copy that assumes two bytes would have to change with it, and the title's memory is mapped by those sizes. The stand-in is the only option that keeps the byte layout, which is what a render target the title writes and reads through the same memory needs. That is the argument for this over widening, and it is why I did not join those branches — but where a host takes 4-4-4-4 natively, neither is needed and this now does nothing.Consolidation: #2305 was the same cluster and is closed into this branch, so there is one place that decides what a refused target is made as (
stand_in_for) and one that decides how a view of it is bound (Host::rtv).Measured:
cargo test -p victory-gpu --lib→ 232 passed, 0 failed;cargo clippy -p victory-gpu --all-targets -- -D warningsclean. On this machine (RTX 4090, driver 32.0.16.2124)stand_in_for(115)returns the stand-in, and a boot reaches the title's 2560x1440 target without a device removal.Written with an AI assistant.
@fiestorra on GitHub · 2026-11-26 13:55 UTC · original
KainanP's UAV half is now handled where it belongs: the stand-in is skipped for textures written through a UAV
Head
9ada995b. The report you relayed — the UAV half of the same texture still removes the device on an RTX 4060 Laptop becauseB5G5R5A1is not a typed-UAV format there either — changes the decision, and it should:B4G4R4A4is refused as a render target andB5G5R5A1is refused as a typed UAV, so standing one in for the other trades a removed device for lost writes on any texture that is both.stand_in_for(format, flags)now takes the description's flags. A texture with the unordered-access flag keeps its own format:stand_in_decision(115, refused, stand_in_taken, unordered_use)returnsNonefor it, with adebugline saying why. The render-target case (no UAV flag) still stands in as before.B4G4R4A4, the render-target view of it is refused (this is whatHost::rtvhandles with a null view and a warning, and what #1832 handles on the UAV side by dropping a permission the element cannot carry) instead of the whole device being removed atCreateRenderTargetView.Measured:
cargo test -p victory-gpu --lib -- packed_four_bit→ 1 passed;cargo clippy -p victory-gpu --all-targets -- -D warningsclean.Still true from before: where a host renders to 4-4-4-4 natively, none of this runs and the colours are unchanged.
Written with an AI assistant.
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.