Gaussian Splat Sorter

The acron.gsplat module is the native half of Gaussian-splat rendering: the back-to-front draw order. A splat scan is millions of alpha-blended primitives, and they composite correctly only drawn far to near, so every change of view wants a fresh order of all of them – a sort that sits on the frame’s critical path and has no business in Python. The renderer itself (the work-buffer pass that decodes the splats, the instanced draw, the modifier hook that lets a program deform them) lives in the Python tier, acron.splats, over public engine API; this module is what it calls.

One class

GSplatSorter

Owns three arrays sized to the splat count. depths holds one view-space depth per splat and visible one byte per splat (1 = draw); the caller fills both – from Python, numpy writes straight into them through the buffer protocol. sort() then fills order with the indices of the visible splats, farthest first, as float32 (the format an R32F order texture takes), and returns how many; write_order() copies them into such a texture’s RAM image in one step. The sort quantises the depth range to 2^bits buckets (bits = clamp(log2(n / 4), 10, 20) unless set) and counting-sorts on the key, stable, so ties keep index order: O(n), and BLOCKING, so a worker thread can run it while the frame loop draws. depth_along() gives the plain undeformed depth of a centre array along a direction; a deformed scene computes its own depths.

from acron.gsplat import GSplatSorter
import numpy as np

sorter = GSplatSorter(count)
np.frombuffer(memoryview(sorter.depths), np.float32)[:] = my_depths
np.frombuffer(memoryview(sorter.visible), np.uint8)[:] = my_mask
n = sorter.sort()                 # farthest first, visible only
sorter.write_order(order_texture) # an R32F texture the draw reads