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`.
Constructors1
Showing 1 constructors
public ComputeShader(string path)
Create a compute shader from the specified path.
| Parameter | Type | Description |
|---|---|---|
| path | string | — |
No results match this filter.
Methods4
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.
| Parameter | Type | Description |
|---|---|---|
| threadsX = 32 | int | The number of threads to dispatch in the X dimension. |
| threadsY = 32 | int | The number of threads to dispatch in the Y dimension. |
| threadsZ = 32 | int | The number of threads to dispatch in the Z dimension. |
void—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.
| Parameter | Type | Description |
|---|---|---|
| indirectBuffer | GpuBuffer | The GPU buffer containing one or more dispatch argument entries. |
| indirectElementOffset = 0 | uint | The index of the dispatch arguments element to use (each element = 12 bytes). |
void—public void DispatchIndirectWithAttributes(Sandbox.RenderAttributes attributes, Sandbox.GpuBuffer indirectBuffer, uint indirectElementOffset = 0)
| Parameter | Type | Description |
|---|---|---|
| attributes | RenderAttributes | — |
| indirectBuffer | GpuBuffer | — |
| indirectElementOffset = 0 | uint | — |
void—public void DispatchWithAttributes(Sandbox.RenderAttributes attributes, int threadsX = 32, int threadsY = 32, int threadsZ = 32)
| Parameter | Type | Description |
|---|---|---|
| attributes | RenderAttributes | — |
| threadsX = 32 | int | — |
| threadsY = 32 | int | — |
| threadsZ = 32 | int | — |
void—No results match this filter.
Properties1
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.