# IsGraphicsAPISupported

> Checks whether the given shader pass supports the provided graphics API.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.5/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

## IsGraphicsAPISupported(Shader, PassIdentifier, GraphicsDeviceType)

Checks whether the given shader pass supports the provided graphics API.

```csharp
public static bool IsGraphicsAPISupported(Shader shader, in PassIdentifier passIdentifier, GraphicsDeviceType graphicsAPI)
```

### Parameters

**** (\[Shader]\(/engine/6000.5/script-reference/unityengine/shader)): The shader the pass belongs to.**** (\[PassIdentifier]\(/engine/6000.5/script-reference/unityengine/rendering/passidentifier)): The identifier of the pass in the shader.**** (\[GraphicsDeviceType]\(/engine/6000.5/script-reference/unityengine/rendering/graphicsdevicetype)): The graphics API to check against.

### Returns

| Type                                                          | Description                                                               |
| ------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | If the graphics API is supported, returns true. Otherwise, returns false. |

### Remarks

Use this method to check if the shader pass has a `#pragma exclude_renderers` or `#pragma only_renderers` that excludes the `graphicsAPI`.

### Examples

```csharp
ComputeShader FindComputeShader()
{
    return (ComputeShader)AssetDatabase.LoadAssetAtPath("Assets/Shaders/ShaderName.compute", typeof(ComputeShader));
}

public void CheckComputeShaderSupportsD3D11()
{
    // Get a compute shader object to check
    var shader = FindComputeShader();
    // Check whether it supports D3D11
    bool supports = ShaderUtil.IsGraphicsAPISupported(shader, GraphicsDeviceType.Direct3D11);
    // Log the result
    Debug.Log("Compute shader supports D3D11: " + supports);
}
```

## IsGraphicsAPISupported(ComputeShader, GraphicsDeviceType)

Checks whether the given compute shader supports the provided graphics API.

```csharp
public static bool IsGraphicsAPISupported(ComputeShader shader, GraphicsDeviceType graphicsAPI)
```

### Parameters

**** (\[ComputeShader]\(/engine/6000.5/script-reference/unityengine/computeshader)): The shader to check.**** (\[GraphicsDeviceType]\(/engine/6000.5/script-reference/unityengine/rendering/graphicsdevicetype)): The graphics API to check against.

### Returns

| Type                                                          | Description                                                               |
| ------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | If the graphics API is supported, returns true. Otherwise, returns false. |

### Remarks

Use this method to check if the compute shader has a `#pragma exclude_renderers` or `#pragma only_renderers` that excludes the `graphicsAPI`.

### Examples

```csharp
public void CheckShaderPassSupportsD3D11()
{
    // Get a shader object to check
    var shader = Shader.Find("Custom/ShaderName");
    // Check whether the first pass of the first subshader supports D3D11
    bool supports = ShaderUtil.IsGraphicsAPISupported(shader, new PassIdentifier(0, 0), GraphicsDeviceType.Direct3D11);
    // Log the result
    Debug.Log("Shader pass supports D3D11: " + supports);
}
```
