d3d12: give narrow textures room for their 4 KiB swizzle #198

Merged
Jerkin42 merged 2 commits from upstream-pr/198 into main 2026-11-25 23:23:58 +00:00
Jerkin42 commented 2026-11-25 21:08:55 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Jerkin42 on 2026-11-25T21:08:55Z.


Summary

ProjectScarlett asks GetResourceAllocationInfo how big a small texture is (undefined layout, 4 KiB alignment), allocates that much guest memory, reads the texture from its archive into it and then creates it with the 4 KiB swizzle. TuxBox passed on the host driver's answer. RADV gives narrow images 256-byte tiles, so a 256x2 RGBA16F table was 0x2000 bytes instead of 0x8000.

The compressed stream then did not fit the destination and the whole read failed, which left the texture zero. In the prologue that was 46 to 69 textures a run, among them the table hair lighting divides by: hair and cloth sparkled with NaN pixels and the picture had a white haze.

Such a texture is now at least as large as its 4 KiB swizzle, which the XG layout code already computes. The host's answer stays when it is larger or when the host does not place the texture at 4 KiB, so textures placed in a host heap still fit. GetResourceAllocationInfo1 answers the same way.

With this change no read fails on that path, 110 of the 111 narrow textures loaded at the window shot hold data (the other one is written by the game at run time), and the sparkle and the haze are gone.

Verified on Lanes

  • python tuxbox.py check passed on this branch
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below

GPU, driver and backend: RX 9060 XT, RADV (Mesa 26.1.8), Proton Experimental

passed   Build the shader compiler
passed   Python tests
passed   Shader compiler tests
passed   DXBC tests
passed   XG layout tests
passed   D3D12 Windows typecheck
passed   Build
FAILED   Lanes and fixtures on the GPU   guest-present (5 cases), invalid-route
FAILED   D3D12 regression controls       buffer-remap
passed   Shader translator on the GPU

The same seven cases fail on plain main on this machine (last compared at 7b22d71), where I run the check in a private Xwayland inside a container.

Not a Lanes scenario because it is about one query's answer. d3d12-features now asks for six narrow textures (two of them with unordered access), alone and as a batch, through both queries. It fails on the old runtime, fails without the second query's part and passes on this branch. The full check above ran before the second commit. After it I reran d3d12-features and the typecheck.

Only measured on RADV. A host driver that already returns the larger size sees no change.

Checks

  • shader compiler tests: 313 passed
  • tuxbox-dxbc: 64, tuxbox-xg-layout: 14, Python suite passed
  • cargo check of tuxbox-d3d12 for x86_64-pc-windows-msvc

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:6613798084 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/198). Originally posted by [Jerkin42](https://github.com/Jerkin42) on 2026-11-25T21:08:55Z. --- ## Summary ProjectScarlett asks `GetResourceAllocationInfo` how big a small texture is (undefined layout, 4 KiB alignment), allocates that much guest memory, reads the texture from its archive into it and then creates it with the 4 KiB swizzle. TuxBox passed on the host driver's answer. RADV gives narrow images 256-byte tiles, so a 256x2 RGBA16F table was 0x2000 bytes instead of 0x8000. The compressed stream then did not fit the destination and the whole read failed, which left the texture zero. In the prologue that was 46 to 69 textures a run, among them the table hair lighting divides by: hair and cloth sparkled with NaN pixels and the picture had a white haze. Such a texture is now at least as large as its 4 KiB swizzle, which the XG layout code already computes. The host's answer stays when it is larger or when the host does not place the texture at 4 KiB, so textures placed in a host heap still fit. `GetResourceAllocationInfo1` answers the same way. With this change no read fails on that path, 110 of the 111 narrow textures loaded at the window shot hold data (the other one is written by the game at run time), and the sparkle and the haze are gone. ## Verified on Lanes - [ ] `python tuxbox.py check` passed on this branch - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below GPU, driver and backend: RX 9060 XT, RADV (Mesa 26.1.8), Proton Experimental ```text passed Build the shader compiler passed Python tests passed Shader compiler tests passed DXBC tests passed XG layout tests passed D3D12 Windows typecheck passed Build FAILED Lanes and fixtures on the GPU guest-present (5 cases), invalid-route FAILED D3D12 regression controls buffer-remap passed Shader translator on the GPU ``` The same seven cases fail on plain main on this machine (last compared at 7b22d71), where I run the check in a private Xwayland inside a container. Not a Lanes scenario because it is about one query's answer. `d3d12-features` now asks for six narrow textures (two of them with unordered access), alone and as a batch, through both queries. It fails on the old runtime, fails without the second query's part and passes on this branch. The full check above ran before the second commit. After it I reran `d3d12-features` and the typecheck. Only measured on RADV. A host driver that already returns the larger size sees no change. ## Checks - shader compiler tests: 313 passed - tuxbox-dxbc: 64, tuxbox-xg-layout: 14, Python suite passed - `cargo check` of tuxbox-d3d12 for x86_64-pc-windows-msvc 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tsunderejay commented 2026-11-25 21:23:33 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by tsunderejay on 2026-11-25T21:23:33Z.


Review found no blocking issue in the GTA slot-25 path, but two coverage gaps before treating this as API-wide: (1) needs_packed(desc) is evaluated before small_texture, so narrow R9G9B9E5/B5G5R5A1 UAVs can still be undersized on fallback hosts; (2) GetResourceAllocationInfo2 (slot 108) still returns the native host size for UNKNOWN-layout small textures. Please reuse small_texture in both paths and add parity/fallback tests.

<!-- greyfinch-sync:brcly/TuxBox:comment:7175014533 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/198#issuecomment-7175014533). Originally posted by [tsunderejay](https://github.com/tsunderejay) on 2026-11-25T21:23:33Z. --- Review found no blocking issue in the GTA slot-25 path, but two coverage gaps before treating this as API-wide: (1) needs_packed(desc) is evaluated before small_texture, so narrow R9G9B9E5/B5G5R5A1 UAVs can still be undersized on fallback hosts; (2) GetResourceAllocationInfo2 (slot 108) still returns the native host size for UNKNOWN-layout small textures. Please reuse small_texture in both paths and add parity/fallback tests.
Jerkin42 commented 2026-11-26 01:42:30 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Jerkin42 on 2026-11-26T01:42:30Z.


Ai

Thanks, both fixed in e87627e. small_texture now runs before needs_packed, and GetResourceAllocationInfo2 (slot 108) gives the same answer. d3d12-features covers six narrow textures through both queries, including RGBA16F and R9G9B9E5 UAVs. B5G5R5A1 isn't covered because the XG plane code doesn't know format 86 yet, so that format keeps the host's answer.

<!-- greyfinch-sync:brcly/TuxBox:comment:7180044601 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/198#issuecomment-7180044601). Originally posted by [Jerkin42](https://github.com/Jerkin42) on 2026-11-26T01:42:30Z. --- Ai Thanks, both fixed in e87627e. `small_texture` now runs before `needs_packed`, and `GetResourceAllocationInfo2` (slot 108) gives the same answer. `d3d12-features` covers six narrow textures through both queries, including RGBA16F and R9G9B9E5 UAVs. B5G5R5A1 isn't covered because the XG plane code doesn't know format 86 yet, so that format keeps the host's answer.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!198
No description provided.