Skip to content

Recompiler: direct DXIL geometry shaders read ES inputs from window 0's heap view - #2254

Open
joeypercia wants to merge 1 commit into
xcl-dev:mainfrom
joeypercia:dxil-gs-heap-window-inputs
Open

joeypercia wants to merge 1 commit into
xcl-dev:mainfrom
joeypercia:dxil-gs-heap-window-inputs

Conversation

@joeypercia

Copy link
Copy Markdown

With the memory windows in the descriptor heap (XCL_HEAP_WINDOWS=1, the setting #2057 runs with), the direct DXIL translator refuses 158 of the newer retail title's 390 geometry shaders, and they fall back to the HLSL route (direct_fallback). The GS entry (geom_init) loads the ES outputs it reads (v9..) through lw.mems[0]. In heap mode that's a placeholder whose handle is the constant 0 (kernel::mem_windows: "mems then only counts them"), so the raw load gets an i32 as its handle. The DXIL builder refuses that: function dx.op.rawBufferLoad.i32 redeclared with another type. Window 0 now comes from the heap (MEM_HEAP_BASE), as every other access in this mode takes it.

Part of #1269 (fewer programs off the direct route).

What is in it

  • crates/xcl/src/gpu/dxil/kernel.rs: geom_init takes window 0's raw view from the descriptor heap when heap_mem is set, and mems[0] otherwise (unchanged).
  • crates/xcl/src/gpu/dxil/geometry_tests.rs: geometry_inputs_with_heap_windows_validate, the test program of geometry_forms_validate reading one ES input (v9), translated with 1 window, 4 root windows and 4 heap windows, wave64 and split. Without the change it fails with the error above, for windows 0x104.

Tested

  • NVIDIA GeForce RTX 4070 Ti (Ada, 32-lane waves), driver 621.40, and the AMD Radeon iGPU of a Ryzen 7 7800X3D (RDNA2, no mesh shaders) with XCL_ADAPTER=Radeon; Windows 11 Pro 26200; Rust 1.100.0 MSVC; DXC 1.8.2502.11; debug for the tests, release for the runs.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on c1e6807:
    • RTX 4070 Ti: 1242 passed, 2 failed, 46 ignored.
    • RDNA2: 1240 passed, 4 failed, 46 ignored.
    • The failures fail the same way on main 9633138 on each adapter (run with the same filter): shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator and device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa on both, plus recomp::tests::gpu_image_get_resinfo_past_last_level and fuzz_tests::fuzz_validate_and_gpu_1 on RDNA2.
    • SKIPPED: RTX 4070 Ti: the wave64 cases of the lower / lower_dxil GPU tests, gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64). RDNA2: the mesh-shader tests, gpu_geometry_direct_records among them. Both: heap_window_out_of_memory_falls_back_to_the_switch_form, pso_measurement_compiles_an_exact_synthetic_record (no Developer Mode), test_title_draws_with_a_root_signature_under_the_debug_layer, uploads_start_from_each_subresources_state, and the lower_dxil f16 / f32 cases the direct backend refuses.
  • The title's shader pack, every program, heap windows: xcl shaders shaders.rpf --direct --sample 0 --windows 260 --validate:
    • main: GS 232 of 390 translated (158 refused with the error above). CS 2689 / 2689, MS 9282 / 9282, PS 12101 / 12101 and VS 2236 / 2236.
    • this PR: GS 390 of 390, all of them validating. The other stages are unchanged.

Regression run

RTX 4070 Ti (driver 621.40), release builds, 60 s each, scripts/smoke.ps1 -Game <folder> -Title retail-title on the newer retail title, run one after the other from the same shell, with the same settings. The runs stay on the menus, so they're a regression check only: they don't show a heap-window geometry shader being translated. main 9633138 (this PR's base) and this PR's head (no uncommitted changes):

main:

xcl-smoke v1
commit: 963313835813f475037b3a9f5fcc3cb591696928
gpu: NVIDIA GeForce RTX 4070 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1544 (PresentX 1544)
presents per 2 s (last 3): 60 60 57
device removals: 0
crashes: 0
peak commit: 16068 MB

PR:

xcl-smoke v1
commit: c1e6807941d8951c111900b14cce7cef2c2543c6
gpu: NVIDIA GeForce RTX 4070 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1578 (PresentX 1578)
presents per 2 s (last 3): 60 60 53
device removals: 0
crashes: 0
peak commit: 16488 MB

Not tested

  • The GPU output of a heap-window geometry shader with inputs. The direct GS GPU test (gpu_geometry_direct_records) runs one window only, and its program reads no inputs. This change only affects heap mode.
  • Whether the title draws differently in the world with these geometry shaders on the direct route. The smoke run stays on the menus.
  • AMD with heap windows in the title.

AI use

  • Claude Code with Claude Opus 5.5: found the error in a shader-pack sweep, wrote the fix, the test and this description, and ran the tests and the runs on the hardware above.

…'s heap view

With the memory windows in the descriptor heap (XCL_HEAP_WINDOWS=1), `mems`
holds placeholders whose handle is the constant 0, and only counts the
windows. The GS entry (`geom_init`) loaded the ES outputs it reads (v9..)
through `mems[0]` directly, so the raw load took an i32 as its handle. The
DXIL builder refuses that ("function dx.op.rawBufferLoad.i32 redeclared with
another type"), and the direct route gives up on the shader.

On the newer retail title's shader pack that is 158 of its 390 geometry
shaders (`xcl shaders <pack> --direct --sample 0 --windows 260`): 232
translated before, 390 now, all of them validating. Window 0 now comes from
the heap (`MEM_HEAP_BASE`), as every other access takes it in this mode.
@itsSio

itsSio commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Tested

Independent Windows verification on clean c1e6807941d8951c111900b14cce7cef2c2543c6. Windows 11 Pro build 26200, x64 MSVC, unoptimized dev/test profiles with debug info off. cargo build --workspace --locked exited 0 on both PCs. cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture exited 101 on both:

GPU / driver CPU, RAM, toolchain Passed / failed / ignored Runtime SKIPPED
RTX 5080 / 32.0.16.1088 Ryzen 7 9800X3D, 32 GiB; Rust 1.97.0, DXC/DXIL 1.9.2609.5 1242 / 2 / 46 25
RTX 2080 SUPER / 32.0.16.1088 Ryzen 5 5600X, 16 GiB; Rust 1.99.1, DXC/DXIL 1.8.2502.11 1242 / 2 / 46 27

On both PCs the failures were rerouted_disk_entries_follow_the_direct_translator (68 vs 1) and pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa (format 85, got 28). These match the assertions reproduced on an earlier main revision, not an exact-parent rerun for this PR. Both workspace results remain failing. The RTX 2080 SUPER logged two additional skips for the unavailable D3D12 debug layer.

cargo test -p xcl --lib --locked gpu::dxil::geometry_tests:: -- --test-threads=1 --nocapture: 3 passed / 0 failed / 0 ignored, no runtime skips, on each RTX card and the Radeon RDNA2 iGPU (driver 32.0.21043.5001, on the same Ryzen 7 system). geometry_inputs_with_heap_windows_validate passed DXIL validation with heap-window inputs on both DXIL validator versions. gpu_geometry_direct_records passed separately; it is a one-window smoke and does not validate GPU output for heap-window inputs.

Not tested

Heap-window geometry GPU readback with inputs, the exact parent, full AMD workspace, Intel, and retail smoke or performance.

AI use

Ran via Samaritan:

  • OpenCode with OpenAI GPT-6.2 Sol (openai/gpt-6.2-sol): scoped and ran the Windows verification, checked both PCs' logs, and wrote this report. No subagents contributed to this check.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@nnonno91

Copy link
Copy Markdown

Independent Windows check of c1e6807941d8951c111900b14cce7cef2c2543c6. The geometry translation tests passed, and the new heap-window test caught the original builder failure with the parent implementation.

Tested

  • Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, Radeon integrated graphics (32.0.21042.62), RTX 5090 (32.0.16.1742), Rust 1.100.0 x64 MSVC, Windows SDK DXC/DXIL 1.8.2502.11. Unoptimized test profile.
  • Clean head, cargo test --locked -p xcl --lib gpu::dxil::geometry_tests -- --nocapture --test-threads=1 on each selected adapter: 3 passed, 0 failed, 0 ignored, no logged skips per adapter. The new fixture checked translation with one window, four root windows, and four heap windows, in both native and split forms. The separate GPU test matched the expected geometry records on both adapters, using one window.
  • Temporarily used kernel.rs from parent 963313835813f475037b3a9f5fcc3cb591696928 with the PR's test source. cargo test --locked -p xcl --lib geometry_inputs_with_heap_windows_validate -- --nocapture --test-threads=1: 0 passed, 1 failed, 0 ignored, no logged skips. For native translation with windows 0x104, the old code rejected the shader with dx.op.rawBufferLoad.i32 redeclared with another type. Restored the clean checkout.

Not tested

GPU execution of the heap-window fixture, retail titles, or the full workspace suite.

AI use

OpenAI Codex (GPT-6.2 Sol) prepared and ran the tests, verified the results, and wrote this report.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

amd-win test report for head c1e6807941d8951c111900b14cce7cef2c2543c6 (exact PR head, not a merge; its merge-base with main is 96331383).

Hardware: AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 26200, Rust 1.100.0, debug for tests, release for the smoke runs.

Focused test

  • cargo test -p xcl --lib geometry_inputs_with_heap_windows_validate: 1 passed, 0 failed
  • cargo test -p xcl --lib gpu::dxil::: 147 passed, 1 failed (fuzz_validate_and_gpu_1, see below), 3 ignored

Full suite: cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4: 1240 passed, 4 failed, 46 ignored.

  • The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, gpu::recomp::pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator, gpu::recomp::tests::gpu_image_get_resinfo_past_last_level and hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa. All 4 fail the same way on the merge-base 96331383 on this machine, so none is caused by this PR.
  • SKIPPED (adapter/semantics, not coverage): f16_programs_on_the_gpu and f32_programs_on_the_gpu (several forms, "unsupported V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32"), heap_window_out_of_memory_falls_back_to_the_switch_form ("no heap windows").

Regression run (retail title, 60 s, scripts/smoke.ps1 -Seconds 60, release builds of 96331383 and of the PR head; one run each, so run-to-run noise applies). These are not pasted xcl-smoke blocks: the script stamps the checkout's HEAD, and I ran both binaries from one checkout, so I quote the numbers instead.

frames shown presents per 2 s (last 3) device removals crashes peak commit
96331383 (main) 1506 61 59 61 0 0 17017 MB
PR head 1455 60 61 60 0 0 16608 MB

PR head is 97 % of main's frames, and its peak commit is 98 % of main's.

Not tested: NVIDIA, wave32-only GPUs, runs longer than 60 s, any title other than the one above. The change is to GS translation (ES inputs read from the heap view); I did not check whether the smoke run's title uses a direct-DXIL geometry shader, so the run is a regression check only.

AI use: this report was run and written by Claude Code (Claude Sonnet 5.5).

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants