Skip to content

GPU: the console's packed 4-bit colour target stands in as B5G5R5A1 - #2332

Open
fiestorra wants to merge 1 commit into
Marvisak:mainfrom
fiestorra:gpu/b4g4r4a4-stands-in
Open

fiestorra wants to merge 1 commit into
Marvisak:mainfrom
fiestorra:gpu/b4g4r4a4-stands-in

Conversation

@fiestorra

Copy link
Copy Markdown
Contributor

The 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_format maps 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:

  • same element size — two bytes per texel both, so no ladder step, no copy size and no footprint changes. The obvious alternative, R8G8B8A8_UNORM (28), would double the resource and every copy of it;
  • a format PC does take as a target, which is the thing that was killing the run;
  • the mapping is applied by every path that names the format — host_desc, view_format, the descriptor tables, the twin path, the pipeline's render-target formats — because they all call pc_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 R8G8B8A8 precision 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):

no host texture                  0        (before: 1, the 2560x1440 format 115 target)
CreateRenderTargetView   …        0 layer errors
RemoveDevice             …        0
GPU failure                       0
last frame presented              frame=8192 draws=53248

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.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JAEdotUK

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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 0e350ab1 both 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.

4×4 test RTX 5080 pixels differing from the original RGBA4 colors WARP pixels differing
Parent 940d32f6, upload the packed words and sample format 115 0/16 0/16
PR, upload the same words and sample format 86 14/16 14/16
PR, clear format 86 to the original colors and sample it 11/16 11/16
RGBA8 control, either revision 0/16 0/16

Alpha 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants