D3D12.X: a title's TEXTURECUBE view is the cube array of its one cube #149

Manually merged
github merged 1 commit from gh-pr/149/head into gh-pr/149/base 2026-11-26 04:12:41 +00:00
Owner

@⁠cortexreaver2099-creator on GitHub · 2026-11-23 16:17 UTC · original
cortexreaver2099-creator:srv-cube-as-cube-array → main · +59 −0 · 1 files · 1 commits · merged 2026-11-23 21:08 UTC

Follow-up to the risk @⁠Foniass noted on #117 (#105 item 2).

Since #117, translated shaders declare every cube T# as a TextureCubeArray. But dev_create_srv_x (hle/d3d12x/real.rs) still forwarded a title's own SRV description unchanged. So a title that makes a D3D12_SRV_DIMENSION_TEXTURECUBE view had it bound to a shader declaring a cube array, a dimension mismatch that D3D12 leaves undefined.

This is the cheap guard suggested there. Before the view is forwarded, a TEXTURECUBE description is rewritten into:

TEXTURECUBEARRAY { MostDetailedMip, MipLevels, ResourceMinLODClamp: copied, First2DArrayFace: 0, NumCubes: 1 }
  • Format and component mapping are kept.
  • A title's own TEXTURECUBEARRAY and every other dimension are forwarded unchanged.
  • Device #70 (dev_create_srv_at_x, views of memory) calls dev_create_srv_x, so it gets the same rewrite.
  • The console T# written to the slot doesn't change: view_shape already maps dimensions 9 and 10 to ImageType::Cube with 6 layers for one cube.

Test: srv_tests::a_cube_view_becomes_the_cube_array_of_one_cube covers the rewrite: mips, clamp, format and mapping are kept, and cube arrays and other dimensions are left alone.

This test doesn't prove the mismatch was harmful. As Foniass found, a plain TEXTURECUBE SRV sampled correctly on NVIDIA. A GPU test can't fail reliably on undefined behaviour, and the debug layer (d3d12SDKLayers.dll, from the Windows "Graphics Tools" feature) isn't installed on this machine, so I couldn't confirm the validation message goes away. AMD hasn't been checked.

Tested on an NVIDIA RTX 3090 (32-lane waves, driver 32.0.16.1714), Windows 11 26200, DXC from SDK 10.0.26100. I ran cargo test --workspace --no-fail-fast without the retail samples:

  • lib: 533 passed, 0 failed, 19 ignored. gpu_cube_array_slices passes. The only 2 skips are by design (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware.
  • console_dlls_e2e, console_shaders, disasm_e2e, gpu_compute_e2e, gpu_pso_e2e, rpf_e2e, xg_oracle: all pass.
  • e2e::test_title_runs_and_game_folder_is_untouched fails on main too. This PC has no System32\xgameruntime.dll, and the test treats the launcher's resulting WARNING as a failure, the same reason #143 skips it on CI. The test title's 50 checks all print [PASS].

🤖 Generated with Claude Code

**@⁠cortexreaver2099-creator** on GitHub · 2026-11-23 16:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/149) `cortexreaver2099-creator:srv-cube-as-cube-array` → `main` · +59 −0 · 1 files · 1 commits · merged 2026-11-23 21:08 UTC Follow-up to the risk @⁠Foniass noted on #117 (#105 item 2). Since #117, translated shaders declare every cube T# as a `TextureCubeArray`. But `dev_create_srv_x` (`hle/d3d12x/real.rs`) still forwarded a title's own SRV description unchanged. So a title that makes a `D3D12_SRV_DIMENSION_TEXTURECUBE` view had it bound to a shader declaring a cube array, a dimension mismatch that D3D12 leaves undefined. This is the cheap guard suggested there. Before the view is forwarded, a `TEXTURECUBE` description is rewritten into: ``` TEXTURECUBEARRAY { MostDetailedMip, MipLevels, ResourceMinLODClamp: copied, First2DArrayFace: 0, NumCubes: 1 } ``` - Format and component mapping are kept. - A title's own `TEXTURECUBEARRAY` and every other dimension are forwarded unchanged. - Device #70 (`dev_create_srv_at_x`, views of memory) calls `dev_create_srv_x`, so it gets the same rewrite. - The console T# written to the slot doesn't change: `view_shape` already maps dimensions 9 and 10 to `ImageType::Cube` with 6 layers for one cube. **Test:** `srv_tests::a_cube_view_becomes_the_cube_array_of_one_cube` covers the rewrite: mips, clamp, format and mapping are kept, and cube arrays and other dimensions are left alone. This test doesn't prove the mismatch was harmful. As Foniass found, a plain `TEXTURECUBE` SRV sampled correctly on NVIDIA. A GPU test can't fail reliably on undefined behaviour, and the debug layer (`d3d12SDKLayers.dll`, from the Windows "Graphics Tools" feature) isn't installed on this machine, so I couldn't confirm the validation message goes away. AMD hasn't been checked. **Tested on an NVIDIA RTX 3090** (32-lane waves, driver 32.0.16.1714), Windows 11 26200, DXC from SDK 10.0.26100. I ran `cargo test --workspace --no-fail-fast` without the retail samples: - lib: 533 passed, 0 failed, 19 ignored. `gpu_cube_array_slices` passes. The only 2 skips are by design (`no wave64`): `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware`. - `console_dlls_e2e`, `console_shaders`, `disasm_e2e`, `gpu_compute_e2e`, `gpu_pso_e2e`, `rpf_e2e`, `xg_oracle`: all pass. - `e2e::test_title_runs_and_game_folder_is_untouched` fails **on `main` too**. This PC has no `System32\xgameruntime.dll`, and the test treats the launcher's resulting `WARNING` as a failure, the same reason #143 skips it on CI. The test title's 50 checks all print `[PASS]`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:12:39 +00:00
github manually merged commit b21057672c into gh-pr/149/base 2026-11-26 04:12:41 +00:00
Author
Owner

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

Merged (main 6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on main eaa36b6: cargo build --workspace && cargo test --workspace -- --test-threads=4 - 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).

**@⁠ivall** on GitHub · 2026-11-23 21:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/149#issuecomment-7114073487) Merged (main 6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on main eaa36b6: `cargo build --workspace && cargo test --workspace -- --test-threads=4` - 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).
This discussion has been locked. Commenting is limited to contributors.
No description provided.