Función WavePrefixCountBits
Devuelve la suma de todas las variables booleanas especificadas establecidas en true en todos los carriles activos con índices más pequeños que la calle actual.
Sintaxis
uint WavePrefixCountBits(
bool bBit
);
Parámetros
-
bBit
-
Variables booleanas especificadas.
Valor devuelto
Suma de todas las variables booleanas especificadas establecidas en true en todos los carriles activos con índices más pequeños que el carril actual.
Comentarios
Esta función es compatible con el modelo de sombreador 6.0 en todas las fases del sombreador.
Ejemplos
En el código siguiente se describe cómo implementar una escritura compactada en una secuencia ordenada donde el número de elementos escritos por carril es 1 o 0.
bool bDoesThisLaneHaveAnAppendItem = <expr>;
// compute number of items to append for the whole wave
uint laneAppendOffset = WavePrefixCountBits( bDoesThisLaneHaveAnAppendItem );
uint appendCount = WaveActiveCountBits( bDoesThisLaneHaveAnAppendItem);
// update the output location for this whole wave
uint appendOffset;
if ( WaveIsFirstLane () )
{
// this way, we only issue one atomic for the entire wave, which reduces contention
// and keeps the output data for each lane in this wave together in the output buffer
InterlockedAdd(bufferSize, appendCount, appendOffset);
}
appendOffset = WaveReadLaneFirst( appendOffset ); // broadcast value
appendOffset += laneAppendOffset; // and add in the offset for this lane
buffer[appendOffset] = myData; // write to the offset location for this lane
Consulte también