Skip to content

Commit 7cd55b7

Browse files
committed
Created integration tests
1 parent 611ef98 commit 7cd55b7

15 files changed

+255
-436
lines changed

.github/workflows/wasm-splats-ci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
- name: Build wasm-splats
5454
run: wasm-pack build ./wasm-splats --release --target web --scope cesium
5555

56-
- name: Pack wasm-splats
57-
run: wasm-pack pack ./wasm-splats/pkg
58-
59-
## TODO: Save artifacts to AWS.
56+
# TODO: Get rid of this when I no longer need it.
57+
# - name: Pack wasm-splats
58+
# run: wasm-pack publish ./wasm-splats/pkg

wasm-splats/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/common/data/** filter=lfs diff=lfs merge=lfs -text

wasm-splats/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wasm-splats"
3-
version = "1.0.0"
3+
version = "0.1.0-alpha"
44
authors = ["Cesium GS, Inc. <https://cesium.com>"]
55
edition = "2021"
66

@@ -22,7 +22,9 @@ web-sys = { version = "0.3.76", features = ["console"] }
2222
console_error_panic_hook = { version = "0.1.7", optional = true }
2323

2424
[dev-dependencies]
25-
wasm-bindgen-test = "0.3.49"
25+
wasm-bindgen-test = "0.3"
26+
serde = { version = "1.0", features = ["derive"] }
27+
serde_json = "1.0"
2628

2729
# Typically we wouldn't include profiles in a workspace project like this, but `wasm-pack` doesn't support workspaces yet.
2830
[profile.release]

wasm-splats/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
mod radix;
2-
mod radix_simd;
3-
mod texture_gen;
1+
pub mod radix;
2+
pub mod texture_gen;
43

54
use js_sys::{Float32Array, Object, Uint32Array, Uint8Array};
65
use wasm_bindgen::prelude::*;

wasm-splats/src/radix.rs

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,6 @@
11
use js_sys::{Float32Array, Uint32Array, Uint8Array};
22
use wasm_bindgen::prelude::*;
33

4-
#[wasm_bindgen]
5-
pub fn radix_sort_gaussians_attrs(
6-
positions: &Float32Array,
7-
scales: &Float32Array,
8-
rotations: &Float32Array,
9-
colors: &Uint8Array,
10-
model_view: &Float32Array,
11-
count: usize,
12-
) -> Result<js_sys::Array, JsValue> {
13-
if positions.length() as usize != count * 3
14-
|| scales.length() as usize != count * 3
15-
|| rotations.length() as usize != count * 4
16-
|| colors.length() as usize != count * 4
17-
|| model_view.length() != 16
18-
{
19-
return Err(JsValue::from_str("Invalid array lengths"));
20-
}
21-
22-
//set capacity first
23-
let positions_vec = positions.to_vec();
24-
let model_view_vec = model_view.to_vec();
25-
26-
let mut depth_values = vec![0i32; count];
27-
let mut max_depth = f32::NEG_INFINITY;
28-
let mut min_depth = f32::INFINITY;
29-
30-
for i in 0..count {
31-
let depth = positions_vec[i * 3] * model_view_vec[2]
32-
+ positions_vec[i * 3 + 1] * model_view_vec[6]
33-
+ positions_vec[i * 3 + 2] * model_view_vec[10];
34-
35-
let depth_int = (depth * 4096.0) as i32;
36-
depth_values[i] = depth_int;
37-
max_depth = max_depth.max(depth_int as f32);
38-
min_depth = min_depth.min(depth_int as f32);
39-
}
40-
41-
let depth_offset = (-min_depth) as i32;
42-
for depth in depth_values.iter_mut() {
43-
*depth += depth_offset;
44-
}
45-
46-
let mut indices: Vec<u32> = (0..count as u32).collect();
47-
let mut temp_depths = vec![0i32; count];
48-
let mut temp_indices = vec![0u32; count];
49-
50-
for shift in (0..32).step_by(8) {
51-
let mut counts = [0u32; 256];
52-
53-
for &depth in depth_values.iter() {
54-
let byte = ((depth >> shift) & 0xFF) as usize;
55-
counts[byte] += 1;
56-
}
57-
58-
let mut total = 0;
59-
for count in counts.iter_mut() {
60-
let current = *count;
61-
*count = total;
62-
total += current;
63-
}
64-
65-
for i in 0..count {
66-
let byte = ((depth_values[i] >> shift) & 0xFF) as usize;
67-
let pos = counts[byte] as usize;
68-
counts[byte] += 1;
69-
70-
temp_depths[pos] = depth_values[i];
71-
temp_indices[pos] = indices[i];
72-
}
73-
74-
depth_values.copy_from_slice(&temp_depths);
75-
indices.copy_from_slice(&temp_indices);
76-
}
77-
78-
let mut new_positions: Vec<f32> = vec![0.0; count * 3];
79-
let mut new_scales: Vec<f32> = vec![0.0; count * 3];
80-
let mut new_rotations: Vec<f32> = vec![0.0; count * 4];
81-
let mut new_colors: Vec<u8> = vec![0; count * 4];
82-
83-
let scales_vec = scales.to_vec();
84-
let rotations_vec = rotations.to_vec();
85-
let colors_vec = colors.to_vec();
86-
87-
for i in 0..count {
88-
let j = indices[i] as usize;
89-
90-
new_positions[i * 3] = positions_vec[j * 3];
91-
new_positions[i * 3 + 1] = positions_vec[j * 3 + 1];
92-
new_positions[i * 3 + 2] = positions_vec[j * 3 + 2];
93-
94-
new_scales[i * 3] = scales_vec[j * 3];
95-
new_scales[i * 3 + 1] = scales_vec[j * 3 + 1];
96-
new_scales[i * 3 + 2] = scales_vec[j * 3 + 2];
97-
98-
new_rotations[i * 4] = rotations_vec[j * 4];
99-
new_rotations[i * 4 + 1] = rotations_vec[j * 4 + 1];
100-
new_rotations[i * 4 + 2] = rotations_vec[j * 4 + 2];
101-
new_rotations[i * 4 + 3] = rotations_vec[j * 4 + 3];
102-
103-
new_colors[i * 4] = colors_vec[j * 4];
104-
new_colors[i * 4 + 1] = colors_vec[j * 4 + 1];
105-
new_colors[i * 4 + 2] = colors_vec[j * 4 + 2];
106-
new_colors[i * 4 + 3] = colors_vec[j * 4 + 3];
107-
}
108-
109-
let new_positions_array = Float32Array::new_with_length(count as u32 * 3);
110-
new_positions_array.copy_from(&new_positions[..]);
111-
112-
let new_scales_array = Float32Array::new_with_length(count as u32 * 3);
113-
new_scales_array.copy_from(&new_scales[..]);
114-
115-
let new_rotations_array = Float32Array::new_with_length(count as u32 * 4);
116-
new_rotations_array.copy_from(&new_rotations[..]);
117-
118-
let new_colors_array = Uint8Array::new_with_length(count as u32 * 4);
119-
new_colors_array.copy_from(&new_colors[..]);
120-
121-
let result = js_sys::Array::new();
122-
result.push(&new_positions_array);
123-
result.push(&new_scales_array);
124-
result.push(&new_rotations_array);
125-
result.push(&new_colors_array);
126-
127-
Ok(result)
128-
}
129-
1304
#[wasm_bindgen]
1315
pub fn radix_sort_gaussians_indexes(
1326
positions: &Float32Array,

0 commit comments

Comments
 (0)