FfxInterface

FidelityFX SDK function signatures and core defines requiring overrides for backend implementation.

Typedefs

Type

Description

typedef uint32_t

Stand in type for FfxPass.

typedef FfxVersionNumber

(*FfxGetSDKVersionFunc )(FfxInterface *backendInterface)
Get the SDK version of the backend context.

typedef FfxErrorCode

(*FfxGetEffectGpuMemoryUsageFunc )( FfxInterface *backendInterface, FfxUInt32 effectContextId, FfxEffectMemoryUsage *outVramUsage )
Get effect VRAM usage.

typedef FfxErrorCode

(*FfxCreateBackendContextFunc )( FfxInterface *backendInterface, FfxEffect effect, FfxEffectBindlessConfig *bindlessConfig, FfxUInt32 *effectContextId )
Create and initialize the backend context.

typedef FfxErrorCode

(*FfxGetDeviceCapabilitiesFunc )( FfxInterface *backendInterface, FfxDeviceCapabilities *outDeviceCapabilities )
Get a list of capabilities of the device.

typedef FfxErrorCode

(*FfxDestroyBackendContextFunc )( FfxInterface *backendInterface, FfxUInt32 effectContextId )
Destroy the backend context and dereference the device.

typedef FfxErrorCode

(*FfxCreateResourceFunc )( FfxInterface *backendInterface, const FfxCreateResourceDescription *createResourceDescription, FfxUInt32 effectContextId, FfxResourceInternal *outResource )
Create a resource.

typedef FfxErrorCode

(*FfxRegisterResourceFunc )( FfxInterface *backendInterface, const FfxResource *inResource, FfxUInt32 effectContextId, FfxResourceInternal *outResource )
Register a resource in the backend for the current frame.

typedef FfxResource

(*FfxGetResourceFunc )( FfxInterface *backendInterface, FfxResourceInternal resource )
Get an FfxResource from an FfxResourceInternal resource.

typedef FfxErrorCode

(*FfxUnregisterResourcesFunc )( FfxInterface *backendInterface, FfxCommandList commandList, FfxUInt32 effectContextId )
Unregister all temporary FfxResourceInternal from the backend.

typedef FfxErrorCode

(*FfxRegisterStaticResourceFunc )( FfxInterface *backendInterface, const FfxStaticResourceDescription *desc, FfxUInt32 effectContextId )
Register a resource in the static bindless table of the backend.

typedef FfxResourceDescription

(*FfxGetResourceDescriptionFunc )( FfxInterface *backendInterface, FfxResourceInternal resource )
Retrieve a “FfxResourceDescription“ matching a “FfxResource“ structure.

typedef FfxErrorCode

(*FfxDestroyResourceFunc )( FfxInterface *backendInterface, FfxResourceInternal resource, FfxUInt32 effectContextId )
Destroy a resource.

typedef FfxErrorCode

(*FfxMapResourceFunc )( FfxInterface *backendInterface, FfxResourceInternal resource, void **ptr )
Map resource memory.

typedef FfxErrorCode

(*FfxUnmapResourceFunc )( FfxInterface *backendInterface, FfxResourceInternal resource )
Unmap resource memory.

typedef FfxErrorCode

(*FfxStageConstantBufferDataFunc )( FfxInterface *backendInterface, void *data, FfxUInt32 size, FfxConstantBuffer *constantBuffer )
Destroy a resource.

typedef FfxErrorCode

(*FfxCreatePipelineFunc )( FfxInterface *backendInterface, FfxEffect effect, FfxPass pass, uint32_t permutationOptions, const FfxPipelineDescription *pipelineDescription, FfxUInt32 effectContextId, FfxPipelineState *outPipeline )
Create a render pipeline.

typedef FfxErrorCode

(*FfxDestroyPipelineFunc )( FfxInterface *backendInterface, FfxPipelineState *pipeline, FfxUInt32 effectContextId )
Destroy a render pipeline.

typedef FfxErrorCode

(*FfxScheduleGpuJobFunc )( FfxInterface *backendInterface, const FfxGpuJobDescription *job )
Schedule a render job to be executed on the next call of “FfxExecuteGpuJobsFunc“.

typedef FfxErrorCode

(*FfxExecuteGpuJobsFunc )( FfxInterface *backendInterface, FfxCommandList commandList, FfxUInt32 effectContextId )
Execute scheduled render jobs on the “comandList“ provided.

typedef FfxErrorCode

(*FfxBreadcrumbsAllocBlockFunc )( FfxInterface *backendInterface, uint64_t blockBytes, FfxBreadcrumbsBlockData *blockData )
Allocate AMD FidelityFX Breadcrumbs Library markers buffer.

typedef void

(*FfxBreadcrumbsFreeBlockFunc )( FfxInterface *backendInterface, FfxBreadcrumbsBlockData *blockData )
Deallocate AMD FidelityFX Breadcrumbs Library markers buffer.

typedef void

(*FfxBreadcrumbsWriteFunc )( FfxInterface *backendInterface, FfxCommandList commandList, uint32_t value, uint64_t gpuLocation, void *gpuBuffer, bool isBegin )
Write marker to AMD FidelityFX Breadcrumbs Library buffer on the “comandList“ provided.

typedef void

(*FfxBreadcrumbsPrintDeviceInfoFunc )( FfxInterface *backendInterface, FfxAllocationCallbacks *allocs, bool extendedInfo, char **printBuffer, size_t *printSize )
Printing GPU specific info to the AMD FidelityFX Breadcrumbs Library status buffer.

typedef void

(*FfxRegisterConstantBufferAllocatorFunc )( FfxInterface *backendInterface, FfxConstantBufferAllocator constantAllocator )
Register a **Thread Safe* constant buffer allocator to be used by the backend.*

Structs

Name

Description

FfxFrameGenerationConfig

A structure representing the configuration options to pass to FfxFrameInterpolation.

FfxInterface

A structure encapsulating the interface between the core implementation of the FfxInterface and any graphics API that it should ultimately call.

Macros

Name

Description

FFX_SDK_MAKE_VERSION (major, minor, patch) ( ( major << 22 ) | ( minor << 12 ) | patch )

Macro to pack a FidelityFX SDK version id together.

FFX_SDK_VERSION_MAJOR (1)

FidelityFX SDK major version.

FFX_SDK_VERSION_MINOR (1)

FidelityFX SDK minor version.

FFX_SDK_VERSION_PATCH (1)

FidelityFX SDK patch version.

Detailed description

FidelityFX SDK function signatures and core defines requiring overrides for backend implementation.

Typedefs

FfxPass

Copied!

typedef uint32_t FfxPass

Stand in type for FfxPass.

These will be defined for each effect individually (i.e. FfxFsr2Pass). They are used to fetch the proper blob index to build effect shaders


FfxGetSDKVersionFunc

Copied!

typedef FfxVersionNumber  (*FfxGetSDKVersionFunc )(FfxInterface *backendInterface)

Get the SDK version of the backend context.

Parameters:

backendInterface

A pointer to the backend interface.

Returns:

The SDK version a backend was built with.


FfxGetEffectGpuMemoryUsageFunc

Copied!

typedef FfxErrorCode  (*FfxGetEffectGpuMemoryUsageFunc )(
    FfxInterface *backendInterface,
    FfxUInt32 effectContextId,
    FfxEffectMemoryUsage *outVramUsage
    )

Get effect VRAM usage.

Newer effects may require support that legacy versions of the SDK will not be able to provide. A version query is thus required to ensure an effect component will always be paired with a backend which will support all needed functionality.

Parameters:

backendInterface

A pointer to the backend interface.

effectContextId

The context space to be used for the effect in question.

outVramUsage

The effect memory usage structure to fill out.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxCreateBackendContextFunc

Copied!

typedef FfxErrorCode  (*FfxCreateBackendContextFunc )(
    FfxInterface *backendInterface,
    FfxEffect effect,
    FfxEffectBindlessConfig *bindlessConfig,
    FfxUInt32 *effectContextId
    )

Create and initialize the backend context.

The callback function sets up the backend context for rendering. It will create or reference the device and create required internal data structures.

Parameters:

backendInterface

A pointer to the backend interface.

effect

The effect the context is being created for

bindlessConfig

A pointer to the bindless configuration, if required by the effect.

effectContextId

The context space to be used for the effect in question.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxGetDeviceCapabilitiesFunc

Copied!

typedef FfxErrorCode  (*FfxGetDeviceCapabilitiesFunc )(
    FfxInterface *backendInterface,
    FfxDeviceCapabilities *outDeviceCapabilities
    )

Get a list of capabilities of the device.

When creating an FfxEffectContext it is desirable for the FFX core implementation to be aware of certain characteristics of the platform that is being targetted. This is because some optimizations which FFX SDK attempts to perform are more effective on certain classes of hardware than others, or are not supported by older hardware. In order to avoid cases where optimizations actually have the effect of decreasing performance, or reduce the breadth of support provided by FFX SDK, the FFX interface queries the capabilities of the device to make such decisions.

For target platforms with fixed hardware support you need not implement this callback function by querying the device, but instead may hardcore what features are available on the platform.

Parameters:

backendInterface

A pointer to the backend interface.

outDeviceCapabilities

The device capabilities structure to fill out.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxDestroyBackendContextFunc

Copied!

typedef FfxErrorCode  (*FfxDestroyBackendContextFunc )(
    FfxInterface *backendInterface,
    FfxUInt32 effectContextId
    )

Destroy the backend context and dereference the device.

This function is called when the FfxEffectContext is destroyed.

Parameters:

backendInterface

A pointer to the backend interface.

effectContextId

The context space to be used for the effect in question.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxCreateResourceFunc

Copied!

typedef FfxErrorCode  (*FfxCreateResourceFunc )(
    FfxInterface *backendInterface,
    const FfxCreateResourceDescription *createResourceDescription,
    FfxUInt32 effectContextId,
    FfxResourceInternal *outResource
    )

Create a resource.

This callback is intended for the backend to create internal resources.

Please note: It is also possible that the creation of resources might itself cause additional resources to be created by simply calling the FfxCreateResourceFunc function pointer again. This is useful when handling the initial creation of resources which must be initialized. The flow in such a case would be an initial call to create the CPU-side resource, another to create the GPU-side resource, and then a call to schedule a copy render job to move the data between the two. Typically this type of function call flow is only seen during the creation of an FfxEffectContext.

Parameters:

backendInterface

A pointer to the backend interface.

createResourceDescription

A pointer to a FfxCreateResourceDescription.

effectContextId

The context space to be used for the effect in question.

outResource

A pointer to a FfxResource object.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxRegisterResourceFunc

Copied!

typedef FfxErrorCode  (*FfxRegisterResourceFunc )(
    FfxInterface *backendInterface,
    const FfxResource *inResource,
    FfxUInt32 effectContextId,
    FfxResourceInternal *outResource
    )

Register a resource in the backend for the current frame.

Since the FfxInterface and the backends are not aware how many different resources will get passed in over time, it’s not safe to register all resources simultaneously in the backend. Also passed resources may not be valid after the dispatch call. As a result it’s safest to register them as FfxResourceInternal and clear them at the end of the dispatch call.

Parameters:

backendInterface

A pointer to the backend interface.

inResource

A pointer to a FfxResource.

effectContextId

The context space to be used for the effect in question.

outResource

A pointer to a FfxResourceInternal object.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxGetResourceFunc

Copied!

typedef FfxResource  (*FfxGetResourceFunc )(
    FfxInterface *backendInterface,
    FfxResourceInternal resource
    )

Get an FfxResource from an FfxResourceInternal resource.

At times it is necessary to create an FfxResource representation of an internally created resource in order to register it with a child effect context. This function sets up the FfxResource needed to register.

Parameters:

backendInterface

A pointer to the backend interface.

resource

The FfxResourceInternal for which to setup an FfxResource.

Returns:

An FfxResource built from the internal resource


FfxUnregisterResourcesFunc

Copied!

typedef FfxErrorCode  (*FfxUnregisterResourcesFunc )(
    FfxInterface *backendInterface,
    FfxCommandList commandList,
    FfxUInt32 effectContextId
    )

Unregister all temporary FfxResourceInternal from the backend.

Unregister FfxResourceInternal referencing resources passed to a function as a parameter.

Parameters:

backendInterface

A pointer to the backend interface.

commandList

A pointer to a FfxCommandList structure.

effectContextId

The context space to be used for the effect in question.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxRegisterStaticResourceFunc

Copied!

typedef FfxErrorCode  (*FfxRegisterStaticResourceFunc )(
    FfxInterface *backendInterface,
    const FfxStaticResourceDescription *desc,
    FfxUInt32 effectContextId
    )

Register a resource in the static bindless table of the backend.

A static resource will persist in their respective bindless table until it is overwritten by a different resource at the same index. The calling code must take care not to immediately register a new resource at an index that might be in use by an in-flight frame.

Parameters:

backendInterface

A pointer to the backend interface.

desc

A pointer to an FfxStaticResourceDescription.

effectContextId

The context space to be used for the effect in question.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxGetResourceDescriptionFunc

Copied!

typedef FfxResourceDescription  (*FfxGetResourceDescriptionFunc )(
    FfxInterface *backendInterface,
    FfxResourceInternal resource
    )

Retrieve a FfxResourceDescription matching a FfxResource structure.

Parameters:

backendInterface

A pointer to the backend interface.

resource

A pointer to a FfxResource object.

Returns:

A description of the resource.


FfxDestroyResourceFunc

Copied!

typedef FfxErrorCode  (*FfxDestroyResourceFunc )(
    FfxInterface *backendInterface,
    FfxResourceInternal resource,
    FfxUInt32 effectContextId
    )

Destroy a resource.

This callback is intended for the backend to release an internal resource.

Parameters:

backendInterface

A pointer to the backend interface.

resource

A pointer to a FfxResource object.

effectContextId

The context space to be used for the effect in question.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxMapResourceFunc

Copied!

typedef FfxErrorCode  (*FfxMapResourceFunc )(
    FfxInterface *backendInterface,
    FfxResourceInternal resource,
    void **ptr
    )

Map resource memory.

Maps the memory of the resource to a pointer and returns it.

Parameters:

backendInterface

A pointer to the backend interface.

resource

A pointer to a FfxResource object.

ptr

A pointer to the mapped memory.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxUnmapResourceFunc

Copied!

typedef FfxErrorCode  (*FfxUnmapResourceFunc )(
    FfxInterface *backendInterface,
    FfxResourceInternal resource
    )

Unmap resource memory.

Unmaps previously mapped memory of a resource.

Parameters:

backendInterface

A pointer to the backend interface.

resource

A pointer to a FfxResource object.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxStageConstantBufferDataFunc

Copied!

typedef FfxErrorCode  (*FfxStageConstantBufferDataFunc )(
    FfxInterface *backendInterface,
    void *data,
    FfxUInt32 size,
    FfxConstantBuffer *constantBuffer
    )

Destroy a resource.

This callback is intended for the backend to release an internal resource.

Parameters:

backendInterface

A pointer to the backend interface.

resource

A pointer to a FfxResource object.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxCreatePipelineFunc

Copied!

typedef FfxErrorCode  (*FfxCreatePipelineFunc )(
    FfxInterface *backendInterface,
    FfxEffect effect,
    FfxPass pass,
    uint32_t permutationOptions,
    const FfxPipelineDescription *pipelineDescription,
    FfxUInt32 effectContextId,
    FfxPipelineState *outPipeline
    )

Create a render pipeline.

A rendering pipeline contains the shader as well as resource bindpoints and samplers.

Parameters:

backendInterface

A pointer to the backend interface.

pass

The identifier for the pass.

pipelineDescription

A pointer to a FfxPipelineDescription describing the pipeline to be created.

effectContextId

The context space to be used for the effect in question.

outPipeline

A pointer to a FfxPipelineState structure which should be populated.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxDestroyPipelineFunc

Copied!

typedef FfxErrorCode  (*FfxDestroyPipelineFunc )(
    FfxInterface *backendInterface,
    FfxPipelineState *pipeline,
    FfxUInt32 effectContextId
    )

Destroy a render pipeline.

Parameters:

backendInterface

A pointer to the backend interface.

effectContextId

The context space to be used for the effect in question.

pipeline

A pointer to a FfxPipelineState structure which should be released.

effectContextId

The context space to be used for the effect in question.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxScheduleGpuJobFunc

Copied!

typedef FfxErrorCode  (*FfxScheduleGpuJobFunc )(
    FfxInterface *backendInterface,
    const FfxGpuJobDescription *job
    )

Schedule a render job to be executed on the next call of FfxExecuteGpuJobsFunc.

Render jobs can perform one of three different tasks: clear, copy or compute dispatches.

Parameters:

backendInterface

A pointer to the backend interface.

job

A pointer to a FfxGpuJobDescription structure.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxExecuteGpuJobsFunc

Copied!

typedef FfxErrorCode  (*FfxExecuteGpuJobsFunc )(
    FfxInterface *backendInterface,
    FfxCommandList commandList,
    FfxUInt32 effectContextId
    )

Execute scheduled render jobs on the comandList provided.

The recording of the graphics API commands should take place in this callback function, the render jobs which were previously enqueued (via callbacks made to FfxScheduleGpuJobFunc) should be processed in the order they were received. Advanced users might choose to reorder the rendering jobs, but should do so with care to respect the resource dependencies.

Depending on the precise contents of FfxDispatchDescription a different number of render jobs might have previously been enqueued (for example if sharpening is toggled on and off).

Parameters:

backendInterface

A pointer to the backend interface.

commandList

A pointer to a FfxCommandList structure.

effectContextId

The context space to be used for the effect in question.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxBreadcrumbsAllocBlockFunc

Copied!

typedef FfxErrorCode  (*FfxBreadcrumbsAllocBlockFunc )(
    FfxInterface *backendInterface,
    uint64_t blockBytes,
    FfxBreadcrumbsBlockData *blockData
    )

Allocate AMD FidelityFX Breadcrumbs Library markers buffer.

Parameters:

backendInterface

A pointer to the backend interface.

blockBytes

Size in bytes of the buffer to be allocated.

blockData

Output information about allocated AMD FidelityFX Breadcrumbs Library buffer. Filled only on success of operation.

Return values:

FFX_OK

The operation completed successfully.

Anything

else The operation failed.


FfxBreadcrumbsFreeBlockFunc

Copied!

typedef void (*FfxBreadcrumbsFreeBlockFunc )(
    FfxInterface *backendInterface,
    FfxBreadcrumbsBlockData *blockData
    )

Deallocate AMD FidelityFX Breadcrumbs Library markers buffer.

Parameters:

backendInterface

A pointer to the backend interface.

blockData

Information about buffer to be freed. All resource handles are cleared after this operation.


FfxBreadcrumbsWriteFunc

Copied!

typedef void (*FfxBreadcrumbsWriteFunc )(
    FfxInterface *backendInterface,
    FfxCommandList commandList,
    uint32_t value,
    uint64_t gpuLocation,
    void *gpuBuffer,
    bool isBegin
    )

Write marker to AMD FidelityFX Breadcrumbs Library buffer on the comandList provided.

Parameters:

backendInterface

A pointer to the backend interface.

commandList

GPU command list to record marker writing command.

value

Marker value to be written.

gpuLocation

GPU destination address where marker will be written.

gpuBuffer

Destination AMD FidelityFX Breadcrumbs Library buffer.

isBegin

true for writing opening marker and false for ending marker.


FfxBreadcrumbsPrintDeviceInfoFunc

Copied!

typedef void (*FfxBreadcrumbsPrintDeviceInfoFunc )(
    FfxInterface *backendInterface,
    FfxAllocationCallbacks *allocs,
    bool extendedInfo,
    char **printBuffer,
    size_t *printSize
    )

Printing GPU specific info to the AMD FidelityFX Breadcrumbs Library status buffer.

Parameters:

backendInterface

A pointer to the backend interface.

allocs

A pointer to the allocation callbacks.

extendedInfo

true if should print more verbose device info and false for standard output.

printBuffer

String buffer for writing GPU info.

printSize

Size of string buffer for writing GPU info.


FfxRegisterConstantBufferAllocatorFunc

Copied!

typedef void (*FfxRegisterConstantBufferAllocatorFunc )(
    FfxInterface *backendInterface,
    FfxConstantBufferAllocator constantAllocator
    )

Register a Thread Safe constant buffer allocator to be used by the backend.

Parameters:

backendInterface

A pointer to the backend interface.

constantAllocator

An FfxConstantBufferAllocator callback to be used by the backend.


Macros

FFX_SDK_MAKE_VERSION

Copied!

#define FFX_SDK_MAKE_VERSION (major, minor, patch) ( ( major << 22 ) | ( minor << 12 ) | patch )

Macro to pack a FidelityFX SDK version id together.


FFX_SDK_VERSION_MAJOR

Copied!

#define FFX_SDK_VERSION_MAJOR (1)

FidelityFX SDK major version.


FFX_SDK_VERSION_MINOR

Copied!

#define FFX_SDK_VERSION_MINOR (1)

FidelityFX SDK minor version.


FFX_SDK_VERSION_PATCH

Copied!

#define FFX_SDK_VERSION_PATCH (1)

FidelityFX SDK patch version.