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

Merged
cortexreaver2099-creator merged 1 commit from upstream-pr/149 into main 2026-11-23 21:08:36 +00:00
cortexreaver2099-creator commented 2026-11-23 16:17:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by cortexreaver2099-creator on 2026-11-23T16:17:06Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:6563641744 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/149). Originally posted by [cortexreaver2099-creator](https://github.com/cortexreaver2099-creator) on 2026-11-23T16:17:06Z. --- 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)
upstream-sync closed this pull request 2026-11-24 06:57:24 +00:00
ivall commented 2026-11-24 07:04:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T21:09:05Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7114073487 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/149#issuecomment-7114073487). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T21:09:05Z. --- 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).
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!146
No description provided.