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.

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