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

Manually merged
github merged 1 commit from gh-pr/117/head into gh-pr/117/base 2026-11-26 04:10:55 +00:00
Owner

@⁠gefydev on GitHub · 2026-11-23 13:15 UTC · original
gefydev:recomp-cube-arrays → main · +68 −14 · 5 files · 1 commits · merged 2026-11-23 14:13 UTC

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

**@⁠gefydev** on GitHub · 2026-11-23 13:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/117) `gefydev:recomp-cube-arrays` → `main` · +68 −14 · 5 files · 1 commits · merged 2026-11-23 14:13 UTC #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.
A cube T# with more than 6 layers got a TEXTURECUBEARRAY SRV, but translated
shaders declared TextureCube for every DIM = cube image, and cube_dir kept
only face % 8 of the face coordinate (face + 8 · cube): a cube array was read
through the wrong view type and always as its first cube. image_get_resinfo
returned depth 1.

Every cube T# now gets a cube array view (of one cube too, since the T# says
nothing at compile time about how many it has), the shader declares
TextureCubeArray and samples / gathers at (direction, face / 8), and resinfo
returns the layers (6 per cube) as the hardware does. A title's own
TEXTURECUBEARRAY SRV keeps its NumCubes (it became 6 faces), and the test
runner's cube texture can hold several cubes.

Test gpu_cube_array_slices: two cubes, every layer its own colour, sampled
at each face of both, and resinfo.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:10:53 +00:00
github manually merged commit 0056934a9c into gh-pr/117/base 2026-11-26 04:10:55 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 14:14 UTC · original

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!

**@⁠ivall** on GitHub · 2026-11-23 14:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/117#issuecomment-7103686321) 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!
Author
Owner

@⁠Foniass on GitHub · 2026-11-23 14:50 UTC · original

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.
**@⁠Foniass** on GitHub · 2026-11-23 14:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/117#issuecomment-7104619790) 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.