Skip to content

Present: area-average when the game renders larger than the window - #880

Open
peiikai wants to merge 2 commits into
developfrom
fix/downscale-area-filter
Open

peiikai wants to merge 2 commits into
developfrom
fix/downscale-area-filter

Conversation

@peiikai

@peiikai peiikai commented Nov 23, 2026

Copy link
Copy Markdown
Owner

What

When the game renders larger than the window (Resolution 2x-8x, or any render size above the window's), the present pass now averages every game pixel a window pixel covers, instead of taking one bilinear tap.

Before, at 3:1 (4x into a 2560x1440 window) each window pixel kept 1 of the 9 game pixels it covers, so edges, the HUD and text aliased and crawled like native resolution. 2:1 happened to average 2x2; 4:1 kept 4 of 16. The upscalers (MetalFX, FSR 1) only run when upscaling, so nothing else filtered it.

How

  • runtime/nvn/present_area.h (new): the shared shader snippet and its constants. Area weights per texel, so fractional ratios (3x into 1440p = 2.25:1) stay correct; averaged in linear light (sRGB decode, average, encode) so thin bright lines keep their brightness; clamped to the shown rect (interior crop, Dynamic's content part).
  • Metal: present_src in metal.m; compose() passes the ratio in pf.yz. Frame Generation's in-betweens go through compose() too.
  • Vulkan: present.frag in vulkan/shaders.c; vk_present_draw() passes the ratio in the push constants (both the normal frame and the in-betweens call it). present_rcas.frag (FSR) is untouched.
  • At a ratio of 1 or less the shader keeps the single tap exactly. MetalFX / FSR unchanged.
  • LARECOMP_PRESENT_AREA=0: the old single tap, for A/B shots (added to docs/debug-hooks.md).

Tested

Mac (Metal, M3 Max, 2560x1440 window):

  • 2x, 3x, 4x on/off: stair-stepping on Link, shield, grass and fences gone with it on; HUD hearts clean. Catfish's Maw room at 4x: no seams at the room edges.
  • 1x: unchanged (on/off difference below run-to-run noise; the ratio is 1, so the new path never runs).
  • Present pass alone (Metal timestamps, 100 draws): 4x into 1440p 0.45 ms (was 0.06), 3x 0.33, 2x 0.25, 1x unchanged. Mostly memory bandwidth: 4x reads a 133 MB source per frame.
  • Frame Generation at 3:1: 120 images/s, none late; in-betweens smoothed like game frames. Present pass 0.05 -> about 0.28 ms.
  • Dynamic resolution: looks and times as before (it tops out at the window's size, so it stays on the single tap).

Windows (Vulkan, RTX 3080 Ti, 2560x1440 window):

  • No validation errors from the present shader (strict validation at 4x).
  • 2x-4x smooth with it on, jagged off; 1x identical. Laplacian std dev (lower = less aliasing) on vs off: 1x 19.53 / 19.42, 2x 16.47 / 17.34, 3x 15.91 / 19.38, 4x 16.80 / 21.95.
  • Catfish's Maw 4x: no seams or garbage at the room edge.
  • Present pass: 4x 0.21 vs 0.09 ms; frame rate unchanged (60 fps).
  • Frame Generation at 4x: in-betweens match game frames, late 0. SMAA at 4x: looks right.

Note

With averaging on, SMAA at 2x and above is mostly redundant (the average already anti-aliases the edges). Moving SMAA after the downsample (at window size) would make it cheaper there; that's a separate decision, not part of this PR.

🤖 Generated with Claude Code

peiikai and others added 2 commits November 23, 2026 10:29
Resolution 2x-8x (and any render size above the window's) was shrunk with one
bilinear tap: at 3:1 each window pixel took 1 of the 9 game pixels it covers,
so edges, the HUD and text aliased and crawled like native resolution. The
upscalers only run when upscaling, so nothing else filtered it.

The present shader now averages every game pixel a window pixel covers, area
weighted (fractional ratios too), in linear light, clamped to the shown rect.
At 1:1 or below it keeps the single tap. Both backends share the code
(present_area.h); frame interpolation's in-betweens go through the same pass.
LARECOMP_PRESENT_AREA=0 turns it off for A/B tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant