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`.
Related Guides
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.
No results match this filter.
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: 32threadsY: The number of threads to dispatch in the Y dimension. Default: 32threadsZ: 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: 32threadsY: Default: 32threadsZ: Default: 32
No results match this filter.
Properties
Showing 1 properties
public Sandbox.RenderAttributes Sandbox.ComputeShader.Attributes { get; set; }
Attributes that are passed to the compute shader on dispatch.
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox |
| Type | class |
| Assembly | Sandbox.Engine |
| Doc ID | T:Sandbox.ComputeShader |