Funzione WavePrefixCountBits

Restituisce la somma di tutte le variabili booleane specificate impostate su true in tutte le corsie attive con indici più piccoli rispetto alla corsia corrente.

Sintassi

uint WavePrefixCountBits(
   bool bBit
);

Parametri

bBit

Variabili booleane specificate.

Valore restituito

Somma di tutte le variabili booleane specificate impostate su true in tutte le corsie attive con indici più piccoli rispetto alla corsia corrente.

Commenti

Questa funzione è supportata dal modello shader 6.0 in tutte le fasi dello shader.

 

Esempio

Il codice seguente descrive come implementare una scrittura compattata in un flusso ordinato in cui il numero di elementi scritti per corsia è 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

Vedi anche

Panoramica del modello shader 6

Modello shader 6