recomp: cube T#s are cube arrays – the face coordinate's slice is sampled #116

Merged
gefydev merged 1 commit from upstream-pr/117 into main 2026-11-23 14:13:38 +00:00
gefydev commented 2026-11-23 13:15:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gefydev on 2026-11-23T13:15:22Z.


#105 item 2.

A cube T# with more than 6 layers got a TEXTURECUBEARRAY SRV (desc::image_d3d12), but the shader declared TextureCube for every DIM = cube image and cube_dir kept only face % 8 of the face coordinate (face + 8 · cube, as v_cubeid and the console compiler give it). So a cube array was read through the wrong view type and always as its first cube. image_get_resinfo returned depth 1.

The fix:

  • every cube T# gets a cube array view, of one cube too: the T# says nothing at compile time about how many cubes it has, and one view type keeps the HLSL fixed;
  • the shader declares TextureCubeArray; sample / gather use (cube_dir(...), face / 8); CalculateLevelOfDetail takes the direction only; the gradient LOD path reads the size with the array overload;
  • resinfo returns the layers (6 per cube), as the hardware does (Mesa divides it by 6 for GL);
  • a title's own TEXTURECUBEARRAY SRV keeps its NumCubes in dev_create_srv_x / view_shape (it became 6 faces);
  • the test runner's cube texture can hold several cubes.

Test gpu_cube_array_slices: two cubes, a different value in every layer, sampled at each face of both, plus resinfo. Without the change it fails (resinfo [2, 2, 1, 1]). With it, it passes on a GTX 1650 under Wine (vkd3d-proton), and so do the other lib tests that run there. Not run on AMD or with the retail samples. The prelude and the HLSL of cube sampling change, so titles recompile those shaders once.

<!-- greyfinch-sync:ivall/xcl:issue:6560152890 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/117). Originally posted by [gefydev](https://github.com/gefydev) on 2026-11-23T13:15:22Z. --- #105 item 2. A cube T# with more than 6 layers got a `TEXTURECUBEARRAY` SRV (`desc::image_d3d12`), but the shader declared `TextureCube` for every DIM = cube image and `cube_dir` kept only `face % 8` of the face coordinate (face + 8 · cube, as `v_cubeid` and the console compiler give it). So a cube array was read through the wrong view type and always as its first cube. `image_get_resinfo` returned depth 1. The fix: - every cube T# gets a cube array view, of one cube too: the T# says nothing at compile time about how many cubes it has, and one view type keeps the HLSL fixed; - the shader declares `TextureCubeArray`; sample / gather use `(cube_dir(...), face / 8)`; `CalculateLevelOfDetail` takes the direction only; the gradient LOD path reads the size with the array overload; - resinfo returns the layers (6 per cube), as the hardware does (Mesa divides it by 6 for GL); - a title's own `TEXTURECUBEARRAY` SRV keeps its `NumCubes` in `dev_create_srv_x` / `view_shape` (it became 6 faces); - the test runner's cube texture can hold several cubes. Test `gpu_cube_array_slices`: two cubes, a different value in every layer, sampled at each face of both, plus resinfo. Without the change it fails (resinfo `[2, 2, 1, 1]`). With it, it passes on a GTX 1650 under Wine (vkd3d-proton), and so do the other lib tests that run there. Not run on AMD or with the retail samples. The prelude and the HLSL of cube sampling change, so titles recompile those shaders once.
upstream-sync closed this pull request 2026-11-24 06:57:13 +00:00
ivall commented 2026-11-24 07:00:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T14:14:06Z.


Merged – this one was not run on AMD before, it passes there. Checked on Windows 11 with an RX 9070 (RDNA4), merged together with the rest of #110–#129: cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with XCL_SPLIT_WAVE64=1; the retail pack still translates 26 698 / 26 698; the FSR4 GPU probe passes; Unicorn Overlord and XDefiant run. Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7103686321 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/117#issuecomment-7103686321). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T14:14:06Z. --- Merged – this one was not run on AMD before, it passes there. Checked on Windows 11 with an RX 9070 (RDNA4), merged together with the rest of #110–#129: `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with `XCL_SPLIT_WAVE64=1`; the retail pack still translates 26 698 / 26 698; the FSR4 GPU probe passes; Unicorn Overlord and XDefiant run. Thanks!
Foniass commented 2026-11-24 07:00:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-23T14:50:33Z.


Tested on an RTX 5070 Ti, merged onto f311ca5: 528 passed / 0 failed in plain, XCL_SPLIT_WAVE64=1 and XCL_SAMPLE_RPF runs. gpu_cube_array_slices runs on the GPU, and fails at resinfo [2,2,1,1] with the old emitter. The pack translates 26 698 / 26 698, and the 2 335 retail programs with a TextureCube all compile with DXC.

One risk, not a verified bug. dev_create_srv_x (hle/d3d12x/real.rs) forwards a title's own SRV description unchanged. A title that creates a D3D12_SRV_DIMENSION_TEXTURECUBE view now binds it to a shader that declares TextureCubeArray, and D3D12 calls that dimension mismatch undefined.

  • NVIDIA: in a scratch test with a plain TEXTURECUBE SRV, sample, gather and resinfo (6 layers) were all correct on this card. GPU-based validation wasn't available here.
  • AMD: not checked.
  • Cheap guard: rewrite a TEXTURECUBE description into TEXTURECUBEARRAY { First2DArrayFace: 0, NumCubes: 1, MostDetailedMip / MipLevels / ResourceMinLODClamp copied } before forwarding it.
<!-- greyfinch-sync:ivall/xcl:comment:7104619790 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/117#issuecomment-7104619790). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-23T14:50:33Z. --- Tested on an RTX 5070 Ti, merged onto f311ca5: 528 passed / 0 failed in plain, `XCL_SPLIT_WAVE64=1` and `XCL_SAMPLE_RPF` runs. `gpu_cube_array_slices` runs on the GPU, and fails at resinfo `[2,2,1,1]` with the old emitter. The pack translates 26 698 / 26 698, and the 2 335 retail programs with a `TextureCube` all compile with DXC. One risk, not a verified bug. `dev_create_srv_x` (`hle/d3d12x/real.rs`) forwards a title's own SRV description unchanged. A title that creates a `D3D12_SRV_DIMENSION_TEXTURECUBE` view now binds it to a shader that declares `TextureCubeArray`, and D3D12 calls that dimension mismatch undefined. - **NVIDIA:** in a scratch test with a plain `TEXTURECUBE` SRV, sample, gather and resinfo (6 layers) were all correct on this card. GPU-based validation wasn't available here. - **AMD:** not checked. - **Cheap guard:** rewrite a `TEXTURECUBE` description into `TEXTURECUBEARRAY { First2DArrayFace: 0, NumCubes: 1, MostDetailedMip / MipLevels / ResourceMinLODClamp copied }` before forwarding it.
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
xcl-dev/xcl!116
No description provided.