# AMDUnityPlugin

> Provides methods to manage loading and unloading AMD module plugins.

## Definition

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

```csharp
public static class AMDUnityPlugin
```

## Remarks

`AMDUnityPlugin` contains the implementation for AMD's [FidelityFX Super Resolution 2](https://gpuopen.com/fidelityfx-superresolution-2/) (FSR2) temporal upscaler.

To access this API, follow these steps:

1. Open the **Package Manager** window
2. Go to **Built-in packages**.
3. Enable the **AMD** package.

Once enabled, the plugin is automatically loaded by Unity and becomes available for both built-in and custom FSR2 integration workflows.

**Note:** You don't need to use this API to enable FSR2 in a Unity project. For more information, refer to [HDRP Dynamic Resolution](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@17.2/manual/Dynamic-Resolution.html).

`AMDUnityPlugin` enables advanced users to access and integrate AMD's FSR2 functionality directly in custom rendering workflows. It's primarily intended for users who want to bypass the built-in engine integration available in the High Definition Render Pipeline (HDRP) and implement their own FSR2 logic, such as through a `CustomPass` or other Scriptable Render Pipeline (SRP) extensions.

When using this API manually, it's good practice to verify that the plugin is available using [AMDUnityPlugin.IsLoaded](/engine/6000.6/script-reference/unityengine/amd/amdunityplugin/isloaded.md). In case the plugin fails to load automatically (for example, the end user isn't using the native AMD package), you can load it manually using [AMDUnityPlugin.Load](/engine/6000.6/script-reference/unityengine/amd/amdunityplugin/load.md).

Additional Resources: [FSR2Context](/engine/6000.6/script-reference/unityengine/amd/fsr2context.md), [GraphicsDevice](/engine/6000.6/script-reference/unityengine/amd/graphicsdevice.md), [CommandBuffer](/engine/6000.6/script-reference/unityengine/rendering/commandbuffer.md), [ScriptableRenderContext](/engine/6000.6/script-reference/unityengine/rendering/scriptablerendercontext.md).

## Examples

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

// Example HDRP custom pass 
public class CustomFSRPass : CustomPass
{
    public static bool EnsureAMDPluginLoaded()
    {
        if (!AMDUnityPlugin.IsLoaded())
        {
            Debug.Log("AMDUnityPlugin is not loaded!");
            if (!AMDUnityPlugin.Load())
            {
                Debug.LogError("Unable to load AMDUnityPlugin");
                return false;
            }
        }

        Debug.Log("AMDUnityPlugin is successfully loaded!");
        return true;
    }

    void InitializeAMDDevice()
    {
        if (!EnsureAMDPluginLoaded())
            return;

        // device initialization code
    }

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

        // other pass setup code
    }

    protected override void Execute(CustomPassContext ctx)
    {
        // pass execution code
    }

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

    private GraphicsDevice amdDevice = null;
    // other member variables
}
```

## Static Methods

| Method                                                                                 | Description                                                                          |
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| [IsLoaded](/engine/6000.6/script-reference/unityengine/amd/amdunityplugin/isloaded.md) | Checks whether the `AMDUnityPlugin` in the AMD native module has been loaded or not. |
| [Load](/engine/6000.6/script-reference/unityengine/amd/amdunityplugin/load.md)         | Attempts to dynamically load the AMDUnityPlugin.                                     |
