FfxInterface

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

File location: sdk/include/FidelityFX/host/ffx_interface.h

Detailed description

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

This set of functions serves as an abstraction layer between FfxInterfae and the API used to implement it. While the FidelityFX SDK ships with backends for DirectX12 and Vulkan, it is possible to implement your own backend for other platforms which sit on top of your engine’s own abstraction layer. For details on the expectations of what each function should do you should refer the description of the following function pointer types:

  • FfxCreateDeviceFunc

  • FfxGetDeviceCapabilitiesFunc

  • FfxDestroyDeviceFunc

  • FfxCreateResourceFunc

  • FfxRegisterResourceFunc

  • FfxGetResourceFunc

  • FfxUnregisterResourcesFunc

  • FfxGetResourceDescriptionFunc

  • FfxDestroyResourceFunc

  • FfxCreatePipelineFunc

  • FfxDestroyPipelineFunc

  • FfxScheduleGpuJobFunc

  • FfxExecuteGpuJobsFunc

  • FfxBeginMarkerFunc

  • FfxEndMarkerFunc

  • FfxRegisterConstantBufferAllocatorFunc

Depending on the graphics API that is abstracted by the backend, it may be required that the backend is to some extent stateful. To ensure that applications retain full control to manage the memory used by the FidelityFX SDK, the scratchBuffer and scratchBufferSize fields are provided. A backend should provide a means of specifying how much scratch memory is required for its internal implementation (e.g: via a function or constant value). The application is then responsible for allocating that memory and providing it when setting up the SDK backend. Backends provided with the FidelityFX SDK do not perform dynamic memory allocations, and instead sub-allocate all memory from the scratch buffers provided.

The scratchBuffer and scratchBufferSize fields should be populated according to the requirements of each backend. For example, if using the DirectX 12 backend you should call the ffxGetScratchMemorySizeDX12 function. It is not required that custom backend implementations use a scratch buffer.

Any functional addition to this interface mandates a version bump to ensure full functionality across effects and backends.

Data fields

Type

Description

FfxGetSDKVersionFunc

fpGetSDKVersion
A callback function to query the SDK version.

FfxGetEffectGpuMemoryUsageFunc

fpGetEffectGpuMemoryUsage
A callback function to query effect Gpu memory usage.

FfxCreateBackendContextFunc

fpCreateBackendContext
A callback function to create and initialize the backend context.

FfxGetDeviceCapabilitiesFunc

fpGetDeviceCapabilities
A callback function to query device capabilites.

FfxDestroyBackendContextFunc

fpDestroyBackendContext
A callback function to destroy the backendcontext. This also dereferences the device.

FfxCreateResourceFunc

fpCreateResource
A callback function to create a resource.

FfxRegisterResourceFunc

fpRegisterResource
A callback function to register an external resource.

FfxGetResourceFunc

fpGetResource
A callback function to convert an internal resource to external resource type.

FfxUnregisterResourcesFunc

fpUnregisterResources
A callback function to unregister external resource.

FfxRegisterStaticResourceFunc

fpRegisterStaticResource
A callback function to register a static resource.

FfxGetResourceDescriptionFunc

fpGetResourceDescription
A callback function to retrieve a resource description.

FfxDestroyResourceFunc

fpDestroyResource
A callback function to destroy a resource.

FfxMapResourceFunc

fpMapResource
A callback function to map a resource.

FfxUnmapResourceFunc

fpUnmapResource
A callback function to unmap a resource.

FfxStageConstantBufferDataFunc

fpStageConstantBufferDataFunc
A callback function to copy constant buffer data into staging memory.

FfxCreatePipelineFunc

fpCreatePipeline
A callback function to create a render or compute pipeline.

FfxDestroyPipelineFunc

fpDestroyPipeline
A callback function to destroy a render or compute pipeline.

FfxScheduleGpuJobFunc

fpScheduleGpuJob
A callback function to schedule a render job.

FfxExecuteGpuJobsFunc

fpExecuteGpuJobs
A callback function to execute all queued render jobs.

FfxBreadcrumbsAllocBlockFunc

fpBreadcrumbsAllocBlock
A callback function to allocate block of memory for AMD FidelityFX Breadcrumbs Library buffer.

FfxBreadcrumbsFreeBlockFunc

fpBreadcrumbsFreeBlock
A callback function to free AMD FidelityFX Breadcrumbs Library buffer.

FfxBreadcrumbsWriteFunc

fpBreadcrumbsWrite
A callback function to write marker into AMD FidelityFX Breadcrumbs Library.

FfxBreadcrumbsPrintDeviceInfoFunc

fpBreadcrumbsPrintDeviceInfo
A callback function to print active GPU info for AMD FidelityFX Breadcrumbs Library log.

FfxSwapChainConfigureFrameGenerationFunc

fpSwapChainConfigureFrameGeneration
A callback function to configure swap chain present callback.

FfxRegisterConstantBufferAllocatorFunc

fpRegisterConstantBufferAllocator
A callback function to register a custom **Thread Safe* constant buffer allocator.*

void*

scratchBuffer
A preallocated buffer for memory utilized internally by the backend.

size_t

scratchBufferSize
Size of the buffer pointed to by “scratchBuffer“.

FfxDevice

device
A backend specific device.