Skip to content

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

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
cortexreaver2099-creator:srv-cube-as-cube-array
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
cortexreaver2099-creator:srv-cube-as-cube-array

Conversation

@cortexreaver2099-creator

Copy link
Copy Markdown
Contributor

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 recomp: run wave64 compute programs as two wave32 halves on 32-lane GPUs #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 CI: build and tests on a Windows runner (no GPU) #143 skips it on CI. The test title's 50 checks all print [PASS].

🤖 Generated with Claude Code

Since xcl-dev#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
xcl-dev#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 xcl-dev#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]>
@ivall
ivall merged commit 61f6a78 into xcl-dev:main Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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

2 participants