s&box docs

public class Sandbox.ComputeShader

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`.

Broader workflow and conceptual references connected to this API.

Constructors

Showing 1 constructors

public ComputeShader(string path)

Create a compute shader from the specified path.

Methods

Showing 4 methods

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

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.

Parameters

  • threadsX: The number of threads to dispatch in the X dimension. Default: 32
  • threadsY: The number of threads to dispatch in the Y dimension. Default: 32
  • threadsZ: The number of threads to dispatch in the Z dimension. Default: 32

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

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.

Parameters

  • indirectBuffer: The GPU buffer containing one or more dispatch argument entries.
  • indirectElementOffset: The index of the dispatch arguments element to use (each element = 12 bytes). Default: 0

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

Parameters

  • indirectElementOffset: Default: 0

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

Parameters

  • threadsX: Default: 32
  • threadsY: Default: 32
  • threadsZ: Default: 32

Properties

Showing 1 properties

Metadata

FieldValue
NamespaceSandbox
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.ComputeShader

On this page