# GraphicsDevice

Class · extends [`EventHandler`](https://api.playcanvas.com/engine/classes/EventHandler.md) · category: Graphics

Source: https://github.com/playcanvas/engine/blob/b5b983982a9860d21e0c1dafb2f85f72e2c01afb/src/platform/graphics/graphics-device.js#L55

The graphics device manages the underlying graphics context. It is responsible for submitting
render state changes and graphics primitives to the hardware. A graphics device is tied to a
specific canvas HTML element. It is valid to have more than one canvas element per page and
create a new graphics device against each.

## Properties

### backBufferAntialias

```ts
backBufferAntialias: boolean = false
```

True if the back buffer should use anti-aliasing.

### canvas

```ts
readonly canvas: HTMLCanvasElement
```

The canvas DOM element that provides the underlying WebGL context used by the graphics device.

### gpuProfiler

```ts
gpuProfiler: GpuProfiler
```

The GPU profiler.

### insideRenderPass

```ts
insideRenderPass: boolean = false
```

### isHdr

```ts
isHdr: boolean = false
```

True if the back-buffer is using HDR format, which means that the browser will display the
rendered images in high dynamic range mode. This is true if the options.displayFormat is set
to [DISPLAYFORMAT_HDR](https://api.playcanvas.com/engine/variables/DISPLAYFORMAT_HDR.md) when creating the graphics device using
[createGraphicsDevice](https://api.playcanvas.com/engine/functions/createGraphicsDevice.md), and HDR is supported by the device.

### isNull

```ts
readonly isNull: boolean = false
```

True if the deviceType is Null

### isWebGL2

```ts
readonly isWebGL2: boolean = false
```

True if the deviceType is WebGL2

### isWebGPU

```ts
readonly isWebGPU: boolean = false
```

True if the deviceType is WebGPU

### maxAnisotropy

```ts
readonly maxAnisotropy: number
```

The maximum supported texture anisotropy setting.

### maxColorAttachments

```ts
readonly maxColorAttachments: number = 1
```

The maximum supported number of color buffers attached to a render target.

### maxCubeMapSize

```ts
readonly maxCubeMapSize: number
```

The maximum supported dimension of a cube map.

### maxIndirectDispatchCount

```ts
maxIndirectDispatchCount: number = 256
```

The maximum number of indirect compute dispatches that can be used within a single frame.
Used on WebGPU only. Defaults to 256.

### maxIndirectDrawCount

```ts
maxIndirectDrawCount: number = 1024
```

The maximum number of indirect draw calls that can be used within a single frame. Used on
WebGPU only. This needs to be adjusted based on the maximum number of draw calls that can
be used within a single frame. Defaults to 1024.

### maxSamples

```ts
readonly maxSamples: number = 1
```

The maximum supported number of hardware anti-aliasing samples.

### maxSubgroupSize

```ts
readonly maxSubgroupSize: number = 0
```

Maximum subgroup (warp/wavefront) size reported for the device. Zero means either the device
does not expose subgroup sizes, or the WebGPU implementation did not report the value.

### maxTextureSize

```ts
readonly maxTextureSize: number
```

The maximum supported dimension of a texture.

### maxVolumeSize

```ts
readonly maxVolumeSize: number
```

The maximum supported dimension of a 3D texture (any axis).

### minSubgroupSize

```ts
readonly minSubgroupSize: number = 0
```

Minimum subgroup (warp/wavefront) size reported for the device. Zero means either the device
does not expose subgroup sizes, or the WebGPU implementation did not report the value.

### precision

```ts
readonly precision: string
```

The highest shader precision supported by this graphics device. Can be 'hiphp', 'mediump' or
'lowp'.

### samples

```ts
readonly samples: number
```

The number of hardware anti-aliasing samples used by the frame buffer.

### scope

```ts
readonly scope: ScopeSpace
```

The scope namespace for shader attributes and variables.

### supportsClipDistances

```ts
supportsClipDistances: boolean = false
```

True if the device supports clip distances (WebGPU only). Clip distances allow you to restrict
primitives' clip volume with user-defined half-spaces in the output of vertex stage.

### supportsCompute

```ts
readonly supportsCompute: boolean = false
```

True if the device supports compute shaders.

### supportsDualSourceBlending

```ts
readonly supportsDualSourceBlending: boolean = false
```

True if the device supports dual-source blending, which allows a fragment shader to output a
secondary color used by the source 1 blend factors.

### supportsHtmlTextures

```ts
readonly supportsHtmlTextures: boolean = false
```

True if HTML elements (e.g. `<div>`) can be used as texture sources via the HTML-in-Canvas
API. When supported, an HTML element appended to a canvas with the `layoutsubtree` attribute
can be passed to [Texture#setSource](https://api.playcanvas.com/engine/classes/Texture.md#setsource) and rendered as a live texture in the 3D scene.

### supportsIndependentBlending

```ts
readonly supportsIndependentBlending: boolean = false
```

True if the device supports independent blending, which allows each color attachment of a
render target to use its own blend state and color write mask, specified using
[BlendState#setAttachment](https://api.playcanvas.com/engine/classes/BlendState.md#setattachment). When false, the state of the attachment 0 is used for all
attachments.

### supportsLinearIndexing

```ts
readonly supportsLinearIndexing: boolean = false
```

True if the device supports the WGSL `linear_indexing` extension, which provides the
`global_invocation_index` and `workgroup_index` built-in values in compute shaders. The
`requires linear_indexing;` directive is then automatically injected for compute shader
modules, and the shader define `CAPS_LINEAR_INDEXING` is set for conditional
compilation.

### supportsMultiDraw

```ts
supportsMultiDraw: boolean = true
```

True if the device supports multi-draw. This is always supported on WebGPU, and support on
WebGL2 is optional, but pretty common.

### supportsPacked4x8IntegerDotProduct

```ts
readonly supportsPacked4x8IntegerDotProduct: boolean = false
```

True if the device supports the WGSL `packed_4x8_integer_dot_product` language feature,
which exposes the DP4a-family built-in functions for 8-bit packed integer dot products:
`dot4U8Packed`, `dot4I8Packed`, and the `pack4x{I,U}8`, `pack4x{I,U}8Clamp`,
`unpack4x{I,U}8` helpers. Useful for accelerating quantized inference and similar
integer-heavy compute workloads. The `requires packed_4x8_integer_dot_product;`
directive is automatically injected into WGSL shaders when this feature is available,
and the shader define `CAPS_PACKED_4X8_INTEGER_DOT_PRODUCT` is set for conditional
compilation.

### supportsPointerCompositeAccess

```ts
readonly supportsPointerCompositeAccess: boolean = false
```

True if the device supports the WGSL `pointer_composite_access` language feature, which
provides syntactic sugar for dereferencing pointers to composite types: `p.field` and
`p[i]` may be written instead of `(*p).field` and `(*p)[i]`. The
`requires pointer_composite_access;` directive is automatically injected into WGSL
shaders when this feature is available, and the shader define
`CAPS_POINTER_COMPOSITE_ACCESS` is set for conditional compilation.

### supportsPrimitiveIndex

```ts
readonly supportsPrimitiveIndex: boolean = false
```

True if the device supports primitive index in fragment shaders (WebGPU only). When
supported, fragment shaders can access the `pcPrimitiveIndex` built-in variable which
uniquely identifies the current primitive being processed.

### supportsShaderF16

```ts
readonly supportsShaderF16: boolean = false
```

True if the device supports 16-bit floating-point types in shaders (WebGPU only). When
supported, shaders can use native WGSL types: `f16`, `vec2h`, `vec3h`, `vec4h`, `mat2x2h`,
`mat3x3h`, `mat4x4h`. For convenience, PlayCanvas also provides type aliases (`half`,
`half2`, `half3`, `half4`, `half2x2`, `half3x3`, `half4x4`) that resolve to f16 types when
supported, or fall back to f32 types when not supported.

### supportsStorageTextureRead

```ts
readonly supportsStorageTextureRead: boolean = false
```

True if the device can read from StorageTexture in the compute shader. By default, the
storage texture can be only used with the write operation.
When a shader uses this feature, add a `requires` directive to signal non-portability at the
top of the WGSL shader code. The shader define `CAPS_STORAGE_TEXTURE_READ` is set when this
capability is available.
```wgsl
requires readonly_and_readwrite_storage_textures;
```

### supportsSubgroupId

```ts
readonly supportsSubgroupId: boolean = false
```

True if the device supports the WGSL subgroup_id extension, which provides access to
`subgroup_id` and `num_subgroups` built-in values in workgroups. The `requires subgroup_id;`
directive is automatically injected into WGSL shaders when this feature is available.

### supportsSubgroups

```ts
readonly supportsSubgroups: boolean = false
```

True if the device supports subgroup operations in shaders (WebGPU only). When supported,
compute and fragment shaders can use WGSL subgroup builtins such as `subgroupBroadcast`,
`subgroupAll`, `subgroupAny`, `subgroupAdd`, `subgroupShuffle`, etc. The `enable subgroups;`
directive is automatically injected into WGSL shaders when this feature is available.

### supportsSubgroupSizeControl

```ts
readonly supportsSubgroupSizeControl: boolean = false
```

True if the device supports subgroup size control (WebGPU only). This depends on
[supportsSubgroups](https://api.playcanvas.com/engine/classes/GraphicsDevice.md#supportssubgroups) and, when available, allows a compute shader to pin its execution
to a specific subgroup size (a power of two within the [minSubgroupSize](https://api.playcanvas.com/engine/classes/GraphicsDevice.md#minsubgroupsize) to
[maxSubgroupSize](https://api.playcanvas.com/engine/classes/GraphicsDevice.md#maxsubgroupsize) range) via the WGSL `@subgroup_size` attribute. The
`subgroup-size-control` device feature is automatically requested when this is supported, and
the shader define `CAPS_SUBGROUP_SIZE_CONTROL` is set for conditional compilation.

### supportsSubgroupUniformity

```ts
readonly supportsSubgroupUniformity: boolean = false
```

True if the device supports the WGSL subgroup_uniformity extension, which allows
subgroup functionality to be considered uniform in more cases during shader compilation.
This is automatically enabled via the `enable subgroups;` directive when
[supportsSubgroups](https://api.playcanvas.com/engine/classes/GraphicsDevice.md#supportssubgroups) is true.

### supportsTextureAndSamplerLet

```ts
readonly supportsTextureAndSamplerLet: boolean = false
```

True if the device supports the WGSL `texture_and_sampler_let` language feature, which
allows assigning texture and sampler variables to `let` bindings within a WGSL shader
(preparation for bindless-style indirection patterns). The
`requires texture_and_sampler_let;` directive is automatically injected into WGSL
shaders when this feature is available, and the shader define
`CAPS_TEXTURE_AND_SAMPLER_LET` is set for conditional compilation.

### supportsTextureFormatTier1

```ts
readonly supportsTextureFormatTier1: boolean = false
```

True if the device supports WebGPU texture format tier 1 capabilities. When enabled, a wider
set of normalized texture formats can be used as render targets and storage textures.

### supportsTextureFormatTier2

```ts
readonly supportsTextureFormatTier2: boolean = false
```

True if the device supports WebGPU texture format tier 2 capabilities. This extends tier 1
and enables read-write storage access for selected texture formats.

### supportsTransientAttachments

```ts
readonly supportsTransientAttachments: boolean = false
```

True if the device supports transient ("memoryless") render target attachments (WebGPU only).
When supported, attachments that are only used within a single render pass (cleared on load
and discarded on store) can be allocated as memoryless, allowing tile-based GPUs to keep their
contents in on-chip memory and avoid VRAM allocation. See the `transientColor` /
`transientDepth` options of [RenderTarget](https://api.playcanvas.com/engine/classes/RenderTarget.md) and [createGraphicsDevice](https://api.playcanvas.com/engine/functions/createGraphicsDevice.md).

### supportsUnrestrictedPointerParameters

```ts
readonly supportsUnrestrictedPointerParameters: boolean = false
```

True if the device supports the WGSL `unrestricted_pointer_parameters` language feature,
which allows passing pointers in the `storage`, `uniform`, and `workgroup` address spaces
as function arguments. The `requires unrestricted_pointer_parameters;` directive is
automatically injected into WGSL shaders when this feature is available, and the shader
define `CAPS_UNRESTRICTED_POINTER_PARAMETERS` is set for conditional compilation.

### textureFloatBlendable

```ts
readonly textureFloatBlendable: boolean = false
```

True if blending can be used when rendering to 32-bit floating-point render targets. Note that
16-bit floating-point render targets are always blendable when they are renderable.

### textureFloatFilterable

```ts
readonly textureFloatFilterable: boolean = false
```

True if filtering can be applied when sampling float textures.

### textureFloatRenderable

```ts
readonly textureFloatRenderable: boolean
```

True if 32-bit floating-point textures can be used as a frame buffer.

### textureHalfFloatRenderable

```ts
readonly textureHalfFloatRenderable: boolean
```

True if 16-bit floating-point textures can be used as a frame buffer.

### textureRG11B10Renderable

```ts
readonly textureRG11B10Renderable: boolean = false
```

True if small-float textures with format [PIXELFORMAT_111110F](https://api.playcanvas.com/engine/variables/PIXELFORMAT_111110F.md) can be used as a frame
buffer. This is always true on WebGL2, but optional on WebGPU device.

## Accessors

### deviceType

```ts
get deviceType(): "webgl2" | "webgpu"
```

Gets the type of the device. Can be:

- [DEVICETYPE_WEBGL2](https://api.playcanvas.com/engine/variables/DEVICETYPE_WEBGL2.md)
- [DEVICETYPE_WEBGPU](https://api.playcanvas.com/engine/variables/DEVICETYPE_WEBGPU.md)

### fullscreen

```ts
get fullscreen(): boolean
set fullscreen(fullscreen: boolean)
```

Gets whether the device is currently in fullscreen mode.

### height

```ts
get height(): number
```

Height of the back buffer in pixels.

### indirectDispatchBuffer

```ts
get indirectDispatchBuffer(): StorageBuffer | null
```

Returns the buffer used to store arguments for indirect compute dispatch calls. The size of
the buffer is controlled by the [maxIndirectDispatchCount](https://api.playcanvas.com/engine/classes/GraphicsDevice.md#maxindirectdispatchcount) property. This buffer can
be passed to a [Compute](https://api.playcanvas.com/engine/classes/Compute.md) shader along with a slot obtained by calling
[getIndirectDispatchSlot](https://api.playcanvas.com/engine/classes/GraphicsDevice.md#getindirectdispatchslot), in order to prepare indirect dispatch parameters.

Only available on WebGPU, returns null on other platforms.

### indirectDrawBuffer

```ts
get indirectDrawBuffer(): StorageBuffer | null
```

Returns the buffer used to store arguments for indirect draw calls. The size of the buffer is
controlled by the [maxIndirectDrawCount](https://api.playcanvas.com/engine/classes/GraphicsDevice.md#maxindirectdrawcount) property. This buffer can be passed to a
[Compute](https://api.playcanvas.com/engine/classes/Compute.md) shader along with a slot obtained by calling [getIndirectDrawSlot](https://api.playcanvas.com/engine/classes/GraphicsDevice.md#getindirectdrawslot), in
order to prepare indirect draw parameters. Also see [MeshInstance#setIndirect](https://api.playcanvas.com/engine/classes/MeshInstance.md#setindirect).

Only available on WebGPU, returns null on other platforms.

### maxPixelRatio

```ts
get maxPixelRatio(): number
set maxPixelRatio(ratio: number)
```

Gets the maximum pixel ratio.

### width

```ts
get width(): number
```

Width of the back buffer in pixels.

## Methods

### computeDispatch

```ts
computeDispatch(computes: Compute[], name?: string): void
```

Dispatch multiple compute shaders inside a single compute shader pass.

**Parameters**

- `computes` ([`Compute`](https://api.playcanvas.com/engine/classes/Compute.md)`[]`): An array of compute shaders to dispatch.
- `name` (`string`, optional, default `'Unnamed'`): The name of the dispatch, used for debugging and reporting only.

### destroy

```ts
destroy(): void
```

Destroy the graphics device.

### getIndirectDispatchSlot

```ts
getIndirectDispatchSlot(count?: number): number
```

Retrieves the first available slot in the [indirectDispatchBuffer](https://api.playcanvas.com/engine/classes/GraphicsDevice.md#indirectdispatchbuffer) used for indirect
compute dispatch, which can be utilized by a [Compute](https://api.playcanvas.com/engine/classes/Compute.md) shader to generate indirect
dispatch parameters for another compute shader.

When reserving multiple consecutive slots, specify the optional `count` parameter.

**Parameters**

- `count` (`number`, optional, default `1`): Number of consecutive slots to reserve. Defaults to 1.

**Returns** `number`: - The first reserved slot index used for indirect dispatch.

### getIndirectDrawSlot

```ts
getIndirectDrawSlot(count?: number): number
```

Retrieves the first available slot in the [indirectDrawBuffer](https://api.playcanvas.com/engine/classes/GraphicsDevice.md#indirectdrawbuffer) used for indirect
rendering, which can be utilized by a [Compute](https://api.playcanvas.com/engine/classes/Compute.md) shader to generate indirect draw
parameters and by [MeshInstance#setIndirect](https://api.playcanvas.com/engine/classes/MeshInstance.md#setindirect) to configure indirect draw calls.

When reserving multiple consecutive slots, specify the optional `count` parameter.

**Parameters**

- `count` (`number`, optional, default `1`): Number of consecutive slots to reserve. Defaults to 1.

**Returns** `number`: - The first reserved slot index used for indirect rendering.

### getRenderableHdrFormat

```ts
getRenderableHdrFormat(formats?: number[], filterable?: boolean, samples?: number, blendable?: boolean): number | undefined
```

Get a renderable HDR pixel format supported by the graphics device.

Note:

- When the `filterable` parameter is set to false, this function returns one of the supported
formats on the majority of devices apart from some very old iOS and Android devices (99%).
- When the `filterable` parameter is set to true, the function returns a format on a
considerably lower number of devices (70%).
- Support is determined by the precision of a format and not by its number of channels, and so
all the half float formats are supported wherever any of them is, and similarly for the 32bit
float formats.

**Parameters**

- `formats` (`number[]`, optional): An array of pixel formats to check for support. Can contain:

  - [PIXELFORMAT_111110F](https://api.playcanvas.com/engine/variables/PIXELFORMAT_111110F.md)
  - [PIXELFORMAT_R16F](https://api.playcanvas.com/engine/variables/PIXELFORMAT_R16F.md)
  - [PIXELFORMAT_R32F](https://api.playcanvas.com/engine/variables/PIXELFORMAT_R32F.md)
  - [PIXELFORMAT_RG16F](https://api.playcanvas.com/engine/variables/PIXELFORMAT_RG16F.md)
  - [PIXELFORMAT_RG32F](https://api.playcanvas.com/engine/variables/PIXELFORMAT_RG32F.md)
  - [PIXELFORMAT_RGBA16F](https://api.playcanvas.com/engine/variables/PIXELFORMAT_RGBA16F.md)
  - [PIXELFORMAT_RGBA32F](https://api.playcanvas.com/engine/variables/PIXELFORMAT_RGBA32F.md)

  Any other format in the array is skipped, allowing a non-HDR format to be included in the
  list and handled by the caller's own fallback.
- `filterable` (`boolean`, optional, default `true`): If true, the format also needs to be filterable, allowing it
  to be sampled with linear filtering. Defaults to true.
- `samples` (`number`, optional, default `1`): The number of samples to check for. Some formats are not
  compatible with multi-sampling, for example [PIXELFORMAT_RGBA32F](https://api.playcanvas.com/engine/variables/PIXELFORMAT_RGBA32F.md) on WebGPU platform.
  Defaults to 1.
- `blendable` (`boolean`, optional, default `false`): If true, the format also needs to be blendable, allowing it to
  be used as a blended render target attachment. This is an independent capability to
  filtering, and only the 32bit float formats can fail to support it. Defaults to false.

**Returns** `number | undefined`: The first supported renderable HDR format or undefined if none is
supported.

### getRenderTarget

```ts
getRenderTarget(): RenderTarget
```

Queries the currently set render target on the device.

**Returns** [`RenderTarget`](https://api.playcanvas.com/engine/classes/RenderTarget.md): The current render target.

**Example**

```ts
// Get the current render target
const renderTarget = device.getRenderTarget();
```

### postInit

```ts
postInit(): void
```

Function that executes after the device has been created.

### setBlendColor

```ts
setBlendColor(r: number, g: number, b: number, a: number): void
```

Sets the constant blend color and alpha values used with [BLENDMODE_CONSTANT](https://api.playcanvas.com/engine/variables/BLENDMODE_CONSTANT.md) and
[BLENDMODE_ONE_MINUS_CONSTANT](https://api.playcanvas.com/engine/variables/BLENDMODE_ONE_MINUS_CONSTANT.md) factors specified in [BlendState](https://api.playcanvas.com/engine/classes/BlendState.md). Defaults to
[0, 0, 0, 0].

**Parameters**

- `r` (`number`): The value for red.
- `g` (`number`): The value for green.
- `b` (`number`): The value for blue.
- `a` (`number`): The value for alpha.

### setBlendState

```ts
setBlendState(blendState: BlendState): void
```

Sets the specified blend state.

**Parameters**

- `blendState` ([`BlendState`](https://api.playcanvas.com/engine/classes/BlendState.md)): New blend state.

### setCullMode

```ts
setCullMode(cullMode: number): void
```

Controls how triangles are culled based on their face direction. The default cull mode is
[CULLFACE_BACK](https://api.playcanvas.com/engine/variables/CULLFACE_BACK.md).

**Parameters**

- `cullMode` (`number`): The cull mode to set. Can be:

  - [CULLFACE_NONE](https://api.playcanvas.com/engine/variables/CULLFACE_NONE.md)
  - [CULLFACE_BACK](https://api.playcanvas.com/engine/variables/CULLFACE_BACK.md)
  - [CULLFACE_FRONT](https://api.playcanvas.com/engine/variables/CULLFACE_FRONT.md)

### setDepthState

```ts
setDepthState(depthState: DepthState): void
```

Sets the specified depth state.

**Parameters**

- `depthState` ([`DepthState`](https://api.playcanvas.com/engine/classes/DepthState.md)): New depth state.

### setDrawStates

```ts
setDrawStates(blendState?: BlendState, depthState?: DepthState, cullMode?: number, frontFace?: number, stencilFront?: StencilParameters, stencilBack?: StencilParameters): void
```

Sets all draw-related render states in a single call. All parameters have sensible defaults
for utility rendering (full-screen quads, particles, etc.), so calling `setDrawStates()` with
no arguments resets to a safe baseline.

**Parameters**

- `blendState` ([`BlendState`](https://api.playcanvas.com/engine/classes/BlendState.md), optional, default `BlendState.NOBLEND`): Blend state. Defaults to [BlendState.NOBLEND](https://api.playcanvas.com/engine/classes/BlendState.md#noblend).
- `depthState` ([`DepthState`](https://api.playcanvas.com/engine/classes/DepthState.md), optional, default `DepthState.NODEPTH`): Depth state. Defaults to [DepthState.NODEPTH](https://api.playcanvas.com/engine/classes/DepthState.md#nodepth).
- `cullMode` (`number`, optional, default `CULLFACE_NONE`): Cull mode. Defaults to [CULLFACE_NONE](https://api.playcanvas.com/engine/variables/CULLFACE_NONE.md).
- `frontFace` (`number`, optional, default `FRONTFACE_CCW`): Front face winding. Defaults to [FRONTFACE_CCW](https://api.playcanvas.com/engine/variables/FRONTFACE_CCW.md).
- `stencilFront` ([`StencilParameters`](https://api.playcanvas.com/engine/classes/StencilParameters.md), optional): Front stencil parameters.
- `stencilBack` ([`StencilParameters`](https://api.playcanvas.com/engine/classes/StencilParameters.md), optional): Back stencil parameters.

### setFrontFace

```ts
setFrontFace(frontFace: number): void
```

Controls whether polygons are front- or back-facing by setting a winding
orientation. The default frontFace is [FRONTFACE_CCW](https://api.playcanvas.com/engine/variables/FRONTFACE_CCW.md).

**Parameters**

- `frontFace` (`number`): The front face to set. Can be:

  - [FRONTFACE_CW](https://api.playcanvas.com/engine/variables/FRONTFACE_CW.md)
  - [FRONTFACE_CCW](https://api.playcanvas.com/engine/variables/FRONTFACE_CCW.md)

### setRenderTarget

```ts
setRenderTarget(renderTarget: RenderTarget | null): void
```

Sets the specified render target on the device. If null is passed as a parameter, the back
buffer becomes the current target for all rendering operations.

**Parameters**

- `renderTarget` ([`RenderTarget`](https://api.playcanvas.com/engine/classes/RenderTarget.md) `| null`): The render target to activate.

**Example**

```ts
// Set a render target to receive all rendering output
device.setRenderTarget(renderTarget);

// Set the back buffer to receive all rendering output
device.setRenderTarget(null);
```

### setStencilState

```ts
setStencilState(stencilFront?: StencilParameters, stencilBack?: StencilParameters): void
```

Sets the specified stencil state. If both stencilFront and stencilBack are null, stencil
operation is disabled.

**Parameters**

- `stencilFront` ([`StencilParameters`](https://api.playcanvas.com/engine/classes/StencilParameters.md), optional): The front stencil parameters. Defaults to
  [StencilParameters.DEFAULT](https://api.playcanvas.com/engine/classes/StencilParameters.md#default) if not specified.
- `stencilBack` ([`StencilParameters`](https://api.playcanvas.com/engine/classes/StencilParameters.md), optional): The back stencil parameters. Defaults to
  [StencilParameters.DEFAULT](https://api.playcanvas.com/engine/classes/StencilParameters.md#default) if not specified.

### validateAttributes

```ts
protected validateAttributes(shader: Shader, vertexBuffers: (VertexBuffer | null | undefined)[]): void
```

Validate that all attributes required by the shader are present in the currently assigned
vertex buffers.

**Parameters**

- `shader` ([`Shader`](https://api.playcanvas.com/engine/classes/Shader.md)): The shader to validate.
- `vertexBuffers` (`(`[`VertexBuffer`](https://api.playcanvas.com/engine/classes/VertexBuffer.md) `| null | undefined)[]`): The vertex buffers of the draw.

## Inherited from [EventHandler](https://api.playcanvas.com/engine/classes/EventHandler.md)

- `fire(name: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any, arg6?: any, arg7?: any, arg8?: any): EventHandler`
- `hasEvent(name: string): boolean`
- `off(name?: string, callback?: HandleEventCallback, scope?: any): EventHandler`
- `on(name: string, callback: HandleEventCallback, scope?: any): EventHandle`
- `once(name: string, callback: HandleEventCallback, scope?: any): EventHandle`
