ComputeShaderclass

A compute shader is a program that runs on the GPU, often with data provided to/from the CPU by means of a `Sandbox.GpuBuffer` or a `Sandbox.Texture`.

objectComputeShader
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public class Sandbox.ComputeShader

Constructors1

Showing 1 constructors

public ComputeShader(string path)PUBLICCONSTRUCTOR

Create a compute shader from the specified path.

ParameterTypeDescription
pathstring

Methods4

Showing 4 methods

public void Dispatch(int threadsX = 32, int threadsY = 32, int threadsZ = 32)PUBLIC

Dispatch this compute shader using explicit thread counts.

Note

The specified thread counts will be automatically divided by the thread group size defined in the shader to compute the final dispatch group count. When called outside a graphics context, the dispatch runs immediately. When called inside a graphics context, the dispatch runs async.

ParameterTypeDescription
threadsX = 32intThe number of threads to dispatch in the X dimension.
threadsY = 32intThe number of threads to dispatch in the Y dimension.
threadsZ = 32intThe number of threads to dispatch in the Z dimension.
Returns:void

public void DispatchIndirect(Sandbox.GpuBuffer indirectBuffer, uint indirectElementOffset = 0)PUBLIC

Dispatch this compute shader by reading thread group counts (x, y, z) from an indirect buffer of type `Sandbox.GpuBuffer.IndirectDispatchArguments`.

Note

`indirectBuffer` must be created with `Sandbox.GpuBuffer.UsageFlags.IndirectDrawArguments` and have an element size of 12 bytes. `indirectElementOffset` is an element index into `indirectBuffer`, not a byte offset. When called outside a graphics context, the dispatch runs immediately. When called inside a graphics context, the dispatch runs async.

ParameterTypeDescription
indirectBufferGpuBufferThe GPU buffer containing one or more dispatch argument entries.
indirectElementOffset = 0uintThe index of the dispatch arguments element to use (each element = 12 bytes).
Returns:void

public void DispatchIndirectWithAttributes(Sandbox.RenderAttributes attributes, Sandbox.GpuBuffer indirectBuffer, uint indirectElementOffset = 0)PUBLIC

ParameterTypeDescription
attributesRenderAttributes
indirectBufferGpuBuffer
indirectElementOffset = 0uint
Returns:void

public void DispatchWithAttributes(Sandbox.RenderAttributes attributes, int threadsX = 32, int threadsY = 32, int threadsZ = 32)PUBLIC

ParameterTypeDescription
attributesRenderAttributes
threadsX = 32int
threadsY = 32int
threadsZ = 32int
Returns:void

Properties1

Showing 1 properties

On this page