Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

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

shader

The shader the pass belongs to.

passIdentifier

The identifier of the pass in the shader.

The graphics API to check against.

Returns

Type

Description

boolIf 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

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

boolIf 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

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);}