Skip to content

FidelityFX FSR2

Navigation: SDKEffect Components

FidelityFX FSR2

FidelityFX Super Resolution 2 runtime library.

Defines

FFX_FSR2_VERSION_MAJOR

#define FFX_FSR2_VERSION_MAJOR (2)

FidelityFX Super Resolution 2 major version.

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 36, column 9)

FFX_FSR2_VERSION_MINOR

#define FFX_FSR2_VERSION_MINOR (3)

FidelityFX Super Resolution 2 minor version.

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 41, column 9)

FFX_FSR2_VERSION_PATCH

#define FFX_FSR2_VERSION_PATCH (3)

FidelityFX Super Resolution 2 patch version.

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 46, column 9)

FFX_FSR2_CONTEXT_COUNT

#define FFX_FSR2_CONTEXT_COUNT 1

FidelityFX Super Resolution 2 context count.

Defines the number of internal effect contexts required by FSR2

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 53, column 9)

FFX_FSR2_CONTEXT_SIZE

#define FFX_FSR2_CONTEXT_SIZE (FFX_SDK_DEFAULT_CONTEXT_SIZE)

The size of the context specified in 32bit values.

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 58, column 9)

Functions

ffxFsr2ContextCreate

FFX_API FfxErrorCode ffxFsr2ContextCreate(FfxFsr2Context *pContext, const FfxFsr2ContextDescription *pContextDescription)

Create a FidelityFX Super Resolution 2 context from the parameters programmed to the FfxFsr2CreateParams structure.

The context structure is the main object used to interact with the FSR2 API, and is responsible for the management of the internal resources used by the FSR2 algorithm. When this API is called, multiple calls will be made via the pointers contained in the callbacks structure. These callbacks will attempt to retreive the device capabilities, and create the internal resources, and pipelines required by FSR2’s frame-to-frame function. Depending on the precise configuration used when creating the FfxFsr2Context a different set of resources and pipelines might be requested via the callback functions.

The flags included in the flags field of FfxFsr2Context how match the configuration of your application as well as the intended use of FSR2. It is important that these flags are set correctly (as well as a correct programmed FfxFsr2DispatchDescription) to ensure correct operation. It is recommended to consult the overview documentation for further details on how FSR2 should be integerated into an application.

When the FfxFsr2Context is created, you should use the ffxFsr2ContextDispatch function each frame where FSR2 upscaling should be applied. See the documentation of ffxFsr2ContextDispatch for more details.

The FfxFsr2Context should be destroyed when use of it is completed, typically when an application is unloaded or FSR2 upscaling is disabled by a user. To destroy the FSR2 context you should call ffxFsr2ContextDestroy.

Parameters:

  • pContext (FfxFsr2Context *) – [out] A pointer to a FfxFsr2Context structure to populate.
  • pContextDescription (const FfxFsr2ContextDescription *) – [in] A pointer to a FfxFsr2ContextDescription structure.

Returns: FFX_API FfxErrorCode

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 284, column 22)

ffxFsr2ContextGetGpuMemoryUsage

FFX_API FfxErrorCode ffxFsr2ContextGetGpuMemoryUsage(FfxFsr2Context *pContext, FfxEffectMemoryUsage *pVramUsage)

Get GPU memory usage of the FidelityFX Super Resolution context.

Parameters:

  • pContext (FfxFsr2Context *) – [in] A pointer to a FfxFsr2Context structure.
  • pVramUsage (FfxEffectMemoryUsage *) – [out] A pointer to a FfxEffectMemoryUsage structure.

Returns: FFX_API FfxErrorCode

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 297, column 22)

ffxFsr2ContextDispatch

FFX_API FfxErrorCode ffxFsr2ContextDispatch(FfxFsr2Context *pContext, const FfxFsr2DispatchDescription *pDispatchDescription)

Dispatch the various passes that constitute FidelityFX Super Resolution 2.

FSR2 is a composite effect, meaning that it is compromised of multiple constituent passes (implemented as one or more clears, copies and compute dispatches). The ffxFsr2ContextDispatch function is the function which (via the use of the functions contained in the callbacks field of the FfxFsr2Context structure) utlimately generates the sequence of graphics API calls required each frame.

As with the creation of the FfxFsr2Context correctly programming the FfxFsr2DispatchDescription is key to ensuring the correct operation of FSR2. It is particularly important to ensure that camera jitter is correctly applied to your application’s projection matrix (or camera origin for raytraced applications). FSR2 provides the ffxFsr2GetJitterPhaseCount and ffxFsr2GetJitterOffset entry points to help applications correctly compute the camera jitter. Whatever jitter pattern is used by the application it should be correctly programmed to the jitterOffset field of the dispatchDescription structure. For more guidance on camera jitter please consult the documentation for ffxFsr2GetJitterOffset as well as the accompanying overview documentation for FSR2.

Parameters:

  • pContext (FfxFsr2Context *) – [in] A pointer to a FfxFsr2Context structure.
  • pDispatchDescription (const FfxFsr2DispatchDescription *) – [in] A pointer to a FfxFsr2DispatchDescription structure.

Returns: FFX_API FfxErrorCode

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 338, column 22)

ffxFsr2ContextGenerateReactiveMask

FFX_API FfxErrorCode ffxFsr2ContextGenerateReactiveMask(FfxFsr2Context *pContext, const FfxFsr2GenerateReactiveDescription *pParams)

A helper function generate a Reactive mask from an opaque only texure and one containing translucent objects.

Parameters:

  • pContext (FfxFsr2Context *) – [in] A pointer to a FfxFsr2Context structure.
  • pParams (const FfxFsr2GenerateReactiveDescription *) – [in] A pointer to a FfxFsr2GenerateReactiveDescription structure

Returns: FFX_API FfxErrorCode

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 349, column 22)

ffxFsr2ContextDestroy

FFX_API FfxErrorCode ffxFsr2ContextDestroy(FfxFsr2Context *pContext)

Destroy the FidelityFX Super Resolution context.

Parameters:

  • pContext (FfxFsr2Context *) – [out] A pointer to a FfxFsr2Context structure to destroy.

Returns: FFX_API FfxErrorCode

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 361, column 22)

ffxFsr2GetUpscaleRatioFromQualityMode

FFX_API float ffxFsr2GetUpscaleRatioFromQualityMode(FfxFsr2QualityMode qualityMode)

Get the upscale ratio from the quality mode.

The following table enumerates the mapping of the quality modes to per-dimension scaling ratios.

Quality preset
Scale factor

FFX_FSR2_QUALITY_MODE_QUALITY
1.5x

FFX_FSR2_QUALITY_MODE_BALANCED
1.7x

FFX_FSR2_QUALITY_MODE_PERFORMANCE
2.0x

FFX_FSR2_QUALITY_MODE_ULTRA_PERFORMANCE
3.0x

Passing an invalid qualityMode will return 0.0f.

Returns: The upscaling the per-dimension upscaling ratio for qualityMode according to the table above.

Parameters:

  • qualityMode (FfxFsr2QualityMode) – [in] The quality mode preset.

Returns: FFX_API float

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 384, column 15)

ffxFsr2GetRenderResolutionFromQualityMode

FFX_API FfxErrorCode ffxFsr2GetRenderResolutionFromQualityMode(uint32_t *pRenderWidth, uint32_t *pRenderHeight, uint32_t displayWidth, uint32_t displayHeight, FfxFsr2QualityMode qualityMode)

A helper function to calculate the rendering resolution from a target resolution and desired quality level.

This function applies the scaling factor returned by ffxFsr2GetUpscaleRatioFromQualityMode to each dimension.

Parameters:

  • pRenderWidth (uint32_t *) – [out] A pointer to a uint32_t which will hold the calculated render resolution width.
  • pRenderHeight (uint32_t *) – [out] A pointer to a uint32_t which will hold the calculated render resolution height.
  • displayWidth (uint32_t) – [in] The target display resolution width.
  • displayHeight (uint32_t) – [in] The target display resolution height.
  • qualityMode (FfxFsr2QualityMode) – [in] The desired quality mode for FSR 2 upscaling.

Returns: FFX_API FfxErrorCode

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 406, column 22)

ffxFsr2GetJitterPhaseCount

FFX_API int32_t ffxFsr2GetJitterPhaseCount(int32_t renderWidth, int32_t displayWidth)

A helper function to calculate the jitter phase count from display resolution.

For more detailed information about the application of camera jitter to your application’s rendering please refer to the ffxFsr2GetJitterOffset function.

The table below shows the jitter phase count which this function would return for each of the quality presets.

Quality preset
Scale factor
Phase count

FFX_FSR2_QUALITY_MODE_QUALITY
1.5x
18

FFX_FSR2_QUALITY_MODE_BALANCED
1.7x
23

FFX_FSR2_QUALITY_MODE_PERFORMANCE
2.0x
32

FFX_FSR2_QUALITY_MODE_ULTRA_PERFORMANCE
3.0x
72

Custom
[1..n]x
ceil(8*n^2)

Returns: The jitter phase count for the scaling factor between renderWidth and displayWidth.

Parameters:

  • renderWidth (int32_t) – [in] The render resolution width.
  • displayWidth (int32_t) – [in] The display resolution width.

Returns: FFX_API int32_t

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 438, column 17)

ffxFsr2GetJitterOffset

FFX_API FfxErrorCode ffxFsr2GetJitterOffset(float *pOutX, float *pOutY, int32_t index, int32_t phaseCount)

A helper function to calculate the subpixel jitter offset.

FSR2 relies on the application to apply sub-pixel jittering while rendering. This is typically included in the projection matrix of the camera. To make the application of camera jitter simple, the FSR2 API provides a small set of utility function which computes the sub-pixel jitter offset for a particular frame within a sequence of separate jitter offsets. To begin, the index within the jitter phase must be computed. To calculate the sequence’s length, you can call the ffxFsr2GetJitterPhaseCount function. The index should be a value which is incremented each frame modulo the length of the sequence computed by ffxFsr2GetJitterPhaseCount. The index within the jitter phase is passed to ffxFsr2GetJitterOffset via the index parameter.

This function uses a Halton(2,3) sequence to compute the jitter offset. The ultimate index used for the sequence is index % phaseCount.

It is important to understand that the values returned from the ffxFsr2GetJitterOffset function are in unit pixel space, and in order to composite this correctly into a projection matrix we must convert them into projection offsets. This is done as per the pseudo code listing which is shown below. const int32_t jitterPhaseCount = ffxFsr2GetJitterPhaseCount(renderWidth, displayWidth);

float jitterX = 0; float jitterY = 0; ffxFsr2GetJitterOffset(&jitterX, &jitterY, index, jitterPhaseCount);

const float jitterX = 2.0f * jitterX / (float)renderWidth; const float jitterY = -2.0f * jitterY / (float)renderHeight; const Matrix4 jitterTranslationMatrix = translateMatrix(Matrix3::identity, Vector3(jitterX, jitterY, 0)); const Matrix4 jitteredProjectionMatrix = jitterTranslationMatrix * projectionMatrix; Jitter should be applied to all rendering. This includes opaque, alpha transparent, and raytraced objects. For rasterized objects, the sub-pixel jittering values calculated by the iffxFsr2GetJitterOffset function can be applied to the camera projection matrix which is ultimately used to perform transformations during vertex shading. For raytraced rendering, the sub-pixel jitter should be applied to the ray’s origin, often the camera’s position.

Whether you elect to use the ffxFsr2GetJitterOffset function or your own sequence generator, you must program the jitterOffset field of the FfxFsr2DispatchParameters structure in order to inform FSR2 of the jitter offset that has been applied in order to render each frame.

If not using the recommended ffxFsr2GetJitterOffset function, care should be taken that your jitter sequence never generates a null vector; that is value of 0 in both the X and Y dimensions.

Parameters:

  • pOutX (float *) – [out] A pointer to a float which will contain the subpixel jitter offset for the x dimension.
  • pOutY (float *) – [out] A pointer to a float which will contain the subpixel jitter offset for the y dimension.
  • index (int32_t) – [in] The index within the jitter sequence.
  • phaseCount (int32_t) – [in] The length of jitter phase. See ffxFsr2GetJitterPhaseCount.

Returns: FFX_API FfxErrorCode

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 506, column 22)

ffxFsr2ResourceIsNull

FFX_API bool ffxFsr2ResourceIsNull(FfxResource resource)

A helper function to check if a resource is FFX_FSR2_RESOURCE_IDENTIFIER_NULL.

Returns: true The resource was not FFX_FSR2_RESOURCE_IDENTIFIER_NULL.

Returns: false The resource was FFX_FSR2_RESOURCE_IDENTIFIER_NULL.

Parameters:

  • resource (FfxResource) – [in] A FfxResource.

Returns: FFX_API bool

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 519, column 14)

ffxFsr2GetEffectVersion

FFX_API FfxVersionNumber ffxFsr2GetEffectVersion()

Queries the effect version number.

Returns: The SDK version the effect was built with.

Returns: FFX_API FfxVersionNumber

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 527, column 26)

Typedefs

FfxFsr2Message

typedef void(* FfxFsr2Message) (FfxMsgType type, const wchar_t *message)

Pass a string message.

Used for debug messages.

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 152, column 9)

Enumerations

FfxFsr2Pass

enum FfxFsr2Pass

An enumeration of all the passes which constitute the FSR2 algorithm.

FSR2 is implemented as a composite of several compute passes each computing a key part of the final result. Each call to the FfxFsr2ScheduleGpuJobFunc callback function will correspond to a single pass included in FfxFsr2Pass. For a more comprehensive description of each pass, please refer to the FSR2 reference documentation.

Please note in some cases e.g.: FFX_FSR2_PASS_ACCUMULATE and FFX_FSR2_PASS_ACCUMULATE_SHARPEN either one pass or the other will be used (they are mutually exclusive). The choice of which will depend on the way the FfxFsr2Context is created and the precise contents of FfxFsr2DispatchParamters each time a call is made to ffxFsr2ContextDispatch.

Values:

FFX_FSR2_PASS_DEPTH_CLIP

FFX_FSR2_PASS_DEPTH_CLIP = 0

A pass which performs depth clipping.

FFX_FSR2_PASS_RECONSTRUCT_PREVIOUS_DEPTH

FFX_FSR2_PASS_RECONSTRUCT_PREVIOUS_DEPTH = 1

A pass which performs reconstruction of previous frame’s depth.

FFX_FSR2_PASS_LOCK

FFX_FSR2_PASS_LOCK = 2

A pass which calculates pixel locks.

FFX_FSR2_PASS_ACCUMULATE

FFX_FSR2_PASS_ACCUMULATE = 3

A pass which performs upscaling.

FFX_FSR2_PASS_ACCUMULATE_SHARPEN

FFX_FSR2_PASS_ACCUMULATE_SHARPEN = 4

A pass which performs upscaling when sharpening is used.

FFX_FSR2_PASS_RCAS

FFX_FSR2_PASS_RCAS = 5

A pass which performs sharpening.

FFX_FSR2_PASS_COMPUTE_LUMINANCE_PYRAMID

FFX_FSR2_PASS_COMPUTE_LUMINANCE_PYRAMID = 6

A pass which generates the luminance mipmap chain for the current frame.

FFX_FSR2_PASS_GENERATE_REACTIVE

FFX_FSR2_PASS_GENERATE_REACTIVE = 7

An optional pass to generate a reactive mask.

FFX_FSR2_PASS_TCR_AUTOGENERATE

FFX_FSR2_PASS_TCR_AUTOGENERATE = 8

An optional pass to automatically generate transparency/composition and reactive masks.

FFX_FSR2_PASS_COUNT

The number of passes performed by FSR2.

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 81, column 1)

FfxFsr2QualityMode

enum FfxFsr2QualityMode

An enumeration of all the quality modes supported by FidelityFX Super Resolution 2 upscaling.

In order to provide a consistent user experience across multiple applications which implement FSR2. It is strongly recommended that the following preset scaling factors are made available through your application’s user interface.

If your application does not expose the notion of preset scaling factors for upscaling algorithms (perhaps instead implementing a fixed ratio which is immutable) or implementing a more dynamic scaling scheme (such as dynamic resolution scaling), then there is no need to use these presets.

Please note that FFX_FSR2_QUALITY_MODE_ULTRA_PERFORMANCE is an optional mode which may introduce significant quality degradation in the final image. As such it is recommended that you evaluate the final results of using this scaling mode before deciding if you should include it in your application.

Values:

FFX_FSR2_QUALITY_MODE_QUALITY

FFX_FSR2_QUALITY_MODE_QUALITY = 1

Perform upscaling with a per-dimension upscaling ratio of 1.5x.

FFX_FSR2_QUALITY_MODE_BALANCED

FFX_FSR2_QUALITY_MODE_BALANCED = 2

Perform upscaling with a per-dimension upscaling ratio of 1.7x.

FFX_FSR2_QUALITY_MODE_PERFORMANCE

FFX_FSR2_QUALITY_MODE_PERFORMANCE = 3

Perform upscaling with a per-dimension upscaling ratio of 2.0x.

FFX_FSR2_QUALITY_MODE_ULTRA_PERFORMANCE

FFX_FSR2_QUALITY_MODE_ULTRA_PERFORMANCE = 4

Perform upscaling with a per-dimension upscaling ratio of 3.0x.

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 117, column 1)

FfxFsr2InitializationFlagBits

enum FfxFsr2InitializationFlagBits

An enumeration of bit flags used when creating a FfxFsr2Context. See FfxFsr2ContextDescription.

Values:

FFX_FSR2_ENABLE_HIGH_DYNAMIC_RANGE

FFX_FSR2_ENABLE_HIGH_DYNAMIC_RANGE = (1<<0)

A bit indicating if the input color data provided is using a high-dynamic range.

FFX_FSR2_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS

FFX_FSR2_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS = (1<<1)

A bit indicating if the motion vectors are rendered at display resolution.

FFX_FSR2_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION

FFX_FSR2_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION = (1<<2)

A bit indicating that the motion vectors have the jittering pattern applied to them.

FFX_FSR2_ENABLE_DEPTH_INVERTED

FFX_FSR2_ENABLE_DEPTH_INVERTED = (1<<3)

A bit indicating that the input depth buffer data provided is inverted [1..0].

FFX_FSR2_ENABLE_DEPTH_INFINITE

FFX_FSR2_ENABLE_DEPTH_INFINITE = (1<<4)

A bit indicating that the input depth buffer data provided is using an infinite far plane.

FFX_FSR2_ENABLE_AUTO_EXPOSURE

FFX_FSR2_ENABLE_AUTO_EXPOSURE = (1<<5)

A bit indicating if automatic exposure should be applied to input color data.

FFX_FSR2_ENABLE_DYNAMIC_RESOLUTION

FFX_FSR2_ENABLE_DYNAMIC_RESOLUTION = (1<<6)

A bit indicating that the application uses dynamic resolution scaling.

FFX_FSR2_ENABLE_TEXTURE1D_USAGE

FFX_FSR2_ENABLE_TEXTURE1D_USAGE = (1<<7)

A bit indicating that the backend should use 1D textures.

FFX_FSR2_ENABLE_DEBUG_CHECKING

FFX_FSR2_ENABLE_DEBUG_CHECKING = (1<<8)

A bit indicating that the runtime should check some API values and report issues.

FFX_FSR2_ENABLE_RCAS_LOWER_LIMITER_COMPENSATION

FFX_FSR2_ENABLE_RCAS_LOWER_LIMITER_COMPENSATION = (1<<9)

A bit indicating if we should compensate for possible negative output values during rcas.

Source: sdk/include/FidelityFX/host/ffx_fsr2.h (line 129, column 1)

Dependencies

This module depends on: