nx_fwddiff_equiv_gate.nx
buildroot/runtime/nx_fwddiff_equiv_gate.nx
about
nx_fwddiff_equiv_gate.nx -- THE ARITHMETIC CORE OF THE FORWARD-DIFFERENCED CONIC EVALUATION,
PROVEN INDEPENDENT OF THE RENDERER.
WHY THIS GATE EXISTS. The splat rasterizer's inner loop evaluated, per pixel per splat:
pnum = cc*dx*dx - 2*cb*dx*dy + ca*dy*dy ; k = pnum * MUL / det
which is six multiplies and ONE 64-BIT INTEGER DIVISION on the hottest path in the estate --
measured at 25.9 ns per conic evaluation, an idiv's price rather than a multiply's. The published
remedy (SHARP-GS, SIGGRAPH 2026: "Forward Differencing, which replaces expensive probability
density function evaluations with efficient incremental updates") is to walk the quadratic by its
constant second difference and to carry the quotient in a bracket instead of dividing.
THAT REWRITE IS ONLY ADMISSIBLE IF IT IS EXACT. A renderer that is faster and changes one pixel is
a broken renderer. Two identities carry the whole change, and this gate proves BOTH over a swept
domain rather than asserting them from the algebra:
IDENTITY 1 (forward difference): walking P by P += D ; D += DD reproduces
P(dx) = MUL*(cc*dx^2 - 2*cb*dx*dy + ca*dy^2) exactly,
because P is quadratic in dx and DD = 2*cc*MUL is its
constant second difference. Integer arithmetic, so "exactly"
means bit-for-bit, not "to within rounding".
IDENTITY 2 (bracket = division): maintaining k*det <= P < (k+1)*det by stepping k yields
exactly floor(P/det) = the integer the division produced,
for every P >= 0 and det >= 1.
THE SUBJECT IS THE IDENTITY, NOT THE RENDERER, so this gate deliberately imports NO renderer
constants: it sweeps the multiplier, the LUT cut and the covariance terms, and our shipped values
are one point inside that sweep. A gate that mirrored GLUTU/GEXPN would be a second copy of them --
this one is strictly stronger and owns nothing it could drift from.
THE SWEEP IS DERIVED FROM THE GEOMETRY IT MODELS, never picked: ca and cc are built as
e^2 + e^2 + 1 exactly as the projector builds them, cb is swept across the Cauchy-Schwarz bound
that makes the form positive definite, and the pixel rectangle is the 3-sigma box the rasterizer
actually walks.
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 41 | const FD_NE: i64 = 6 // distinct projected-axis magnitudes |
| 42 | const FD_NCB: i64 = 5 // cross-term steps across the positive-definite range |
| 43 | const FD_NDY: i64 = 7 // scanline offsets from the splat centre |
| 44 | const FD_NMUL: i64 = 3 // LUT sub-step multipliers (ours is one of these) |
| 45 | const FD_SIGMA: i64 = 3 // AABB half-extent in sigma -- the box the rasterizer walks |
functions
| 47 | func fd_isqrt(v: i64) -> i64 called by 1: main |
| 55 | func fd_e_at(i: i64) -> i64 called by 1: main |
| 63 | func fd_mul_at(i: i64) -> i64 called by 1: main |
| 69 | func main() -> i64 |