Return type |
Description |
int4
|
SamplerName.dimensions()
Returns an int4 containing the grid dimensions.
Grids with less than 4 dimensions have a dimension of 1 in the unused axes.
For example, a 128x128 2D grid will have a dimension of int4(128, 128, 1, 1)
|
int
|
SamplerName.type()
Returns the data type of the grid as a compile-time constant.
-
0: Grid contains float values
-
1: Grid contains float2 values
-
2: Grid contains float3 values
-
3: Grid contains float4 values
-
4: Grid contains int values
-
5: Grid contains int2 values
-
6: Grid contains int3 values
-
7: Grid contains int4 values
|
int#
float#
|
SamplerName.read(int cellIndex)
Reads the value from a cell of the grid.
cellIndex is the flat index of the cell to read, in the [0, dimensions.x * dimensions.y * dimensions.z * dimensions.w] range.
The return type matches the data type of the grid.
|
void
|
SamplerName.write(int cellIndex, int# value[, bool enabled = true]);
SamplerName.write(int cellIndex, float# value[, bool enabled = true]);
Writes a value to a cell of the grid.
cellIndex is the flat index of the cell to write, in the [0, dimensions.x * dimensions.y * dimensions.z * dimensions.w] range.
The input value type should match the data type of the grid.
|
void
|
SamplerName.atomicAdd(int cellIndex, int value[, bool enabled = true])
Performs an integer atomic add on the grid.
Only supports grids of type int, does not support float or vector grids.
|
int
|
SamplerName.atomicFetchAdd(int cellIndex, int value[, bool enabled = true])
Performs an integer atomic add on the grid, and returns the previous value.
Only supports grids of type int, does not support float or vector grids.
|
void
|
SamplerName.atomicMin(int cellIndex, int value[, bool enabled = true])
Performs an integer atomic min on the grid.
Only supports grids of type int, does not support float or vector grids.
|
void
|
SamplerName.atomicMax(int cellIndex, int value[, bool enabled = true])
Performs an integer atomic max on the grid.
Only supports grids of type int, does not support float or vector grids.
|
int#
float#
|
SamplerName.reduce(int cellIndex, int4 querySize, int mode) [v2.23.0]
Performs a reduction operation on all cells that fall in the region defined by the start cell cellIndex and extent querySize.
The return type matches the data type of the grid.
For example, a querySize value of int4(2, 2, 1, 1) will perform the query on the 2x2 rect starting at cellIndex.
The mode parameter can have the following values:
* 0: Performs a Sum query: Adds together the values of all cells within the query region.
* 1: Performs a Min query: Returns the component-wise smallest value across all cells within the query region.
* 2: Performs a Max query: Returns the component-wise highest value across all cells within the query region.
* 3: Performs an Average query: Returns the average value of all cells within the query region.
Performance considerations:
The cost of reduction operations can quickly increase beyond reasonable budgets if you are not careful. Also, some queries will be faster than others with similar parameters.
The highest performance will be reached with a constant querySize (does not vary per-particle, and is a wave-constant or a true constant), on the X axis.
For example, when querying a 2D grid, querySize = int4(N, 1, 1, 1) will be more efficient than doing querySize = int4(1, N, 1, 1). So when laying out the contents of a grid, if you need
to sum entire columns, but never rows, it’ll be more efficient to switch the grid around so you store the data to be summed in the rows instead of the columns, so the reduction query can be made on rows to reach the highest performance.
|
int#
float#
|
SamplerName.reduceSum(int cellIndex, int4 querySize) [v2.23.0]
Adds together the values of all cells within the query region.
Identical to SamplerName.reduce(cellIndex, querySize, 0);
The return type matches the data type of the grid.
|
int#
float#
|
SamplerName.reduceMin(int cellIndex, int4 querySize) [v2.23.0]
Returns the component-wise smallest value across all cells within the query region.
Identical to SamplerName.reduce(cellIndex, querySize, 1);
The return type matches the data type of the grid.
|
int#
float#
|
SamplerName.reduceMax(int cellIndex, int4 querySize) [v2.23.0]
Returns the component-wise highest value across all cells within the query region.
Identical to SamplerName.reduce(cellIndex, querySize, 2);
The return type matches the data type of the grid.
|
int#
float#
|
SamplerName.reduceAvg(int cellIndex, int4 querySize) [v2.23.0]
Returns the average value of all cells within the query region.
Identical to SamplerName.reduce(cellIndex, querySize, 3);
The return type matches the data type of the grid.
|