diff --git a/AGENTS.md b/AGENTS.md index 943f2d0e4..a2af25cb4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -48,7 +48,7 @@ Game workspace (root `Cargo.toml`); `launcher/` and `crates/horizon-telemetry-se | `horizon-port-pack` | Porting Java modpacks ([docs/modpacks.md](docs/modpacks.md)) | | `horizon-theme` | Design tokens and fonts for the launcher, the game's own menus and the website | | `horizon-telemetry`, `horizon-telemetry-server`, `horizon-bench` | Opt-in data collection, its ingest server, the benchmark report format | -| `horizon-dualsense`, `horizon-threads`, `horizon-release-sign`, `horizon-bots`, `voxel-kernels`, `xtask` | DualSense output, thread priorities, signed release checksums, load-test bots, occupancy kernels, repo tasks | +| `horizon-dualsense`, `horizon-threads`, `horizon-release-sign`, `horizon-bots`, `xtask` | DualSense output, thread priorities, signed release checksums, load-test bots, repo tasks | | `launcher/` | GPUI launcher: `main.rs` (UI), `backend.rs` (installs, updates), `cli.rs`, `mcp.rs`, `*_page.rs` | Other top-level folders: `tools/` (harnesses and dev scripts), `tests/` (Python unit tests: `python3 -m diff --git a/Cargo.lock b/Cargo.lock index 1a1b288c9..550d3eb4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3968,10 +3968,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "voxel-kernels" -version = "0.1.0" - [[package]] name = "walkdir" version = "2.5.0" diff --git a/Cargo.toml b/Cargo.toml index bc67ec748..7ffc68471 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] exclude = ["launcher", "crates/horizon-telemetry-server", "third_party/wgpu-hal"] -members = ["crates/horizon-core", "crates/horizon-dualsense", "crates/horizon-threads", "crates/horizon-world", "crates/voxel-kernels", "crates/horizon-client", "crates/horizon-server-files", "crates/horizon-server", "crates/horizon-bots", "crates/horizon-assets", "crates/horizon-protocol", "crates/horizon-theme", "crates/horizon-shaderpack", "crates/horizon-prepare", "crates/horizon-telemetry", "crates/horizon-bench", "crates/horizon-friends", "crates/horizon-relay", "crates/horizon-mod-sdk", "crates/horizon-mods", "crates/horizon-mods/tests/guest", "crates/cargo-horizon-mod", "crates/horizon-port-pack", "crates/horizon-release-sign", "crates/horizon-mod-sdk/examples/coords-hud", "xtask"] +members = ["crates/horizon-core", "crates/horizon-dualsense", "crates/horizon-threads", "crates/horizon-world", "crates/horizon-client", "crates/horizon-server-files", "crates/horizon-server", "crates/horizon-bots", "crates/horizon-assets", "crates/horizon-protocol", "crates/horizon-theme", "crates/horizon-shaderpack", "crates/horizon-prepare", "crates/horizon-telemetry", "crates/horizon-bench", "crates/horizon-friends", "crates/horizon-relay", "crates/horizon-mod-sdk", "crates/horizon-mods", "crates/horizon-mods/tests/guest", "crates/cargo-horizon-mod", "crates/horizon-port-pack", "crates/horizon-release-sign", "crates/horizon-mod-sdk/examples/coords-hud", "xtask"] resolver = "2" [workspace.package] diff --git a/crates/voxel-kernels/Cargo.toml b/crates/voxel-kernels/Cargo.toml deleted file mode 100644 index f4582e0d1..000000000 --- a/crates/voxel-kernels/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "voxel-kernels" -version = "0.1.0" -edition.workspace = true -license.workspace = true -rust-version.workspace = true - -[[bin]] -name = "voxel-bench" -path = "src/main.rs" - -[lints] -workspace = true diff --git a/crates/voxel-kernels/src/lib.rs b/crates/voxel-kernels/src/lib.rs deleted file mode 100644 index caf72879f..000000000 --- a/crates/voxel-kernels/src/lib.rs +++ /dev/null @@ -1,136 +0,0 @@ -//! Original occupancy kernels for synthetic 16³ voxel sections. -//! A set bit means an opaque full cube; all neighbors outside the section are air. -//! This is not a Minecraft renderer or a model of partial/transparent blocks. - -pub const SIDE: usize = 16; - -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct Section { - rows: [u16; SIDE * SIDE], -} - -impl Default for Section { - fn default() -> Self { - Self { - rows: [0; SIDE * SIDE], - } - } -} - -impl Section { - pub fn from_fn(mut occupied: impl FnMut(usize, usize, usize) -> bool) -> Self { - let mut section = Self::default(); - for z in 0..SIDE { - for y in 0..SIDE { - for x in 0..SIDE { - if occupied(x, y, z) { - section.rows[z * SIDE + y] |= 1 << x; - } - } - } - } - section - } - - pub fn occupied(&self, x: usize, y: usize, z: usize) -> bool { - assert!(x < SIDE && y < SIDE && z < SIDE); - self.rows[z * SIDE + y] & (1 << x) != 0 - } - - /// Simple per-voxel reference. Count each opaque cube's exposed unit faces. - pub fn exposed_faces_scalar(&self) -> u32 { - let mut faces = 0; - for z in 0..SIDE { - for y in 0..SIDE { - for x in 0..SIDE { - if !self.occupied(x, y, z) { - continue; - } - faces += u32::from(x == 0 || !self.occupied(x - 1, y, z)); - faces += u32::from(x + 1 == SIDE || !self.occupied(x + 1, y, z)); - faces += u32::from(y == 0 || !self.occupied(x, y - 1, z)); - faces += u32::from(y + 1 == SIDE || !self.occupied(x, y + 1, z)); - faces += u32::from(z == 0 || !self.occupied(x, y, z - 1)); - faces += u32::from(z + 1 == SIDE || !self.occupied(x, y, z + 1)); - } - } - } - faces - } - - /// Evaluate sixteen voxels at once with row masks and population counts. - pub fn exposed_faces_bitset(&self) -> u32 { - let mut faces = 0; - for z in 0..SIDE { - for y in 0..SIDE { - let i = z * SIDE + y; - let row = self.rows[i]; - let below = if y == 0 { 0 } else { self.rows[i - 1] }; - let above = if y + 1 == SIDE { 0 } else { self.rows[i + 1] }; - let back = if z == 0 { 0 } else { self.rows[i - SIDE] }; - let front = if z + 1 == SIDE { - 0 - } else { - self.rows[i + SIDE] - }; - faces += (row & !(row << 1)).count_ones(); - faces += (row & !(row >> 1)).count_ones(); - faces += (row & !below).count_ones(); - faces += (row & !above).count_ones(); - faces += (row & !back).count_ones(); - faces += (row & !front).count_ones(); - } - } - faces - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn check(section: &Section, expected: u32) { - assert_eq!(section.exposed_faces_scalar(), expected); - assert_eq!(section.exposed_faces_bitset(), expected); - } - - #[test] - fn known_geometry() { - check(&Section::default(), 0); - check(&Section::from_fn(|_, _, _| true), 6 * 16 * 16); - check(&Section::from_fn(|x, y, z| x == 3 && y == 4 && z == 5), 6); - check(&Section::from_fn(|x, y, z| x < 2 && y == 4 && z == 5), 10); - check( - &Section::from_fn(|x, y, z| (x + y + z) % 2 == 0), - 4096 / 2 * 6, - ); - } - - #[test] - fn every_single_voxel_including_boundaries() { - for i in 0..SIDE.pow(3) { - let mut section = Section::default(); - section.rows[i / SIDE] = 1 << (i % SIDE); - check(§ion, 6); - } - } - - #[test] - fn random_occupancy_matches_reference_at_multiple_densities() { - let mut state = 0x1234_5678_9abc_def0_u64; - for threshold in [0, 1, 16, 64, 128, 192, 254, 255, 256] { - for _ in 0..32 { - let section = Section::from_fn(|_, _, _| { - state ^= state << 13; - state ^= state >> 7; - state ^= state << 17; - (state & 255) < threshold - }); - assert_eq!( - section.exposed_faces_scalar(), - section.exposed_faces_bitset() - ); - } - } - } -} diff --git a/crates/voxel-kernels/src/main.rs b/crates/voxel-kernels/src/main.rs deleted file mode 100644 index e2443958b..000000000 --- a/crates/voxel-kernels/src/main.rs +++ /dev/null @@ -1,92 +0,0 @@ -use std::{hint::black_box, time::Instant}; -use voxel_kernels::Section; - -fn sample(corpus: &[Section], kernel: fn(&Section) -> u32, repeats: usize) -> f64 { - let start = Instant::now(); - let mut checksum = 0_u64; - for _ in 0..repeats { - for section in corpus { - checksum = checksum.wrapping_add(u64::from(kernel(black_box(section)))); - } - } - black_box(checksum); - start.elapsed().as_nanos() as f64 / (corpus.len() * repeats) as f64 -} - -fn median(samples: &mut [f64]) -> f64 { - samples.sort_by(f64::total_cmp); - samples[samples.len() / 2] -} - -fn main() { - let repeats: usize = match std::env::args().nth(1) { - None => 100, - Some(value) => match value.parse() { - Ok(n) if n > 0 => n, - _ => { - eprintln!("usage: voxel-bench [positive repeat count]"); - std::process::exit(2); - } - }, - }; - let mut rng = 0x7065_7273_6f6e_616c_u64; - let random = |rng: &mut u64| { - *rng ^= *rng << 13; - *rng ^= *rng >> 7; - *rng ^= *rng << 17; - *rng - }; - println!( - "workload,sections,samples,repeats,scalar_ns_per_section,bitset_ns_per_section,speedup" - ); - for workload in [ - "empty", - "solid", - "flat", - "checkerboard", - "random_10", - "random_50", - "random_90", - ] { - let corpus: Vec<_> = (0..32) - .map(|i| { - Section::from_fn(|x, y, z| match workload { - "empty" => false, - "solid" => true, - "flat" => y < 1 + i % 15, - "checkerboard" => (x + y + z + i) % 2 == 0, - "random_10" => random(&mut rng) % 100 < 10, - "random_50" => random(&mut rng) % 100 < 50, - "random_90" => random(&mut rng) % 100 < 90, - _ => unreachable!(), - }) - }) - .collect(); - for section in &corpus { - assert_eq!( - section.exposed_faces_scalar(), - section.exposed_faces_bitset() - ); - } - for kernel in [Section::exposed_faces_scalar, Section::exposed_faces_bitset] { - sample(&corpus, kernel, 10); - } - let mut scalar = Vec::new(); - let mut bitset = Vec::new(); - for trial in 0..21 { - if trial % 2 == 0 { - scalar.push(sample(&corpus, Section::exposed_faces_scalar, repeats)); - bitset.push(sample(&corpus, Section::exposed_faces_bitset, repeats)); - } else { - bitset.push(sample(&corpus, Section::exposed_faces_bitset, repeats)); - scalar.push(sample(&corpus, Section::exposed_faces_scalar, repeats)); - } - } - let scalar = median(&mut scalar); - let bitset = median(&mut bitset); - println!( - "{workload},32,21,{repeats},{scalar:.2},{bitset:.2},{:.2}", - scalar / bitset - ); - } -} diff --git a/docs/research-lab.md b/docs/research-lab.md index ae147364e..f7aa969d5 100644 --- a/docs/research-lab.md +++ b/docs/research-lab.md @@ -75,11 +75,8 @@ separate implementation. [Geometry and collision scope](collision-geometry.md). ```sh cargo test --workspace -cargo run --release --bin voxel-bench -- 100 > .local/voxel-benchmark.csv ``` -The dependency-free occupancy experiment compares scalar and bitset exposed-face counting for synthetic 16³ sections. It has no real mesh, material/AO/light work, neighboring-section context, JNI bridge or game integration. Speedups are kernel-only, not Minecraft FPS. - Public branding and new mod downloads use **Horizon**. The existing Fabric mod ID and `dev.horizonlab` namespace remain stable for installed instances and measurement compatibility. The installer backs up both old `horizon-lab-*.jar` diff --git a/tests/test_lab.py b/tests/test_lab.py index 648160ce1..f10a5fd55 100644 --- a/tests/test_lab.py +++ b/tests/test_lab.py @@ -172,7 +172,7 @@ class PublicationTests(unittest.TestCase): def test_private_paths_rejected(self): for path in [".local/minecraft/source.java", "decompiled/Foo.txt", "game.JAR", "capture.jfr", "source/Foo.java"]: self.assertTrue(check_public_tree.prohibited(path), path) - for path in ["tools/lab.py", "crates/voxel-kernels/src/lib.rs", "Cargo.lock", "docs/analysis.md", + for path in ["tools/lab.py", "crates/horizon-core/src/lib.rs", "Cargo.lock", "docs/analysis.md", "mods/horizon/src/main/java/dev/horizonlab/HorizonLab.java", "mods/horizon-lab/src/main/java/dev/horizonlab/HorizonLab.java"]: self.assertFalse(check_public_tree.prohibited(path), path)