The interface

Like gpu/vk/fsr2/fsr2.h, the interface knows nothing of the renderer, the settings or the log. The caller gives the device, the images in the layouts said and the command buffer, and each backend records plain vkCmd* calls into it. What can't run comes back as a reason in words, which the caller logs. It is the library snx_upscaler, which tests/vk_hook_upscale.c links without the renderer.

Capabilities

Each backend has a SnxUpscalerCaps (snx_upscaler_caps):

FieldSays
kindtemporal (it keeps a history), spatial (one frame) or the copy
needsthe inputs it can't run without: depth, motion vectors
takesthe inputs it uses when given: jitter, exposure, a reactive mask
rangethe color it takes: display-referred (LDR), linear and unbounded (HDR), or both
scale_min, scale_maxthe output's size over the render size, on each axis
sharpenswhether the sharpness does something
filteredwhether it samples the color with a linear filter, so that the color's format must filter (every backend stores its output, whose format must be one the device stores)

snx_upscaler_available says whether a backend is built in and the device can run it, and why not.

The choice and the fallback rule

snx_upscaler_choose takes the preferred backend, the device and what the call has (SnxUpscaleNeeds: the inputs given, the kinds the caller takes, the color's range, both sizes, and the color's and the output's formats). It tries the preferred one, then Best's order: DLSS, newer FSR, XeSS, FSR 2, the spatial upscaler, the copy. The first that passes every test runs:

  1. the caller takes its kind
  2. it is available
  3. the call gives every input it needs
  4. it takes the color's range
  5. the device stores the output's format, and filters the color's where the backend filters the color (the copy and the spatial upscaler sample it with a linear filter)
  6. both scales are within its range

When the preferred one is passed over, the reason comes back with the one that stands in, for the log. When none passes, the call gets no backend and the reason of the first one it would take that is built in, and runs its own fallback. So a DLSS evaluation with render_upscaler set to the spatial upscaler still gets FSR 2: it takes temporal upscalers only. A module that gives no motion vectors gets the spatial upscaler under Best, when it takes one, and the filtered copy when it doesn't, unless it gives depth and a reprojection matrix (hook ABI 1.2, Hooks): then gpu/vk/upscaler/reproject.c makes the camera's motion vectors from the depth before the upscaler runs, and a temporal one takes the frame.

Contexts and evaluations

snx_upscaler_create makes a context of one backend for the largest render size it will be given, the output size, the color's and the output's formats and the conventions (SNX_UP_FLAG_*, the bits of fsr2.h: HDR color, motion vectors at the output's size, motion vectors that include the jitter, inverted depth, the backend's own exposure). snx_upscaler_evaluate records one evaluation (SnxUpscaleEval):

A context goes round its descriptors over SNX_UPSCALER_IN_FLIGHT (4) evaluations whose commands haven't finished. snx_upscaler_destroy needs the device done with them.


Made from docs/layers/gpu/upscalers.md at 69237645142c. GPL-3.0-or-later.