Skip to content

Front end: reactive-mask generation reaches AMD's context when one exists - #83

Merged
phantoslayer21 merged 1 commit into
mainfrom
fix/59-forward-reactive-mask
Nov 13, 2026
Merged

phantoslayer21 merged 1 commit into
mainfrom
fix/59-forward-reactive-mask

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Fixes #59

What was wrong

While a context belongs to WrongGPU, a dispatch of type FFX_API_DISPATCH_DESC_TYPE_UPSCALE_GENERATEREACTIVEMASK returned OK and recorded nothing (clean/fsr/src/frontend.cpp, FrontEnd::Dispatch). The public description names outReactive as the surface the mask is generated into. Some frames of a WrongGPU context are still sent to AMD's upscaler with the game's original description, which includes that reactive resource: the "bad frame" path (frames flagged sRGB or PQ, and frames the mapping refuses when the stand-in cannot take them) and the comparison with AMD. Those frames read a mask that was not written this frame (the last mask AMD wrote, zeros, or leftover data). The effect is extra ghosting on translucent and particle areas for a short time, and a biased comparison. It does not crash.

The fix

In the generate-mask branch of FrontEnd::Dispatch (Own mode), the call is now sent to an AMD context when one exists:

  • while the player compares with AMD (and the context is not in the custom slot, as for the upscale dispatch), to the comparison context if there is one;
  • otherwise to u->amd, the AMD context made for an earlier bad frame or for the comparison.

The descriptor is passed on unchanged and AMD's return code is the call's result (logged when it is not OK or when the call would be logged anyway). Without an AMD context there is nothing to send it to: it still returns OK with nothing recorded, as before. The first frame of a run needs no change (it is sent to AMD with reset = true). No AMD context is created for this call. A forwarded call from a host that routes back into WrongGPU is stopped by the existing re-entry guard.

The test

TestReactiveMaskForwarded in clean/fsr/tests/test_frontend.cpp (ctest fsr_frontend_unit, in the CI set), with the fake AMD DLL that records every call and its descriptor type:

  • comparison: before any AMD context the mask call returns OK and AMD sees nothing; after the comparison context exists the mask call is recorded by AMD on that context; a failing AMD dispatch makes the call fail; with the comparison off but AMD's context still alive the call still reaches it;
  • bad frame: after a frame with no output (AMD's FSR takes that frame from the saved create parameters), the mask call is recorded on AMD's context; before it, nothing is.

Before / after (MSVC, Release, cmake -S clean/fsr -B <out> -G Ninja -DWG_MODEL_K=OFF -DWG_BUILD_ID=ci -DWG_BUILD_ASI=ON, cmake --build <out> --target test_frontend, <out>\test_frontend.exe):

  • main plus the test only: 1141 checks, 4 failures (all four are the "AMD recorded a mask dispatch" checks; the count today is 0).
  • with the fix: 1140 checks, 0 failures (the total varies by a check or two between runs: a polling loop in an earlier test checks once per iteration).

Tested

  • test_frontend before and after, as above.
  • The CI set (ctest -R "unit|hosted|diagnostic|support" -E "overlay|split|d3d12") plus fsr_custom_slot (WARP): 16 tests, all passed (fsr_asi_scan_unit skipped, as usual).
  • Repository gates (secrets, personal data, licence, view layout): pass.

Not tested

  • No game and no GPU; the issue was found by reading the code and has not been reproduced in a game, so the ghosting effect is not measured.
  • The generated mask itself (AMD's pass) is not exercised: the AMD side is a recording fake.

…ists

A dispatch of type GENERATEREACTIVEMASK on a WrongGPU context returned OK and
recorded nothing. Some frames of such a context still go to AMD's upscaler with
the game's reactive resource (frames WrongGPU cannot take, the player's
comparison), and those frames read a mask that was not written this frame.
With an AMD context at hand (the comparison context while comparing, else the
context made for an earlier frame) the call is now sent to it. Without one it
stays OK with nothing recorded; the first frame of a run needs no change.

Fixes #59

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 13, 2026 21:05
@phantoslayer21
phantoslayer21 merged commit b3a07df into main Nov 13, 2026
2 checks passed
@phantoslayer21
phantoslayer21 deleted the fix/59-forward-reactive-mask branch November 13, 2026 21:06
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.

Reactive-mask generation returns success without writing the mask

1 participant