Skip to content

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

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:recomp-cube-arrays
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:recomp-cube-arrays

Conversation

@gefydev

@gefydev gefydev commented Nov 23, 2026

Copy link
Copy Markdown
Member

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

…pled

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.
@ivall
ivall merged commit 7f1e3f4 into xcl-dev:main Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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

Foniass commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

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.

ivall pushed a commit that referenced this pull request Nov 23, 2026
Since #117 translated shaders declare every cube T# as a TextureCubeArray,
but dev_create_srv_x forwarded a title's own SRV description unchanged: a
D3D12_SRV_DIMENSION_TEXTURECUBE view was bound to a shader that declares a
cube array, a dimension mismatch D3D12 leaves undefined (the risk noted on
#117). It now becomes TEXTURECUBEARRAY { First2DArrayFace 0, NumCubes 1 }
with the view's mips and LOD clamp; format, mapping and every other view
dimension are forwarded as before. Device #70 (views of memory) goes
through the same path.

Test srv_tests::a_cube_view_becomes_the_cube_array_of_one_cube.

Co-Authored-By: Claude Code <[email protected]>
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.

3 participants