Skip to content

upscale/gpu: FSR 1.0 on the GPU (Metal, Vulkan) as a nested module - #151

Merged
tannevaled merged 1 commit into
mainfrom
upscale-gpu-land
Nov 29, 2026
Merged

tannevaled merged 1 commit into
mainfrom
upscale-gpu-land

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Adds upscale/gpu, a nested module (github.com/go-avkit/avkit/upscale/gpu, requires avkit v0.25.0) that runs FSR 1.0 EASU+RCAS on the GPU: Metal via go-macos/metal, Vulkan via go-gfx/vulkan with SPIR-V from go-gfx/wgsl. API: gpu.Open(), (*Scaler).Upscale(dst, src), Close(); ErrUnsupported when no device. Sources with alpha are refused (ErrAlpha). Limits and options are those of upscale.Scaler.

Refs #141

Accuracy against fsrref.Upscale (noise, edges, gradient, black, white; sharpness -1, 0, 0.2, 1.5; 662520 samples; float result before quantisation; bound upscale.ErrorBound = 2e-4):

  • Metal, Apple M4 Max: max error 5.69e-06, 0 samples outside.
  • Vulkan, RADV NAVI32 (Radeon PRO W7700): max error 5.69e-06, 0 samples outside.
  • TestPhaseTies (saturated diagonal edge on the odd:odd sizes, plus 640x8 to 1920x24): 0 outside on both, worst 4.2e-07.

Two things GPUs do not do exactly are taken out of the shader: the source position comes from per-column/row tables built from fsrref.Phase, and u8/255 from a host float32(i)/255 table (GPU division is not correctly rounded; it gave errors up to 0.04 on near-equal lumas).

Timing (BenchmarkGPU720to1080, 1280x720 YCbCr 4:2:0 to 1920x1080 RGBA, sharpness 0.2), fractal, Ryzen 7950X, RADV NAVI32, taskset -c 9, load about 1.4: 5.77 to 5.87 ms per frame with upload and readback; dispatch alone about 2.0 ms. Mac timings were deferred: the 1-minute load was 50 to 90. No player comparison and no AMD sample comparison was made.

Tests and CI: device tests skip visibly with no GPU and fail when AVKIT_GPU_REQUIRE=1 and none is found. The Vulkan sequencing runs against a fake device (failure at every step, nothing left allocated). mutsweep: 23 of 23 caught. New CI job gpu (gofmt, build, vet, test; ubuntu and macOS).

A module of its own, github.com/go-avkit/avkit/upscale/gpu, requiring avkit
v0.25.0: EASU+RCAS on Metal (go-macos/metal) and Vulkan (go-gfx/vulkan, SPIR-V
from go-gfx/wgsl), held to upscale.ErrorBound of fsrref. Source positions come
from fsrref.Phase tables and 8-bit values from a float32(i)/255 table, because
GPU float arithmetic is not exact there. CI job gpu.

Refs #141

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit f1890a8 into main Nov 29, 2026
24 checks passed
@tannevaled
tannevaled deleted the upscale-gpu-land branch November 29, 2026 18:44
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