# FSR2TextureTable

> The set of texture slots available for the FSR2Context. SA GraphicsDevice.ExecuteFSR2.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine.AMD](/engine/6000.6/script-reference/unityengine/amd.md)
* **Assembly:** UnityEngine.AMDModule

```csharp
public struct FSR2TextureTable
```

## Remarks

Use this struct to specify input and output textures for the FSR2 implementation.

**Note:** You must create output color texture `colorOutput` with `enableRandomWrite` parameter set to `true` when initializing the RTHandle of the texture. This is due to FSR2 passes requiring access to the resources in a compute shader

Refer to the [Input resources section in FSR2 Documentation](https://gpuopen.com/manuals/fidelityfx_sdk/fidelityfx_sdk-page_techniques_super-resolution-temporal/#id12) for more details.

Additional Resources: [AMDUnityPlugin](/engine/6000.6/script-reference/unityengine/amd/amdunityplugin.md), [GraphicsDevice](/engine/6000.6/script-reference/unityengine/amd/graphicsdevice.md), [FSR2Context](/engine/6000.6/script-reference/unityengine/amd/fsr2context.md), [FSR2CommandInitializationData](/engine/6000.6/script-reference/unityengine/amd/fsr2commandinitializationdata.md), [FSR2CommandExecutionData](/engine/6000.6/script-reference/unityengine/amd/fsr2commandexecutiondata.md)

## Examples

```csharp
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Experimental.Rendering;
using UnityEngine.AMD;

// Example HDRP custom pass 
public class CustomFSRPass : CustomPass
{
    void InitializeAMDDevice()
    {
        // device initialization code
    }
    bool HasOutputResolutionChanged(CustomPassContext ctx) 
    { 
        // detect resolution change
    }
    bool HasInputResolutionChanged(CustomPassContext ctx) 
    { 
        // detect resolution change
    }

    protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
    {
        if (amdDevice == null)
        {
            InitializeAMDDevice();
        }

        float scalingRatio = fsr2Context == null ? 1.0f : amdDevice.GetUpscaleRatioFromQualityMode(m_Quality);
        fsr2OutputColorBuffer = RTHandles.Alloc(
            new Vector2(scalingRatio, scalingRatio), 
            slices: 1, 
            dimension: TextureDimension.Tex2D,
            colorFormat: GraphicsFormat.R16G16B16A16_SFloat,
            name: "fsr2OutputColorBuffer",
            enableRandomWrite: true
        );
    }

    protected override void Execute(CustomPassContext ctx)
    {
        bool initializeFsr2Context = fsr2Context == null || HasInputResolutionChanged(ctx) || HasOutputResolutionChanged(ctx);
        if (initializeFsr2Context)
        {
            // fsr2Context initialization code
        }

        fsr2Context.executeData.enableSharpening = m_EnableSharpening ? 1 : 0;
        // populate rest of the fsr2Context.executeData


        FSR2TextureTable fsr2TextureTable = new FSR2TextureTable()
        {
            // Mandatory inputs
            colorInput = ctx.cameraColorBuffer,
            colorOutput = fsr2OutputColorBuffer,
            depth = ctx.cameraDepthBuffer,
            motionVectors = ctx.cameraMotionVectorsBuffer,

            // Optional inputs
            transparencyMask = null,
            exposureTexture = null,
            reactiveMask = null,
            biasColorMask = null
        };

        amdDevice.ExecuteFSR2(ctx.cmd, fsr2Context, fsr2TextureTable);
    }

    protected override void Cleanup()
    {
        // cleanup code
    }

    private GraphicsDevice amdDevice = null;
    private FSR2Context fsr2Context = null;
    private RTHandle fsr2OutputColorBuffer;

    [SerializeField] public float m_Sharpness = 0.92f;
    [SerializeField] public bool m_EnableSharpening = true;
    [SerializeField] public FSR2Quality m_Quality = FSR2Quality.Quality;
    FSR2Quality m_QualityBefore = FSR2Quality.Quality;
    Vector2Int m_InputTextureSize = new Vector2Int(0,0);
}
```

## Properties

| Property                                                                                                 | Description                                                                                                                                                                                                                                                                                                                                                                                             |
| -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [biasColorMask](/engine/6000.6/script-reference/unityengine/amd/fsr2texturetable/biascolormask.md)       | A mask, same size as colorInput, preferably of format R8\_UNORM that informs FSR2 of possible moving pixels. If heavy ghosting is encountered, set pixels to this mask to fix the problem. This texture is optional.                                                                                                                                                                                    |
| [colorInput](/engine/6000.6/script-reference/unityengine/amd/fsr2texturetable/colorinput.md)             | The input color buffer to upsample for [FSR2Context](/engine/6000.6/script-reference/unityengine/amd/fsr2context.md). This texture is mandatory and you must set it to a non-null value.                                                                                                                                                                                                                |
| [colorOutput](/engine/6000.6/script-reference/unityengine/amd/fsr2texturetable/coloroutput.md)           | The input color buffer to upsample for [FSR2Context](/engine/6000.6/script-reference/unityengine/amd/fsr2context.md). This texture is mandatory and you must set it to a non-null value.                                                                                                                                                                                                                |
| [depth](/engine/6000.6/script-reference/unityengine/amd/fsr2texturetable/depth.md)                       | The input depth buffer. This must be the same size as the input color buffer. This texture is mandatory and you must set it to a non-null value.                                                                                                                                                                                                                                                        |
| [exposureTexture](/engine/6000.6/script-reference/unityengine/amd/fsr2texturetable/exposuretexture.md)   | A 1x1 texture with pre-exposure values. If you do not use pre-exposure, do not set this texture. This texture is optional.                                                                                                                                                                                                                                                                              |
| [motionVectors](/engine/6000.6/script-reference/unityengine/amd/fsr2texturetable/motionvectors.md)       | The motion vectors requested by the [FSR2Context](/engine/6000.6/script-reference/unityengine/amd/fsr2context.md). Depending on the FSR2FeatureFlags specified in [FSR2Context.initData](/engine/6000.6/script-reference/unityengine/amd/fsr2context/initdata.md), this buffer can be a smaller scale or the full output resolution. This texture is mandatory and you must set it to a non-null value. |
| [reactiveMask](/engine/6000.6/script-reference/unityengine/amd/fsr2texturetable/reactivemask.md)         | Rendering mask specifying reliance on temporal information. Additional Resources: [Github documentation on reactive mask.](https://github.com/GPUOpen-Effects/FidelityFX-FSR2/tree/master#reactive-mask)                                                                                                                                                                                                |
| [transparencyMask](/engine/6000.6/script-reference/unityengine/amd/fsr2texturetable/transparencymask.md) | A transparency bit mask. This must be the same size as the input texture. This texture helps the [FSR2Context](/engine/6000.6/script-reference/unityengine/amd/fsr2context.md) with ghosting issues. This texture is optional.                                                                                                                                                                          |
