perf(vk): read the picture's own pixel for the window filter at the window's own size #3217

Merged
HumanBean merged 2 commits from klimovich008/Longshot:perf/filter-1to1 into main 2026-12-05 17:36:59 +00:00
Member

Summary

What was wrong: with the Window scaling filter on Catmull-Rom or Lanczos, the last pass, which fits the game's picture to the window, still ran the filter's 16 taps for every pixel when the picture is shown at its own size. That happens with an Output resolution at the window's size (the menu's filter row then reads "Not needed (window = output)"), the default on 1080p and 1440p screens, and on the Steam Deck, whose 16:9 picture sits between bars on its 16:10 screen (1280x720 on 1280x800). At that size both filters weigh 1 at the pixel itself and 0 at every other pixel, so all that work returned the picture's own pixel.

What this changes: there the pass now reads that pixel directly: fg_scale.comp's new mode 3, one texelFetch at the crop's corner plus the window pixel, kept in the crop as the filter's taps are. framegen_scale chooses it when the checked crop is the window's size and no ultrawide menu side is drawn.

The result: the same picture for less GPU time. On the Steam Deck's GPU, every 8-bit code Catmull-Rom and Lanczos stored at 1:1 is the one mode 3 stores, from 1280x720 to 7680x2160 (Testing). The pass alone takes 0.10 ms instead of 0.94 ms with Lanczos (0.85 ms with Catmull-Rom) on the Steam Deck at 1280x720, its GPU held at 1300 MHz as the game holds it, and 0.89 ms instead of 9.08 ms at 3840x2160 (Measurements).

Who it affects: players whose picture is shown at its own size with the filter on Catmull-Rom or Lanczos. On PCs that is the default on 1080p and 1440p screens: the Output resolution is the game's 2560x1440, or the screen's size where that is smaller, so the picture is the window's size, and the presets Auto picks above Minimum use Lanczos (Low, High, Ultra; #3100) or Catmull-Rom (Balanced). On the Steam Deck the default is not affected: Auto picks Minimum and sets its filter Off. A Deck player who chooses Catmull-Rom or Lanczos is affected (the Deck's 16:9 picture is 1280x720, between bars on its 1280x800 screen). It also applies to frame generation's made frames, headless runs and shots, which go through the same function.

Unchanged: a picture that is scaled (any other size), the Off filter, and the picture beside an ultrawide menu's sides, black or blurred, whose soft edge mixes the filter's own result. The pass itself still runs, with its image, its alpha, and what reads it afterwards (the HDR pass, the output effects, the blit). No switch and no setting are added, and no shader-cache input changes (fg_scale.comp is not part of the translator's stamp), so no player prepares shaders again.

Read first: framegen_scale in gpu/vk/vk_framegen.cpp (the one_to_one line and the push constants), then the end of main() in gpu/vk/shaders/fg_scale.comp.

Prior work: none found (searched for window filter, "Not needed", fg_scale, upscale 1:1, window scaling, Lanczos, texelFetch). #2706 also changed how this pass samples cropped pictures, but not the 1:1 case. #2542 (WIP) would have the Output resolution a player never chose fit their window, which makes this 1:1 case more common. No open PR changes the files this one does, apart from #2515, which already conflicts with main in vk_framegen.cpp; this branch adds no file to its conflicts.

Testing

Tested: in the game on a Steam Deck OLED (SteamOS 3.9.5, kernel 7.2.7, Mesa 26.2.0-devel RADV, 4 cores / 8 threads, AC power, stock 15 W). main f8b54338 against f8b54338 with this change (the same renderer lines as the head; later commits changed tests only), each built from source on the Deck. The game kept its window under gamescope's headless backend at 1280x720 (the harness's --gamescope; output and picture 1280x720), with Lanczos. With RX_VK_UPSCALE_LOG=1 every main run logged upscale dispatched: mode 2, source 1280x720 ... destination 1280x720, and every run of this change logged mode 3 (the filter 2), source 1280x720 ... destination 1280x720. Market as a child, 3 alternating pairs, 150 s lead; no crash or Vulkan error. Then at 1920x1080 and 2560x1440, the window, the Output resolution and the picture all that size (HOS_WINDOW_SIZE, --gamescope, Render resolution 100 %), where the GPU's work is most of the frame: the same log lines at those sizes, no crash or Vulkan error (Measurements).

The picture, on the GPU: a standalone Vulkan program (not part of this PR; its source, and the timing program's below, can be posted on request) ran fg_scale.comp from this branch on the Deck's GPU at 1:1 over a picture of random codes (fixed seed). It stored the window with Catmull-Rom, with Lanczos and with mode 3, read all three back, and compared them code by code:

Picture (8-bit) Sizes Catmull-Rom or Lanczos vs mode 3 Mode 3 vs the picture's own codes
UNORM 1280x720, 1281x719, 1920x1080, 2560x1440, 3840x2160, 5120x1440, 7680x2160 0 codes differ identical
sRGB view the same at most 1 code, in 0.01 % to 1.3 % of codes (decoded values: mode 3 is exact)

The sRGB rows are the filters' own arithmetic error crossing a rounding point, which mode 3 does not have; the commit message names this case. Negative control: the same shader with mode 3 reading the next pixel over fails (2,751,546 of 2,764,800 codes differ at 1280x720).

Checks: the related tests pass (test_fg_scale_sharpen, test_upscale_independent, test_sharpen, test_temporal_present_bandwidth, test_hdr_encode, test_crt_policy, test_present_aspect, test_upscaler_rows, test_output_trial, test_capture_dimensions). test_present_aspect_vulkan cannot link on the Deck (no -lvulkan there), the same as on main. ruff and git diff --check are clean. The tests check what the code does, not its spelling (the second commit, after review). test_upscale_independent runs framegen_scale over the window sizes and crops as played, with frame generation on and headless, beside menu sides of three widths, with the filter Off too, one call after another as the window is resized, and with a filter the menu changes while it is read: mode 3 exactly at the checked crop's own size with no sides, every pass into an image of its window's size, and the upscale log's line naming the very mode dispatched and the filter chosen, for a table of first calls (each filter, each kind of side, a picture of the window's size, cropped, larger and smaller). test_fg_scale_sharpen compiles fg_scale.comp itself (both builds) as C++ and runs every invocation of a dispatch as framegen_scale makes it: at 1:1 mode 3 stores every pixel once, opaque, its picture pixel's value exactly, from one read; at any other size every read stays in the crop; Catmull-Rom, Lanczos and the Off filter's plain pass at 1:1 give the same codes, their reads in the crop. Each commit message lists its negative controls (41 for the tests' second commit), each failing as expected, and the equivalent rewrites that pass (14). 25 rounds of a second-opinion review (gpt-6.2-sol); rounds 6 to 25 found no runtime defect, and every test gap they found in this PR's lines is closed.

Still to test:

  • Windows and Linux PCs with a discrete GPU (NVIDIA, AMD, Intel): main and this PR, Window scaling filter Lanczos, the picture at the output's size (the farm's headless 1920x1080 output, Render resolution 100 %), uncapped, RX_VK_UPSCALE_LOG=1. Expect mode 3 (the filter 2) in this PR's log and mode 2 in main's, the same picture, and no fps loss (a small gain where the GPU limits the whole frame) (@Beanstalk).
  • The Steam Deck in Game Mode at its own 1280x800, the 16:9 picture between bars (the runs above had a 1280x720 output): RX_VK_UPSCALE_LOG=1 logs mode 3 (the filter 2), source 1280x720 ... destination 1280x720, and the picture looks the same (by hand).

Measurements

Verdict: At 1:1 the pass takes about 89 % less GPU time: 0.83 ms a frame with Lanczos (0.75 ms with Catmull-Rom) at the Steam Deck's 1280x720, 2.0 ms at 1920x1080, 3.4 ms at 2560x1440 and 8.2 ms at 3840x2160, on the Deck's GPU; the existing filters' own times are unchanged. In the game on the Steam Deck at 15 W, fps does not move, at 1280x720 (CPU-bound) nor at 1920x1080 and 2560x1440 where the GPU's work is most of the frame: on the Deck's thread shape the frame is about 10 ms longer than the GPU's work at every size, and this pass runs in that wait. What changes there is the GPU's load: at 1920x1080 it is busy 74 % of the time instead of 90 %, and the APU draws 15.1 W instead of 15.7 W. A gain in fps needs a GPU that is busy the whole frame (desktop GPU limits; Still to test).

Setup: Steam Deck OLED, SteamOS 3.9.5, Mesa 26.2.0-devel RADV, stock 15 W, AC power.

The pass alone (the standalone program above: fg_scale.comp at 1:1, RGBA8, 64 dispatches between two GPU timestamps, a barrier after each, 15 rounds after a warm-up round, amdgpu held at its peak power state (1300 MHz at every batch) as the renderer holds it on the Deck (vk_gpu_clock.cpp); main's shader and this branch's interleaved in every round, in rotated order, with the GPU clock read around each batch). Median GPU time a frame:

Picture = window Before: main @ f359e262, Catmull-Rom Before: main @ f359e262, Lanczos After: this PR @ 185051fb (mode 3)
1280x720 (the Steam Deck's 16:9 picture) 0.855 ms 0.936 ms 0.104 ms
1280x800 0.942 ms 1.017 ms 0.114 ms
1920x1080 1.914 ms 2.278 ms 0.233 ms
2560x1440 3.371 ms 3.796 ms 0.397 ms
3840x2160 7.563 ms 9.082 ms 0.887 ms

Saved a frame against Lanczos (Catmull-Rom): 0.833 ms (0.751 ms) at 1280x720, 0.903 ms (0.828 ms) at 1280x800, 2.045 ms (1.680 ms) at 1920x1080, 3.400 ms (2.974 ms) at 2560x1440, 8.195 ms (6.676 ms) at 3840x2160: 89 to 90 % of the pass. (fg_scale.comp is the same at f359e262 and f8b54338, and at feef390f, the earlier head the program took it from, 185051fb and the head e086045f.)

This branch's shader ran Catmull-Rom and Lanczos within 0.2 % of main's at every size (at 1280x720: 0.8531 against 0.8545 ms, 0.9345 against 0.9365 ms), so mode 3's branch costs the other modes nothing measurable.

In the game (Market child, uncapped, --lead 150 steady state, the Deck's own thread shape, 3 alternating pairs; pair 1 was skipped because its main run swapped 183 MB in its window, so 2 pairs counted):

Before: main @ f8b54338 After: this PR @ 185051fb, on main f8b54338
fps (median of runs) 44.24 43.28 (-2.2 %; pairs -5.3 %, +0.9 %)
CPU ms a frame 82.15 81.47 (-0.8 %)
1 % low 25.9 24.9
p99 (ms) 35.2 35.4
GPU ms a frame (the replay's recordings; this pass is not in it) 11.75 11.95
the upscale log line mode 2 mode 3 (the filter 2)

In the game where the GPU's work is most of the frame (BeanBot's L1): the game windowed at 1920x1080 under gamescope's headless backend, Output resolution 1920x1080, Render resolution 100 %, Lanczos, so the pass is 1:1 (main logged mode 2, source 1920x1080 ... destination 1920x1080, this change mode 3 (the filter 2)); Market child, uncapped, --lead 150, 4 alternating pairs, 15 W. The Deck's harness counted only one run: it refuses a run whose window saw over 64 MB of swap-ins, and at this size the game's own memory (1.2 to 1.5 GB of it swapped out while it loads) is re-read in the window in most runs. Every run is listed, as their numbers agree:

Run (1920x1080) Before: main @ f8b54338 After: this PR @ 185051fb, on main f8b54338
fps 26.97, 27.40, 27.09 26.76, 27.29 (counted)
p50 frame time (ms) 36.64, 36.23, 36.52 36.77, 36.38
p99 (ms) 48.84, 45.50, 46.54 49.02, 45.35
1 % low (fps) 18.7, 19.1, 17.5 17.4, 20.1
GPU ms a frame (the replay's recordings; this pass is not in it) 28.2, 28.1, 28.15 28.1, 28.1
GPU busy (amdgpu, the window's mean) 90.3 %, 94.2 %, 87.0 % 75.2 %, 73.0 %
APU power (slow PPT, mean) 15.74, 15.76, 15.48 W 15.19, 15.09 W

At 2560x1440 (the same setup, 2560x1440 everywhere): main 18.75, 18.31, 18.89, 18.49 fps (GPU busy 94.8, 85.9, 89.2, 88.9 %), this change 18.76 fps (82.9 %); the GPU's work 43 ms of a 53 ms frame. Main's runs there were all refused (swap-ins of 0.6 to 0.8 GB, or one game-clock probe in the window at 18 fps), so this size was not finished.

Risks

What could break: the window would show a wrong pixel at 1:1 if mode 3's read were wrong. The GPU check above and the tests rule out an offset, a sampled read, or a read outside the crop. A developer's RX_VK_SHADER_DIR override of fg_scale built from an earlier tree reads mode 3 as its tent filter; build the override from this tree's fg_scale.comp, as for any change to the pass's push constants. A revert is enough to undo the change; no switch turns it off.

What a player notices after updating: nothing on screen. Where the GPU limits the whole frame, slightly more fps at 1:1 with Catmull-Rom or Lanczos; on the Steam Deck, a less busy GPU at the same fps.

Not covered: discrete GPUs and Windows (Still to test). Native HDR's 10-bit picture is covered by the tests (the FG_SCALE_PQ build, mode 3 dispatched for it), not by the GPU check above, which ran 8-bit pictures.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named): its two steps on the Deck (gen-shaders all with the system's glslang 16.3.0, the pinned 16.6.0 not being there, then run_all.py --strict), this branch and main f359e262 alike: 210 failing cases in 134 test files, the same set on both, none only on this branch. They are the tools this Deck lacks under --strict (clang, clang++, the SPIR-V headers, cmake, zstandard) and the checks that need them; every test this PR changes or touches passes.
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • The SPIR-V headers regenerated (a shader changed): fg_scale.comp changed; its headers are generated by gen-shaders (none are checked in), here and in every build of this branch.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths: no host code changed; the renderer's Windows and Linux builds are CI's.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg

## Summary **What was wrong:** with the Window scaling filter on Catmull-Rom or Lanczos, the last pass, which fits the game's picture to the window, still ran the filter's 16 taps for every pixel when the picture is shown at its own size. That happens with an Output resolution at the window's size (the menu's filter row then reads "Not needed (window = output)"), the default on 1080p and 1440p screens, and on the Steam Deck, whose 16:9 picture sits between bars on its 16:10 screen (1280x720 on 1280x800). At that size both filters weigh 1 at the pixel itself and 0 at every other pixel, so all that work returned the picture's own pixel. **What this changes:** there the pass now reads that pixel directly: `fg_scale.comp`'s new mode 3, one `texelFetch` at the crop's corner plus the window pixel, kept in the crop as the filter's taps are. `framegen_scale` chooses it when the checked crop is the window's size and no ultrawide menu side is drawn. **The result:** the same picture for less GPU time. On the Steam Deck's GPU, every 8-bit code Catmull-Rom and Lanczos stored at 1:1 is the one mode 3 stores, from 1280x720 to 7680x2160 (Testing). The pass alone takes 0.10 ms instead of 0.94 ms with Lanczos (0.85 ms with Catmull-Rom) on the Steam Deck at 1280x720, its GPU held at 1300 MHz as the game holds it, and 0.89 ms instead of 9.08 ms at 3840x2160 (Measurements). **Who it affects:** players whose picture is shown at its own size with the filter on Catmull-Rom or Lanczos. On PCs that is the default on 1080p and 1440p screens: the Output resolution is the game's 2560x1440, or the screen's size where that is smaller, so the picture is the window's size, and the presets Auto picks above Minimum use Lanczos (Low, High, Ultra; #3100) or Catmull-Rom (Balanced). On the Steam Deck the default is not affected: Auto picks Minimum and sets its filter Off. A Deck player who chooses Catmull-Rom or Lanczos is affected (the Deck's 16:9 picture is 1280x720, between bars on its 1280x800 screen). It also applies to frame generation's made frames, headless runs and shots, which go through the same function. **Unchanged:** a picture that is scaled (any other size), the Off filter, and the picture beside an ultrawide menu's sides, black or blurred, whose soft edge mixes the filter's own result. The pass itself still runs, with its image, its alpha, and what reads it afterwards (the HDR pass, the output effects, the blit). No switch and no setting are added, and no shader-cache input changes (`fg_scale.comp` is not part of the translator's stamp), so no player prepares shaders again. **Read first:** `framegen_scale` in `gpu/vk/vk_framegen.cpp` (the `one_to_one` line and the push constants), then the end of `main()` in `gpu/vk/shaders/fg_scale.comp`. **Prior work:** none found (searched for window filter, "Not needed", `fg_scale`, upscale 1:1, window scaling, Lanczos, `texelFetch`). #2706 also changed how this pass samples cropped pictures, but not the 1:1 case. #2542 (WIP) would have the Output resolution a player never chose fit their window, which makes this 1:1 case more common. No open PR changes the files this one does, apart from #2515, which already conflicts with main in `vk_framegen.cpp`; this branch adds no file to its conflicts. ## Testing **Tested:** in the game on a Steam Deck OLED (SteamOS 3.9.5, kernel 7.2.7, Mesa 26.2.0-devel RADV, 4 cores / 8 threads, AC power, stock 15 W). main f8b54338 against f8b54338 with this change (the same renderer lines as the head; later commits changed tests only), each built from source on the Deck. The game kept its window under gamescope's headless backend at 1280x720 (the harness's `--gamescope`; output and picture 1280x720), with Lanczos. With `RX_VK_UPSCALE_LOG=1` every main run logged `upscale dispatched: mode 2, source 1280x720 ... destination 1280x720`, and every run of this change logged `mode 3 (the filter 2), source 1280x720 ... destination 1280x720`. Market as a child, 3 alternating pairs, 150 s lead; no crash or Vulkan error. Then at 1920x1080 and 2560x1440, the window, the Output resolution and the picture all that size (`HOS_WINDOW_SIZE`, `--gamescope`, Render resolution 100 %), where the GPU's work is most of the frame: the same log lines at those sizes, no crash or Vulkan error (Measurements). **The picture, on the GPU:** a standalone Vulkan program (not part of this PR; its source, and the timing program's below, can be posted on request) ran `fg_scale.comp` from this branch on the Deck's GPU at 1:1 over a picture of random codes (fixed seed). It stored the window with Catmull-Rom, with Lanczos and with mode 3, read all three back, and compared them code by code: | Picture (8-bit) | Sizes | Catmull-Rom or Lanczos vs mode 3 | Mode 3 vs the picture's own codes | |---|---|---|---| | UNORM | 1280x720, 1281x719, 1920x1080, 2560x1440, 3840x2160, 5120x1440, 7680x2160 | 0 codes differ | identical | | sRGB view | the same | at most 1 code, in 0.01 % to 1.3 % of codes | (decoded values: mode 3 is exact) | The sRGB rows are the filters' own arithmetic error crossing a rounding point, which mode 3 does not have; the commit message names this case. Negative control: the same shader with mode 3 reading the next pixel over fails (2,751,546 of 2,764,800 codes differ at 1280x720). **Checks:** the related tests pass (`test_fg_scale_sharpen`, `test_upscale_independent`, `test_sharpen`, `test_temporal_present_bandwidth`, `test_hdr_encode`, `test_crt_policy`, `test_present_aspect`, `test_upscaler_rows`, `test_output_trial`, `test_capture_dimensions`). `test_present_aspect_vulkan` cannot link on the Deck (no `-lvulkan` there), the same as on main. ruff and `git diff --check` are clean. The tests check what the code does, not its spelling (the second commit, after review). `test_upscale_independent` runs `framegen_scale` over the window sizes and crops as played, with frame generation on and headless, beside menu sides of three widths, with the filter Off too, one call after another as the window is resized, and with a filter the menu changes while it is read: mode 3 exactly at the checked crop's own size with no sides, every pass into an image of its window's size, and the upscale log's line naming the very mode dispatched and the filter chosen, for a table of first calls (each filter, each kind of side, a picture of the window's size, cropped, larger and smaller). `test_fg_scale_sharpen` compiles `fg_scale.comp` itself (both builds) as C++ and runs every invocation of a dispatch as `framegen_scale` makes it: at 1:1 mode 3 stores every pixel once, opaque, its picture pixel's value exactly, from one read; at any other size every read stays in the crop; Catmull-Rom, Lanczos and the Off filter's plain pass at 1:1 give the same codes, their reads in the crop. Each commit message lists its negative controls (41 for the tests' second commit), each failing as expected, and the equivalent rewrites that pass (14). 25 rounds of a second-opinion review (gpt-6.2-sol); rounds 6 to 25 found no runtime defect, and every test gap they found in this PR's lines is closed. **Still to test:** - Windows and Linux PCs with a discrete GPU (NVIDIA, AMD, Intel): main and this PR, Window scaling filter Lanczos, the picture at the output's size (the farm's headless 1920x1080 output, Render resolution 100 %), uncapped, `RX_VK_UPSCALE_LOG=1`. Expect `mode 3 (the filter 2)` in this PR's log and `mode 2` in main's, the same picture, and no fps loss (a small gain where the GPU limits the whole frame) (@Beanstalk). - The Steam Deck in Game Mode at its own 1280x800, the 16:9 picture between bars (the runs above had a 1280x720 output): `RX_VK_UPSCALE_LOG=1` logs `mode 3 (the filter 2), source 1280x720 ... destination 1280x720`, and the picture looks the same (by hand). ## Measurements **Verdict:** At 1:1 the pass takes about 89 % less GPU time: 0.83 ms a frame with Lanczos (0.75 ms with Catmull-Rom) at the Steam Deck's 1280x720, 2.0 ms at 1920x1080, 3.4 ms at 2560x1440 and 8.2 ms at 3840x2160, on the Deck's GPU; the existing filters' own times are unchanged. In the game on the Steam Deck at 15 W, fps does not move, at 1280x720 (CPU-bound) nor at 1920x1080 and 2560x1440 where the GPU's work is most of the frame: on the Deck's thread shape the frame is about 10 ms longer than the GPU's work at every size, and this pass runs in that wait. What changes there is the GPU's load: at 1920x1080 it is busy 74 % of the time instead of 90 %, and the APU draws 15.1 W instead of 15.7 W. A gain in fps needs a GPU that is busy the whole frame (desktop GPU limits; Still to test). Setup: Steam Deck OLED, SteamOS 3.9.5, Mesa 26.2.0-devel RADV, stock 15 W, AC power. **The pass alone** (the standalone program above: `fg_scale.comp` at 1:1, RGBA8, 64 dispatches between two GPU timestamps, a barrier after each, 15 rounds after a warm-up round, amdgpu held at its peak power state (1300 MHz at every batch) as the renderer holds it on the Deck (`vk_gpu_clock.cpp`); main's shader and this branch's interleaved in every round, in rotated order, with the GPU clock read around each batch). Median GPU time a frame: | Picture = window | Before: main @ f359e262, Catmull-Rom | Before: main @ f359e262, Lanczos | After: this PR @ 185051fb (mode 3) | |---|---|---|---| | 1280x720 (the Steam Deck's 16:9 picture) | 0.855 ms | 0.936 ms | 0.104 ms | | 1280x800 | 0.942 ms | 1.017 ms | 0.114 ms | | 1920x1080 | 1.914 ms | 2.278 ms | 0.233 ms | | 2560x1440 | 3.371 ms | 3.796 ms | 0.397 ms | | 3840x2160 | 7.563 ms | 9.082 ms | 0.887 ms | Saved a frame against Lanczos (Catmull-Rom): 0.833 ms (0.751 ms) at 1280x720, 0.903 ms (0.828 ms) at 1280x800, 2.045 ms (1.680 ms) at 1920x1080, 3.400 ms (2.974 ms) at 2560x1440, 8.195 ms (6.676 ms) at 3840x2160: 89 to 90 % of the pass. (fg_scale.comp is the same at f359e262 and f8b54338, and at feef390f, the earlier head the program took it from, 185051fb and the head e086045f.) This branch's shader ran Catmull-Rom and Lanczos within 0.2 % of main's at every size (at 1280x720: 0.8531 against 0.8545 ms, 0.9345 against 0.9365 ms), so mode 3's branch costs the other modes nothing measurable. **In the game** (Market child, uncapped, `--lead 150` steady state, the Deck's own thread shape, 3 alternating pairs; pair 1 was skipped because its main run swapped 183 MB in its window, so 2 pairs counted): | | Before: main @ f8b54338 | After: this PR @ 185051fb, on main f8b54338 | |---|---|---| | fps (median of runs) | 44.24 | 43.28 (-2.2 %; pairs -5.3 %, +0.9 %) | | CPU ms a frame | 82.15 | 81.47 (-0.8 %) | | 1 % low | 25.9 | 24.9 | | p99 (ms) | 35.2 | 35.4 | | GPU ms a frame (the replay's recordings; this pass is not in it) | 11.75 | 11.95 | | the upscale log line | `mode 2` | `mode 3 (the filter 2)` | **In the game where the GPU's work is most of the frame** (BeanBot's L1): the game windowed at 1920x1080 under gamescope's headless backend, Output resolution 1920x1080, Render resolution 100 %, Lanczos, so the pass is 1:1 (main logged `mode 2, source 1920x1080 ... destination 1920x1080`, this change `mode 3 (the filter 2)`); Market child, uncapped, `--lead 150`, 4 alternating pairs, 15 W. The Deck's harness counted only one run: it refuses a run whose window saw over 64 MB of swap-ins, and at this size the game's own memory (1.2 to 1.5 GB of it swapped out while it loads) is re-read in the window in most runs. Every run is listed, as their numbers agree: | Run (1920x1080) | Before: main @ f8b54338 | After: this PR @ 185051fb, on main f8b54338 | |---|---|---| | fps | 26.97, 27.40, 27.09 | 26.76, 27.29 (counted) | | p50 frame time (ms) | 36.64, 36.23, 36.52 | 36.77, 36.38 | | p99 (ms) | 48.84, 45.50, 46.54 | 49.02, 45.35 | | 1 % low (fps) | 18.7, 19.1, 17.5 | 17.4, 20.1 | | GPU ms a frame (the replay's recordings; this pass is not in it) | 28.2, 28.1, 28.15 | 28.1, 28.1 | | GPU busy (amdgpu, the window's mean) | 90.3 %, 94.2 %, 87.0 % | 75.2 %, 73.0 % | | APU power (slow PPT, mean) | 15.74, 15.76, 15.48 W | 15.19, 15.09 W | At 2560x1440 (the same setup, 2560x1440 everywhere): main 18.75, 18.31, 18.89, 18.49 fps (GPU busy 94.8, 85.9, 89.2, 88.9 %), this change 18.76 fps (82.9 %); the GPU's work 43 ms of a 53 ms frame. Main's runs there were all refused (swap-ins of 0.6 to 0.8 GB, or one game-clock probe in the window at 18 fps), so this size was not finished. ## Risks **What could break:** the window would show a wrong pixel at 1:1 if mode 3's read were wrong. The GPU check above and the tests rule out an offset, a sampled read, or a read outside the crop. A developer's `RX_VK_SHADER_DIR` override of `fg_scale` built from an earlier tree reads mode 3 as its tent filter; build the override from this tree's `fg_scale.comp`, as for any change to the pass's push constants. A revert is enough to undo the change; no switch turns it off. **What a player notices after updating:** nothing on screen. Where the GPU limits the whole frame, slightly more fps at 1:1 with Catmull-Rom or Lanczos; on the Steam Deck, a less busy GPU at the same fps. **Not covered:** discrete GPUs and Windows (Still to test). Native HDR's 10-bit picture is covered by the tests (the `FG_SCALE_PQ` build, mode 3 dispatched for it), not by the GPU check above, which ran 8-bit pictures. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named): its two steps on the Deck (`gen-shaders all` with the system's glslang 16.3.0, the pinned 16.6.0 not being there, then `run_all.py --strict`), this branch and main f359e262 alike: 210 failing cases in 134 test files, the same set on both, none only on this branch. They are the tools this Deck lacks under `--strict` (clang, clang++, the SPIR-V headers, cmake, zstandard) and the checks that need them; every test this PR changes or touches passes. - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] The SPIR-V headers regenerated (a shader changed): `fg_scale.comp` changed; its headers are generated by `gen-shaders` (none are checked in), here and in every build of this branch. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths: no host code changed; the renderer's Windows and Linux builds are CI's. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
perf(vk): read the picture's own pixel for the window filter at the window's own size
Some checks failed
beanstalk/approval can't be tested as asked: see the farm's comment
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
185051fbde
The Window scaling filter (Catmull-Rom, Lanczos) took its 16 taps and weights a pixel also where the picture is shown at
its own size: an Output resolution at the window's (the menu's row then says "Not needed (window = output)", vk_menu.cpp
filter_needed), and a 16:9 picture between bars on a 16:10 screen (the Steam Deck's 1280x720 on 1280x800). There both
kernels weigh 1 at the pixel and 0 at every other, so each window pixel came to its own picture pixel, within the
filter's arithmetic. framegen_scale now has the pass read that pixel there, exactly: fg_scale.comp's new mode 3, one
texelFetch at the checked crop's corner plus the window pixel, kept in the crop as the filter's taps are. The pass, its
image, its alpha and what reads it after (the HDR pass, the output effects, the blit) stay as they were; beside an
ultrawide menu, black sides or blurred, whose soft edge mixes the filter's own result, the filter stays too. The upscale
log line now names the mode the pass ran and the filter chosen, both from one reading of the setting.

The stored code is the filter's own for 8-bit pictures up to 4K (the filter's error at 1:1 is under half a step there,
below). Where that error crossed a rounding point (an sRGB view's decoded values, Native HDR's 10 bits, and past 4K
8-bit ones too), it is now the pixel's own.

A developer's RX_VK_SHADER_DIR override of fg_scale built from an earlier tree reads mode 3 as its tent filter: build
the override from this tree's fg_scale.comp (vk_builtin_spv.h), as for any change to the pass's push constants.

tests: test_fg_scale_sharpen bounds, from the shader's own kernel() and tap range at eight window sizes, how far any
picture's pixel can move under the filter at 1:1 over both axes with uv 3 of its steps off (a GPU's division): at most
0.40 of an 8-bit step up to 4K (Lanczos, 3840x2160), and 0.75 at the largest output sizes the host accepts (negative
control: a blurring kernel, 191 steps). It also checks, in the code without its comments, that mode 3 is the pixel's
own, read with an integer address, kept in the crop and stored, nothing between its read and its store, with one main()
for the SDR and FG_SCALE_PQ builds, and pins what the bound assumes (each window pixel once, at its middle, each stored;
the crop's extent; the stretch) (negative controls: the shader without mode 3, with a sampled read, with its read not
kept in the crop, storing the filter instead, with an FG_SCALE_PQ-only change to the store or to the crop's corner, also
behind a comment, with a statement slipped in after mode 3's corner, with mode 3's corner changed and the old line
commented out, with the stretch scaled or the extent one less, and with the last row and column left out, by the edge's
test or by a new way out of main()). upscale_independent_test's filter cases move to a real upscale (3840x2160); new
cases: mode 3 at 1:1, with a crop of the window's size, for Native HDR, and at the checked crop's size, not the one
asked, each with its crop pushed, and with an output effect, which reads the pass's picture; the filter where only one
side matches, either way, and one pixel off on both, and beside either kind of menu side (Native HDR's picture too), and
shrinking, Native HDR's picture too; and the log line's text, arguments and one reading of the filter, the first
dispatch's whatever its mode, with no preprocessor line in framegen_scale, and mode 3's block word for word (its
condition, the filter's one reading and the pass's push constants), the mode set nowhere else (frame generation's made
frames, headless runs and shots call it too) and over the whole matrix of the SDR picture and Native HDR's, no sides or
either kind, both filters and 19 picture and window sizes (1:1 from 1281x719 to 7680x2160, 8192x1536 and 9400x1763,
uncropped, cropped, at odd offsets and past the edge; a pixel off; as many pixels in another shape; one side off;
larger; smaller; and every window within two pixels of the picture's size on either axis), mode 3 exactly at 1:1 with no
sides, at the checked crop's corner, the filter elsewhere (negative controls: main's framegen_scale, and variants that
ignore the sides, guard only the black ones, compare the crop asked, check one dimension, never read the pixel, push
mode 3 another crop, drop the effect at 1:1, take a wider window or one a pixel off for 1:1, compare Native HDR's whole
picture instead of its crop, allow Native HDR's black sides, stop at 4K or at 7680 wide, compare pixel counts or allow a
pixel's difference on one axis, add any other condition or set the mode again shrink with another kernel (also only for
Native HDR), read the filter again for the log line, log only with a filter or only in some builds, take mode 3 beside
Native HDR's blurred sides, or swap the log line's two modes or its two sizes, each fail).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
Author
Member

@Beanstalk windows and linux, PCs with a discrete GPU (NVIDIA, AMD and Intel, whichever are free), this PR's head and main: Window scaling filter Lanczos, Output resolution at the window's size (the filter row then reads "Not needed (window = output)"), uncapped (frame_rate_cap=6, vsync=2), RX_VK_UPSCALE_LOG=1, the Market for 3 minutes a side. Expect upscale dispatched: mode 3 (the filter 2) with the window's size as source and destination in this PR's log and mode 2 in main's, no crash or device loss, and no fps loss (a small gain where the GPU limits the frame rate).

@Beanstalk windows and linux, PCs with a discrete GPU (NVIDIA, AMD and Intel, whichever are free), this PR's head and main: Window scaling filter Lanczos, Output resolution at the window's size (the filter row then reads "Not needed (window = output)"), uncapped (frame_rate_cap=6, vsync=2), `RX_VK_UPSCALE_LOG=1`, the Market for 3 minutes a side. Expect `upscale dispatched: mode 3 (the filter 2)` with the window's size as source and destination in this PR's log and `mode 2` in main's, no crash or device loss, and no fps loss (a small gain where the GPU limits the frame rate).
Author
Member
@review
BeanBot left a comment

Recommendation: Approve. The new path substantially reduces the scaler’s GPU time in isolation, but an in-game gain has not been demonstrated. The affected desktop GPUs and the Steam Deck’s actual 16:10 presentation path still need testing. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

At a 1:1 picture size, the window filter fetches the corresponding source pixel instead of running the Catmull-Rom or Lanczos kernel. This saves work in the pass at the cost of an additional shader mode and implementation-specific test assertions.

Should fix (1): not blocking, but worth doing before merging.

  • L3 tests/test_upscale_independent.py:76: The new checks require the implementation and even its comment to match literal source text, despite the fixture already exercising the routing behavior. (more on the line) Do: Keep the behavioral matrix and log assertions, and replace the literal implementation checks with behavior-focused checks that allow equivalent code.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L1 gpu/vk/vk_framegen.cpp:1401: The measured pass saving has not yet produced a demonstrated player-facing gain. (more on the line) Do: Measure base and head in an in-game GPU-limited 1:1 scene with interleaved runs, reporting FPS, 1% lows and frame times.
  • L2 gpu/vk/shaders/fg_scale.comp:115: The new shader path still needs runs on the supported systems it affects. (more on the line) Do: Run the requested base-versus-head desktop GPU and Deck Game Mode checks, and compare Native HDR output on a supported HDR setup.

@fix can do L3.

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven in game. On the Steam Deck, the standalone pass measured 0.936 ms before and 0.104 ms after at 1280x720 with Lanczos; two counted in-game pairs had median FPS fall from 44.24 to 43.28, within the reported spread, with 1% lows of 25.9 and 24.9.

Other systems: The path also runs for Native HDR, output effects, frame-generated frames, headless output and captures. The routing tests cover several of these, but the GPU comparison covered 8-bit pictures on RADV only; Windows, discrete GPUs, Native HDR pixels and the Deck’s letterboxed Game Mode remain unverified.

Switches: No switches added, changed or removed. RX_VK_UPSCALE_LOG now reports both the dispatched mode and selected filter; its default is unchanged.

Reviewed: 185051fbde against f359e26213: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the PR template, the diff and commit message, the changed shader and test files, and the changed framegen function with its present caller and related references. Skimmed the rest of the large renderer files. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. No generated files or recorded runs were changed.; nothing run (a code review).

Checked and fine:

  • The checked crop dimensions select the fast path, and its origin is passed to the integer fetch.
  • Menu sides retain the existing filter path, including the blurred-side preliminary dispatch.
  • The commit records AI assistance, and the diff contains no generated shader headers or game-derived files.

Testing: Read-only review; no builds, tests or project scripts were run. The supplied CI checks are still running.

Overlaps and merge order: The PR reports #2542 as making the case more common and #2515 as touching vk_framegen.cpp; no merge order was established from the available offline evidence.


Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The new path substantially reduces the scaler’s GPU time in isolation, but an in-game gain has not been demonstrated. The affected desktop GPUs and the Steam Deck’s actual 16:10 presentation path still need testing. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. At a 1:1 picture size, the window filter fetches the corresponding source pixel instead of running the Catmull-Rom or Lanczos kernel. This saves work in the pass at the cost of an additional shader mode and implementation-specific test assertions. **Should fix (1)**: not blocking, but worth doing before merging. - **L3** `tests/test_upscale_independent.py:76`: The new checks require the implementation and even its comment to match literal source text, despite the fixture already exercising the routing behavior. (more on the line) **Do:** Keep the behavioral matrix and log assertions, and replace the literal implementation checks with behavior-focused checks that allow equivalent code. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L1** `gpu/vk/vk_framegen.cpp:1401`: The measured pass saving has not yet produced a demonstrated player-facing gain. (more on the line) **Do:** Measure base and head in an in-game GPU-limited 1:1 scene with interleaved runs, reporting FPS, 1% lows and frame times. - **L2** `gpu/vk/shaders/fg_scale.comp:115`: The new shader path still needs runs on the supported systems it affects. (more on the line) **Do:** Run the requested base-versus-head desktop GPU and Deck Game Mode checks, and compare Native HDR output on a supported HDR setup. `@fix` can do L3. **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven in game. On the Steam Deck, the standalone pass measured 0.936 ms before and 0.104 ms after at 1280x720 with Lanczos; two counted in-game pairs had median FPS fall from 44.24 to 43.28, within the reported spread, with 1% lows of 25.9 and 24.9. **Other systems:** The path also runs for Native HDR, output effects, frame-generated frames, headless output and captures. The routing tests cover several of these, but the GPU comparison covered 8-bit pictures on RADV only; Windows, discrete GPUs, Native HDR pixels and the Deck’s letterboxed Game Mode remain unverified. **Switches:** No switches added, changed or removed. RX_VK_UPSCALE_LOG now reports both the dispatched mode and selected filter; its default is unchanged. **Reviewed:** 185051fbde60 against f359e2621315: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the PR template, the diff and commit message, the changed shader and test files, and the changed framegen function with its present caller and related references. Skimmed the rest of the large renderer files. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. No generated files or recorded runs were changed.; nothing run (a code review). **Checked and fine:** - The checked crop dimensions select the fast path, and its origin is passed to the integer fetch. - Menu sides retain the existing filter path, including the blurred-side preliminary dispatch. - The commit records AI assistance, and the diff contains no generated shader headers or game-derived files. **Testing:** Read-only review; no builds, tests or project scripts were run. The supplied CI checks are still running. **Overlaps and merge order:** The PR reports #2542 as making the case more common and #2515 as touching vk_framegen.cpp; no merge order was established from the available offline evidence. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.</sub>
@ -112,0 +112,4 @@
// Catmull-Rom's and Lanczos' 16 taps come to there (tests/test_fg_scale_sharpen.py); kept in the crop as their taps
// are, whatever size dst has)
const ivec2 own = ivec2(pc.crop_x, pc.crop_y);
vec3 c = pc.mode == 3 ? texelFetch(src, clamp(own + g, own, own + ivec2(pc.crop_w, pc.crop_h) - 1), 0).rgb : filtered(uv);
Member

L2 (should fix): The new shader path still needs runs on the supported systems it affects.

When: The pixel comparison used 8-bit inputs on the Deck’s RADV GPU, while desktop Windows and Linux drivers, Native HDR’s 10-bit path, and the Deck’s 1280x800 letterboxed presentation also execute this fetch.

Do: Run the requested base-versus-head desktop GPU and Deck Game Mode checks, and compare Native HDR output on a supported HDR setup.

**L2** (should fix): The new shader path still needs runs on the supported systems it affects. *When:* The pixel comparison used 8-bit inputs on the Deck’s RADV GPU, while desktop Windows and Linux drivers, Native HDR’s 10-bit path, and the Deck’s 1280x800 letterboxed presentation also execute this fetch. **Do:** Run the requested base-versus-head desktop GPU and Deck Game Mode checks, and compare Native HDR output on a supported HDR setup.
@ -1397,0 +1398,4 @@
// are 0 at every other pixel there, so their 16 taps and weights a pixel came to the picture's own pixel, within less
// than half an 8-bit step (tests/test_fg_scale_sharpen.py): the pass reads that pixel instead, exactly (fg_scale.comp's
// mode 3, one texelFetch). Not beside an ultrawide menu, either side: its soft edge mixes the filter's own result)
const bool one_to_one = source.w == dw && source.h == dh && !wide.side;
Member

L1 (should fix): The measured pass saving has not yet produced a demonstrated player-facing gain.

When: The only in-game comparison was CPU-bound and its two counted pairs overlap in spread; the isolated dispatch does not establish the effect on frame pacing or FPS when this pass is on the critical path.

Do: Measure base and head in an in-game GPU-limited 1:1 scene with interleaved runs, reporting FPS, 1% lows and frame times.

**L1** (should fix): The measured pass saving has not yet produced a demonstrated player-facing gain. *When:* The only in-game comparison was CPU-bound and its two counted pairs overlap in spread; the isolated dispatch does not establish the effect on frame pacing or FPS when this pass is on the critical path. **Do:** Measure base and head in an in-game GPU-limited 1:1 scene with interleaved runs, reporting FPS, 1% lows and frame times.
@ -67,0 +73,4 @@
"framegen_scale: a preprocessor line in it: the fixture checks one build only"
# (mode 3's condition, word for word: the fixture's matrix checks what it does with the sizes and sides, and nothing
# else may decide it, frame generation's made frames, headless runs and shots included, all of which call this)
assert '''
Member

L3 (should fix): The new checks require the implementation and even its comment to match literal source text, despite the fixture already exercising the routing behavior.

When: Renaming the local filter variable or rewording its comment without changing any dispatch makes this test fail; the shader test similarly requires the exact spelling of its final statements.

Do: Keep the behavioral matrix and log assertions, and replace the literal implementation checks with behavior-focused checks that allow equivalent code.

**L3** (should fix): The new checks require the implementation and even its comment to match literal source text, despite the fixture already exercising the routing behavior. *When:* Renaming the local filter variable or rewording its comment without changing any dispatch makes this test fail; the shader test similarly requires the exact spelling of its final statements. **Do:** Keep the behavioral matrix and log assertions, and replace the literal implementation checks with behavior-focused checks that allow equivalent code.
test(vk): check mode 3 by what it does, not by its spelling
Some checks reported errors
CI / What the change needs (pull_request) Successful in 8s
CI / Third-party parts and guide screenshots (pull_request) Successful in 12s
beanstalk/approval approved by klimovich008 (reviewed)
beanstalk/windows+nvidia+dgpu 0/1 pass, 2 error
beanstalk/linux+nvidia+dgpu 0/1 pass, 0 running, 0 queued
beanstalk/windows+amd+dgpu 0/1 pass, 2 error
beanstalk/linux+amd+dgpu 0/1 pass, 1 error
beanstalk/windows+intel+dgpu 0/1 pass, 0 running, 0 queued
beanstalk/linux+intel+dgpu 0/1 pass, 0 running, 0 queued
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 18s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m26s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 13m25s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 10m18s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 12m44s
CI / Website build and checks (pull_request) Failing after 41s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 48m46s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 1h0m6s
PR description / Title and description (pull_request_target) Failing after 7s
e086045f00
The review of #3217 (L3) found that the checks of mode 3 asked for the code's own words: framegen_scale's lines and their
comment, and the last statements of fg_scale.comp's main(). Renaming a variable or rewording a comment failed them,
though nothing the pass does had changed. Both now check what the code does:

- tests/upscale_independent_test.cpp: the matrix and the grid of window sizes run in three states, as played, with frame
  generation on (its made frames go through the pass too) and headless, with menu sides a fourth of the window, 21:9's
  0.119 and a sliver (under 3 pixels in a 648x360 window), and still expect mode 3 exactly at the checked crop's own
  size with no sides, the pass over the whole window into an image of the window's size each time; with the filter Off
  too (beside sides the plain filter, never mode 3); and one call after another with the window resized on one axis,
  then the other (each pass into an image of its own window's size). The upscale log's line, a process's first
  dispatch's only, is checked for a table of first calls (UPSCALE_FIRST): each filter (Off, Catmull-Rom, Lanczos),
  menu sides none, blurred or black, and a picture of the window's size, the same cropped, larger and smaller, for the
  SDR picture and Native HDR's (UPSCALE_PQ): a pass where the window needs one, and the line naming the very mode
  dispatched and the filter chosen. The menu's filter can change while the scaler reads it (UPSCALE_FLIP: at each
  reading, or once after the first, second or third reading, then held): the mode dispatched and the filter the line
  names must be one reading's. A copy of the filter is one reading, held, as an int's is, and the log stub takes it as
  logf would. The literal pins in test_upscale_independent.py are gone; the no-preprocessor-line check stays.
- tests/test_fg_scale_sharpen.py: fg_scale.comp as it is, both builds (FG_SCALE_PQ taken by C++'s preprocessor, VULKAN
  defined as glslang -V does), compiled as C++ with its floating-point literals floats, and run over every invocation of
  a dispatch as framegen_scale makes it: its push constants' bytes copied in (the shader's block must match the host's
  layout), its (w + 7) / 8 groups of the shader's own local size (in any order, as expressions); min and max of
  integer vectors as GLSL has them. On pictures of random codes of the build's steps (the whole picture, cropped at an
  odd corner and size, cropped past padding, a small one): at the window's own size mode 3 stores every pixel once,
  opaque (the picture's own alpha is not 1), its picture pixel's value exactly, from one texelFetch and no sampled
  read; in a window 9 by 5 pixels larger or smaller, either axis or both, every read stays in the crop, fetched or
  sampled (each texel a sampled read weighs from 1/512); nothing GLSL leaves undefined happens (a clamp's bounds
  crossed, a fetch or size query of another level, a fetch outside the picture); Catmull-Rom, Lanczos and the plain
  filter (Off's, beside menu sides) at 1:1 come to the same codes, their reads in the crop (8-bit with vec2's
  divisions up to 3 steps off, a GPU's). main's filtered() check is back as it was; the source pins are gone.

Negative controls, each fails as named:
- framegen_scale: one_to_one also asking !framegen_on() (matrix, frame generation state) or !dev.offscreen (headless
  state); mode 3 beside menu sides narrower than 0.125 (the 0.119 sides); a line before the push constants forcing the
  filter while frame generation is on or headless; the mode set again after them while frame generation is on; pc.mode
  taking opts.upscale again instead of the one reading, or the log line doing so ("dispatched mode 2, logged: mode 2
  (the filter 1)"), or logging `opts.upscale ? opts.upscale : filter` (the once-after-the-second sequence); the log's
  mode `pq ? filter : pc.mode` (Native HDR's first 1:1 line), or recomputed from the picture's whole size (the cropped
  first line), or from the sizes alone beside menu sides, or 0 when shrinking, or 3 for the filter Off
  (`one_to_one || filter == 0 ? 3 : filter`); the window's width within one pixel (the grid); mode 3 beside sides under 5 pixels (`wide.x0 * dw < 5.0f`, the 648x360 window), or beside blurred sides
  with the filter Off; the last pass at 1:1 over dh & ~7 rows, or the scaled image made dh & ~7 rows high, or kept
  when only one axis of the window changed. main's vk_framegen.cpp fails at the first mode-3 check. A renamed
  `filter`, `const auto filter` and a reworded comment pass.
- fg_scale.comp: main's shader (16 reads a pixel, 102,371 of 921,600 pixels not bit-exact); mode 3 reading the next
  pixel over; a sampled read (textureLod) instead of texelFetch; outside = clamp(outside + dither(g), 0, 1) before the
  read (460,647 pixels off); no clamp to the crop (6,426 reads outside it in a larger window); the clamp's low bound
  own + g (6,426 undefined clamps); level 1 fetched; the address clamped to textureSize(src, 1); a sampled fallback
  for mode 3 at another size (2,729,465 texels outside the crop), or only where both axes are larger; mode 3 storing the
  fetched vec4 (the picture's alpha); local_size_x = 8 / 2; the plain filter's 1:1 read without crop_uv (889,649
  texels outside the crop); crop_x and crop_y swapped in the push block; local_size_x 4 (460,800 pixels never
  stored); int(float(g.x) + 0.99999999) (a float literal's rounding); alpha 0 for mode 3; mode 3 black under
  #ifdef VULKAN; an FG_SCALE_PQ-only change after the read; an early return for one column; two reads averaged. Mode 3
  as an if/else with its corner renamed and its comment reworded, vec4(c.r, c.g, c.b, 1.0), ivec2(1), .xyz,
  `void main ()`, the local size's y first, local_size_x = 4 * 2 or (4 * 2), own + min(g, size - 1) for the clamp,
  the address clamped in the crop and then `address += own`, and the fetched vec4 kept with its .w set to 1 pass.

Assisted-by: gpt-6.2-sol (second-opinion review)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
Author
Member

Pushed e086045f (tests only; the renderer change is 185051fb, unchanged). The description now has the Deck's in-game 1080p and 1440p runs, the suite result, and every Measurements column named by its commit.

Answers to the review (BeanBot, 185051fb):

L3 (literal checks): done in e086045f. Both tests now check what the code does, and allow equivalent code:

  • test_upscale_independent: no source pins left (only the existing no-preprocessor-line check). The fixture runs framegen_scale over the window sizes and crops as played, with frame generation on and headless, beside menu sides of three widths, with the filter Off too and as the window is resized, and checks the whole window is dispatched into an image of its size. For a table of first calls (each filter, each kind of side, a picture of the window's size, cropped, larger, smaller) the log line must name the very mode dispatched and the filter chosen. It also runs with a filter the menu changes while the scaler reads it (at each reading, or once after the first, second or third), for the SDR picture and Native HDR's: the log line must name the mode and filter that were dispatched. Renaming filter, const auto filter, or a reworded comment pass.
  • test_fg_scale_sharpen: the tail pin is gone. The test compiles fg_scale.comp itself (both builds) as C++ and runs every invocation of a dispatch as framegen_scale makes it (its push-constant bytes, its group count, the shader's local size). Mode 3 must store every pixel once, opaque, as the picture pixel's exact value, from one read. At any other window size every read must stay in the crop, and nothing GLSL leaves undefined may happen. Catmull-Rom, Lanczos and the Off filter's plain pass at 1:1 must give the same codes. An if/else form, renamed locals, vec4(c.r, c.g, c.b, 1.0), .xyz or void main () pass.
  • The commit message lists 41 negative controls, each failing as expected, and 14 equivalent rewrites that pass. They include main's code, a dither added before the read, a crop-order swap in the push block, a local-size change and a sampled fallback.

L1 (an in-game GPU-limited 1:1 measurement): measured on the Steam Deck, no fps change. At 1920x1080 and 2560x1440 (window, output and picture all that size, Lanczos, 15 W), the GPU's own work is 28 and 43 ms of 37 and 53 ms frames. fps, frame times and 1 % lows match: 26.97–27.40 vs 26.76–27.29 fps at 1080p. But the GPU is less busy: 74 % instead of 90 % at 1080p, and the APU draws 15.1 W instead of 15.7 W (Measurements, every run listed).

  • Why fps doesn't move: on the Deck's thread shape the frame is about 10 ms longer than the GPU's work at every size (720p, 1080p, 1440p), and the window pass runs in that wait.
  • Where a gain should show: a GPU busy for the whole frame (desktop GPU limits). That is in Still to test, and I've asked the farm for it below.
  • Counting: the Deck's harness counted only one run, because it refuses windows with swap-ins and at these sizes the game re-reads pages swapped out during loading. The recorded runs all agree.

L2: desktop discrete GPUs via the farm (requested below). The Deck in Game Mode at 1280x800 and Native HDR on an HDR screen are by-hand checks in Still to test.

🤖 Generated with Claude Code

https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg

Pushed e086045f (tests only; the renderer change is 185051fb, unchanged). The description now has the Deck's in-game 1080p and 1440p runs, the suite result, and every Measurements column named by its commit. Answers to the review (BeanBot, 185051fb): **L3 (literal checks): done in e086045f.** Both tests now check what the code does, and allow equivalent code: - `test_upscale_independent`: no source pins left (only the existing no-preprocessor-line check). The fixture runs `framegen_scale` over the window sizes and crops as played, with frame generation on and headless, beside menu sides of three widths, with the filter Off too and as the window is resized, and checks the whole window is dispatched into an image of its size. For a table of first calls (each filter, each kind of side, a picture of the window's size, cropped, larger, smaller) the log line must name the very mode dispatched and the filter chosen. It also runs with a filter the menu changes while the scaler reads it (at each reading, or once after the first, second or third), for the SDR picture and Native HDR's: the log line must name the mode and filter that were dispatched. Renaming `filter`, `const auto filter`, or a reworded comment pass. - `test_fg_scale_sharpen`: the tail pin is gone. The test compiles `fg_scale.comp` itself (both builds) as C++ and runs every invocation of a dispatch as `framegen_scale` makes it (its push-constant bytes, its group count, the shader's local size). Mode 3 must store every pixel once, opaque, as the picture pixel's exact value, from one read. At any other window size every read must stay in the crop, and nothing GLSL leaves undefined may happen. Catmull-Rom, Lanczos and the Off filter's plain pass at 1:1 must give the same codes. An if/else form, renamed locals, `vec4(c.r, c.g, c.b, 1.0)`, `.xyz` or `void main ()` pass. - The commit message lists 41 negative controls, each failing as expected, and 14 equivalent rewrites that pass. They include main's code, a dither added before the read, a crop-order swap in the push block, a local-size change and a sampled fallback. **L1 (an in-game GPU-limited 1:1 measurement): measured on the Steam Deck, no fps change.** At 1920x1080 and 2560x1440 (window, output and picture all that size, Lanczos, 15 W), the GPU's own work is 28 and 43 ms of 37 and 53 ms frames. fps, frame times and 1 % lows match: 26.97–27.40 vs 26.76–27.29 fps at 1080p. But the GPU is less busy: 74 % instead of 90 % at 1080p, and the APU draws 15.1 W instead of 15.7 W (Measurements, every run listed). - **Why fps doesn't move:** on the Deck's thread shape the frame is about 10 ms longer than the GPU's work at every size (720p, 1080p, 1440p), and the window pass runs in that wait. - **Where a gain should show:** a GPU busy for the whole frame (desktop GPU limits). That is in Still to test, and I've asked the farm for it below. - **Counting:** the Deck's harness counted only one run, because it refuses windows with swap-ins and at these sizes the game re-reads pages swapped out during loading. The recorded runs all agree. **L2:** desktop discrete GPUs via the farm (requested below). The Deck in Game Mode at 1280x800 and Native HDR on an HDR screen are by-hand checks in Still to test. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
Author
Member

@Beanstalk windows and linux, PCs with a discrete GPU (NVIDIA, AMD and Intel, whichever are free), this PR's head and main, at the farm's own 1920x1080 headless output with Render resolution 100 %, so the picture is the output's size (1:1): Window scaling filter Lanczos (LONGSHOT_SET=system/graphics:upscaling=2,system/graphics:resolution=1), uncapped (frame_rate_cap = 6, vsync = 2, frame_generation = 0), RX_VK_UPSCALE_LOG=1, the Market, three starts a side. Expect upscale dispatched: mode 3 (the filter 2) in this PR's log (main logs mode 2); the same pictures; frame times and GPU time the same or better within the noise; no crash or device loss. One-start metrics (run_hitch_count, run_frametime_max_ms) report-only.

@Beanstalk windows and linux, PCs with a discrete GPU (NVIDIA, AMD and Intel, whichever are free), this PR's head and main, at the farm's own 1920x1080 headless output with Render resolution 100 %, so the picture is the output's size (1:1): Window scaling filter Lanczos (`LONGSHOT_SET=system/graphics:upscaling=2,system/graphics:resolution=1`), uncapped (`frame_rate_cap = 6`, `vsync = 2`, `frame_generation = 0`), `RX_VK_UPSCALE_LOG=1`, the Market, three starts a side. Expect `upscale dispatched: mode 3 (the filter 2)` in this PR's log (main logs `mode 2`); the same pictures; frame times and GPU time the same or better within the noise; no crash or device loss. One-start metrics (`run_hitch_count`, `run_frametime_max_ms`) report-only.
Member

Beanstalk test farm · 🔄 testing (0 of 6 reports so far)

Commit e086045 · approved by klimovich008 (reviewed) · dashboard

⚠️ Note: The expected log rule judges the PR only; main's mode-2 log is recorded but cannot be required by that rule.
⚠️ Note: GPU total time is measured rather than the scaler pass alone, and a CPU-limited run may hide an in-game frame-time gain.
⚠️ Note: The Deck's letterboxed Game Mode presentation and Native HDR output are not covered by this headless desktop plan.

Done (started 03:58 UTC). Comment @Beanstalk to run it again.

Target Result Reports Frame time p99 (ms), main → PR VRAM peak (MB) Crashes
windows+nvidia+dgpu ⚠️ couldn't be judged 0 of 1 — — —
linux+nvidia+dgpu ⏳ queued 0 of 1 — — —
windows+amd+dgpu ⚠️ couldn't be judged 0 of 1 — — —
linux+amd+dgpu ⚠️ couldn't be judged 0 of 1 — — —
windows+intel+dgpu ⏳ queued 0 of 1 — — —
linux+intel+dgpu ⏳ queued 0 of 1 — — —
What was tested

What will be tested · AI plan (gpt-6.1-terra)

The plan compares the PR with main in the Market at 1920x1080 headless output, using Lanczos at 1:1 and uncapped rendering. Three starts per side measure 30 seconds of frame and GPU time and compare a stationary picture on Windows and Linux discrete GPUs from NVIDIA, AMD and Intel. A missing PR mode-3 dispatch log, crash, device loss, material picture difference, or frame-time or GPU-time regression beyond the allowed noise fails the test. Targets without a matching online discrete GPU will wait for a volunteer. No tester online now matches windows+intel+dgpu, linux+intel+dgpu: those targets wait for one.

  • Where: windows+nvidia+dgpu (1-2 reports), linux+nvidia+dgpu (1-2 reports), windows+amd+dgpu (1-2 reports), linux+amd+dgpu (1-2 reports), windows+intel+dgpu (1-2 reports), linux+intel+dgpu (1-2 reports).
  • market-lanczos: from the repository's save market-entrance (settings vsync=2, upscaling=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0; switches HOS_OUTPUT_RES=1920x1080, RX_VK_AUTO_TUNE=0), then teleport to Market, take the picture market to compare with main, measure market for 30 s (after 10 s warm-up); 3 runs on each side.
  • Measured: crashes, frame times, stutters and hitches, GPU time per pass, the game's log.
  • The PR fails if: it crashes; or a picture differs from main by more than 20%; or GPU time a frame is more than 15% above main; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0; or expected log lines missing is above 0; or frame time (worst 1%) is more than 15% above main.
  • Time: about 35 min of game runs per tester (6 game starts), plus the two builds.
<!-- beanstalk:sticky --> ### Beanstalk test farm · 🔄 testing (0 of 6 reports so far) Commit `e086045` · approved by klimovich008 (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/3217) ⚠️ **Note:** The expected log rule judges the PR only; main's mode-2 log is recorded but cannot be required by that rule. ⚠️ **Note:** GPU total time is measured rather than the scaler pass alone, and a CPU-limited run may hide an in-game frame-time gain. ⚠️ **Note:** The Deck's letterboxed Game Mode presentation and Native HDR output are not covered by this headless desktop plan. Done (started 03:58 UTC). Comment `@Beanstalk` to run it again. | Target | Result | Reports | Frame time p99 (ms), main → PR | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | --- | | `windows+nvidia+dgpu` | ⚠️ couldn't be judged | 0 of 1 | — | — | — | | `linux+nvidia+dgpu` | ⏳ queued | 0 of 1 | — | — | — | | `windows+amd+dgpu` | ⚠️ couldn't be judged | 0 of 1 | — | — | — | | `linux+amd+dgpu` | ⚠️ couldn't be judged | 0 of 1 | — | — | — | | `windows+intel+dgpu` | ⏳ queued | 0 of 1 | — | — | — | | `linux+intel+dgpu` | ⏳ queued | 0 of 1 | — | — | — | <details><summary>What was tested</summary> **What will be tested** · AI plan (`gpt-6.1-terra`) The plan compares the PR with main in the Market at 1920x1080 headless output, using Lanczos at 1:1 and uncapped rendering. Three starts per side measure 30 seconds of frame and GPU time and compare a stationary picture on Windows and Linux discrete GPUs from NVIDIA, AMD and Intel. A missing PR mode-3 dispatch log, crash, device loss, material picture difference, or frame-time or GPU-time regression beyond the allowed noise fails the test. Targets without a matching online discrete GPU will wait for a volunteer. No tester online now matches windows+intel+dgpu, linux+intel+dgpu: those targets wait for one. - **Where:** windows+nvidia+dgpu (1-2 reports), linux+nvidia+dgpu (1-2 reports), windows+amd+dgpu (1-2 reports), linux+amd+dgpu (1-2 reports), windows+intel+dgpu (1-2 reports), linux+intel+dgpu (1-2 reports). - **market-lanczos:** from the repository's save `market-entrance` (settings vsync=2, upscaling=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0; switches `HOS_OUTPUT_RES=1920x1080`, `RX_VK_AUTO_TUNE=0`), then teleport to Market, take the picture market to compare with main, measure market for 30 s (after 10 s warm-up); 3 runs on each side. - **Measured:** crashes, frame times, stutters and hitches, GPU time per pass, the game's log. - **The PR fails if:** it crashes; or a picture differs from main by more than 20%; or GPU time a frame is more than 15% above main; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0; or expected log lines missing is above 0; or frame time (worst 1%) is more than 15% above main. - **Time:** about 35 min of game runs per tester (6 game starts), plus the two builds. </details>
Author
Member

In-game run on Windows: mode 3 is the path taken at 1:1, and the frame rate and GPU time are level on this PC.

This head (e086045f0) as a pack over main f359e2621, its merge base (the DLL only).

Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2. Market center (child, a save at the fountain, loaded directly), the right stick held right from the load, a 1280x720 window with Output resolution 1280x720 and the Window scaling filter on Lanczos (the 1:1 case this PR changes), uncapped (HOS_FPS_MAX=240), render thread on, 3 alternating pairs, all 6 runs admitted, game clock 1.000.

Market center, 1:1 Lanczos, 3 pairs main f359e2621 this PR
fps, median 96.09 96.29
CPU ms a frame, median 54.70 53.95
GPU ms a frame, median 3.9 3.8
p99 frame time, ms 14.05 14.24
worst frame, ms (max of 3) 30.2 27.5
frames over 100 ms 0 0
  • All three PR runs logged vk: upscale dispatched: mode 3 (the filter 2), source 1280x720, crop request 0,0 1280x720, destination 1280x720 (RX_VK_UPSCALE_LOG=1).
  • By pair, fps: −4.3 %, +0.2 %, +0.7 %. The PR's first run was on a freshly made runtime and was the slow one (p99 18.1 ms); the other two are level.
  • At 1280x720 the pass is too small on this GPU for the harness's 0.1 ms GPU time to show a difference, here or in an earlier still-camera round (3.8 against 3.8 ms). The savings in Measurements are from the Steam Deck and at 3840x2160.

Note for anyone measuring on main since #2822: Mouse camera now defaults to Native, and with HOS_INPUT_EXCLUSIVE=1 read_input (host/nn_hid.c) returns before hos_mouse_native_stick(), so a scripted right stick turns nothing. These runs set HOS_MOUSE_NATIVE=0.

🤖 Generated with Claude Code

**In-game run on Windows: mode 3 is the path taken at 1:1, and the frame rate and GPU time are level on this PC.** This head (e086045f0) as a pack over main f359e2621, its merge base (the DLL only). Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2. Market center (child, a save at the fountain, loaded directly), the right stick held right from the load, a 1280x720 window with Output resolution 1280x720 and the Window scaling filter on Lanczos (the 1:1 case this PR changes), uncapped (HOS_FPS_MAX=240), render thread on, 3 alternating pairs, all 6 runs admitted, game clock 1.000. | Market center, 1:1 Lanczos, 3 pairs | main f359e2621 | this PR | |---|---|---| | fps, median | 96.09 | 96.29 | | CPU ms a frame, median | 54.70 | 53.95 | | GPU ms a frame, median | 3.9 | 3.8 | | p99 frame time, ms | 14.05 | 14.24 | | worst frame, ms (max of 3) | 30.2 | 27.5 | | frames over 100 ms | 0 | 0 | - All three PR runs logged `vk: upscale dispatched: mode 3 (the filter 2), source 1280x720, crop request 0,0 1280x720, destination 1280x720` (`RX_VK_UPSCALE_LOG=1`). - By pair, fps: −4.3 %, +0.2 %, +0.7 %. The PR's first run was on a freshly made runtime and was the slow one (p99 18.1 ms); the other two are level. - At 1280x720 the pass is too small on this GPU for the harness's 0.1 ms GPU time to show a difference, here or in an earlier still-camera round (3.8 against 3.8 ms). The savings in Measurements are from the Steam Deck and at 3840x2160. Note for anyone measuring on main since #2822: Mouse camera now defaults to Native, and with `HOS_INPUT_EXCLUSIVE=1` `read_input` (`host/nn_hid.c`) returns before `hos_mouse_native_stick()`, so a scripted right stick turns nothing. These runs set `HOS_MOUSE_NATIVE=0`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
HumanBean changed title from WIP: perf(vk): read the picture's own pixel for the window filter at the window's own size to perf(vk): read the picture's own pixel for the window filter at the window's own size 2026-12-05 17:36:53 +00:00
HumanBean deleted branch perf/filter-1to1 2026-12-05 17:36:59 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!3217
No description provided.