From 081b84c5ca85a04bd8500cb74820087480ff6be0 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Thu, 19 Dec 2024 23:37:04 +0300 Subject: [PATCH] add fsr3.0 fg files --- .../fsr3/include/ffx_frameinterpolation.h | 242 +++++++++ OptiScaler/fsr3/include/ffx_fsr3.h | 503 ++++++++++++++++++ OptiScaler/fsr3/include/ffx_opticalflow.h | 202 +++++++ 3 files changed, 947 insertions(+) create mode 100644 OptiScaler/fsr3/include/ffx_frameinterpolation.h create mode 100644 OptiScaler/fsr3/include/ffx_fsr3.h create mode 100644 OptiScaler/fsr3/include/ffx_opticalflow.h diff --git a/OptiScaler/fsr3/include/ffx_frameinterpolation.h b/OptiScaler/fsr3/include/ffx_frameinterpolation.h new file mode 100644 index 00000000..e17e04a1 --- /dev/null +++ b/OptiScaler/fsr3/include/ffx_frameinterpolation.h @@ -0,0 +1,242 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +// @defgroup FRAMEINTERPOLATION + +#pragma once + +// Include the interface for the backend of the Frameinterpolation API. +#include "ffx_interface.h" + +/// FidelityFX Frameinterpolation major version. +/// +/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION +#define FFX_FRAMEINTERPOLATION_VERSION_MAJOR (1) + +/// FidelityFX Frameinterpolation minor version. +/// +/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION +#define FFX_FRAMEINTERPOLATION_VERSION_MINOR (0) + +/// FidelityFX Frameinterpolation patch version. +/// +/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION +#define FFX_FRAMEINTERPOLATION_VERSION_PATCH (0) + +/// FidelityFX Frame Interpolation context count +/// +/// Defines the number of internal effect contexts required by Frame Interpolation +/// +/// @ingroup ffxFrameInterpolation +#define FFX_FRAMEINTERPOLATION_CONTEXT_COUNT (1) + +/// The size of the context specified in 32bit values. +/// +/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION +#define FFX_FRAMEINTERPOLATION_CONTEXT_SIZE (FFX_SDK_DEFAULT_CONTEXT_SIZE) + +#if defined(__cplusplus) +extern "C" { +#endif // #if defined(__cplusplus) + +/// An enumeration of all the passes which constitute the FSR3 algorithm. +/// +/// FSR3 is implemented as a composite of several compute passes each +/// computing a key part of the final result. Each call to the +/// FfxFsr3ScheduleGpuJobFunc callback function will +/// correspond to a single pass included in FfxFsr3Pass. For a +/// more comprehensive description of each pass, please refer to the FSR3 +/// reference documentation. +/// +/// Please note in some cases e.g.: FFX_FSR3_PASS_ACCUMULATE +/// and FFX_FSR3_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 FfxFsr3Context is created and the +/// precise contents of FfxFsr3DispatchParamters each time a call +/// is made to ffxFsr3ContextDispatch. +/// +/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION +typedef enum FfxFrameInterpolationPass +{ + FFX_FRAMEINTERPOLATION_PASS_SETUP, + FFX_FRAMEINTERPOLATION_PASS_RECONSTRUCT_PREV_DEPTH, + FFX_FRAMEINTERPOLATION_PASS_GAME_MOTION_VECTOR_FIELD, + FFX_FRAMEINTERPOLATION_PASS_OPTICAL_FLOW_VECTOR_FIELD, + FFX_FRAMEINTERPOLATION_PASS_DISOCCLUSION_MASK, + FFX_FRAMEINTERPOLATION_PASS_INTERPOLATION, + FFX_FRAMEINTERPOLATION_PASS_INPAINTING_PYRAMID, + FFX_FRAMEINTERPOLATION_PASS_INPAINTING, + FFX_FRAMEINTERPOLATION_PASS_GAME_VECTOR_FIELD_INPAINTING_PYRAMID, + FFX_FRAMEINTERPOLATION_PASS_DEBUG_VIEW, + FFX_FRAMEINTERPOLATION_PASS_COUNT ///< The number of passes performed by FrameInterpolation. +} FfxFrameInterpolationPass; + +// forward declarations +struct FfxFrameInterpolationContext; + +/// An enumeration of bit flags used when creating a +/// FfxFrameInterpolationContext. See FfxFrameInterpolationContextDescription. +/// +/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION +typedef enum FfxFrameInterpolationInitializationFlagBits { + + FFX_FRAMEINTERPOLATION_ENABLE_DEPTH_INVERTED = (1<<0), ///< A bit indicating that the input depth buffer data provided is inverted [1..0]. + FFX_FRAMEINTERPOLATION_ENABLE_DEPTH_INFINITE = (1<<1), ///< A bit indicating that the input depth buffer data provided is using an infinite far plane. + FFX_FRAMEINTERPOLATION_ENABLE_TEXTURE1D_USAGE = (1<<2), ///< A bit indicating that the backend should use 1D textures. + FFX_FRAMEINTERPOLATION_ENABLE_HDR_COLOR_INPUT = (1<<3) ///< A bit indicating that HDR values are present in the imaging pipeline. +} FfxFrameInterpolationInitializationFlagBits; + +/// A structure encapsulating the parameters required to initialize +/// FidelityFX Frameinterpolation upscaling. +/// +/// @ingroup FRAMEINTERPOLATION +typedef struct FfxFrameInterpolationContextDescription { + + FfxInterface backendInterface; ///< A set of pointers to the backend implementation for FidelityFX SDK + + uint32_t flags; ///< A collection of FfxFrameInterpolationInitializationFlagBits. + FfxDimensions2D maxRenderSize; ///< The maximum size that rendering will be performed at. + FfxDimensions2D displaySize; ///< The size of the presentation resolution + FfxSurfaceFormat backBufferFormat; +} FfxFrameInterpolationContextDescription; + +/// A structure encapsulating the FidelityFX Super Resolution 2 context. +/// +/// This sets up an object which contains all persistent internal data and +/// resources that are required by FSR3. +/// +/// The FfxFsr3Context object should have a lifetime matching +/// your use of FSR3. Before destroying the FSR3 context care should be taken +/// to ensure the GPU is not accessing the resources created or used by FSR3. +/// It is therefore recommended that the GPU is idle before destroying the +/// FSR3 context. +/// +/// @ingroup FRAMEINTERPOLATION +typedef struct FfxFrameInterpolationContext +{ + uint32_t data[FFX_FRAMEINTERPOLATION_CONTEXT_SIZE]; ///< An opaque set of uint32_t which contain the data for the context. +} FfxFrameInterpolationContext; + + +/// Create a FidelityFX Super Resolution 2 context from the parameters +/// programmed to the FfxFsr3CreateParams structure. +/// +/// The context structure is the main object used to interact with the FSR3 +/// API, and is responsible for the management of the internal resources used +/// by the FSR3 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 FSR3's +/// frame-to-frame function. Depending on the precise configuration used when +/// creating the FfxFsr3Context a different set of resources and +/// pipelines might be requested via the callback functions. +/// +/// The flags included in the flags field of +/// FfxFsr3Context how match the configuration of your +/// application as well as the intended use of FSR3. It is important that these +/// flags are set correctly (as well as a correct programmed +/// FfxFsr3DispatchDescription) to ensure correct operation. It is +/// recommended to consult the overview documentation for further details on +/// how FSR3 should be integerated into an application. +/// +/// When the FfxFsr3Context is created, you should use the +/// ffxFsr3ContextDispatch function each frame where FSR3 +/// upscaling should be applied. See the documentation of +/// ffxFsr3ContextDispatch for more details. +/// +/// The FfxFsr3Context should be destroyed when use of it is +/// completed, typically when an application is unloaded or FSR3 upscaling is +/// disabled by a user. To destroy the FSR3 context you should call +/// ffxFsr3ContextDestroy. +/// +/// @param [out] context A pointer to a FfxFsr3Context structure to populate. +/// @param [in] contextDescription A pointer to a FfxFsr3ContextDescription structure. +/// +/// @retval +/// FFX_OK The operation completed successfully. +/// @retval +/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either context or contextDescription was NULL. +/// @retval +/// FFX_ERROR_INCOMPLETE_INTERFACE The operation failed because the FfxFsr3ContextDescription.callbacks was not fully specified. +/// @retval +/// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend. +/// +/// @ingroup FRAMEINTERPOLATION +FFX_API FfxErrorCode ffxFrameInterpolationContextCreate(FfxFrameInterpolationContext* context, FfxFrameInterpolationContextDescription* contextDescription); + +typedef enum FfxFrameInterpolationDispatchFlags +{ + FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_TEAR_LINES = (1 << 0), ///< A bit indicating that the debug tear lines will be drawn to the interpolated output. + FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_VIEW = (1 << 1), ///< A bit indicating that the interpolated output resource will contain debug views with relevant information. +} FfxFrameInterpolationDispatchFlags; + +typedef struct FfxFrameInterpolationDispatchDescription { + + uint32_t flags; ///< combination of FfxFrameInterpolationDispatchFlags + FfxCommandList commandList; ///< The FfxCommandList to record frame interpolation commands into. + FfxDimensions2D displaySize; ///< The destination output dimensions + FfxDimensions2D renderSize; ///< The dimensions used to render game content, dilatedDepth, dilatedMotionVectors are expected to be of ths size. + FfxResource currentBackBuffer; ///< The current presentation color, if currentBackBuffer_HUDLess is not used, this will be used as interpolation source data. + FfxResource currentBackBuffer_HUDLess; ///< The current presentation color without HUD content, when use it will be used as interpolation source data. + FfxResource output; ///< The output resource where to store the interpolated result. + FfxResource dilatedDepth; ///< The dilated depth buffer data (see example computation in the FfxFsr3Upscaler effect) + FfxResource dilatedMotionVectors; ///< The dilated motion vector data (see example computation in the FfxFsr3Upscaler effect) + FfxResource reconstructPrevNearDepth; ///< The estimated previous frame depth buffer (see example computation in the FfxFsr3Upscaler effect) + + FfxRect2D interpolationRect; ///< The area of the backbuffer that should be used for interpolation in case only a part of the screen is used e.g. due to movie bars + + FfxResource opticalFlowVector; ///< The optical flow motion vectors (see example computation in the FfxOpticalFlow effect) + FfxResource opticalFlowSceneChangeDetection; ///< The optical flow scene change detection data + FfxDimensions2D opticalFlowBufferSize; ///< The optical flow motion vector resource dimensions + FfxFloatCoords2D opticalFlowScale; ///< The optical flow motion vector scale factor, used to scale resoure values into [0.0,1.0] range. + int opticalFlowBlockSize; ///< The optical flow block dimension size + + float cameraNear; ///< The distance to the near plane of the camera. + float cameraFar; ///< The distance to the far plane of the camera. This is used only used in case of non infinite depth. + float cameraFovAngleVertical; ///< The camera angle field of view in the vertical direction (expressed in radians). + float viewSpaceToMetersFactor; ///< The unit to scale view space coordinates to meters. + + float frameTimeDelta; ///< The time elapsed since the last frame (expressed in milliseconds). + bool reset; ///< A boolean value which when set to true, indicates the camera has moved discontinuously. + + FfxBackbufferTransferFunction backBufferTransferFunction; ///< The transfer function use to convert interpolation source color data to linear RGB. + float minMaxLuminance[2]; ///< Min and max luminance values, used when converting HDR colors to linear RGB + +} FfxFrameInterpolationDispatchDescription; + +FFX_API FfxErrorCode ffxFrameInterpolationDispatch(FfxFrameInterpolationContext* context, const FfxFrameInterpolationDispatchDescription* params); + +/// Destroy the FidelityFX Super Resolution context. +/// +/// @param [out] context A pointer to a FfxFsr3Context structure to destroy. +/// +/// @retval +/// FFX_OK The operation completed successfully. +/// @retval +/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either context was NULL. +/// +/// @ingroup FRAMEINTERPOLATION +FFX_API FfxErrorCode ffxFrameInterpolationContextDestroy(FfxFrameInterpolationContext* context); + +#if defined(__cplusplus) +} +#endif // #if defined(__cplusplus) diff --git a/OptiScaler/fsr3/include/ffx_fsr3.h b/OptiScaler/fsr3/include/ffx_fsr3.h new file mode 100644 index 00000000..4503bfee --- /dev/null +++ b/OptiScaler/fsr3/include/ffx_fsr3.h @@ -0,0 +1,503 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +// @defgroup FSR3 + +#pragma once + +// Include the interface for the backend of the FSR3 API. +#include "ffx_interface.h" +#include "ffx_fsr3upscaler.h" +#include "ffx_frameinterpolation.h" +#include "ffx_opticalflow.h" + +/// FidelityFX Super Resolution 3 major version. +/// +/// @ingroup FSR3 +#define FFX_FSR3_VERSION_MAJOR (3) + +/// FidelityFX Super Resolution 0 minor version. +/// +/// @ingroup FSR3 +#define FFX_FSR3_VERSION_MINOR (0) + +/// FidelityFX Super Resolution 0 patch version. +/// +/// @ingroup FSR3 +#define FFX_FSR3_VERSION_PATCH (3) + +/// FidelityFX Super Resolution 3 context count +/// +/// Defines the number of internal effect contexts required by FSR3 (+1 for proxy swapchain) +/// +/// @ingroup ffxFsr3 +#define FFX_FSR3_CONTEXT_COUNT (FFX_FSR3UPSCALER_CONTEXT_COUNT + FFX_OPTICALFLOW_CONTEXT_COUNT + FFX_FRAMEINTERPOLATION_CONTEXT_COUNT + 1) + +/// The size of the context specified in 32bit values. +/// +/// @ingroup FSR3 +#define FFX_FSR3_CONTEXT_SIZE (16536) + +#if defined(__cplusplus) +extern "C" { +#endif // #if defined(__cplusplus) + +///// An enumeration of all the passes which constitute the FSR3 algorithm. +///// +///// FSR3 is implemented as a composite of several compute passes each +///// computing a key part of the final result. Each call to the +///// FfxFsr3ScheduleGpuJobFunc callback function will +///// correspond to a single pass included in FfxFsr3Pass. For a +///// more comprehensive description of each pass, please refer to the FSR3 +///// reference documentation. +///// +///// Please note in some cases e.g.: FFX_FSR3_PASS_ACCUMULATE +///// and FFX_FSR3_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 FfxFsr3Context is created and the +///// precise contents of FfxFsr3DispatchParamters each time a call +///// is made to ffxFsr3ContextDispatch. +///// +///// @ingroup FSR3 +//typedef enum FfxFsr3Pass +//{ +// // no special FSR3 pipelines +// +// FFX_FSR3_PASS_COUNT ///< The number of passes performed by FSR3. +//} FfxFsr3Pass; + +/// 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 FSR3. 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_FSR3_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. +/// +/// @ingroup FSR3 +typedef enum FfxFsr3QualityMode { + + FFX_FSR3_QUALITY_MODE_QUALITY = 1, ///< Perform upscaling with a per-dimension upscaling ratio of 1.5x. + FFX_FSR3_QUALITY_MODE_BALANCED = 2, ///< Perform upscaling with a per-dimension upscaling ratio of 1.7x. + FFX_FSR3_QUALITY_MODE_PERFORMANCE = 3, ///< Perform upscaling with a per-dimension upscaling ratio of 2.0x. + FFX_FSR3_QUALITY_MODE_ULTRA_PERFORMANCE = 4 ///< Perform upscaling with a per-dimension upscaling ratio of 3.0x. +} FfxFsr3QualityMode; + +/// An enumeration of bit flags used when creating a +/// FfxFsr3Context. See FfxFsr3ContextDescription. +/// +/// @ingroup FSR3 +typedef enum FfxFsr3InitializationFlagBits { + + FFX_FSR3_ENABLE_HIGH_DYNAMIC_RANGE = (1<<0), ///< A bit indicating if the input color data provided to all inputs is using a high-dynamic range. + FFX_FSR3_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS = (1<<1), ///< A bit indicating if the motion vectors are rendered at display resolution. + FFX_FSR3_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION = (1<<2), ///< A bit indicating that the motion vectors have the jittering pattern applied to them. + FFX_FSR3_ENABLE_DEPTH_INVERTED = (1<<3), ///< A bit indicating that the input depth buffer data provided is inverted [1..0]. + FFX_FSR3_ENABLE_DEPTH_INFINITE = (1<<4), ///< A bit indicating that the input depth buffer data provided is using an infinite far plane. + FFX_FSR3_ENABLE_AUTO_EXPOSURE = (1<<5), ///< A bit indicating if automatic exposure should be applied to input color data. + FFX_FSR3_ENABLE_DYNAMIC_RESOLUTION = (1<<6), ///< A bit indicating that the application uses dynamic resolution scaling. + FFX_FSR3_ENABLE_TEXTURE1D_USAGE = (1<<7), ///< A bit indicating that the backend should use 1D textures. + FFX_FSR3_ENABLE_DEBUG_CHECKING = (1<<8), ///< A bit indicating that the runtime should check some API values and report issues. + FFX_FSR3_ENABLE_UPSCALING_ONLY = (1<<9), ///, A bit indicating that the context will only be used for upscaling + FFX_FSR3_ENABLE_HDR_UPSCALE_SDR_FINALOUTPUT = (1<<10), ///, A bit indicating if the input color data provided to UPSCALE is using a high-dynamic range, final output SDR. + FFX_FSR3_ENABLE_SDR_UPSCALE_HDR_FINALOUTPUT = (1<<11), ///, A bit indicating if the input color data provided to UPSCALE is using SDR, final output is high-dynamic range. + FFX_FSR3_ENABLE_ASYNC_WORKLOAD_SUPPORT = (1<<12), +} FfxFsr3InitializationFlagBits; + +typedef enum FfxFsr3FrameGenerationFlags +{ + FFX_FSR3_FRAME_GENERATION_FLAG_DRAW_DEBUG_TEAR_LINES = FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_TEAR_LINES, ///< A bit indicating that the debug tear lines will be drawn to the interpolated output. + FFX_FSR3_FRAME_GENERATION_FLAG_DRAW_DEBUG_VIEW = FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_VIEW, ///< A bit indicating that the interpolated output resource will contain debug views with relevant information. +} FfxFsr3FrameGenerationFlags; + +/// A structure encapsulating the parameters required to initialize FidelityFX +/// Super Resolution 3 upscaling. +/// +/// @ingroup FSR3 +typedef struct FfxFsr3ContextDescription { + uint32_t flags; ///< A collection of FfxFsr3InitializationFlagBits. + FfxDimensions2D maxRenderSize; ///< The maximum size that rendering will be performed at. + FfxDimensions2D upscaleOutputSize; ///< The size of the presentation resolution targeted by the upscaling process. + FfxDimensions2D displaySize; ///< The size of the presentation resolution targeted by the frame interpolation process. + FfxInterface backendInterfaceSharedResources; ///< A set of pointers to the backend implementation for FidelityFX SDK + FfxInterface backendInterfaceUpscaling; ///< A set of pointers to the backend implementation for FidelityFX SDK + FfxInterface backendInterfaceFrameInterpolation; ///< A set of pointers to the backend implementation for FidelityFX SDK + FfxFsr3UpscalerMessage fpMessage; ///< A pointer to a function that can recieve messages from the runtime. + + FfxSurfaceFormat backBufferFormat; ///< The format of the swapchain surface + +} FfxFsr3ContextDescription; + +/// A structure encapsulating the parameters for dispatching the various passes +/// of FidelityFX Super Resolution 3. +/// +/// @ingroup FSR3 +typedef struct FfxFsr3DispatchUpscaleDescription { + + FfxCommandList commandList; ///< The FfxCommandList to record FSR2 rendering commands into. + FfxResource color; ///< A FfxResource containing the color buffer for the current frame (at render resolution). + FfxResource depth; ///< A FfxResource containing 32bit depth values for the current frame (at render resolution). + FfxResource motionVectors; ///< A FfxResource containing 2-dimensional motion vectors (at render resolution if FFX_FSR2_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS is not set). + FfxResource exposure; ///< A optional FfxResource containing a 1x1 exposure value. + FfxResource reactive; ///< A optional FfxResource containing alpha value of reactive objects in the scene. + FfxResource transparencyAndComposition; ///< A optional FfxResource containing alpha value of special objects in the scene. + FfxResource upscaleOutput; ///< A FfxResource containing the output color buffer for the current frame (at presentation resolution). + FfxFloatCoords2D jitterOffset; ///< The subpixel jitter offset applied to the camera. + FfxFloatCoords2D motionVectorScale; ///< The scale factor to apply to motion vectors. + FfxDimensions2D renderSize; ///< The resolution that was used for rendering the input resources. + bool enableSharpening; ///< Enable an additional sharpening pass. + float sharpness; ///< The sharpness value between 0 and 1, where 0 is no additional sharpness and 1 is maximum additional sharpness. + float frameTimeDelta; ///< The time elapsed since the last frame (expressed in milliseconds). + float preExposure; ///< The pre exposure value (must be > 0.0f) + bool reset; ///< A boolean value which when set to true, indicates the camera has moved discontinuously. + float cameraNear; ///< The distance to the near plane of the camera. + float cameraFar; ///< The distance to the far plane of the camera. This is used only used in case of non infinite depth. + float cameraFovAngleVertical; ///< The camera angle field of view in the vertical direction (expressed in radians). + float viewSpaceToMetersFactor; ///< The scale factor to convert view space units to meters +} FfxFsr3DispatchUpscaleDescription; + +FFX_API FfxErrorCode ffxFsr3DispatchFrameGeneration(const FfxFrameGenerationDispatchDescription* desc); + +/// A structure encapsulating the parameters for automatic generation of a reactive mask +/// +/// @ingroup FSR3 +typedef struct FfxFsr3GenerateReactiveDescription { + + FfxCommandList commandList; ///< The FfxCommandList to record FSR3 rendering commands into. + FfxResource colorOpaqueOnly; ///< A FfxResource containing the opaque only color buffer for the current frame (at render resolution). + FfxResource colorPreUpscale; ///< A FfxResource containing the opaque+translucent color buffer for the current frame (at render resolution). + FfxResource outReactive; ///< A FfxResource containing the surface to generate the reactive mask into. + FfxDimensions2D renderSize; ///< The resolution that was used for rendering the input resources. + float scale; ///< A value to scale the output + float cutoffThreshold; ///< A threshold value to generate a binary reactive mask + float binaryValue; + uint32_t flags; ///< Flags to determine how to generate the reactive mask +} FfxFsr3GenerateReactiveDescription; + +/// A structure encapsulating the FidelityFX Super Resolution 3 context. +/// +/// This sets up an object which contains all persistent internal data and +/// resources that are required by FSR3. +/// +/// The FfxFsr3Context object should have a lifetime matching +/// your use of FSR3. Before destroying the FSR3 context care should be taken +/// to ensure the GPU is not accessing the resources created or used by FSR3. +/// It is therefore recommended that the GPU is idle before destroying the +/// FSR3 context. +/// +/// @ingroup FSR3 +typedef struct FfxFsr3Context +{ + uint32_t data[ FFX_FSR3UPSCALER_CONTEXT_SIZE + + FFX_OPTICALFLOW_CONTEXT_SIZE + + FFX_FRAMEINTERPOLATION_CONTEXT_SIZE + + (16536)]; ///< An opaque set of uint32_t which contain the data for the context. +} FfxFsr3Context; + +/// Create a FidelityFX Super Resolution 3 context from the parameters +/// programmed to the FfxFsr3CreateParams structure. +/// +/// The context structure is the main object used to interact with the FSR3 +/// API, and is responsible for the management of the internal resources used +/// by the FSR3 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 FSR3's +/// frame-to-frame function. Depending on the precise configuration used when +/// creating the FfxFsr3Context a different set of resources and +/// pipelines might be requested via the callback functions. +/// +/// The flags included in the flags field of +/// FfxFsr3Context how match the configuration of your +/// application as well as the intended use of FSR3. It is important that these +/// flags are set correctly (as well as a correct programmed +/// FfxFsr3DispatchDescription) to ensure correct operation. It is +/// recommended to consult the overview documentation for further details on +/// how FSR3 should be integerated into an application. +/// +/// When the FfxFsr3Context is created, you should use the +/// ffxFsr3ContextDispatch function each frame where FSR3 +/// upscaling should be applied. See the documentation of +/// ffxFsr3ContextDispatch for more details. +/// +/// The FfxFsr3Context should be destroyed when use of it is +/// completed, typically when an application is unloaded or FSR3 upscaling is +/// disabled by a user. To destroy the FSR3 context you should call +/// ffxFsr3ContextDestroy. +/// +/// @param [out] context A pointer to a FfxFsr3Context structure to populate. +/// @param [in] contextDescription A pointer to a FfxFsr3ContextDescription structure. +/// +/// @retval +/// FFX_OK The operation completed successfully. +/// @retval +/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either context or contextDescription was NULL. +/// @retval +/// FFX_ERROR_INCOMPLETE_INTERFACE The operation failed because the FfxFsr3ContextDescription.callbacks was not fully specified. +/// @retval +/// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend. +/// +/// @ingroup FSR3 +FFX_API FfxErrorCode ffxFsr3ContextCreate(FfxFsr3Context* context, FfxFsr3ContextDescription* contextDescription); + + +/// Dispatch the various passes that constitute FidelityFX Super Resolution 3 Upscaling. +/// +/// FSR3 is a composite effect, meaning that it is compromised of multiple +/// constituent passes (implemented as one or more clears, copies and compute +/// dispatches). The ffxFsr3ContextDispatchUpscale function is the +/// function which (via the use of the functions contained in the +/// callbacks field of the FfxFsr3Context +/// structure) utlimately generates the sequence of graphics API calls required +/// each frame. +/// +/// As with the creation of the FfxFsr3Context correctly +/// programming the dispatchParams is key to ensuring +/// the correct operation of FSR3. It is particularly important to ensure that +/// camera jitter is correctly applied to your application's projection matrix +/// (or camera origin for raytraced applications). FSR3 provides the +/// ffxFsr3GetJitterPhaseCount and +/// ffxFsr3GetJitterOffset 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 dispatchParams +/// structure. For more guidance on camera jitter please consult the +/// documentation for ffxFsr3GetJitterOffset as well as the +/// accompanying overview documentation for FSR3. +/// +/// @param [in] context A pointer to a FfxFsr3Context structure. +/// @param [in] dispatchParams A pointer to a FfxFsr3DispatchUpscaleDescription structure. +/// +/// @retval +/// FFX_OK The operation completed successfully. +/// @retval +/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either context or dispatchParams was NULL. +/// @retval +/// FFX_ERROR_OUT_OF_RANGE The operation failed because dispatchParams.renderSize was larger than the maximum render resolution. +/// @retval +/// FFX_ERROR_NULL_DEVICE The operation failed because the device inside the context was NULL. +/// @retval +/// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend. +/// +/// @ingroup FSR3 +FFX_API FfxErrorCode ffxFsr3ContextDispatchUpscale(FfxFsr3Context* context, const FfxFsr3DispatchUpscaleDescription* dispatchParams); + +FFX_API FfxErrorCode ffxFsr3SkipPresent(FfxFsr3Context* context); + +/// A helper function generate a Reactive mask from an opaque only texure and one containing translucent objects. +/// +/// @param [in] context A pointer to a FfxFsr3Context structure. +/// @param [in] params A pointer to a FfxFsr3GenerateReactiveDescription structure +/// +/// @retval +/// FFX_OK The operation completed successfully. +/// +/// @ingroup FSR3 +FFX_API FfxErrorCode ffxFsr3ContextGenerateReactiveMask(FfxFsr3Context* context, const FfxFsr3GenerateReactiveDescription* params); + +FFX_API FfxErrorCode ffxFsr3ConfigureFrameGeneration(FfxFsr3Context* context, const FfxFrameGenerationConfig* config); + +/// Destroy the FidelityFX Super Resolution context. +/// +/// @param [out] context A pointer to a FfxFsr3Context structure to destroy. +/// +/// @retval +/// FFX_OK The operation completed successfully. +/// @retval +/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either context was NULL. +/// +/// @ingroup FSR3 +FFX_API FfxErrorCode ffxFsr3ContextDestroy(FfxFsr3Context* context); + +/// 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_FSR3_QUALITY_MODE_NATIVEAA | 1.0x +/// FFX_FSR3_QUALITY_MODE_QUALITY | 1.5x +/// FFX_FSR3_QUALITY_MODE_BALANCED | 1.7x +/// FFX_FSR3_QUALITY_MODE_PERFORMANCE | 2.0x +/// FFX_FSR3_QUALITY_MODE_ULTRA_PERFORMANCE | 3.0x +/// +/// Passing an invalid qualityMode will return 0.0f. +/// +/// @param [in] qualityMode The quality mode preset. +/// +/// @returns +/// The upscaling the per-dimension upscaling ratio for +/// qualityMode according to the table above. +/// +/// @ingroup FSR3 +FFX_API float ffxFsr3GetUpscaleRatioFromQualityMode(FfxFsr3QualityMode 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 +/// ffxFsr3GetUpscaleRatioFromQualityMode to each dimension. +/// +/// @param [out] renderWidth A pointer to a uint32_t which will hold the calculated render resolution width. +/// @param [out] renderHeight A pointer to a uint32_t which will hold the calculated render resolution height. +/// @param [in] displayWidth The target display resolution width. +/// @param [in] displayHeight The target display resolution height. +/// @param [in] qualityMode The desired quality mode for FSR 2 upscaling. +/// +/// @retval +/// FFX_OK The operation completed successfully. +/// @retval +/// FFX_ERROR_INVALID_POINTER Either renderWidth or renderHeight was NULL. +/// @retval +/// FFX_ERROR_INVALID_ENUM An invalid quality mode was specified. +/// +/// @ingroup FSR3 +FFX_API FfxErrorCode ffxFsr3GetRenderResolutionFromQualityMode( + uint32_t* renderWidth, + uint32_t* renderHeight, + uint32_t displayWidth, + uint32_t displayHeight, + FfxFsr3QualityMode qualityMode); + +/// 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 +/// ffxFsr3GetJitterOffset 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_FSR3_QUALITY_MODE_QUALITY | 1.5x | 18 +/// FFX_FSR3_QUALITY_MODE_BALANCED | 1.7x | 23 +/// FFX_FSR3_QUALITY_MODE_PERFORMANCE | 2.0x | 32 +/// FFX_FSR3_QUALITY_MODE_ULTRA_PERFORMANCE | 3.0x | 72 +/// Custom | [1..n]x | ceil(8*n^2) +/// +/// @param [in] renderWidth The render resolution width. +/// @param [in] displayWidth The display resolution width. +/// +/// @returns +/// The jitter phase count for the scaling factor between renderWidth and displayWidth. +/// +/// @ingroup FSR3 +FFX_API int32_t ffxFsr3GetJitterPhaseCount(int32_t renderWidth, int32_t displayWidth); + +/// A helper function to calculate the subpixel jitter offset. +/// +/// FSR3 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 FSR3 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 ffxFsr3GetJitterPhaseCount +/// function. The index should be a value which is incremented each frame modulo +/// the length of the sequence computed by ffxFsr3GetJitterPhaseCount. +/// The index within the jitter phase is passed to +/// ffxFsr3GetJitterOffset 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 +/// ffxFsr3GetJitterOffset 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 = ffxFsr3GetJitterPhaseCount(renderWidth, displayWidth); +/// +/// float jitterX = 0; +/// float jitterY = 0; +/// ffxFsr3GetJitterOffset(&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 iffxFsr3GetJitterOffset +/// 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 ffxFsr3GetJitterOffset function +/// or your own sequence generator, you must program the +/// jitterOffset field of the +/// FfxFsr3DispatchParameters structure in order to inform FSR3 +/// of the jitter offset that has been applied in order to render each frame. +/// +/// If not using the recommended ffxFsr3GetJitterOffset 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. +/// +/// @param [out] outX A pointer to a float which will contain the subpixel jitter offset for the x dimension. +/// @param [out] outY A pointer to a float which will contain the subpixel jitter offset for the y dimension. +/// @param [in] index The index within the jitter sequence. +/// @param [in] phaseCount The length of jitter phase. See ffxFsr3GetJitterPhaseCount. +/// +/// @retval +/// FFX_OK The operation completed successfully. +/// @retval +/// FFX_ERROR_INVALID_POINTER Either outX or outY was NULL. +/// @retval +/// FFX_ERROR_INVALID_ARGUMENT Argument phaseCount must be greater than 0. +/// +/// @ingroup FSR3 +FFX_API FfxErrorCode ffxFsr3GetJitterOffset(float* outX, float* outY, int32_t index, int32_t phaseCount); + +/// A helper function to check if a resource is +/// FFX_FSR3_RESOURCE_IDENTIFIER_NULL. +/// +/// @param [in] resource A FfxResource. +/// +/// @returns +/// true The resource was not FFX_FSR3_RESOURCE_IDENTIFIER_NULL. +/// @returns +/// false The resource was FFX_FSR3_RESOURCE_IDENTIFIER_NULL. +/// +/// @ingroup FSR3 +FFX_API bool ffxFsr3ResourceIsNull(FfxResource resource); + +#if defined(__cplusplus) +} +#endif // #if defined(__cplusplus) diff --git a/OptiScaler/fsr3/include/ffx_opticalflow.h b/OptiScaler/fsr3/include/ffx_opticalflow.h new file mode 100644 index 00000000..4e4b69d7 --- /dev/null +++ b/OptiScaler/fsr3/include/ffx_opticalflow.h @@ -0,0 +1,202 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +// @defgroup OpticalFlow + +#pragma once + +// Include the interface for the backend of the OpticalFlow API. +#include "ffx_interface.h" + +/// FidelityFX OpticalFlow major version. +/// +/// @ingroup ffxOpticalflow +#define FFX_OPTICALFLOW_VERSION_MAJOR (1) + +/// FidelityFX OpticalFlow minor version. +/// +/// @ingroup ffxOpticalflow +#define FFX_OPTICALFLOW_VERSION_MINOR (0) + +/// FidelityFX OpticalFlow patch version. +/// +/// @ingroup ffxOpticalflow +#define FFX_OPTICALFLOW_VERSION_PATCH (0) + +/// FidelityFX Optical Flow context count +/// +/// Defines the number of internal effect contexts required by Optical Flow +/// +/// @ingroup ffxOpticalFlow +#define FFX_OPTICALFLOW_CONTEXT_COUNT (1) + +/// The size of the context specified in 32bit size units. +/// +/// @ingroup ffxOpticalflow +#define FFX_OPTICALFLOW_CONTEXT_SIZE (FFX_SDK_DEFAULT_CONTEXT_SIZE) + +#if defined(__cplusplus) +extern "C" { +#endif // #if defined(__cplusplus) + +/// An enumeration of all the passes which constitute the OpticalFlow algorithm. +/// +/// @ingroup ffxOpticalflow +typedef enum FfxOpticalflowPass +{ + FFX_OPTICALFLOW_PASS_PREPARE_LUMA = 0, + FFX_OPTICALFLOW_PASS_GENERATE_OPTICAL_FLOW_INPUT_PYRAMID, + FFX_OPTICALFLOW_PASS_GENERATE_SCD_HISTOGRAM, + FFX_OPTICALFLOW_PASS_COMPUTE_SCD_DIVERGENCE, + FFX_OPTICALFLOW_PASS_COMPUTE_OPTICAL_FLOW_ADVANCED_V5, + FFX_OPTICALFLOW_PASS_FILTER_OPTICAL_FLOW_V5, + FFX_OPTICALFLOW_PASS_SCALE_OPTICAL_FLOW_ADVANCED_V5, + + FFX_OPTICALFLOW_PASS_COUNT +} FfxOpticalflowPass; + +/// An enumeration of bit flags used when creating a +/// FfxOpticalflowContext. See FfxOpticalflowDispatchDescription. +/// +/// @ingroup ffxOpticalflow +typedef enum FfxOpticalflowInitializationFlagBits +{ + FFX_OPTICALFLOW_ENABLE_TEXTURE1D_USAGE = (1 << 0), + +} FfxOpticalflowInitializationFlagBits; + +/// A structure encapsulating the parameters required to initialize +/// FidelityFX OpticalFlow. +/// +/// @ingroup ffxOpticalflow +typedef struct FfxOpticalflowContextDescription { + + FfxInterface backendInterface; ///< A set of pointers to the backend implementation for FidelityFX SDK + uint32_t flags; ///< A collection of FfxOpticalflowInitializationFlagBits. + FfxDimensions2D resolution; +} FfxOpticalflowContextDescription; + +/// A structure encapsulating the parameters for dispatching the various passes +/// of FidelityFX Opticalflow. +/// +/// @ingroup ffxOpticalflow +typedef struct FfxOpticalflowDispatchDescription +{ + FfxCommandList commandList; ///< The FfxCommandList to record rendering commands into. + FfxResource color; ///< A FfxResource containing the input color buffer + FfxResource opticalFlowVector; ///< A FfxResource containing the output motion buffer + FfxResource opticalFlowSCD; ///< A FfxResource containing the output scene change detection buffer + bool reset; ///< A boolean value which when set to true, indicates the camera has moved discontinuously. + int backbufferTransferFunction; + FfxFloatCoords2D minMaxLuminance; +} FfxOpticalflowDispatchDescription; + +typedef struct FfxOpticalflowSharedResourceDescriptions { + + FfxCreateResourceDescription opticalFlowVector; + FfxCreateResourceDescription opticalFlowSCD; + +} FfxOpticalflowSharedResourceDescriptions; + +/// A structure encapsulating the FidelityFX OpticalFlow context. +/// +/// This sets up an object which contains all persistent internal data and +/// resources that are required by OpticalFlow. +/// +/// The FfxOpticalflowContext object should have a lifetime matching +/// your use of OpticalFlow. Before destroying the OpticalFlow context care should be taken +/// to ensure the GPU is not accessing the resources created or used by OpticalFlow. +/// It is therefore recommended that the GPU is idle before destroying OpticalFlow +/// OpticalFlow context. +/// +/// @ingroup ffxOpticalflow +typedef struct FfxOpticalflowContext +{ + uint32_t data[FFX_OPTICALFLOW_CONTEXT_SIZE]; ///< An opaque set of uint32_t which contain the data for the context. +} FfxOpticalflowContext; + + +/// Create a FidelityFX OpticalFlow context from the parameters +/// programmed to the FfxOpticalflowContextDescription structure. +/// +/// The context structure is the main object used to interact with the OpticalFlow +/// API, and is responsible for the management of the internal resources used +/// by the OpticalFlow 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 OpticalFlow's +/// frame-to-frame function. Depending on the precise configuration used when +/// creating the FfxOpticalflowContext a different set of resources and +/// pipelines might be requested via the callback functions. +/// +/// The flags included in the flags field of +/// FfxOpticalflowContext how match the configuration of your +/// application as well as the intended use of OpticalFlow. It is important that these +/// flags are set correctly (as well as a correct programmed +/// FfxOpticalflowContextDescription) to ensure correct operation. It is +/// recommended to consult the overview documentation for further details on +/// how OpticalFlow should be integerated into an application. +/// +/// When the FfxOpticalflowContext is created, you should use the +/// ffxOpticalflowContextDispatch function each frame where FSR3 +/// upscaling should be applied. See the documentation of +/// ffxOpticalflowContextDispatch for more details. +/// +/// The FfxOpticalflowContext should be destroyed when use of it is +/// completed, typically when an application is unloaded or OpticalFlow is +/// disabled by a user. To destroy the OpticalFlow context you should call +/// ffxOpticalflowContextDestroy. +/// +/// @param [out] context A pointer to a FfxOpticalflowContext structure to populate. +/// @param [in] contextDescription A pointer to a FfxOpticalflowContextDescription structure. +/// +/// @retval +/// FFX_OK The operation completed successfully. +/// @retval +/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either context or contextDescription was NULL. +/// @retval +/// FFX_ERROR_INCOMPLETE_INTERFACE The operation failed because the FfxOpticalflowContextDescription.callbacks was not fully specified. +/// @retval +/// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend. +/// +/// @ingroup ffxOpticalflow +FFX_API FfxErrorCode ffxOpticalflowContextCreate(FfxOpticalflowContext* context, FfxOpticalflowContextDescription* contextDescription); + +FFX_API FfxErrorCode ffxOpticalflowGetSharedResourceDescriptions(FfxOpticalflowContext* context, FfxOpticalflowSharedResourceDescriptions* SharedResources); + +FFX_API FfxErrorCode ffxOpticalflowContextDispatch(FfxOpticalflowContext* context, const FfxOpticalflowDispatchDescription* dispatchDescription); + +/// Destroy the FidelityFX OpticalFlow context. +/// +/// @param [out] context A pointer to a FfxOpticalflowContext structure to destroy. +/// +/// @retval +/// FFX_OK The operation completed successfully. +/// @retval +/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either context was NULL. +/// +/// @ingroup ffxOpticalflow +FFX_API FfxErrorCode ffxOpticalflowContextDestroy(FfxOpticalflowContext* context); + +#if defined(__cplusplus) +} +#endif // #if defined(__cplusplus)