# FSR2TextureTable

> The set of texture slots available for the FSR2Context and FSRUpscalerContext.

## Definition

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

```csharp
public struct FSR2TextureTable
```

## Remarks

Use this struct to specify input and output textures for FSR2, FSR3, and FSR4 upscaling.

**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 FSR passes requiring access to the resources in a compute shader.

Refer to the Input resources section in AMD's documentation for more details:

* [FSR2 - Input resources](https://gpuopen.com/manuals/fidelityfx_sdk/techniques/super-resolution-temporal/#input-resources)

* [FSR3 - Input resources](https://gpuopen.com/manuals/fsr_sdk/techniques/super-resolution-upscaler/#input-resources)

* [FSR4 - Input resources](https://gpuopen.com/manuals/fsr_sdk/techniques/super-resolution-ml/#input-resources)

Additional Resources: [AMDUnityPlugin](/engine/6000.7/script-reference/unityengine/amd/amdunityplugin.md), [GraphicsDevice](/engine/6000.7/script-reference/unityengine/amd/graphicsdevice.md), [FSR2Context](/engine/6000.7/script-reference/unityengine/amd/fsr2context.md), [FSRUpscalerContext](/engine/6000.7/script-reference/unityengine/amd/fsrupscalercontext.md), [FSR2CommandInitializationData](/engine/6000.7/script-reference/unityengine/amd/fsr2commandinitializationdata.md), [FSRUpscalerCommandInitializationData](/engine/6000.7/script-reference/unityengine/amd/fsrupscalercommandinitializationdata.md), [FSR2CommandExecutionData](/engine/6000.7/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.7/script-reference/unityengine/amd/fsr2texturetable/biascolormask.md)       | This is obsolete. Use transparencyMask instead. If both are specified, then transparencyMask is used and this is ignored.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [colorInput](/engine/6000.7/script-reference/unityengine/amd/fsr2texturetable/colorinput.md)             | The input color texture to upsample for [FSR2Context](/engine/6000.7/script-reference/unityengine/amd/fsr2context.md) or [FSRUpscalerContext](/engine/6000.7/script-reference/unityengine/amd/fsrupscalercontext.md). This texture is mandatory and you must set it to a non-null value.                                                                                                                                                                                                                                                                                                                                            |
| [colorOutput](/engine/6000.7/script-reference/unityengine/amd/fsr2texturetable/coloroutput.md)           | The output color texture. This texture is mandatory and you must set it to a non-null value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [depth](/engine/6000.7/script-reference/unityengine/amd/fsr2texturetable/depth.md)                       | The input depth texture. This must be the same size as the input color texture. This texture is mandatory and you must set it to a non-null value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [exposureTexture](/engine/6000.7/script-reference/unityengine/amd/fsr2texturetable/exposuretexture.md)   | A 1x1 texture with pre-exposure values. See [AMD's documentation](https://gpuopen.com/manuals/fsr_sdk/techniques/super-resolution-upscaler/#exposure) for details. If you do not use pre-exposure, do not set this texture. Also if there's no particular reason then it's recommended to enable auto exposure via FfxFsr2InitializationFlags or FfxApiCreateContextUpscaleFlags instead of using this texture. This texture is optional.                                                                                                                                                                                           |
| [motionVectors](/engine/6000.7/script-reference/unityengine/amd/fsr2texturetable/motionvectors.md)       | The motion vectors texture. Depending on the [FfxFsr2InitializationFlags](/engine/6000.7/script-reference/unityengine/amd/ffxfsr2initializationflags.md) specified in [\_initData](/engine/6000.7/script-reference/unityengine/amd/fsr2context/initdata.md) or [FfxApiCreateContextUpscaleFlags](/engine/6000.7/script-reference/unityengine/amd/ffxapicreatecontextupscaleflags.md) specified in [\_initData](/engine/6000.7/script-reference/unityengine/amd/fsrupscalercontext/initdata.md), this texture can have the input resolution or output resolution. This texture is mandatory and you must set it to a non-null value. |
| [reactiveMask](/engine/6000.7/script-reference/unityengine/amd/fsr2texturetable/reactivemask.md)         | A texture of format R8\_UNORM and same size as colorInput that adjusts the temporal accumulation balance. See [AMD's documentation](https://gpuopen.com/manuals/fsr_sdk/techniques/super-resolution-upscaler/#reactive-mask) for details. This texture is optional in FSR2, FSR3 and ignored in FSR4.                                                                                                                                                                                                                                                                                                                               |
| [transparencyMask](/engine/6000.7/script-reference/unityengine/amd/fsr2texturetable/transparencymask.md) | A texture of format R8\_UNORM and same size as colorInput that adjusts the pixel history protection mechanisms. See [AMD's documentation](https://gpuopen.com/manuals/fsr_sdk/techniques/super-resolution-upscaler/#transparency-and-composition-mask) for details. This texture is optional in FSR2, FSR3 and ignored in FSR4.                                                                                                                                                                                                                                                                                                     |
