Class GorgonComputeEngine
An engine used to perform computation on the GPU.
Implements
Inherited Members
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public sealed class GorgonComputeEngine : IGorgonGraphicsObject
Remarks
This system uses multiple threads/waves to perform work in parallel on the GPU, which gives exceptional performance when executing expensive computations.
The compute engine sends compuational work to the GPU via a GorgonComputeShader. This interface is different from the GorgonGraphics interface in that it does not rely on the standard GPU pipeline to execute, and is stateful (i.e. applications set a state, run the engine, set another state, run again, etc...).
Constructors
| Edit this page View SourceGorgonComputeEngine(GorgonGraphics)
Initializes a new instance of the GorgonComputeEngine class.
Declaration
public GorgonComputeEngine(GorgonGraphics graphics)
Parameters
Type | Name | Description |
---|---|---|
GorgonGraphics | graphics | The graphics interface that allows access to the GPU. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentException | Thrown if the device is not a feature level 11 or better device. |
See Also
Fields
| Edit this page View SourceMaxThreadGroupCount
The maximum number of thread groups that can be sent when executing the shader.
Declaration
public const int MaxThreadGroupCount = 65536
Field Value
Type | Description |
---|---|
int |
See Also
Properties
| Edit this page View SourceGraphics
Property to return the graphics interface that owns this object.
Declaration
public GorgonGraphics Graphics { get; }
Property Value
Type | Description |
---|---|
GorgonGraphics |
See Also
Methods
| Edit this page View SourceExecute(GorgonDispatchCall, GorgonBufferCommon, int)
Function to execute a GorgonComputeShader using a buffer for argument passing.
Declaration
public void Execute(GorgonDispatchCall dispatchCall, GorgonBufferCommon indirectArgs, int threadGroupOffset = 0)
Parameters
Type | Name | Description |
---|---|---|
GorgonDispatchCall | dispatchCall | The GorgonDispatchCall to execute. |
GorgonBufferCommon | indirectArgs | The buffer containing the arguments for the compute shader. |
int | threadGroupOffset | [Optional] The offset within the buffer, in bytes, to where the arguments are stored. |
Remarks
This will take the GorgonDispatchCall and execute it using the indirectArgs
buffer. This method will also bind any buffers set up to the GPU prior to executing
the shader.
The indirectArgs
buffer must contain the thread group count arguments for a ComputeShader. The threadGroupOffset
, will instruct the GPU
to begin reading these arguments at the specified offset.
This method differs from the Execute(GorgonDispatchCall, int, int, int) overload in that it uses a buffer to retrieve the arguments to send to the next compute shader workload. Like the SubmitStreamOut(GorgonStreamOutCall, in GorgonColor?, int, int) method, this method takes a variable sized output from a previous compute shader workload and allows it to be passed directly to the shader without having to stall on the CPU side by retrieving count values.
important
For performance reasons, this method will only throw exceptions when Gorgon is compiled as DEBUG.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentOutOfRangeException | Thrown when the |
See Also
| Edit this page View SourceExecute(GorgonDispatchCall, int, int, int)
Function to execute a GorgonComputeShader.
Declaration
public void Execute(GorgonDispatchCall dispatchCall, int threadGroupCountX, int threadGroupCountY, int threadGroupCountZ)
Parameters
Type | Name | Description |
---|---|---|
GorgonDispatchCall | dispatchCall | The GorgonDispatchCall to execute. |
int | threadGroupCountX | The number of thread groups to dispatch in the X direction. |
int | threadGroupCountY | The number of thread groups to dispatch in the Y direction. |
int | threadGroupCountZ | The number of thread groups to dispatch in the Z direction. |
Remarks
This will take a GorgonDispatchCall and execute it. This method will also bind any buffers set up to the GPU prior to executing the shader.
The ComputeShader will be run in parallel on many threads within a thread group. To understand how thread indexes map to the number of threads defined in the shader, please visit the MSDN documentation for the Dispatch function.
important
For performance reasons, this method will only throw exceptions when Gorgon is compiled as DEBUG.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentOutOfRangeException | Thrown when the |