Share via


WavePrefixCountBits 함수

현재 레인보다 인덱스가 작은 모든 활성 레인에서 true로 설정된 지정된 모든 부울 변수의 합계를 반환합니다.

구문

uint WavePrefixCountBits(
   bool bBit
);

매개 변수

bBit

지정된 부울 변수입니다.

반환 값

현재 레인보다 인덱스가 작은 모든 활성 레인에서 true로 설정된, 지정된 모든 부울 변수의 합계입니다.

설명

이 함수는 모든 셰이더 단계에서 셰이더 모델 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