Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re_renderer: Arrow buffers as (optional) first-class citizen #1482

Merged
merged 30 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
db87ebf
implement depth cloud renderer
teh-cmc Feb 27, 2023
ea87f88
proper rp config
teh-cmc Feb 27, 2023
931b468
self-review
teh-cmc Feb 27, 2023
0ee30e1
handle breaking changes from main
teh-cmc Feb 28, 2023
66729fe
upload depth textures through staging belt
teh-cmc Feb 28, 2023
981ddfc
addressing PR comments part 1 of N
teh-cmc Feb 28, 2023
90ecd3d
work around wgpu d16 web issue
teh-cmc Feb 28, 2023
f8bd1fc
addressing PR comments part 2 of N
teh-cmc Feb 28, 2023
ad9b19e
big refactoring of the whole quad spanning story
teh-cmc Feb 28, 2023
3d79fd6
accomodating breaking changes
teh-cmc Mar 1, 2023
85f40ca
bring back coverage
teh-cmc Mar 1, 2023
5e84d89
todos
teh-cmc Mar 1, 2023
6dd8819
procedural example
teh-cmc Mar 1, 2023
e564ce3
clean
teh-cmc Mar 1, 2023
2114e22
fix wasm cranky
teh-cmc Mar 2, 2023
d12a5b9
set up entity props & selection panel for backprojection
teh-cmc Feb 27, 2023
0335097
integrate depth clouds into rerun
teh-cmc Feb 27, 2023
2356b33
last merge conflicts
teh-cmc Mar 1, 2023
e157911
huh, nasty
teh-cmc Mar 2, 2023
cb9d705
everything working as i want
teh-cmc Mar 2, 2023
7cf4fd0
cleanin up
teh-cmc Mar 2, 2023
6581a98
self review
teh-cmc Mar 2, 2023
e0ea750
arrow as a first-class citizen
teh-cmc Mar 2, 2023
007c81b
Merge branch 'main' into cmc/depth_clouds_integration
teh-cmc Mar 2, 2023
3588352
Merge branch 'main' into cmc/depth_clouds_integration
teh-cmc Mar 3, 2023
4c0ad58
compute auto heuristics properly
teh-cmc Mar 3, 2023
a9c1fb1
gentle radius scale
teh-cmc Mar 3, 2023
cb63756
Merge branch 'cmc/depth_clouds_integration' into cmc/re_renderer_arrow
teh-cmc Mar 3, 2023
bb38d2a
transparent arrow integration
teh-cmc Mar 3, 2023
ec110ce
explicitly enable arrow for re_viewer
teh-cmc Mar 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion crates/re_renderer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]


[features]
default = ["import-obj", "import-gltf"]
default = ["arrow", "import-obj", "import-gltf"]
teh-cmc marked this conversation as resolved.
Show resolved Hide resolved

## Support for Arrow datatypes for end-to-end zero-copy.
arrow = ["dep:arrow2"]

## Support importing .obj files
import-obj = ["dep:tobj"]
Expand Down Expand Up @@ -61,6 +64,7 @@ thiserror.workspace = true
type-map = "0.5"

# optional
arrow2 = { workspace = true, optional = true }
gltf = { workspace = true, optional = true }
serde = { version = "1", features = ["derive"], optional = true }
tobj = { version = "3.2", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/re_renderer/examples/depth_cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ impl DepthTexture {
spiral(dimensions).for_each(|(texcoords, d)| {
data[(texcoords.x + texcoords.y * dimensions.x) as usize] = d;
});
let data = DepthCloudDepthData::F32(data);
let data = DepthCloudDepthData::F32(data.into());

Self { dimensions, data }
}
Expand Down
10 changes: 10 additions & 0 deletions crates/re_renderer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ pub use ecolor::{Color32, Rgba};

// ---------------------------------------------------------------------------

// Make Arrow integration as transparent as possible.

#[cfg(feature = "arrow")]
pub type Buffer<T> = arrow2::buffer::Buffer<T>;

#[cfg(not(feature = "arrow"))]
pub type Buffer<T> = Vec<T>;

// ---------------------------------------------------------------------------

/// Profiling macro for puffin
#[doc(hidden)]
#[macro_export]
Expand Down
12 changes: 9 additions & 3 deletions crates/re_renderer/src/renderer/depth_cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ mod gpu_data {
// TODO(cmc): expose knobs to linearize/normalize/flip/cam-to-plane depth.
#[derive(Debug, Clone)]
pub enum DepthCloudDepthData {
U16(Vec<u16>),
F32(Vec<f32>),
U16(crate::Buffer<u16>),
F32(crate::Buffer<f32>),
}

impl Default for DepthCloudDepthData {
fn default() -> Self {
Self::F32(Default::default())
}
}

pub struct DepthCloud {
Expand Down Expand Up @@ -92,7 +98,7 @@ impl Default for DepthCloud {
depth_camera_intrinsics: glam::Mat3::IDENTITY,
radius_scale: 1.0,
depth_dimensions: glam::UVec2::ZERO,
depth_data: DepthCloudDepthData::F32(Vec::new()),
depth_data: DepthCloudDepthData::default(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ re_log_types = { workspace = true, features = [
] }
re_memory.workspace = true
re_query.workspace = true
re_renderer = { workspace = true, features = ["serde"] }
re_renderer = { workspace = true, features = ["arrow", "serde"] }
re_smart_channel.workspace = true
re_string_interner.workspace = true
re_tensor_ops.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,9 @@ impl ImagesPart {

// TODO(cmc): automagically convert as needed for non-natively supported datatypes?
let data = match &tensor.data {
// TODO(cmc): re_renderer needs native interop with Arrow, we shouldn't need to
// allocate this massive buffer and do a memcpy when we could just carry arround the
// original `arrow::Buffer`.
TensorData::U16(data) => DepthCloudDepthData::U16(data.to_vec()),
TensorData::F32(data) => DepthCloudDepthData::F32(data.to_vec()),
// NOTE: Shallow clone if feature `arrow` is enabled, full alloc + memcpy otherwise.
TensorData::U16(data) => DepthCloudDepthData::U16(data.clone()),
TensorData::F32(data) => DepthCloudDepthData::F32(data.clone()),
_ => {
let discriminant = std::mem::discriminant(&tensor.data);
re_log::warn_once!(
Expand Down