Table of Contents

Struct ComputeShaderKernel

A light wrapper for a compute shader kernel.

public readonly struct ComputeShaderKernel

Constructors

ComputeShaderKernel(ComputeShader, string)

public ComputeShaderKernel(ComputeShader shader, string name)

Parameters

shader ComputeShader
name string

Fields

KernelIndex

The index of the kernel.

public readonly int KernelIndex

Field Value

int

ThreadGroupSizes

The thread group sizes of the kernel as defined in its numthreads attribute.

public readonly (uint x, uint y, uint z) ThreadGroupSizes

Field Value

(uint x, uint y, uint z)

Methods

Dispatch(int, int, int)

Dispatches the shader kernel.

public void Dispatch(int threadsX, int threadsY = 1, int threadsZ = 1)

Parameters

threadsX int

The total threads for computation in the X dimension.

threadsY int

The total threads for computation in the Y dimension.

threadsZ int

The total threads for computation in the Z dimension.

Dispatch(Vector3Int)

Dispatches the shader kernel.

public void Dispatch(Vector3Int threads)

Parameters

threads Vector3Int

The total threads for computation in 3 dimensions.

SetBuffer(int, ComputeBuffer)

Sets a buffer for the kernel.

public void SetBuffer(int id, ComputeBuffer buffer)

Parameters

id int

The parameter ID of the buffer as defined in the shader.

buffer ComputeBuffer

The buffer to set.

SetBuffer(int, GraphicsBuffer)

public void SetBuffer(int id, GraphicsBuffer buffer)

Parameters

id int
buffer GraphicsBuffer

SetTexture(int, Texture)

Sets a texture for the kernel.

public void SetTexture(int id, Texture texture)

Parameters

id int

The parameter ID of the texture as defined in the shader.

texture Texture

The texture to set.