Repository navigation
Description
What happens
ResizeForFrame (clean/fsr/src/frontend.cpp:959) creates the new upscaler and then calls u.backend->destroy(u.upscaler) at once (:987), on the game's recording thread, inside the dispatch for the new frame. The fallback stand-in is handled the same way (:981).
The backend's destroy waits for the network's own work: shutdown (clean/runtime/interop/backend.cpp:1933) waits for the done fence, drains the executor and waits on its own queue, and only then releases the shared slot buffers and fences. What it does not wait for is the second half of the game's command list, which the backend records after the split (clean/fsr/include/wronggpu_upscaler.h:151-:160, step 4): the copy from the backend's output buffer into the game's output, plus barriers. That half runs on the game's queue after the network signals. Two things can go wrong:
- The network has signalled, but the game's queue has not yet executed that copy when the buffer is released. This is a short window right after the previous frame's network work finishes.
- The previous frame's list was recorded but not yet submitted when the next dispatch arrives. Everything in it that refers to the old upscaler outlives it. The comment at
frontend.cpp:1048-:1050states this for the fallback path, which keeps the backend alive for this reason. The resize path does not.
Freeing a resource that a submitted or pending list refers to breaks the D3D12 lifetime rules. Whether that ends in corruption or device removal depends on the driver.
DestroyContext (:1128) does the same, but there the caller is expected to have finished with the GPU. A dynamic change of upscaleSize carries no such promise.
Separately, because destroy blocks on the old network's last frame (up to 5 s, backend.cpp:1937), every resize stalls the recording thread for about one frame of GPU latency.
When it can happen
When a game or host changes the output size within maxUpscaleSize between dispatches (dynamic output resolution, a window resize, a host changing its output size). It happens at most kMaxResizes = 8 times per context (frontend.cpp:960). The first case needs the game's queue to lag by a fraction of a millisecond to a few milliseconds, which is plausible on a busy queue. The second needs an engine that records frame N+1's upscale before submitting frame N, which is rare.
The result can be device removal.
Found by reading the code. It has not been reproduced.
To do
- Do not destroy the old upscaler in
ResizeForFrame. Keep it in aretiredslot onUpscaleContextand destroy it when the context is destroyed, or when a later resize replaces the slot. - Keep only one retired upscaler. If a second resize arrives while one is held, destroy the held one first.
- Do the same for the fallback stand-in at
:981.
The extra GPU memory for a second upscaler stays held until the context goes.
Test
CPU. TestOutputResize (clean/fsr/tests/test_frontend.cpp:599) currently checks g_destroyed == 1 right after the resize and must be updated. Dispatch at 2560x1440 and then at 1920x1080, and check g_destroyed == 0. Destroy the context and check that both upscalers are destroyed. A second test: resize twice and check that the first retired upscaler is destroyed at the second resize. A GPU test is needed to confirm the lifetime on a real queue.
Related: #62, #63 (objects released while a recorded list may still use them).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
Front end: bound the upscalers kept by output resizes to one per cont…