Fungsi WavePrefixCountBits
Mengembalikan jumlah semua variabel boolean yang ditentukan yang diatur ke true di semua jalur aktif dengan indeks yang lebih kecil dari jalur saat ini.
Sintaks
uint WavePrefixCountBits(
bool bBit
);
Parameter
-
bBit
-
Variabel boolean yang ditentukan.
Menampilkan nilai
Jumlah semua variabel Boolean yang ditentukan diatur ke true di semua jalur aktif dengan indeks yang lebih kecil dari jalur saat ini.
Keterangan
Fungsi ini didukung dari model shader 6.0 di semua tahap shader.
Contoh
Kode berikut menjelaskan cara mengimplementasikan tulisan ringkas ke aliran yang diurutkan di mana jumlah elemen yang ditulis per jalur adalah 1 atau 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
Lihat juga
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk