playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
27 lines (23 loc) • 920 B
JavaScript
// Tiny 1-thread shader that reads the large-splat count from countersBuffer[1] and
// computes indirect dispatch args for the cooperative large-splat tile-count pass.
const computeGsplatLocalDispatchPrepLargeSource = /* wgsl */ `
var<storage, read> countersBuffer: array<u32>;
var<storage, read_write> dispatchArgs: array<u32>;
var<storage, read> largeSplatIds: array<u32>;
fn main() {
let count = min(countersBuffer[1], arrayLength(&largeSplatIds));
let maxDim = {MAX_DIM}u;
if (count <= maxDim) {
dispatchArgs[0] = count;
dispatchArgs[1] = 1u;
} else {
let y = (count + maxDim - 1u) / maxDim;
let x = (count + y - 1u) / y;
dispatchArgs[0] = x;
dispatchArgs[1] = y;
}
dispatchArgs[2] = 1u;
}
`;
export { computeGsplatLocalDispatchPrepLargeSource };