Class MapWorker
Represents the result of the different evaluation of a 2D float buffer, based on the used filter implementation, through accessing the ram/v-ram. Also manages compute shader calls.
Implements
Inherited Members
Namespace: Holoride.ElasticSDK
Assembly: Holoride.ElasticSDK.Library.Runtime.dll
Syntax
[PublicAPI]
public class MapWorker : PipelineWorkerBase, IPipelineWorker
Constructors
MapWorker(bool, bool, bool)
Instantiates a MapWorker.
Declaration
public MapWorker(bool provideDoubleBuffer, bool provideCPUBuffer, bool provideGPUBuffer)
Parameters
Type | Name | Description |
---|---|---|
bool | provideDoubleBuffer | |
bool | provideCPUBuffer | |
bool | provideGPUBuffer |
Fields
IsCPUBufferFinal
States whether the map data is final and hence available.
Declaration
public bool IsCPUBufferFinal
Field Value
Type | Description |
---|---|
bool |
IsGPUBufferFinal
States whether the compute buffer is final and hence available.
Declaration
public bool IsGPUBufferFinal
Field Value
Type | Description |
---|---|
bool |
Undefined
A value that states the value undefined but can also be used in the shader.
Declaration
public static float Undefined
Field Value
Type | Description |
---|---|
float |
Properties
CurrentCPUReadBuffer
Gets the CPUReadBuffer. Synchronously initializes it if necessary.
Declaration
public IReadOnlyList<float> CurrentCPUReadBuffer { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<float> |
CurrentCPUWriteBuffer
Gets the CPUWriteBuffer that can only be accessed to in the processing phase.
Declaration
public float[] CurrentCPUWriteBuffer { get; }
Property Value
Type | Description |
---|---|
float[] |
CurrentGPUReadBuffer
Gets the GPUReadBuffer. Synchronously initializes it if necessary.
Declaration
public ComputeBuffer CurrentGPUReadBuffer { get; }
Property Value
Type | Description |
---|---|
ComputeBuffer |
CurrentGPUWriteBuffer
Gets the GPUWriteBuffer that can only be accessed to in the processing phase.
Declaration
public ComputeBuffer CurrentGPUWriteBuffer { get; }
Property Value
Type | Description |
---|---|
ComputeBuffer |
EnsureCPUBuffer
Gets a value indicating whether a CPUBuffer should be ensured.
Declaration
public bool EnsureCPUBuffer { get; }
Property Value
Type | Description |
---|---|
bool |
EnsureGPUBuffer
Gets a value indicating whether a GPUBuffer should be ensured.
Declaration
public bool EnsureGPUBuffer { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
AttachCurveToComputeShader(string, AnimationCurve, int, ComputeShader, float, float)
Attaches a curve to a compute shader.
Declaration
public void AttachCurveToComputeShader(string shaderVariableName, AnimationCurve curve, int sampleResolution, ComputeShader shader, float supportMin = 0, float supportMax = 1)
Parameters
Type | Name | Description |
---|---|---|
string | shaderVariableName | The name of the variable that should get evaluated. |
AnimationCurve | curve | The curve. |
int | sampleResolution | The resolution of the curve. |
ComputeShader | shader | The compute shader. |
float | supportMin | The minimum value of the expected curve value range. |
float | supportMax | The maximum value of the expected curve value range. |
BlendWithPreviousCPUBufferAsync(GenerationContext, CancellationToken)
Blends two CPU buffers and linear interpolates within the BlendMargin.
Declaration
public UniTask BlendWithPreviousCPUBufferAsync(GenerationContext targetGenerationContext, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
GenerationContext | targetGenerationContext | The generation context of the resulting buffer. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Cysharp.Threading.Tasks.UniTask |
BlendWithPreviousGPUBufferAsync(GenerationContext, CancellationToken)
Uses a compute shader to blend two GPU buffers.
Declaration
public UniTask BlendWithPreviousGPUBufferAsync(GenerationContext targetGenerationContext, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
GenerationContext | targetGenerationContext | The generation context of the resulting buffer. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Cysharp.Threading.Tasks.UniTask |
BlendWithPreviousGPUBufferAsync(ComputeShader, int, GenerationContext, CancellationToken)
Uses a compute shader to blend two GPU buffers.
Declaration
public UniTask BlendWithPreviousGPUBufferAsync(ComputeShader shader, int kernelHandle, GenerationContext targetGenerationContext, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
ComputeShader | shader | The shader that implements the blending function. |
int | kernelHandle | The shader kernel that implements the blending function. |
GenerationContext | targetGenerationContext | The generation context of the resulting buffer. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Cysharp.Threading.Tasks.UniTask |
CallInit()
Declaration
public override void CallInit()
Overrides
CallProcessAsync(GenerationContext, IProgress<float>, CancellationToken)
Declaration
public override sealed UniTask CallProcessAsync(GenerationContext context, IProgress<float> onProgressUpdate = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
GenerationContext | context | |
IProgress<float> | onProgressUpdate | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Cysharp.Threading.Tasks.UniTask |
Overrides
CopyFromCPUToGPU()
Uploads the map data to the compute buffer.
Declaration
public void CopyFromCPUToGPU()
CopyFromGPUToCPUAfterProcessAsync(CancellationToken)
Allows asynchronously populating the CPU buffer from the GPU buffer after node processing has completed, e.g. when a consuming node needs CPU data but the node only generated GPU data.
Declaration
public UniTask CopyFromGPUToCPUAfterProcessAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Cysharp.Threading.Tasks.UniTask |
CopyFromGPUToCPUAsync(CancellationToken)
Uploads the map data to the compute buffer.
Declaration
protected UniTask CopyFromGPUToCPUAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Cysharp.Threading.Tasks.UniTask |
Dispose()
Declaration
public override void Dispose()
Overrides
ForEachCoordinate(Action<int, int>)
Processes the modifyFunction for each coordinate of a filters MapData.
Declaration
[Obsolete("Will be removed in a future release.")]
public IEnumerator ForEachCoordinate(Action<int, int> modifyFunction)
Parameters
Type | Name | Description |
---|---|---|
Action<int, int> | modifyFunction | The action to modify the values. The parameters are the array indices. |
Returns
Type | Description |
---|---|
IEnumerator |
GetCPUReadBufferValue(int, int)
Gets a single value from the CPUReadBuffer.
Declaration
public float GetCPUReadBufferValue(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
int | x | The x coordinate. |
int | y | The y coordinate. |
Returns
Type | Description |
---|---|
float | The CPUReadBuffer value at x and y. |
GetCPUReadBufferValueInterpolated(GlobalPosition)
Samples the CPUReadBuffer. If a position is queried that is outside the generation bounds, clamped boundary value will be returned.
Declaration
public float GetCPUReadBufferValueInterpolated(GlobalPosition position)
Parameters
Type | Name | Description |
---|---|---|
GlobalPosition | position | The position to sample. |
Returns
Type | Description |
---|---|
float | The interpolated value. |
GetCPUWriteBufferValue(int, int)
Gets a single value from the CPUWriteBuffer. This can only be done in a processing phase.
Declaration
public float GetCPUWriteBufferValue(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
int | x | The x coordinate. |
int | y | The y coordinate. |
Returns
Type | Description |
---|---|
float | The CPUWriteBuffer value at x and y. |
GetGradientAtPosition(GlobalPosition)
Computes the gradient at a position.
Declaration
public Vector2 GetGradientAtPosition(GlobalPosition position)
Parameters
Type | Name | Description |
---|---|---|
GlobalPosition | position | The position to compute the gradient at. |
Returns
Type | Description |
---|---|
Vector2 | The gradient. |
IsUndefined(float)
States whether a given value is undefined.
Declaration
public bool IsUndefined(float value)
Parameters
Type | Name | Description |
---|---|---|
float | value | The value to check if undefined. |
Returns
Type | Description |
---|---|
bool | Whether the given value is undefined. |
PromiseCPUBuffer()
Call after initialization to ensure a CPU buffer is created for eager evaluation.
Declaration
public void PromiseCPUBuffer()
PromiseGPUBuffer()
Call after initialization to ensure a GPU buffer is created for eager evaluation.
Declaration
public void PromiseGPUBuffer()
RunShader(ComputeShader, int)
Runs a computeShader.
Declaration
public void RunShader(ComputeShader shader, int kernelHandle)
Parameters
Type | Name | Description |
---|---|---|
ComputeShader | shader | The computeShader. |
int | kernelHandle | The kernelHandle. |
SetCPUWriteBufferValue(int, int, float)
Sets a single value to the CPUWriteBuffer. This can only be done in a processing phase.
Declaration
public void SetCPUWriteBufferValue(int x, int y, float value)
Parameters
Type | Name | Description |
---|---|---|
int | x | The x coordinate. |
int | y | The y coordinate. |
float | value | The value to write. |
ToShaderArray(float[])
Converts a float array into a shader readable format.
Declaration
public static float[] ToShaderArray(float[] array)
Parameters
Type | Name | Description |
---|---|---|
float[] | array | The float array to convert. |
Returns
Type | Description |
---|---|
float[] | The float array in a shader readable format. |