IsGraphicsAPISupported
Checks whether the given shader pass supports the provided graphics API.
Read time 1 minuteLast updated 13 days ago
Definition
- Type: Method
- Namespace: UnityEditor
- Assembly: UnityEditor.CoreModule
IsGraphicsAPISupported(Shader, PassIdentifier, GraphicsDeviceType)
Checks whether the given shader pass supports the provided graphics API.
public static bool IsGraphicsAPISupported(Shader shader, in PassIdentifier passIdentifier, GraphicsDeviceType graphicsAPI)
Parameters
The shader the pass belongs to.
The identifier of the pass in the shader.
The graphics API to check against.
Returns
Type | Description |
|---|---|
| bool | If the graphics API is supported, returns true. Otherwise, returns false. |
Remarks
Use this method to check if the shader pass has a or that excludes the .
#pragma exclude_renderers#pragma only_renderersgraphicsAPIExamples
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.
public static bool IsGraphicsAPISupported(ComputeShader shader, GraphicsDeviceType graphicsAPI)
Parameters
The shader to check.
The graphics API to check against.
Returns
Type | Description |
|---|---|
| bool | If the graphics API is supported, returns true. Otherwise, returns false. |
Remarks
Use this method to check if the compute shader has a or that excludes the .
#pragma exclude_renderers#pragma only_renderersgraphicsAPIExamples
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);}