Skip to content

RR releases its descriptor heap and query heap at destroy without waiting for the GPU #63

Closed

Description

@phantoslayer21

What happens

When the game destroys an RR instance, a_destroy takes the runtime-wide lock R().mu and calls destroy_locked (clean/rr_f/runtime/src/rr_runtime.cpp:3598, :2331). That waits up to 2 s for the instance's last serial. Then destroy_instance_resources (:1711) hands the instance's resources to defer_release, which correctly keeps them until the serial is done. It then waits a second time, up to 2 s (:1719), and releases the shader-visible descriptor heap in->heap and the timestamp query heap in->qh (:1720, :1722) whether or not that wait succeeded. Only a log line records the failure.

The game's command list can still use both objects: EndQuery and ResolveQueryData on the query heap (:2851, :3372, :3407), and the descriptor heap for the dispatches. in->null_tmpl is a CPU-only heap used only as a copy source at record time (:2768), so releasing it is harmless.

If the wait times out, the thread has been stalled for up to 4 s while holding the runtime-wide lock.

When it can happen

Only if the list that uses the heaps has not finished when the game destroys the instance. Two cases:

  • The game records an evaluate and destroys the instance before it submits that list, for example a settings or resize handler in the middle of a frame. The waits cannot succeed, so the game thread stalls for 4 s and the heaps are then released under the list.
  • The queue is stalled for longer than the waits without device removal. This is rare.

There is no parking of destroyed instances on the RR path. The adapter contract puts the duty on the runtime (clean/rr_f/proxy/include/wg_rr_adapter.h:153, "must defer GPU destruction past frames in flight"). After device removal, wait_serial stops early and releasing is fine.

Found by reading the code. It has not been reproduced.

To do

  • Widen Deferred (rr_runtime.cpp:381) to hold any pageable/COM object, with a separate flag for the live_resources accounting.
  • Pass heap and qh to defer_release with the same serial as the resources.
  • Remove the second wait_serial at :1719. This also removes the stall.
  • The first wait in destroy_locked (:2334) is only for harvesting timings and can be shortened.

If the list never runs, the heaps stay on the deferred list until drop_device (:1081). That is a small amount of memory.

Test

CPU-only: factor pump and defer_release so a test can drive a fake marker value and fake COM objects that count Release. Defer a heap at serial 5 with the marker at 4 and expect no Release. Set the marker to 5, pump, and expect one Release.

A hardware test is still needed for the full destroy path.

Related: #62, #58 (objects released while a recorded list may still use them), #64, #65.

Activity

  1. added this to the 0.6.1 milestone on Nov 13, 2026
  2. added
    bug
    needs-hardware-test
    area: ray-reconstruction
    on Nov 13, 2026
  3. moved this from Todo to In Progress in WrongGPUon Nov 13, 2026
  4. moved this from In Progress to Done in WrongGPUon Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: ray-reconstructionbugneeds-hardware-test

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions