xshader: query the level of a heap 2D array in a pixel shader #606

Merged
NickStallman merged 2 commits from upstream-pr/606 into main 2026-12-01 03:18:20 +00:00
NickStallman commented 2026-12-01 00:46:23 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-01T00:46:23Z.


image_get_lod on a texture taken from the resource heap was translated for a 2D view only; a program that queries a 2D array was refused ("unsupported direct heap texture operation image_get_lod dim 5"). The level comes from how the coordinates within a slice change between pixels, so a 2D array is queried like one of its slices, with the two coordinates and no slice, as HLSL's CalculateLevelOfDetail takes them. A 1D array bound through a table passed its slice as a second coordinate; it now passes one.

Refs #533.

Measured

  • Recorded ProjectScarlett requests (branch against its base ee38dcf0, both hosts, links): 3 pixel requests newly accepted, one deferred material family; 0 changed, 0 newly refused. All 3 compile with DXC 1.9.2609 and pass dxv.
  • Unit tests and mutations: 3 new unit tests; 6 mutations, each caught (2D only, 1D array admitted, every dimension admitted, slice kept, one coordinate, coordinates swapped).
  • New GPU check heap-lod: a mipped 2D view (translated before, the control) and a three-slice 2D-array view in the heap, each drawn at ten scales (below the chain, on and between levels, past the last mip, different scales in u and v). 20 draws, 5,120 pixels; clamped and unclamped levels are compared with log2 of the larger scale. The largest difference on each card was 0.0016 of a level, 0 failures. The tolerance is 1/16 of a level, which this check chooses; it isn't from a specification.
  • Full python tuxbox.py check of 05fe9f8d (GE-Proton11-15): RTX 5090 (10de:2b85, 620.70.10) 206 pass, 0 fail; AMD iGPU (1002:13c0, RADV) 205 pass, 0 fail.

Evidence: TuxBox check of 05fe9f8dfe, no uncommitted changes, GPU 10de:2b85: 17 passed, 0 failed, 0 not run
Evidence: TuxBox check of 05fe9f8dfe, no uncommitted changes, GPU 1002:13c0: 17 passed, 0 failed, 0 not run

Not covered

  • The game has not been run with this. In our runs' failure tables 2 failed mesh+pixel rows per run have one of these as their pixel stage; whether they then build and draw is not shown.
  • The 1D-array change has a unit test only. No recorded program uses it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5576571982 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/606). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-12-01T00:46:23Z. --- `image_get_lod` on a texture taken from the resource heap was translated for a 2D view only; a program that queries a 2D array was refused ("unsupported direct heap texture operation image_get_lod dim 5"). The level comes from how the coordinates within a slice change between pixels, so a 2D array is queried like one of its slices, with the two coordinates and no slice, as HLSL's `CalculateLevelOfDetail` takes them. A 1D array bound through a table passed its slice as a second coordinate; it now passes one. Refs #533. ## Measured - **Recorded ProjectScarlett requests** (branch against its base ee38dcf0, both hosts, links): 3 pixel requests newly accepted, one deferred material family; 0 changed, 0 newly refused. All 3 compile with DXC 1.9.2609 and pass dxv. - **Unit tests and mutations:** 3 new unit tests; 6 mutations, each caught (2D only, 1D array admitted, every dimension admitted, slice kept, one coordinate, coordinates swapped). - **New GPU check `heap-lod`:** a mipped 2D view (translated before, the control) and a three-slice 2D-array view in the heap, each drawn at ten scales (below the chain, on and between levels, past the last mip, different scales in u and v). 20 draws, 5,120 pixels; clamped and unclamped levels are compared with log2 of the larger scale. The largest difference on each card was 0.0016 of a level, 0 failures. The tolerance is 1/16 of a level, which this check chooses; it isn't from a specification. - Full `python tuxbox.py check` of 05fe9f8d (GE-Proton11-15): RTX 5090 (`10de:2b85`, 620.70.10) 206 pass, 0 fail; AMD iGPU (`1002:13c0`, RADV) 205 pass, 0 fail. Evidence: TuxBox check of 05fe9f8dfeed, no uncommitted changes, GPU 10de:2b85: 17 passed, 0 failed, 0 not run Evidence: TuxBox check of 05fe9f8dfeed, no uncommitted changes, GPU 1002:13c0: 17 passed, 0 failed, 0 not run ## Not covered - The game has not been run with this. In our runs' failure tables 2 failed mesh+pixel rows per run have one of these as their pixel stage; whether they then build and draw is not shown. - The 1D-array change has a unit test only. No recorded program uses it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!606
No description provided.