Функция WavePrefixCountBits

Возвращает сумму всех указанных логических переменных, для всех активных полос с индексами меньше текущего.

Синтаксис

uint WavePrefixCountBits(
   bool bBit
);

Параметры

bBit

Указанные логические переменные.

Возвращаемое значение

Сумма всех указанных логических переменных, для всех активных полос с индексами меньше текущего.

Комментарии

Эта функция поддерживается из модели шейдера версии 6.0 на всех этапах шейдера.

 

Примеры

В следующем коде описывается, как реализовать сжатую запись в упорядоченный поток, где число элементов, записанных на полосу, равно 1 или 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

См. также раздел

Обзор модели шейдера 6

Модель шейдера 6