Skip to content

Recompiler & D3D12.X: mask 9-bit EXP PRIM vertex indices and map newer DispatchMesh to slot #129 - #1984

Open
raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:feat/dispatch-mesh-9bit-v2
Open

raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:feat/dispatch-mesh-9bit-v2

Conversation

@raylitebull

@raylitebull raylitebull commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Masks EXP PRIM vertex indices to 9 bits (0x1FFu) in RDNA2 mesh-shader pass-through lowering and maps newer-layout command list DispatchMesh calls at slot #129 to older slot #126 (two-pass DispatchMesh / ExecuteIndirect execution paths have been split out of this PR and deferred cleanly to #724 and #1887).

Part of #1833.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: mask EXP PRIM vertex indices with 0x1FFu in both unsplit and #304-split mesh pass-through emission paths to strip RDNA2 per-edge flags at bits [9], [19], and [29].
  • crates/xcl/src/gpu/recomp/tests.rs: add mesh_passthrough_strips_rdna2_edge_flag_bits unit test.
  • crates/xcl/src/hle/d3d12x/real.rs: map (129, 126) in NEWER_LIST_SLOTS for newer-layout DispatchMesh and add newer_layout_maps_dispatch_mesh_to_slot_129_not_128.

Tested

  • Toolchain: Windows 11 x64, rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly onto aa9ab8a (3eab40a).
  • Targeted unit tests (mesh_passthrough_strips_rdna2_edge_flag_bits and newer_layout_maps_dispatch_mesh_to_slot_129_not_128): 2 passed, 0 failed (0 new warnings).

Regression run

  • Standalone scripts/smoke.ps1 pair on 3eab40a vs aa9ab8a has not been run locally. AMD and NVIDIA reviewers are invited to test on 3eab40a vs aa9ab8a (including scripts/smoke.ps1 and mesh shader workloads) and post results in the comments.

Not tested

  • 60 s scripts/smoke.ps1 pair on 3eab40a, full cargo test --workspace suite, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton.

AI use

  • Antigravity assisted with implementation, splitting, and unit tests; the author reviewed the diff and test output.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Overlap note, from reading the descriptions and file lists (not run):

The parts that look independent of both are the NEWER_LIST_SLOTS DispatchMesh slot (129 rather than 128) and the 9-bit (0x1FF) vertex index mask in mesh passthrough. Each could go in a small PR of its own, with the evidence for it.

AI-assisted (Claude Code).

@eizispark

Copy link
Copy Markdown

Hardware test report — commit ffcf056

Verified ffcf056f0f41757e90c93f7becd6790b81e32656 (based on 8c4a46a3c2d50498691cbda79cbbf4fadb45fbe8; clean merge with current main 6567c5f): pass (0 new failures vs main; all 4 new unit tests and live RDNA4 mesh-shader GPU tests pass).

Tested

  • Hardware: Windows 11 x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, mesh shaders Tier 1, driver 32.0.32015.16001), 32 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) (stable-x86_64-pc-windows-msvc), debug tests + release smoke
  • Unfiltered cargo test --workspace --no-fail-fast -- --test-threads=4: 997 passed, 2 failed, 45 ignored (8 skipped) — 0 new failures:
    • All 4 new PR unit tests (gpu::recomp::tests::mesh_passthrough_strips_rdna2_edge_flag_bits, hle::d3d12x::bind::tests::dispatch_mesh_signature_tracking_returns_companion_and_clears, hle::d3d12x::console_list::tests::mesh_arguments_go_in_user_sgprs_from_s16, hle::d3d12x::real::queue_tests::newer_layout_maps_dispatch_mesh_to_slot_129_not_128) passed
    • Live RDNA4 mesh-shader & wave64 GPU tests (gpu::recomp::tests::gpu_mesh_mode_two_passes with the 0x1FFu 9-bit vertex index mask, gpu_mesh_mode_reads_memory_windows, hle::d3d12x::real::passthrough_mesh_stream_accepts_a_triangle_driver_blob, retail_mesh_pipelines_through_the_hook, mesh_dispatch::tests::*, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, console_wave64_compute_through_the_pso_hook_dispatch_and_read_back) all executed on the GPU (0 skips) and passed
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on main (#1679); 8 skipped = 6 lower_dxil f16/f32 #1426-semantics sub-cases, pso_measurement_compiles_an_exact_synthetic_record (0x887A002D), and heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows

Regression run
main (8e87fc7b62a87ea589ccb9ea6182f514016cf7db):

xcl-smoke v1
commit: 8e87fc7b62a87ea589ccb9ea6182f514016cf7db
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1675 (PresentX 1675)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14861 MB

PR (ffcf056f0f41757e90c93f7becd6790b81e32656):

xcl-smoke v1
commit: ffcf056f0f41757e90c93f7becd6790b81e32656
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1675 (PresentX 1675)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14860 MB

Not tested

  • live retail 3D gameplay past the menus reaching DispatchMesh / ExecuteIndirect(DispatchMesh) draws (the 60 s menu smoke run did not log DispatchMesh calls), NVIDIA/Intel GPUs, Wine/vkd3d-proton

AI use

  • Antigravity (Google DeepMind, Gemini 4 Carbon) ran the workspace test suite, mesh-shader GPU checks, and 60-second retail smoke check and formatted this report.

@raylitebull

Copy link
Copy Markdown
Member Author

@eizispark Thank you for the thorough RX 9070 XT verification (997 passed,

@raylitebull

Copy link
Copy Markdown
Member Author

Thanks for the overlap breakdown, @upipibi! Full credit to #724 (@Cattn) on the two-pass DispatchMesh / ExecuteIndirect execution architecture and #1887 (@Diskuss) on indirect argument 107 -> DispatchMesh.

For context on why #1984 is open:

If #724 (or #1887) is updated and lands first, we will gladly rebase and trim #1984 down to only the remaining non-overlapping pieces.

@gsucristo

Copy link
Copy Markdown
Contributor

Technical review findings:

Blocking

  1. Unconditional INDIRECT_ARGUMENT -> NON_PIXEL_SHADER_RESOURCE transition (bind.rs, make_scaled_args_buffer): Transitions src unconditionally from INDIRECT_ARGUMENT to NON_PIXEL_SHADER_RESOURCE and back. Indirect argument buffers are frequently in GENERIC_READ (mandatory for UPLOAD heaps, where transitioning away from GENERIC_READ is invalid), COMMON, or combined read states.
  2. Multi-command ExecuteIndirect(DispatchMesh) (max > 1) races on res_buf (bind.rs, execute_indirect): Runs all max compute dispatches into res_buf starting at offset 0 without per-command offsets or intermediate UAV barriers, then runs all max mesh dispatches reading from offset 0.
  3. Unclamped OOB UAV writes/reads on res_buf (bind.rs, dispatch_mesh & execute_indirect): clear_groups is clamped to res_cap / rec_bytes, but list.Dispatch(groups, 1, 1), pc_dm(...), and companion_dispatch are not clamped/rejected when groups * rec_bytes > res_cap.
  4. COM refcount leak on companion ID3D12CommandSignature (device_x.rs, create_command_signature_x; bind.rs, DISPATCH_MESH_SIGS): companion is stored as a raw usize and never Release()d on map overwrite, clear_dispatch_mesh_signature, or signature destruction.

Major

  • let groups = x.saturating_mul(y.max(1)).saturating_mul(z.max(1)) turns a zero-work DispatchMesh(N, 0, 1) into N groups instead of returning early, and flattening 3D (x, y, z) to (groups, 1, 1) breaks console MS shaders reading SV_GroupID.y/z.
  • make_scaled_args_buffer allocates a new committed DEFAULT buffer of max * stride bytes on every ExecuteIndirect call instead of pooling/reusing.
  • clear_record_headers, emit_uav_barrier, and make_scaled_args_buffer don't guard against D3D12_COMMAND_LIST_TYPE_BUNDLE, and dispatch_mesh overwrites the compute RS/PSO without restoring them.

(The #129 NEWER_LIST_SLOTS fix and 0x1FFu 9-bit EXP PRIM mask look clean and would be great split out on their own.)

@raylitebull
raylitebull force-pushed the feat/dispatch-mesh-9bit-v2 branch from ffcf056 to 3eab40a Compare November 25, 2026 01:15
@raylitebull raylitebull changed the title D3D12.X: execute two-pass DispatchMesh (#129) and ExecuteIndirect with 9-bit primitive indices Recompiler & D3D12.X: mask 9-bit EXP PRIM vertex indices and map newer DispatchMesh to slot #129 Nov 25, 2026
@raylitebull

Copy link
Copy Markdown
Member Author

Thanks for the review and split recommendation, @upipibi, @gsucristo, @Cattn, and @Diskuss!

Split and rebased #1984 cleanly onto aa9ab8a (3eab40a, +43 / -3 across 3 files):

  • Split out the two-pass DispatchMesh / ExecuteIndirect execution path (deferring cleanly to #724 + #1887 and removing all overlapping indirect-scaling code).
  • Kept only the two independent, self-contained fixes:
    1. EXP PRIM 9-bit (0x1FFu) vertex index masking in crates/xcl/src/gpu/recomp/emit.rs (both unsplit and #304-split mesh pass-through paths) + mesh_passthrough_strips_rdna2_edge_flag_bits.
    2. NEWER_LIST_SLOTS mapping (129, 126) for newer-layout DispatchMesh in crates/xcl/src/hle/d3d12x/real.rs + newer_layout_maps_dispatch_mesh_to_slot_129_not_128.

Verified locally (2 passed, 0 failed, 0 new warnings).

@JJAutoCompare

Copy link
Copy Markdown

PR #1984 compatibility verification

Tested detached head 3eab40a4bb48c15d4b79ed3f756deba52eb89bdb from origin (refs/pull/1984/head). The tracked checkout was clean.

Environment

  • STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB, driver 32.0.101.9175. DoublePrecisionFloatShaderOps=0, wave range 8–32, and d3d12SDKLayers.dll absent.
  • rustc 1.100.0 (0ef1bc386 2026-11-09). DXC and DXIL 1.9.2609.5. Cargo dev/test builds used no debug info or incremental compilation. The suite selected XCL_ADAPTER=A770 and used the assigned slot on L: for the Cargo target, temp directory, and DXIL cache.

Build and focused tests

  • cargo build --workspace and cargo test --workspace --no-run both exited 0 outside the GPU lock.
  • cargo test -p xcl --lib mesh_passthrough_strips_rdna2_edge_flag_bits -- --nocapture — 1 passed, 0 failed, 0 ignored, 0 skipped. The test checks that both mesh pass-through variants emit three 0x1FFu masks at shifts 0, 10, and 20, excluding the packed EXP PRIM edge flags.
  • cargo test -p xcl --lib newer_layout_maps_dispatch_mesh_to_slot_129_not_128 -- --nocapture — 1 passed, 0 failed, 0 ignored, 0 skipped. The test checks newer slot #129 maps to the older DispatchMesh handler at #126 and that the map has no entry for #128.

Full workspace suite

cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under L:/XclTooling/Invoke-ArcTest.ps1. Cargo exited 101 after all 19 test binaries and the doc-test target reported results. Combined suite log (pr1984-suite.log)

gpu::recomp::tests::gpu_mesh_mode_two_passes also passed on the Arc without a skip notice. It checks that the synthetic unsplit and split draws produce identical pixels. Its EXP PRIM record has all edge flag bits clear.

Target Passed Failed Ignored
unittests src/lib.rs (xcl) 1009 26 26
unittests src/main.rs (xcl) 0 0 0
tests/bcpack_parity.rs 1 0 0
tests/console_dlls_e2e.rs 13 0 0
tests/console_shaders.rs 3 0 4
tests/disasm_e2e.rs 1 0 0
tests/e2e.rs 2 1 0
tests/gpu_compute_e2e.rs 4 0 0
tests/gpu_pso_e2e.rs 7 0 0
tests/heap_probe.rs 0 0 4
tests/low_va.rs 1 0 0
tests/pls_quota.rs 1 0 0
tests/predication_e2e.rs 1 0 0
tests/rpf_e2e.rs 2 0 0
tests/shaders_e2e.rs 4 0 0
tests/sparse_reinit.rs 1 0 0
tests/texture_states.rs 1 0 0
tests/xg_oracle.rs 6 0 12
unittests src/main.rs (xcl_testtitle) 0 0 0
Doc-tests xcl 0 0 0
Total (harness counts) 1057 27 46

Failures

All 27 failures are outside the changed mesh pass-through and DispatchMesh paths. The 25 matching failures also appear in the earlier STOR-WINLAB PR #1982 log at 354ce0c7189d0820ddf7d05bc5c662013ff7a5f4, which has the former mask and lacks the slot mapping. The two remaining cases exercise direct-DXIL denormal rounding and split-wave64 compute reductions. Earlier Arc suite log (pr1982-suite.log)

CreateComputePipelineState returned 0x80070057 in 22 tests.

  • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0
  • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1
  • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_2
  • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3
  • gpu::dxil::ops_tests::doubles_match_cpu
  • gpu::dxil::ops_tests::groupshared_barrier_and_atomics_run
  • gpu::dxil::round_tests::gpu_direct_f32_round_modes_dynamic_and_denormals
  • gpu::dxil::round_tests::gpu_direct_f32_round_modes_static
  • gpu::dxil::round_tests::gpu_direct_f32_round_preserved_denormal_times_inf_is_inf
  • gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu
  • gpu::recomp::tests::gpu_clamp_and_omod_per_instruction
  • gpu::recomp::tests::gpu_f64_class_compare
  • gpu::recomp::tests::gpu_f64_compares_with_nan
  • gpu::recomp::tests::gpu_f64_literal_high_word
  • gpu::recomp::tests::gpu_f64_math_random
  • gpu::recomp::tests::gpu_f64_roots
  • gpu::recomp::tests::gpu_f64_rounding_and_conversions
  • gpu::recomp::tests::gpu_float_compares_random
  • gpu::recomp::tests::gpu_frexp_f64_exp_and_mant
  • gpu::recomp::tests::gpu_ldexp_f64
  • gpu::recomp::tests::gpu_rndne_f64
  • gpu::recomp::tests::gpu_split_wave64_reduction_tails

Five additional tests failed assertions.

  • gpu::recomp::tests::gpu_nonfused_mad_and_mac_prevent_fma_contraction returned 2139095040 for the fused overflow control, expected 1946157055.
  • gpu::recomp::tests::gpu_ps_image_sample_offset_implicit_lod_between_mips returned 25.609375 at pixel (0,0), expected 26.
  • gpu::recomp::tests::gpu_valu_16_and_64_bit failed the v_add_f16 high-half preservation assertion in lane 0.
  • gpu::recomp::tests::gpu_wave64_ps_whole_wave_reductions returned [2, 217, 2] for the pixel 0 min/sum reduction, expected [2, 216, 2].
  • e2e::test_title_runs_and_game_folder_is_untouched failed the synthetic title's dynamic depth-bias check at RSSetDepthBiasX slot #94. The top-right pixel was blue, expected green.

Skips

The log contains exactly 23 lines beginning with SKIPPED across 13 tests. The harness passed count includes tests that returned early or exercised only some subcases. Excluded from coverage were 18 wave64 cases, three refused wave32 DXIL lowering cases (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32), one driver-cache measurement (0x887A002D), and one heap-window OOM fallback.

Not tested

  • A retail Xbox title run, live console calls to newer DispatchMesh slot #129, or a GPU draw with EXP PRIM edge flags set. The run used the synthetic mesh and title tests, and XCL_SAMPLE_* was unset.
  • D3D12 debug-layer checks. The root-signature and texture-state tests can return early with notices captured by libtest, outside the 23 logged lines.
  • A same-run main baseline or retail smoke comparison, AMD and NVIDIA GPUs, and native wave64 hardware.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified the counts against pr1984-suite.log and published this report.

@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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants