playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
33 lines (27 loc) • 1.15 kB
JavaScript
// Per-tile bitonic sort for small tiles (1..4096 entries).
// Reads tile index from smallTileList and delegates to the shared bitonic sort logic.
const computeGsplatLocalTileSortSource = /* wgsl */ `
#include "gsplatLocalBitonicCS"
var<storage, read_write> tileEntries: array<u32>;
var<storage, read> tileSplatCounts: array<u32>;
var<storage, read> depthBuffer: array<u32>;
var<storage, read> smallTileList: array<u32>;
var<storage, read> tileListCounts: array<u32>;
fn main(
localIdx: u32,
wid: vec3u,
numWorkgroups: vec3u
) {
let workgroupIdx = wid.y * numWorkgroups.x + wid.x;
if (workgroupIdx >= tileListCounts[0]) {
return;
}
let tileIdx = smallTileList[workgroupIdx];
let tStart = tileSplatCounts[tileIdx];
let tEnd = tileSplatCounts[tileIdx + 1u];
let count = tEnd - tStart;
bitonicSortRange(localIdx, tStart, count);
}
`;
export { computeGsplatLocalTileSortSource };