Skip to content

Commit 7bba056

Browse files
committed
splat3d: cargo fmt --all pass across all sprint files
Mechanical formatting fixes from `cargo fmt --all` — no semantic changes. Brings the 12 splat3d files (PR 1-7 + fixes) into rustfmt compliance so the workspace gate stays green. Files reformatted: benches/splat3d_bench.rs examples/splat3d_flex.rs src/hpc/splat3d/{mod,spd3,gaussian,sh,project,tile,raster,frame,ply}.rs tests/splat3d_correctness.rs Acceptance: cargo fmt --all --check → clean cargo test --features splat3d --lib hpc::splat3d → 91 passed cargo test --features splat3d --test splat3d_correctness → 5 passed cargo check --features splat3d --benches --bench splat3d_bench → clean cargo check --features splat3d --example splat3d_flex → clean https://claude.ai/code/session_017GFLBnDy23AWBqvkbHHC41
1 parent 24ec2b9 commit 7bba056

12 files changed

Lines changed: 600 additions & 701 deletions

File tree

benches/splat3d_bench.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ fn bench_spd3_from_scale_quat(c: &mut Criterion) {
9696
}
9797

9898
criterion_group!(
99-
spd3,
100-
bench_spd3_sandwich_scalar_loop,
101-
bench_spd3_sandwich_simd_x16,
102-
bench_spd3_eig,
103-
bench_spd3_from_scale_quat,
99+
spd3, bench_spd3_sandwich_scalar_loop, bench_spd3_sandwich_simd_x16, bench_spd3_eig, bench_spd3_from_scale_quat,
104100
);
105101
criterion_main!(spd3);

examples/splat3d_flex.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
3636
#![cfg(feature = "splat3d")]
3737

38-
use ndarray::hpc::splat3d::{
39-
read_ply, Camera, Gaussian3D, SplatFrame, SH_COEFFS_PER_GAUSSIAN,
40-
};
38+
use ndarray::hpc::splat3d::{read_ply, Camera, Gaussian3D, SplatFrame, SH_COEFFS_PER_GAUSSIAN};
4139
use std::env;
4240
use std::fs::{create_dir_all, File};
4341
use std::io::{BufReader, BufWriter, Write};
@@ -68,13 +66,21 @@ impl Args {
6866
"--width" => width = argv.next().and_then(|s| s.parse().ok()).unwrap_or(width),
6967
"--height" => height = argv.next().and_then(|s| s.parse().ok()).unwrap_or(height),
7068
"-h" | "--help" => {
71-
eprintln!("Usage: splat3d_flex [--scene PATH.ply] [--frames N] [--out DIR] [--width W] [--height H]");
69+
eprintln!(
70+
"Usage: splat3d_flex [--scene PATH.ply] [--frames N] [--out DIR] [--width W] [--height H]"
71+
);
7272
std::process::exit(0);
7373
}
7474
other => eprintln!("warning: unrecognized arg `{other}` (ignored)"),
7575
}
7676
}
77-
Args { scene, frames, out, width, height }
77+
Args {
78+
scene,
79+
frames,
80+
out,
81+
width,
82+
height,
83+
}
7884
}
7985
}
8086

@@ -212,10 +218,7 @@ fn main() {
212218
f
213219
};
214220

215-
eprintln!(
216-
"Rendering {} frames at {}×{} into {} …",
217-
args.frames, args.width, args.height, args.out.display()
218-
);
221+
eprintln!("Rendering {} frames at {}×{} into {} …", args.frames, args.width, args.height, args.out.display());
219222
let path = bake_circular_camera_path(args.width, args.height, args.frames);
220223
let mut times_ms: Vec<f64> = Vec::with_capacity(args.frames);
221224

src/hpc/splat3d/frame.rs

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
1111
use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
1212

1313
use crate::hpc::splat3d::gaussian::GaussianBatch;
14-
use crate::hpc::splat3d::project::{Camera, ProjectedBatch, project_batch};
15-
use crate::hpc::splat3d::tile::TileBinning;
14+
use crate::hpc::splat3d::project::{project_batch, Camera, ProjectedBatch};
1615
use crate::hpc::splat3d::raster::rasterize_frame;
16+
use crate::hpc::splat3d::tile::TileBinning;
1717

1818
// ════════════════════════════════════════════════════════════════════════════
1919
// SplatFrame — one frame's full state
@@ -84,14 +84,7 @@ impl SplatFrame {
8484
self.binning = TileBinning::from_projected(&self.projected, camera);
8585

8686
// 3. Rasterize: depth-sorted alpha-blend into framebuffer
87-
rasterize_frame(
88-
&self.binning,
89-
&self.projected,
90-
&mut self.framebuffer,
91-
self.width,
92-
self.height,
93-
background,
94-
);
87+
rasterize_frame(&self.binning, &self.projected, &mut self.framebuffer, self.width, self.height, background);
9588

9689
// 4. Advance frame counter
9790
self.frame_id += 1;
@@ -101,25 +94,38 @@ impl SplatFrame {
10194
pub fn byte_footprint(&self) -> usize {
10295
// GaussianBatch: 11 f32 vecs × capacity + SH vec
10396
let g = &self.gaussians;
104-
let gaussian_bytes = (
105-
g.mean_x.len() + g.mean_y.len() + g.mean_z.len()
106-
+ g.scale_x.len() + g.scale_y.len() + g.scale_z.len()
107-
+ g.quat_w.len() + g.quat_x.len() + g.quat_y.len() + g.quat_z.len()
108-
+ g.opacity.len()
109-
) * 4 + g.sh.len() * 4;
97+
let gaussian_bytes = (g.mean_x.len()
98+
+ g.mean_y.len()
99+
+ g.mean_z.len()
100+
+ g.scale_x.len()
101+
+ g.scale_y.len()
102+
+ g.scale_z.len()
103+
+ g.quat_w.len()
104+
+ g.quat_x.len()
105+
+ g.quat_y.len()
106+
+ g.quat_z.len()
107+
+ g.opacity.len())
108+
* 4
109+
+ g.sh.len() * 4;
110110

111111
// ProjectedBatch: 10 f32 vecs × capacity + 1 u8 vec
112112
let p = &self.projected;
113-
let projected_bytes = (
114-
p.screen_x.len() + p.screen_y.len() + p.depth.len()
115-
+ p.conic_a.len() + p.conic_b.len() + p.conic_c.len()
116-
+ p.radius.len() + p.color_r.len() + p.color_g.len()
117-
+ p.color_b.len() + p.opacity.len()
118-
) * 4 + p.valid.len();
113+
let projected_bytes = (p.screen_x.len()
114+
+ p.screen_y.len()
115+
+ p.depth.len()
116+
+ p.conic_a.len()
117+
+ p.conic_b.len()
118+
+ p.conic_c.len()
119+
+ p.radius.len()
120+
+ p.color_r.len()
121+
+ p.color_g.len()
122+
+ p.color_b.len()
123+
+ p.opacity.len())
124+
* 4
125+
+ p.valid.len();
119126

120127
// TileBinning
121-
let binning_bytes = self.binning.instances.len() * 16
122-
+ self.binning.tile_offsets.len() * 4;
128+
let binning_bytes = self.binning.instances.len() * 16 + self.binning.tile_offsets.len() * 4;
123129

124130
// Framebuffer
125131
let fb_bytes = self.framebuffer.len() * 4;
@@ -241,8 +247,7 @@ mod tests {
241247
assert_eq!(frame.width, 64);
242248
assert_eq!(frame.height, 48);
243249
assert_eq!(frame.framebuffer.len(), 3 * 64 * 48);
244-
assert!(frame.gaussians.capacity >= 100,
245-
"capacity {} < 100", frame.gaussians.capacity);
250+
assert!(frame.gaussians.capacity >= 100, "capacity {} < 100", frame.gaussians.capacity);
246251
assert_eq!(frame.frame_id, 0);
247252
}
248253

@@ -255,8 +260,10 @@ mod tests {
255260
frame.tick(&camera, [0.0, 0.0, 0.0]);
256261
assert_eq!(frame.frame_id, 1);
257262
// With zero gaussians, framebuffer must be all-black (background = black)
258-
assert!(frame.framebuffer.iter().all(|&v| v == 0.0),
259-
"framebuffer should be all black with zero gaussians and black background");
263+
assert!(
264+
frame.framebuffer.iter().all(|&v| v == 0.0),
265+
"framebuffer should be all black with zero gaussians and black background"
266+
);
260267
}
261268

262269
// ── Test 3 ───────────────────────────────────────────────────────────────
@@ -275,7 +282,7 @@ mod tests {
275282
// SH DC contribution: color = 0.5 + 0.282_095 * sh_dc
276283
// To get color > background (0.0), we need a positive DC.
277284
// Use a large positive value so the clamped output is clearly > 0.
278-
g.sh[0] = 3.0; // R channel DC
285+
g.sh[0] = 3.0; // R channel DC
279286
g.sh[16] = 3.0; // G channel DC
280287
g.sh[32] = 3.0; // B channel DC
281288
g.scale = [0.5, 0.5, 0.5]; // Visible screen-space radius
@@ -288,8 +295,7 @@ mod tests {
288295
let cy = 32usize;
289296
let idx = (cy * 64 + cx) * 3;
290297
let r = frame.framebuffer[idx];
291-
assert!(r > 0.0,
292-
"center pixel R={r} should be > 0 after rendering a bright gaussian");
298+
assert!(r > 0.0, "center pixel R={r} should be > 0 after rendering a bright gaussian");
293299
}
294300

295301
// ── Test 4 ───────────────────────────────────────────────────────────────
@@ -368,8 +374,7 @@ mod tests {
368374
#[test]
369375
fn splat_frame_byte_footprint_nonzero() {
370376
let frame = SplatFrame::with_capacity(64, 32, 32);
371-
assert!(frame.byte_footprint() > 0,
372-
"byte_footprint should be > 0 for a non-empty frame");
377+
assert!(frame.byte_footprint() > 0, "byte_footprint should be > 0 for a non-empty frame");
373378
}
374379

375380
// ── Test 10 ──────────────────────────────────────────────────────────────
@@ -401,9 +406,6 @@ mod tests {
401406

402407
r.tick(&camera, [0.0, 0.0, 0.0]);
403408

404-
assert_ne!(
405-
ptr_before_tick1, ptr_before_tick2,
406-
"two ticks must render to different physical frame buffers"
407-
);
409+
assert_ne!(ptr_before_tick1, ptr_before_tick2, "two ticks must render to different physical frame buffers");
408410
}
409411
}

0 commit comments

Comments
 (0)