code wiki / _hdl_build / nx_sdfrender_gate.nx
nx_sdfrender_gate.nx source
↩ module page · 378 lines · 20779 B
1// nx_sdfrender_gate.nx -- gate for the SMOOTH-UNION SDF body (sovereign software GPU, continuous surface).
2// T1 the body renders (solid skin block)
3// T2 per-pixel shading gradient (SDF-gradient normals -> real lighting)
4// T3 full figure top->bottom
5// T4 CONTINUOUS: the centre column is ONE fused run (the parts FUSED, not disjoint blobs) -- the whole
6// point of smooth-union over the rasterized ellipsoids
7// T5 THE CAPTURE ACTUALLY LANDS -- four teeth where there used to be one, see the block below
8// T6 pre-integrated SSS (sr_sss_preint), the non-gameable quad
9//
10// ===================================================================================================
11// WHY T5 IS FOUR TEETH NOW (debt 1787678931, MEASURED 2026-08-25 -- this gate WAS the defect).
12// The old T5 was one line:
13// write_png(fb, ww(), hh(), "knowledge/nx_sdfbody.png"); if diff == 0 { PASS "determinism + PNG" }
14// It DISCARDED write_png's return and gated on DETERMINISM ONLY. Determinism is trivially satisfied by
15// WRITING NOTHING TWICE, so the tooth could not distinguish a landed capture from no capture at all.
16// PROOF IT DID NOT: two runs whose framebuffers provably DIFFERED (skin 37624 vs 37626, bands
17// 10352/18040/9232 vs 10353/18042/9231) left knowledge/nx_sdfbody.png byte-identical at
18// 827bc7718e15f0437a1600326e7bc7ec46a34dfc7c189d2a51607f7ccdf185a5 / 142629 B across BOTH -- while this
19// gate printed "T5 PASS determinism + PNG". A whole rung shipped with no trustworthy before/after image.
20// A TOOTH THAT DISCARDS ITS ACTUATOR'S RETURN CANNOT SEE THE ACTUATOR FAIL.
21// DETERMINISM IS NECESSARY AND IS NOT SUFFICIENT, AND THE TOOTH THAT NAMES ONLY THE NECESSARY HALF
22// READS EXACTLY LIKE A PROOF OF THE WHOLE.
23//
24// The four that replace it, each named for what it can refute:
25// T5a the publish RETURNS a byte count and the ARTIFACT ON DISK IS THAT SIZE -- receipt AND artifact
26// T5b determinism, RENAMED so it can never again be read as evidence the file was written
27// T5c A/B: two captures whose SHADER PROVABLY DIFFERS must be DIFFERENT FILES. This is the tooth a
28// no-op writer, a stale-file writer and an open-that-silently-failed all die at, and the one the
29// old gate had no analogue of.
30// T5d fixture-reached-the-condition: the two swatches' shader values really do differ, asserted
31// ARITHMETICALLY and FIRST, so a T5c failure can never be blamed on a fixture that never varied.
32// plus two neg-controls that must FAIL for the teeth above to mean anything.
33//
34// AND THE OWED ARTIFACT. T5c's A/B pair is not a synthetic fixture -- it IS the before/after this rung
35// owes. nx_sdfrender's own shading site says "curv=0 reproduces the former fixed 120/60/26 widths
36// bit-for-bit", so evaluating the SHIPPED sr_sss_preint over the whole (N.L x curvature) domain with
37// curvature PASSED THROUGH gives the rung, and with curvature FORCED TO ZERO gives the pre-rung shader
38// exactly. Two images, one shipped function, no second implementation to be wrong:
39// knowledge/nx_sdfsss_before.png pre-rung fixed wrap (every row identical: curvature ignored)
40// knowledge/nx_sdfsss_after.png the shipped rung (rows widen with curvature)
41// license_tier: ORIGINAL expect_exit: 0 No hw writes (Rule 26).
42// ===================================================================================================
43import "nx_syscalls.nx"
44import "nx_gate_verdict.nx"
45import "nx_png.nx"
46import "nx_sdfrender.nx"
47
48// ---- CALIBRATION INHERITED UNCHANGED FROM THE INCUMBENT GATE ------------------------------------
49// Every bound below carried the SAME value as a bare literal before this migration. They are NAMED so
50// they are auditable and so the migration is provably neutral; not one was re-tuned, because re-tuning
51// a bound in the same change that rewrites the teeth would make both unprovable. The frame-relative
52// permil of each is PRINTED at run time so a later lane can derive them instead of inheriting them.
53const SDG_SKIN_MIN_PX: i64 = 8000 // T1 floor: fewer than this and no body rendered
54const SDG_SKIN_MAX_PX: i64 = 90000 // T1 ceiling: more than this and the frame is flooded
55const SDG_LUM_SPAN_MIN: i64 = 200 // T2: summed-RGB luminance span that proves per-pixel shading
56const SDG_BAND_TOP_MIN: i64 = 300 // T3: head band
57const SDG_BAND_MID_MIN: i64 = 1500 // T3: torso band
58const SDG_BAND_BOT_MIN: i64 = 300 // T3: legs band
59const SDG_TRUNK_RUNS_MAX: i64 = 3 // T4: chin/crotch may break the centre column, nothing more
60const SDG_BANDS: i64 = 3 // T3 splits the frame into three equal horizontal bands
61const SDG_TRUNK_MIN_DIV: i64 = 2 // T4: the trunk spans more than hh()/2
62// T6 pins the rung against the shader it replaced. 81/48/23 are not chosen: they are 120*256/376,
63// 60*256/316 and 26*256/282 -- the FORMER fixed wrap evaluated at N.L=0 -- so flat skin is byte-identical
64// to the pre-rung renderer. Recorded as the arithmetic, not as three magic results.
65const SDG_OLDWRAP_R: i64 = 120
66const SDG_OLDWRAP_G: i64 = 60
67const SDG_OLDWRAP_B: i64 = 26
68
69// ---- SHADER / IMAGE PACKING ----------------------------------------------------------------------
70const SDG_SSS_PK: i64 = 1024 // the (wR,wG,wB) packing radix of sr_sss_preint_n (nx_sdfrender)
71const SDG_PACK_G: i64 = 256 // write_png contract: c = r + g*256 + b*65536
72const SDG_PACK_B: i64 = 65536
73const SDG_PNG_CH_MAX: i64 = 255 // 8-bit PNG channel maximum -- fixed by the FORMAT, not chosen
74const SDG_PERMIL: i64 = 1000
75const SDG_DIR_MODE_0755: i64 = 0x1ed // rwxr-xr-x, for the gate's own /tmp scratch directory
76const SDG_SEEK_END: i64 = 2
77const SDG_PTR_BYTES: i64 = 8 // one i64 out-parameter slot
78const SDG_PX_BYTES: i64 = 8 // the framebuffer write_png consumes is one packed i64 per pixel
79// render parameters, carried over verbatim from the incumbent gate so T1-T4 measure the same frame
80const SDG_YAW: i64 = 0
81const SDG_CAMZ: i64 = 5
82const SDG_SKIN_R: i64 = 240
83const SDG_SKIN_G: i64 = 184
84const SDG_SKIN_B: i64 = 160
85// curvature modes for the A/B swatch
86const SDG_CURV_PASSTHROUGH: i64 = 1 // the shipped rung: curvature varies down the image
87const SDG_CURV_FORCED_FLAT: i64 = 0 // the pre-rung shader: curvature ignored, every row identical
88
89func sdg_is_skin(px: i64) -> i64 { let r: i64 = px & 255; let b: i64 = (px >> 16) & 255; if r >= b { return 1 } return 0 }
90func sdg_lum(px: i64) -> i64 { return (px & 255) + ((px >> 8) & 255) + ((px >> 16) & 255) }
91
92// THE ARTIFACT, NOT THE RECEIPT: the size the file actually has right now, or -1 if it is not there.
93func sdg_size(path: *u8) -> i64 {
94 let fd: i64 = sys_openat_rd(path)
95 if fd < 0 { return 0 - 1 }
96 let n: i64 = sys_lseek(fd, 0, SDG_SEEK_END)
97 sys_close(fd)
98 return n
99}
100// THE DETECTOR the neg-controls bite: "this capture did NOT land". 1 = did not land.
101// It is deliberately expressed as the FAILURE so a control can make it fire.
102func sdg_did_not_land(path: *u8, claimed: i64) -> i64 {
103 if claimed <= 0 { return 1 }
104 if sdg_size(path) != claimed { return 1 }
105 return 0
106}
107// A WRITER THAT DOES NOTHING. The trivial wrong implementation, kept in the gate so the tooth that is
108// supposed to catch it can be SHOWN catching it rather than assumed to.
109func sdg_noop_writer(path: *u8) -> i64 { return 0 }
110
111// Byte-compare two files. Returns 1 when they DIFFER (or either is unreadable), 0 when identical,
112// and writes the first differing offset (or -1) through outoff.
113func sdg_files_differ(a: *u8, b: *u8, outoff: *i64) -> i64 {
114 outoff[0] = 0 - 1
115 let la: *i64 = sys_mmap(SDG_PTR_BYTES) as *i64
116 let lb: *i64 = sys_mmap(SDG_PTR_BYTES) as *i64
117 let ba: *u8 = sys_read_file(a, la)
118 let bb: *u8 = sys_read_file(b, lb)
119 if (ba as i64) == 0 { return 1 }
120 if (bb as i64) == 0 { return 1 }
121 if la[0] != lb[0] { outoff[0] = la[0]; return 1 }
122 var i: i64 = 0
123 var d: i64 = 0
124 var scan: i64 = 1
125 while scan == 1 {
126 if i >= la[0] { scan = 0 }
127 else {
128 if ba[i] != bb[i] { d = 1; outoff[0] = i; scan = 0 } else { i = i + 1 }
129 }
130 }
131 return d
132}
133
134// THE A/B SWATCH. Evaluates the SHIPPED sr_sss_preint over the whole domain it is defined on:
135// x maps N.L from -SSS_N_FULL..+SSS_N_FULL, y maps curvature 0..SSS_CURV_MAX. usecurv selects which
136// shader is being drawn -- passthrough is the rung, forced-flat is the shader it replaced. There is no
137// second implementation here: both images come out of the same shipped function, so the difference
138// between them cannot be an artefact of a re-typed copy.
139func sdg_swatch(fb: *i64, w: i64, h: i64, usecurv: i64) -> i64 {
140 var y: i64 = 0
141 while y < h {
142 var curv: i64 = 0
143 if usecurv == SDG_CURV_PASSTHROUGH { curv = y }
144 var x: i64 = 0
145 while x < w {
146 let ndl: i64 = x - SSS_N_FULL
147 let v: i64 = sr_sss_preint(ndl, curv)
148 var r: i64 = v % SDG_SSS_PK
149 var g: i64 = (v / SDG_SSS_PK) % SDG_SSS_PK
150 var b: i64 = v / (SDG_SSS_PK * SDG_SSS_PK)
151 if r > SDG_PNG_CH_MAX { r = SDG_PNG_CH_MAX }
152 if g > SDG_PNG_CH_MAX { g = SDG_PNG_CH_MAX }
153 if b > SDG_PNG_CH_MAX { b = SDG_PNG_CH_MAX }
154 fb[y * w + x] = r + g * SDG_PACK_G + b * SDG_PACK_B
155 x = x + 1
156 }
157 y = y + 1
158 }
159 return 0
160}
161
162func main() -> i64 {
163 let ctr: *i64 = gv_ctr()
164 gv_head("nx_sdfrender_gate -- smooth-union SDF body, per-pixel lit, and A CAPTURE THAT PROVES IT LANDED" as *u8)
165
166 let base: i64 = sys_mmap(sdf_bytes()) as i64
167 sdf_body(base)
168 sdf_render(base, SDG_YAW, SDG_CAMZ, SDG_SKIN_R, SDG_SKIN_G, SDG_SKIN_B)
169 let fb: *i64 = (base + fb_off()) as *i64
170 let frame: i64 = ww() * hh()
171
172 var skin: i64 = 0
173 var minl: i64 = 0 - 1
174 var maxl: i64 = 0
175 var topt: i64 = 0
176 var midt: i64 = 0
177 var bott: i64 = 0
178 var pi: i64 = 0
179 while pi < frame {
180 if sdg_is_skin(fb[pi]) == 1 {
181 skin = skin + 1
182 let l: i64 = sdg_lum(fb[pi])
183 if minl < 0 { minl = l }
184 if l < minl { minl = l }
185 if l > maxl { maxl = l }
186 let row: i64 = pi / ww()
187 if row < hh() / SDG_BANDS { topt = topt + 1 }
188 else { if row < hh() * (SDG_BANDS - 1) / SDG_BANDS { midt = midt + 1 } else { bott = bott + 1 } }
189 }
190 pi = pi + 1
191 }
192 if minl < 0 { minl = 0 }
193
194 gv_puts(" frame=" as *u8); gv_num(ww()); gv_puts("x" as *u8); gv_num(hh())
195 gv_puts(" skin=" as *u8); gv_num(skin)
196 gv_puts(" (" as *u8); gv_num(skin * SDG_PERMIL / frame); gv_puts(" permil of frame)" as *u8)
197 gv_puts(" bands top/mid/bot=" as *u8); gv_num(topt); gv_puts("/" as *u8); gv_num(midt); gv_puts("/" as *u8); gv_num(bott)
198 gv_puts(" lum " as *u8); gv_num(minl); gv_puts(".." as *u8); gv_num(maxl); gv_puts("\n" as *u8)
199
200 var t1: i64 = 1
201 if skin < SDG_SKIN_MIN_PX { t1 = 0 }
202 if skin > SDG_SKIN_MAX_PX { t1 = 0 }
203 gv_check("T1 sdf-body-renders-a-solid-skin-block" as *u8, t1, ctr)
204
205 var t2: i64 = 0
206 if maxl - minl > SDG_LUM_SPAN_MIN { t2 = 1 }
207 gv_check("T2 per-pixel-shading-gradient-not-flat-fill" as *u8, t2, ctr)
208
209 var t3: i64 = 1
210 if topt < SDG_BAND_TOP_MIN { t3 = 0 }
211 if midt < SDG_BAND_MID_MIN { t3 = 0 }
212 if bott < SDG_BAND_BOT_MIN { t3 = 0 }
213 gv_check("T3 full-figure-head-torso-legs-all-present" as *u8, t3, ctr)
214
215 // T4 TRUNK CONTINUITY: the centre column (head->neck->torso->hips) must be ONE unbroken vertical run,
216 // proving the smooth-union FUSED the stacked parts. Limbs stay distinct (correct anatomy).
217 let col: i64 = ww() / 2
218 var vruns: i64 = 0
219 var inrun: i64 = 0
220 var runstart: i64 = 0
221 var toprun: i64 = 0
222 var botrun: i64 = 0
223 var yy: i64 = 0
224 while yy < hh() {
225 let s: i64 = sdg_is_skin(fb[yy * ww() + col])
226 if s == 1 { if inrun == 0 { vruns = vruns + 1; inrun = 1; runstart = yy } botrun = yy }
227 else { if inrun == 1 { if toprun == 0 { toprun = runstart } } inrun = 0 }
228 yy = yy + 1
229 }
230 if inrun == 1 { if toprun == 0 { toprun = runstart } }
231 let trunklen: i64 = botrun - toprun
232 var t4: i64 = 1
233 if vruns > SDG_TRUNK_RUNS_MAX { t4 = 0 }
234 if trunklen <= hh() / SDG_TRUNK_MIN_DIV { t4 = 0 }
235 gv_puts(" trunk: " as *u8); gv_num(vruns); gv_puts(" vertical run(s) spanning " as *u8); gv_num(trunklen)
236 gv_puts("px of " as *u8); gv_num(hh()); gv_puts("\n" as *u8)
237 gv_check("T4 trunk-is-one-fused-run-not-stacked-blobs" as *u8, t4, ctr)
238
239 // ================= T5: THE CAPTURE ACTUALLY LANDS ==============================================
240 // Scratch for the neg-controls goes in /tmp/<gate>/, never in knowledge/store/ -- a gate that shares
241 // a fixture with a production plane reports on the fixture, not on the code.
242 sys_mkdir("/tmp/nx_sdfrender_gate" as *u8, SDG_DIR_MODE_0755)
243
244 // T5b FIRST, and named for exactly what it is worth. Two independent renders of the same scene.
245 let base2: i64 = sys_mmap(sdf_bytes()) as i64
246 sdf_body(base2)
247 sdf_render(base2, SDG_YAW, SDG_CAMZ, SDG_SKIN_R, SDG_SKIN_G, SDG_SKIN_B)
248 let fb2: *i64 = (base2 + fb_off()) as *i64
249 var diff: i64 = 0
250 pi = 0
251 while pi < frame { if fb[pi] != fb2[pi] { diff = diff + 1 } pi = pi + 1 }
252 var t5b: i64 = 0
253 if diff == 0 { t5b = 1 }
254 gv_check("T5b determinism-NECESSARY-NOT-SUFFICIENT-writing-nothing-twice-also-passes-this" as *u8, t5b, ctr)
255
256 // T5a THE PUBLISH. png_publish_announced prints "PNGWRITE path= fd= wrote= of= ondisk= RESULT=" on
257 // every call, so the transcript itself carries the proof -- and the tooth re-reads the file rather
258 // than trusting that line, because a receipt is not an artifact.
259 let bodyp: *u8 = "knowledge/nx_sdfbody.png" as *u8
260 let nbody: i64 = png_publish_announced(fb, ww(), hh(), bodyp)
261 let onbody: i64 = sdg_size(bodyp)
262 var t5a: i64 = 0
263 if nbody > 0 { if onbody == nbody { t5a = 1 } }
264 gv_puts(" capture: " as *u8); gv_puts(bodyp); gv_puts(" returned=" as *u8); gv_num(nbody)
265 gv_puts(" on_disk=" as *u8); gv_num(onbody); gv_puts("\n" as *u8)
266 gv_check("T5a publish-returns-bytes-AND-the-artifact-on-disk-is-that-size" as *u8, t5a, ctr)
267
268 // ---- the A/B pair. Same shipped function, two curvature modes; this IS the rung's before/after.
269 let sw: i64 = SSS_N_FULL * 2 + 1
270 let sh: i64 = SSS_CURV_MAX + 1
271 let fbA: *i64 = sys_mmap(sw * sh * SDG_PX_BYTES) as *i64
272 let fbB: *i64 = sys_mmap(sw * sh * SDG_PX_BYTES) as *i64
273 sdg_swatch(fbA, sw, sh, SDG_CURV_FORCED_FLAT)
274 sdg_swatch(fbB, sw, sh, SDG_CURV_PASSTHROUGH)
275
276 // T5d FIXTURE-REACHED-THE-CONDITION, ARITHMETICALLY AND BEFORE ANY OUTCOME IS ASSERTED. If the two
277 // swatches were secretly the same shader, T5c would fail and every reader would blame the capture
278 // path. Count the pixels whose SHADER VALUES differ, and the largest per-channel delta.
279 var pxdiff: i64 = 0
280 var maxdelta: i64 = 0
281 pi = 0
282 while pi < sw * sh {
283 if fbA[pi] != fbB[pi] {
284 pxdiff = pxdiff + 1
285 var d0: i64 = (fbB[pi] & 255) - (fbA[pi] & 255)
286 if d0 < 0 { d0 = 0 - d0 }
287 if d0 > maxdelta { maxdelta = d0 }
288 }
289 pi = pi + 1
290 }
291 var t5d: i64 = 0
292 if pxdiff > 0 { t5d = 1 }
293 let flat0: i64 = sr_sss_preint(0, 0)
294 let curvmax0: i64 = sr_sss_preint(0, SSS_CURV_MAX)
295 gv_puts(" A/B fixture: swatch " as *u8); gv_num(sw); gv_puts("x" as *u8); gv_num(sh)
296 gv_puts(" pixels_whose_shader_differs=" as *u8); gv_num(pxdiff)
297 gv_puts(" (" as *u8); gv_num(pxdiff * SDG_PERMIL / (sw * sh)); gv_puts(" permil) max_red_delta=" as *u8); gv_num(maxdelta)
298 gv_puts("\n at N.L=0 pre-rung rgb=" as *u8)
299 gv_num(flat0 % SDG_SSS_PK); gv_puts("/" as *u8); gv_num((flat0 / SDG_SSS_PK) % SDG_SSS_PK); gv_puts("/" as *u8); gv_num(flat0 / (SDG_SSS_PK * SDG_SSS_PK))
300 gv_puts(" rung-at-max-curvature rgb=" as *u8)
301 gv_num(curvmax0 % SDG_SSS_PK); gv_puts("/" as *u8); gv_num((curvmax0 / SDG_SSS_PK) % SDG_SSS_PK); gv_puts("/" as *u8); gv_num(curvmax0 / (SDG_SSS_PK * SDG_SSS_PK))
302 gv_puts("\n" as *u8)
303 gv_check("T5d fixture-reached-the-condition-the-two-swatch-shaders-really-differ" as *u8, t5d, ctr)
304
305 // T5c THE TOOTH THE OLD GATE HAD NO ANALOGUE OF: publish both, then prove the FILES differ.
306 let beforep: *u8 = "knowledge/nx_sdfsss_before.png" as *u8
307 let afterp: *u8 = "knowledge/nx_sdfsss_after.png" as *u8
308 let nbefore: i64 = png_publish_announced(fbA, sw, sh, beforep)
309 let nafter: i64 = png_publish_announced(fbB, sw, sh, afterp)
310 let offp: *i64 = sys_mmap(SDG_PTR_BYTES) as *i64
311 let filesdiffer: i64 = sdg_files_differ(beforep, afterp, offp)
312 var t5c: i64 = 0
313 if nbefore > 0 { if nafter > 0 { if filesdiffer == 1 { t5c = 1 } } }
314 gv_puts(" A/B capture: before=" as *u8); gv_num(nbefore); gv_puts("B after=" as *u8); gv_num(nafter)
315 gv_puts("B first_differing_byte=" as *u8); gv_num(offp[0]); gv_puts("\n" as *u8)
316 gv_check("T5c ab-captures-DIFFER-when-the-shader-differs" as *u8, t5c, ctr)
317
318 // ---- NEG-CONTROL 1: the no-op writer. The landed-check must FIRE on it and be SILENT on the real
319 // publish. Without this pair, "the capture landed" is an assertion nobody has seen fail.
320 let noopp: *u8 = "/tmp/nx_sdfrender_gate/neg_noop.png" as *u8
321 sys_unlinkat(noopp)
322 sdg_noop_writer(noopp)
323 let d_noop: i64 = sdg_did_not_land(noopp, nbody)
324 let d_real: i64 = sdg_did_not_land(bodyp, nbody)
325 gv_bite("neg-control-noop-writer-must-fail-the-landed-check" as *u8, d_noop, d_real, ctr)
326
327 // ---- NEG-CONTROL 2: THE LIVE DEFECT ITSELF. A publish into a directory that does not exist must
328 // REFUSE with a negative return and must leave no file. This is the failure that was silent before
329 // the fix; it is now bitten inside the gate that was blind to it.
330 let absentp: *u8 = "/tmp/nx_sdfrender_gate/no_such_dir/neg_absent.png" as *u8
331 let rc_absent: i64 = png_publish(fbA, sw, sh, absentp, 0)
332 var fired_absent: i64 = 0
333 if rc_absent < 0 { if sdg_size(absentp) < 0 { fired_absent = 1 } }
334 var fired_present: i64 = 0
335 if nafter < 0 { fired_present = 1 }
336 gv_puts(" neg-control absent-dir: png_publish returned " as *u8); gv_num(rc_absent)
337 gv_puts(", file on disk " as *u8); gv_num(sdg_size(absentp)); gv_puts("\n" as *u8)
338 gv_bite("neg-control-publish-into-absent-directory-must-refuse" as *u8, fired_absent, fired_present, ctr)
339
340 // ================= T6 PRE-INTEGRATED SSS: THE NON-GAMEABLE QUAD ================================
341 // (a) FULLY-AWAY EQUALITY: N.L fully away gives 0 in every channel at every curvature;
342 // (b) TERMINATOR GAIN, RED-ORDERED: at N.L=0 every channel > 0 and red > green > blue;
343 // (c) MONOTONE IN N.L: sun-facing >= terminator >= away, per channel;
344 // (d) CURVATURE WIDENS, NEVER NARROWS, and curv=0 equals the FORMER FIXED WRAP exactly, so flat
345 // skin is byte-identical to the pre-rung renderer. A constant-offset brightener dies at (a),
346 // a uniform one at (b), and the pre-rung shader itself dies at (d).
347 var t6: i64 = 1
348 let aw: i64 = sr_sss_preint(0 - SSS_N_FULL, 0)
349 let awc: i64 = sr_sss_preint(0 - SSS_N_FULL, SSS_CURV_MAX)
350 if aw != 0 { t6 = 0 }
351 if awc != 0 { t6 = 0 }
352 let tm: i64 = flat0
353 let tmr: i64 = tm % SDG_SSS_PK
354 let tmg: i64 = (tm / SDG_SSS_PK) % SDG_SSS_PK
355 let tmb: i64 = tm / (SDG_SSS_PK * SDG_SSS_PK)
356 if tmr <= 0 { t6 = 0 }
357 if tmr <= tmg { t6 = 0 }
358 if tmg <= tmb { t6 = 0 }
359 // the former fixed-wrap values at N.L=0, DERIVED from the widths they came from rather than quoted
360 if tmr != SDG_OLDWRAP_R * SSS_N_FULL / (SDG_OLDWRAP_R + SSS_N_FULL) { t6 = 0 }
361 if tmg != SDG_OLDWRAP_G * SSS_N_FULL / (SDG_OLDWRAP_G + SSS_N_FULL) { t6 = 0 }
362 if tmb != SDG_OLDWRAP_B * SSS_N_FULL / (SDG_OLDWRAP_B + SSS_N_FULL) { t6 = 0 }
363 let sf: i64 = sr_sss_preint(SSS_N_FULL, 0)
364 if (sf % SDG_SSS_PK) < tmr { t6 = 0 }
365 if ((sf / SDG_SSS_PK) % SDG_SSS_PK) < tmg { t6 = 0 }
366 if (sf / (SDG_SSS_PK * SDG_SSS_PK)) < tmb { t6 = 0 }
367 let tc: i64 = curvmax0
368 let tcr: i64 = tc % SDG_SSS_PK
369 let tcg: i64 = (tc / SDG_SSS_PK) % SDG_SSS_PK
370 let tcb: i64 = tc / (SDG_SSS_PK * SDG_SSS_PK)
371 if tcr <= tmr { t6 = 0 }
372 if tcg <= tmg { t6 = 0 }
373 if tcb <= tmb { t6 = 0 }
374 gv_check("T6 sr_sss_preint-away-zero-red-ordered-monotone-and-curvature-widens" as *u8, t6, ctr)
375
376 return gv_verdict("SDFRENDER-GATE" as *u8, ctr,
377 "smooth-union SDF body, one continuous surface, per-pixel lit with curvature-aware pre-integrated SSS -- and the capture is proven on disk, not asserted" as *u8)
378}