Skip to content

Commit f97ac33

Browse files
committed
cesium/oracle: reframe reference renderer as same-binary, no FFI
The oracle's cross-renderer reference is an existing in-scope 3DGS renderer (brush via wgpu by default; Inria gaussian-splatting / diff-gaussian-rasterization under CUDA) wired as an ordinary workspace dependency in the SAME binary. Remove the cesium-native `extern "C"` / `#[link]` FFI placeholder and the CesiumJS framing entirely — there is no foreign ABI and never will be. Both reference paths consume the same CAM SoA GaussianBatch and emit the same interleaved-RGB framebuffer, so ParityMetrics diffs like-for-like. Also fix a clippy len_zero warning. https://claude.ai/code/session_017GFLBnDy23AWBqvkbHHC41
1 parent aaccaa8 commit f97ac33

1 file changed

Lines changed: 55 additions & 21 deletions

File tree

crates/cesium/src/oracle.rs

Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,32 @@
3030
//! `raster::rasterize_tile` then performs a **front-to-back alpha-blend** with
3131
//! early-out at `T < T_SATURATION_EPS = 1e-4`.
3232
//!
33-
//! External renderers (CesiumJS, three-gaussian-splatting) often use
34-
//! **back-to-front** (painter's-algorithm) order instead. When two or more
33+
//! The reference renderers (brush, Inria `diff-gaussian-rasterization`) may
34+
//! sort **back-to-front** (painter's-algorithm) instead. When two or more
3535
//! Gaussians have nearly equal depth, floating-point accumulation order is
3636
//! reversed between the two approaches, producing per-pixel colour differences
3737
//! of order `O(alpha²)`. For high-opacity scenes this can be several dB of
3838
//! PSNR. Any SSIM/PSNR delta unexplained by numerical noise should be
3939
//! investigated for sort-order as the primary suspect.
4040
//!
41-
//! # Real Cesium / cesium-native FFI — DEFERRED
41+
//! # Reference renderer — same binary, NO FFI
4242
//!
43-
//! Running a real CesiumJS or cesium-native render requires a browser/Node
44-
//! context or C++ FFI. That is out of scope for this crate; the interface
45-
//! below is a placeholder. Do NOT attempt to wire it without a full
46-
//! `unsafe` audit by `sentinel-qa`.
43+
//! There is **no Cesium/cesium-native FFI** and there never will be. The
44+
//! oracle's "reference" is one of the existing in-scope 3DGS renderers wired
45+
//! as an ordinary workspace dependency in the **same binary** (A-to-Z, no
46+
//! `extern "C"`, no browser/Node, no C++ ABI):
47+
//!
48+
//! - **`brush`** (`AdaWorldAPI/brush`, Rust + `wgpu`) — runnable in-binary on
49+
//! CPU/any-GPU with no CUDA toolchain; the default reference path.
50+
//! - **Inria `gaussian-splatting`** + **`diff-gaussian-rasterization`**
51+
//! (`AdaWorldAPI/*`, CUDA) — the ground-truth rasterizer when a CUDA device
52+
//! is present; same binary, linked as a normal Rust crate, not via FFI.
53+
//!
54+
//! All three speak our CAM SoA (`splat3d::gaussian::GaussianBatch`) at the
55+
//! boundary, so the oracle compares like-for-like: load → render(ours) vs
56+
//! render(reference) → SSIM/PSNR. None of these is a foreign binary; the
57+
//! wiring is `[dependencies]` + a direct call, gated by `cfg`/feature, once
58+
//! `ndarray` is re-enabled in `Cargo.toml`.
4759
//!
4860
//! # Implementation status
4961
//!
@@ -75,9 +87,10 @@ pub enum OracleError {
7587
DimensionMismatch { ref_len: usize, candidate_len: usize },
7688
/// The render pipeline returned an empty framebuffer (width or height = 0).
7789
EmptyFramebuffer,
78-
// DEFERRED: CesiumNativeFfi — wiring real cesium-native requires C++ FFI
79-
// and a sentinel-qa unsafe audit; placeholder variant reserved.
80-
// CesiumNativeFfi(String),
90+
// DEFERRED: ReferenceRender(String) — reserved for failures from the
91+
// in-binary reference renderer (brush / Inria), wired as a workspace
92+
// dependency once `ndarray` is re-enabled in Cargo.toml. NOT an FFI path.
93+
// ReferenceRender(String),
8194
}
8295

8396
impl std::fmt::Display for OracleError {
@@ -156,7 +169,7 @@ impl ParityMetrics {
156169
/// ```
157170
pub fn compute(reference: &[f32], candidate: &[f32]) -> Result<Self, OracleError> {
158171
let n = reference.len();
159-
if n == 0 || candidate.len() == 0 {
172+
if n == 0 || candidate.is_empty() {
160173
return Err(OracleError::EmptyFramebuffer);
161174
}
162175
if n != candidate.len() {
@@ -319,20 +332,41 @@ impl ParityMetrics {
319332
// }
320333

321334
// ─────────────────────────────────────────────────────────────────────────────
322-
// DEFERRED: Real Cesium / cesium-native FFI
335+
// DEFERRED: in-binary reference renderer (brush / Inria) — NO FFI
323336
// ─────────────────────────────────────────────────────────────────────────────
324337

325-
// DEFERRED: Running a real CesiumJS render requires a browser/Node context
326-
// (Electron or Puppeteer) and is out of scope for this crate.
338+
// The cross-renderer reference is an existing in-scope 3DGS renderer wired as
339+
// an ordinary workspace dependency in the SAME binary — no `extern "C"`, no
340+
// `#[link]`, no browser/Node, no foreign ABI. It consumes the same CAM SoA
341+
// `GaussianBatch` we feed `splat3d`, renders to the same interleaved-RGB
342+
// framebuffer layout, and we diff the two with `ParityMetrics::compute`.
343+
//
344+
// DEFERRED until `ndarray` (and the chosen reference crate) are re-enabled in
345+
// Cargo.toml and the module passes Opus + CodeRabbit review:
327346
//
328-
// DEFERRED: Running cesium-native requires C++ FFI via `unsafe extern "C"`.
329-
// Placeholder stub — do NOT implement without sentinel-qa unsafe audit:
347+
// // Default reference: brush (Rust + wgpu, runnable without CUDA).
348+
// // UNVERIFIED: brush's public render entry point + camera/SoA adapter shape;
349+
// // confirm against AdaWorldAPI/brush before wiring.
350+
// fn render_reference_brush(
351+
// batch: &GaussianBatch,
352+
// camera: &Camera,
353+
// background: [f32; 3],
354+
// ) -> Result<Vec<f32>, OracleError> {
355+
// // brush::render(...) → Vec<f32> interleaved RGB, len = 3·W·H
356+
// todo!("wire brush as same-binary workspace dep")
357+
// }
330358
//
331-
// #[link(name = "cesium_native")]
332-
// extern "C" {
333-
// // UNVERIFIED: cesium-native does not expose a stable C ABI as of 2024-Q3.
334-
// // fn cesium_render_ply(path: *const u8, path_len: usize,
335-
// // out_rgb: *mut f32, width: u32, height: u32) -> i32;
359+
// // Ground truth (when a CUDA device is present): Inria gaussian-splatting /
360+
// // diff-gaussian-rasterization, linked as a normal Rust crate (NOT FFI),
361+
// // gated behind a `cuda` cfg/feature.
362+
// // UNVERIFIED: the Rust-facing entry point exposed by the Inria crates.
363+
// #[cfg(feature = "cuda")]
364+
// fn render_reference_inria(
365+
// batch: &GaussianBatch,
366+
// camera: &Camera,
367+
// background: [f32; 3],
368+
// ) -> Result<Vec<f32>, OracleError> {
369+
// todo!("wire diff-gaussian-rasterization as same-binary workspace dep")
336370
// }
337371

338372
// ─────────────────────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)