Skip to content

D3D12-GPU-REPLAY-WORKER-DROP-AND-PACE: close Worker event handle on drop and guard pace duration - #2994

Open
bobcatchris wants to merge 1 commit into
ProjectLeonida:mainfrom
bobcatchris:fix/d3d12-gpu-replay-worker-drop-pace
Open

bobcatchris wants to merge 1 commit into
ProjectLeonida:mainfrom
bobcatchris:fix/d3d12-gpu-replay-worker-drop-pace

Conversation

@bobcatchris

Copy link
Copy Markdown
Contributor

Addresses claim in #2570 (comment).

Changes

  1. Close Worker event handle on drop (\d3d12/crates/leonida-gpu/src/replay/gpu.rs):
    • Implement \Drop\ for \Worker\ to call \CloseHandle(self.event)\ when valid and reset \self.event, eliminating an OS event handle leak on every \Worker\ replacement in \Player::upload\ / batch copy and on \Player/\Capture\ drop.
  2. Guard replay \pace\ float-to-\Duration\ conversion (\d3d12/crates/leonida-gpu/src/replay/play.rs):
    • Extract \pace_until(now, pace_ms)\ using finite checks, \Duration::try_from_secs_f64(pace_ms / 1e3), and \Instant::checked_add, preventing panics on \NaN, \inf, or overflowing finite millisecond values.

Verification

  • Red -> Green:
    • Stubbing \CloseHandle\ in \Worker::drop\ fails
      eplay::gpu::tests::worker_drop_closes_event_handle\ (exit 101); restoring \CloseHandle\ passes.
    • Using unguarded \Duration::from_secs_f64\ in \pace_until\ fails
      eplay::play::tests::pace_until_rejects_non_finite_and_overflowing_values\ (exit 101); guarded conversion passes.
  • \cargo test --locked -p leonida-gpu --lib --features diagnostics -- replay::: 26 passed, 0 failed.
  • \cargo test --locked -p leonida-gpu --features diagnostics --test replay: 1 passed, 0 failed (includes \pace: f64::INFINITY\ on AMD Radeon RX 7900 XTX).
  • \python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: exit 0.
  • \python -I scripts/check_no_game_data.py\ on changed files: exit 0.
  • Independent read-only code review: approved.

AI-assisted

@merzleckeier

Copy link
Copy Markdown
Contributor

All 26 replay unit tests passed on NVIDIA and RADV through Wine.

I built fccce448 on main 002bd88f8, with #2975 and #2995 layered in. The replay source files match the isolated #2994 integration. A Windows MSVC-target leonida-gpu libtest build with --features diagnostics ran replay:: --nocapture --test-threads=1 on the RTX 4070 SUPER (620.73.4) and Radeon Raphael (RADV 26.3.1). On both GPUs it passed 26/26, including the worker event-handle child on a live D3D12 device and the pacing boundary unit test. Environment: Wine 11.22, VKD3D-Proton 3.1.0, one Vulkan ICD visible per run.

I separately built --features diagnostics --test replay and ran --exact a_frame_is_recorded_and_replayed on both GPUs, using the same setup and a #2975-only build as control. Both trees on both GPUs hit the same Wine read fault after the synthetic scene was created under recording, before the new infinity playback step. All four integration runs exited 5. The paired control shows that this local Wine run stops at the same point without #2994. Synthetic capture only. MEASURED, AI-assisted with OpenAI Codex and independent raw-log verification.

@andrew-ai

Copy link
Copy Markdown

The unmodified a_frame_is_recorded_and_replayed integration test at fccce44 passed on native Windows. It recorded the synthetic scene (3 submissions, 4 lists, 18 resources, 6 pipelines), completed the added player.run with pace=f64::INFINITY, and reached the final replay assertions. The reported final picture hash matched the recording, 4aaec8b6026567d0. One test passed in 1.42 s.

Command: cargo test --locked --profile diag --features diagnostics -p leonida-gpu --test replay -- --exact a_frame_is_recorded_and_replayed --nocapture

This supplies a native result for the integration path that stopped before playback in the Wine run. No game data used. Codex-assisted.

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.

3 participants