Skip to content

shaders: benchmark direct DXIL PSO compilation - #1802

Open
mokkamokacaffe wants to merge 1 commit into
xcl-dev:mainfrom
mokkamokacaffe:codex/direct-pso-benchmark
Open

mokkamokacaffe wants to merge 1 commit into
xcl-dev:mainfrom
mokkamokacaffe:codex/direct-pso-benchmark

Conversation

@mokkamokacaffe

@mokkamokacaffe mokkamokacaffe commented Nov 24, 2026 •

Copy link
Copy Markdown

Part of #1269.

Extends the exact-record PSO benchmark to compare the HLSL/DXC and Direct-DXIL routes. D3D12 cache disabling is requested for every measured call, but the output explicitly does not claim that a driver performed a cold compile.

What is in it

  • Add --measure-pso ... --backend hlsl|direct for one exact console compute record.
  • Refuse silent HLSL fallback in Direct-DXIL measurements.
  • Use the same root signature, static samplers, adapter, window count and split-wave setting for both backends.
  • Report record identity, adapter, translation and DXC time, DXIL size, every driver PSO time and the median in JSON and text output.
  • Report cache_disable_requested: true and cold_compile_verified: false; document that D3D12 cache control is a driver hint and a fast repeat is not proof of a cold compile.
  • Add argument validation and reproducibility documentation.

Tested

  • Windows 11, RTX 5070 Ti, Rust 1.100.0 MSVC, DXC/DXIL 1.9.2609.5 on predecessor 7d14d49: cargo build --release -p xcl passed; cargo test --workspace -- --test-threads=4 reported 891 passed, 0 failed, 42 ignored.
  • The exact-record Direct-DXIL translation and validation command translated one CS with zero unsupported programs, validator failures, panics or timeouts.
  • The benchmark successfully measured the same retail compute record through both backends. Direct produced 264,408-byte DXIL; HLSL produced 395,152-byte DXIL.
  • A temporary per-application NVIDIA profile with shader disk caching disabled prevented repeat times from collapsing to milliseconds on that machine. Interleaved medians were 3.16–3.23 s for Direct and 5.40–5.60 s for HLSL. This validates that controlled procedure on one adapter and record, not all drivers.
  • NVIDIA and AMD workspace runs on the predecessor reported no new failures: NVIDIA 889 passed, AMD 891 passed, 0 failed in both runs after the documented environment-specific skips.
  • A later RTX 3060 Ti report tested the branch merged with current main: cargo test -p xcl --lib passed with 0 failures and approximately 23 ignored tests.
  • git diff --check: passed.

Regression run

The available paired smoke runs are for predecessor 7d14d49, before the current output/documentation clarification and commit-identity rewrite. They were clean on RTX 5070 Ti and RTX 3060, but do not satisfy the exact-head check for current head 4edddca04e9be3735b4082293f376a88add07e01.

main:

Pending exact-head pair against a commit of current main.

PR:

Pending for 4edddca04e9be3735b4082293f376a88add07e01.

Not tested

  • Paired retail smoke on exact current head 4edddca.
  • Intel, Linux/Wine and a verified vendor-cache-off procedure outside the reported NVIDIA profile experiment.
  • Full-pack measurement or GPU output parity of the selected retail shader.
  • World rendering; the historical smoke runs stopped at startup/menu scenes.

AI use

  • OpenAI Codex analyzed [OFFICIAL] Looking for PRs with shaders optimization #1269 and the benchmark paths, implemented the Direct-DXIL backend option, reporting, validation and documentation, and later clarified the cache-control limitation from reviewer evidence.
  • Codex and Claude Code were used by independent contributors to run tests, measurements and historical smoke runs and draft their posted reports; contributors checked those reports before posting.

@Daydream3r

Daydream3r commented Nov 24, 2026 •

Copy link
Copy Markdown

Independent Windows/NVIDIA validation of exact head 7d14d49b664b8053d36f3b7abeef40bb48e2e368, part of #1269. Build and tests pass here, but the apparent cache reuse below prevents me from treating the reported median as a cold driver compilation time on this machine.

Setup and checks

  • Windows 11 Pro 25H2, build 26200.6584; RTX 5070 Ti 16 GB, NVIDIA 621.01; Ryzen 7 9800X3D, 64 GB RAM; Rust 1.100.0 MSVC; DXC/DXIL 1.9.2609.5. Windows Developer Mode is enabled.
  • cargo build --release -p xcl: passed.
  • cargo test --workspace -- --test-threads=4: 891 passed, 0 failed, 42 ignored (debug). Three explicit SKIPPED checks, included in the passed count: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows). XCL_SAMPLE_* unset, so optional external-data fixtures are not coverage of the retail pack.
  • git diff --check: passed; checkout clean, no local code patches.
  • xcl shaders <pack> --direct --hash 1404420b38db8597 --windows 4 --split 1 --validate --dump <local-dir> --json: 1 CS translated, 0 unsupported, validator failures, panics or timeouts. Dumps stay local.

Measured cache behaviour
Retail 1.0.2.1 record 1404420b38db8597, CS_PedStandardSkinning_3, release build. Commands:

xcl shaders <pack> --measure-pso 1404420b38db8597 --backend direct --windows 4 --split 1 --repeat 3 --json
xcl shaders <pack> --measure-pso 1404420b38db8597 --backend hlsl --windows 4 --split 1 --repeat 3 --json

XCL_HEAP_WINDOWS and XCL_DIRECT_DXIL unset. Both commands succeed, including ShaderCacheControl; no HLSL fallback for the direct command.

Backend Driver seconds, in order Reported median DXIL bytes Translation / DXC ms
direct 2.3430261, 0.0015173, 0.0013450 0.0015173 264408 24.7151 / n/a
hlsl 3.8389027, 0.0023389, 0.0020812 0.0023389 395152 13.2070 / 2201.5346

Three further fresh processes, direct backend, identical command except --repeat 1, give driver times 0.0015910, 0.0016459, 0.0016424 s. New processes alone therefore do not restore the initial multi-second cost here. This is consistent with cache reuse even though cache disable was accepted. I have not isolated which cache is responsible, and do not claim that the initial slow samples are proven cold or that the medians measure compiler speed. No NVIDIA profile settings or shared shader caches were changed/cleared.

Microsoft documents IMPLICIT_DRIVER_MANAGED operations as hints: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_shader_cache_kind_flags . The measurement tool needs a verified coldness procedure or an explicit limitation before these medians can support cold-compile comparisons on this setup. The repeated-PSO loop/cache-control mechanism already exists on main; the direct backend extension makes the same issue observable for direct DXIL too.

Regression run
Same retail title, 60 s, isolated title-data and DXIL-cache copies, no input beyond the account picker. The main block is reused unchanged from the earlier same-session run of this PR's base; the head block is a new run at the exact head above. This checks startup/menu stability, not the selected skinning shader's runtime output or world rendering.

main:

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: NVIDIA GeForce RTX 5070 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1650 (PresentX 1650)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14653 MB

PR:

xcl-smoke v1
commit: 7d14d49b664b8053d36f3b7abeef40bb48e2e368
gpu: NVIDIA GeForce RTX 5070 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1646 (PresentX 1646)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14577 MB

Not tested
AMD/Intel, native wave64, Linux/Wine, a genuinely verified cold driver-cache configuration, full-pack precompile, GPU output parity of this retail shader, or world rendering. This is a measurement/test report, not an approval review.

AI use
Codex desktop, GPT-6 (exact variant not exposed): source inspection, commands, actual local measurements/tests and this report.

Follow-up: a per-application NVIDIA cache-off control works here

Same head, adapter, driver, DXC, record, four windows and split wave64. An experimental call to NvAPI_D3D1x_DisableShaderDiskCache returned success but did not remove the fast repeat behaviour. A temporary application profile with PS_SHADERDISKCACHE_ID=OFF, associated with a unique sibling copy of the exe before launching it, did. No shader salt or shader code changes.

A local scripts/measure-nvidia-pso.ps1 wrapper now creates that profile, invokes this PR's measurement command, and deletes the profile and copied exe in finally. Interleaved fresh processes, --repeat 3 each:

Run Backend Driver seconds, in order Median seconds DXC ms
1 direct 2.4875601, 3.2703615, 3.2292201 3.2292201 n/a
2 hlsl 4.2427109, 5.6339293, 5.5971971 5.5971971 2670.3366
3 direct 2.3592782, 3.1550257, 3.2314652 3.1550257 n/a
4 hlsl 4.1287389, 5.5901529, 5.3975774 5.3975774 2398.8375

The copied exe without the temporary profile, same record and --repeat 3, gave 2.5808741, 0.0016611, 0.0016399 s. Thus the application-profile control eliminates the observed collapse to millisecond repeat times on this setup. This is evidence for the controlled procedure on one record, not a guarantee for all drivers or a GPU execution benchmark. Direct/HLSL DXIL sizes remain 264408/395152 B.

The wrapper and docs are a separate uncommitted local patch on this head, 186 added lines, not changes to your branch. Four profile-lifetime checks passed under both Windows PowerShell 5.1 and PowerShell 7. The real missing-record failure also removed its profile and exe; an independent NVAPI query confirmed all six wrapper-created profiles were absent afterwards. Windows PowerShell 5.1 also completed a real HLSL measurement successfully. Full workspace suite rerun on the local tree: 891 passed, 0 failed, 42 ignored, same three explicit skips listed above. No runtime Rust source changes, shared cache deletion, or changes to other application/global profiles. The wrapper is not committed or published as a PR yet.

@Anon64

Anon64 commented Nov 24, 2026

Copy link
Copy Markdown

Regression run for this PR: head 7d14d49, based on main 4178e88. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, XCL_NETWORK=0, A pressed every 4 s from 20 s, scripts/smoke.ps1 on a retail title for 60 s, back to back with the main run.

main 4178e88:

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1474 (PresentX 1474)
presents per 2 s (last 3): 29 7 0
device removals: 0
crashes: 0
peak commit: 24902 MB

this PR:

xcl-smoke v1
commit: 7d14d49b664b8053d36f3b7abeef40bb48e2e368
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1493 (PresentX 1494)
presents per 2 s (last 3): 35 8 0
device removals: 0
crashes: 0
peak commit: 24601 MB

No device removals or crashes; 101 % of main's frames, 99 % of its peak commit.

Not tested: the whole suite; the new xcl shaders benchmark itself (the title run does not use it).

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

@futurepro62

Copy link
Copy Markdown

Adding an AMD GPU (RDNA2, native wave64) to the report above, which has none, with an NVIDIA run alongside. Tested exact head 7d14d49 (on its base 4178e88).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip pso_measurement_compiles_an_exact_synthetic_record: 889 passed, 0 failed, 42 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • No new #[test] functions in the diff.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 891 passed, 0 failed, 42 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)).
  • Two tests were skipped with --skip on NVIDIA. Both fail on main 7f7e768 too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns their skips into failures. heap_window_out_of_memory_falls_back_to_the_switch_form skips when XCL_HEAP_WINDOWS is unset (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), and shaders::tests::pso_measurement_compiles_an_exact_synthetic_record skipped because Developer Mode was off. The AMD run does not set XCL_REQUIRE_GPU, so there both just print SKIPPED.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@mokkamokacaffe
mokkamokacaffe force-pushed the codex/direct-pso-benchmark branch from 7d14d49 to ca9deb7 Compare November 24, 2026 22:52
@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.

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