Skip to content

Commit

Permalink
Merge branch 'main' into katya/update-the-viewer-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gavrelina authored Oct 15, 2024
2 parents c123a8a + 5325fd8 commit 84274e1
Show file tree
Hide file tree
Showing 31 changed files with 598 additions and 149 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/contrib_rerun_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ jobs:
# this stops `re_web_viewer_server/build.rs` from running
RERUN_IS_PUBLISHING: true
run: |
cargo build \
pixi run cargo build \
--locked \
-p rerun-cli \
--no-default-features \
--features native_viewer,web_viewer \
--features release \
--release \
--target x86_64-unknown-linux-gnu
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable_build_and_upload_rerun_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ jobs:
# this stops `re_web_viewer_server/build.rs` from running
RERUN_IS_PUBLISHING: true
run: |
cargo build \
pixi run cargo build \
--locked \
-p rerun-cli \
--no-default-features \
--features native_viewer,web_viewer \
--features release \
--release \
--target ${{ needs.set-config.outputs.TARGET }}
Expand Down
6 changes: 4 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5379,9 +5379,9 @@ dependencies = [

[[package]]
name = "re_rav1d"
version = "0.1.2"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4a4d7117cc5dd728738e5187a78914a3229b3ab819e96079b0ad8bca84b9f30"
checksum = "e5eb64c43c68024d96d99d52ef0525030d17bdcc6a6b4ddba048ec8f713c91fc"
dependencies = [
"assert_matches",
"atomig",
Expand Down Expand Up @@ -5942,6 +5942,8 @@ dependencies = [
"indicatif",
"itertools 0.13.0",
"parking_lot",
"re_build_info",
"re_build_tools",
"re_log",
"re_mp4",
"re_rav1d",
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ re_math = "0.20.0"
# If this package fails to build, install `nasm` locally, or build through `pixi`.
# NOTE: we use `dav1d` as an alias for our own re_rav1d crate
# See https://github.com/rerun-io/re_rav1d/pull/2
dav1d = { package = "re_rav1d", version = "0.1.2", default-features = false }
dav1d = { package = "re_rav1d", version = "0.1.3", default-features = false }
# dav1d = { version = "0.10.3" } # Requires separate install of `dav1d` library. Fast in debug builds. Useful for development.

# egui-crates:
Expand Down
9 changes: 9 additions & 0 deletions crates/build/re_build_info/src/build_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ pub struct BuildInfo {
/// `CARGO_PKG_NAME`
pub crate_name: &'static str,

/// Space-separated names of all features enabled for this crate.
pub features: &'static str,

/// Crate version, parsed from `CARGO_PKG_VERSION`, ignoring any `+metadata` suffix.
pub version: super::CrateVersion,

Expand Down Expand Up @@ -74,6 +77,7 @@ impl std::fmt::Display for BuildInfo {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Self {
crate_name,
features,
version,
rustc_version,
llvm_version,
Expand All @@ -89,6 +93,10 @@ impl std::fmt::Display for BuildInfo {

write!(f, "{crate_name} {version}")?;

if !features.is_empty() {
write!(f, " ({features})")?;
}

if let Some(rustc_version) = rustc_version {
write!(f, " [{rustc_version}")?;
if let Some(llvm_version) = llvm_version {
Expand Down Expand Up @@ -147,6 +155,7 @@ impl CrateVersion {
fn crate_version_from_build_info_string() {
let build_info = BuildInfo {
crate_name: "re_build_info",
features: "default extra",
version: CrateVersion {
major: 0,
minor: 10,
Expand Down
1 change: 1 addition & 0 deletions crates/build/re_build_info/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ macro_rules! build_info {
() => {
$crate::BuildInfo {
crate_name: env!("CARGO_PKG_NAME"),
features: env!("RE_BUILD_FEATURES"),
version: $crate::CrateVersion::parse(env!("CARGO_PKG_VERSION")),
rustc_version: env!("RE_BUILD_RUSTC_VERSION"),
llvm_version: env!("RE_BUILD_LLVM_VERSION"),
Expand Down
27 changes: 27 additions & 0 deletions crates/build/re_build_tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ pub fn export_build_info_vars_for_crate(crate_name: &str) {
);
}
}

set_env(
"RE_BUILD_FEATURES",
&enabled_features_of(crate_name).unwrap().join(" "),
);
}

/// ISO 8601 / RFC 3339 build time.
Expand Down Expand Up @@ -273,3 +278,25 @@ fn rust_llvm_versions() -> anyhow::Result<(String, String)> {
pub fn cargo_metadata() -> anyhow::Result<cargo_metadata::Metadata> {
Ok(cargo_metadata::MetadataCommand::new().exec()?)
}

/// Returns a list of all the enabled features of the given package.
pub fn enabled_features_of(crate_name: &str) -> anyhow::Result<Vec<String>> {
let metadata = cargo_metadata()?;

let mut features = vec![];
for package in &metadata.packages {
if package.name == crate_name {
for feature in package.features.keys() {
println!("Checking if feature is enabled: {feature:?}");
let feature_in_screaming_snake_case =
feature.to_ascii_uppercase().replace('-', "_");
if std::env::var(format!("CARGO_FEATURE_{feature_in_screaming_snake_case}")).is_ok()
{
features.push(feature.clone());
}
}
}
}

Ok(features)
}
6 changes: 3 additions & 3 deletions crates/store/re_chunk_store/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ pub struct QueryExpression {
/// Examples: `Some(Timeline("frame"))`, `None` (only static data).
//
// TODO(cmc): this has to be a selector otherwise this is a horrible UX.
pub filtered_index: Option<Timeline>,
pub filtered_index: Option<Index>,

/// The range of index values used to filter out _rows_ from the view contents.
///
Expand Down Expand Up @@ -589,7 +589,7 @@ pub struct QueryExpression {
/// Example: `ComponentColumnSelector("rerun.components.Position3D")`.
//
// TODO(cmc): multi-pov support
pub filtered_point_of_view: Option<ComponentColumnSelector>,
pub filtered_is_not_null: Option<ComponentColumnSelector>,

/// Specifies how null values should be filled in the returned dataframe.
///
Expand Down Expand Up @@ -792,7 +792,7 @@ impl ChunkStore {
filtered_index_range: _,
filtered_index_values: _,
using_index_values: _,
filtered_point_of_view: _,
filtered_is_not_null: _,
sparse_fill_strategy: _,
selection: _,
} = query;
Expand Down
22 changes: 9 additions & 13 deletions crates/store/re_dataframe/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,7 @@ impl QueryHandle<'_> {
query: &RangeQuery,
view_contents: &[ColumnDescriptor],
) -> (Option<usize>, Vec<Vec<(AtomicU64, Chunk)>>) {
let mut view_pov_chunks_idx = self
.query
.filtered_point_of_view
.as_ref()
.map(|_| usize::MAX);
let mut view_pov_chunks_idx = self.query.filtered_is_not_null.as_ref().map(|_| usize::MAX);

let view_chunks = view_contents
.iter()
Expand All @@ -462,7 +458,7 @@ impl QueryHandle<'_> {
.fetch_chunks(query, &column.entity_path, [column.component_name])
.unwrap_or_default();

if let Some(pov) = self.query.filtered_point_of_view.as_ref() {
if let Some(pov) = self.query.filtered_is_not_null.as_ref() {
if pov.entity_path == column.entity_path
&& column.component_name.matches(&pov.component_name)
{
Expand Down Expand Up @@ -1196,7 +1192,7 @@ mod tests {
// * [x] filtered_index_values
// * [x] view_contents
// * [x] selection
// * [x] filtered_point_of_view
// * [x] filtered_is_not_null
// * [x] sparse_fill_strategy
// * [x] using_index_values
//
Expand Down Expand Up @@ -1551,7 +1547,7 @@ mod tests {
}

#[test]
fn filtered_point_of_view() -> anyhow::Result<()> {
fn filtered_is_not_null() -> anyhow::Result<()> {
re_log::setup_logging();

let store = create_nasty_store()?;
Expand All @@ -1569,7 +1565,7 @@ mod tests {
{
let query = QueryExpression {
filtered_index,
filtered_point_of_view: Some(ComponentColumnSelector {
filtered_is_not_null: Some(ComponentColumnSelector {
entity_path: "no/such/entity".into(),
component_name: MyPoint::name().to_string(),
}),
Expand Down Expand Up @@ -1598,7 +1594,7 @@ mod tests {
{
let query = QueryExpression {
filtered_index,
filtered_point_of_view: Some(ComponentColumnSelector {
filtered_is_not_null: Some(ComponentColumnSelector {
entity_path: entity_path.clone(),
component_name: "AComponentColumnThatDoesntExist".into(),
}),
Expand Down Expand Up @@ -1627,7 +1623,7 @@ mod tests {
{
let query = QueryExpression {
filtered_index,
filtered_point_of_view: Some(ComponentColumnSelector {
filtered_is_not_null: Some(ComponentColumnSelector {
entity_path: entity_path.clone(),
component_name: MyPoint::name().to_string(),
}),
Expand Down Expand Up @@ -1666,7 +1662,7 @@ mod tests {
{
let query = QueryExpression {
filtered_index,
filtered_point_of_view: Some(ComponentColumnSelector {
filtered_is_not_null: Some(ComponentColumnSelector {
entity_path: entity_path.clone(),
component_name: MyColor::name().to_string(),
}),
Expand Down Expand Up @@ -2180,7 +2176,7 @@ mod tests {
{
let query = QueryExpression {
filtered_index,
filtered_point_of_view: Some(ComponentColumnSelector {
filtered_is_not_null: Some(ComponentColumnSelector {
entity_path: entity_path.clone(),
component_name: MyPoint::name().to_string(),
}),
Expand Down
7 changes: 5 additions & 2 deletions crates/store/re_video/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ av1 = ["dep:dav1d"]

## Enable faster native video decoding with assembly.
## You need to install [nasm](https://nasm.us/) to compile with this feature.
# TODO(#7671): this feature flag currently does nothing on Linux.
nasm = [
# The default feature set of our dav1d fork has asm enabled (except on Linux, see above)
# The default feature set of our dav1d fork has asm enabled
"dav1d?/default",
]


[dependencies]
re_build_info.workspace = true
re_log.workspace = true
re_tracing.workspace = true

Expand All @@ -62,6 +62,9 @@ dav1d = { workspace = true, optional = true, default-features = false, features
[dev-dependencies]
indicatif.workspace = true

[build-dependencies]
re_build_tools.workspace = true


[[example]]
name = "frames"
3 changes: 3 additions & 0 deletions crates/store/re_video/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
re_build_tools::export_build_info_vars_for_crate(env!("CARGO_PKG_NAME"));
}
24 changes: 16 additions & 8 deletions crates/store/re_video/src/decode/av1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ impl SyncDav1dDecoder {
pub fn new(debug_name: String) -> Result<Self> {
re_tracing::profile_function!();

// TODO(#7671): enable this warning again on Linux when the `nasm` feature actually does something
#[allow(clippy::overly_complex_bool_expr)]
if !cfg!(target_os = "linux") && !cfg!(feature = "nasm") {
re_log::warn_once!(
"NOTE: native AV1 video decoder is running extra slowly. \
Speed it up by compiling Rerun with the `nasm` feature enabled. \
You'll need to also install nasm: https://nasm.us/"
);
if !cfg!(feature = "nasm") {
// The `nasm` feature makes AV1 decoding much faster.
// On Linux the difference is huge (~25x).
// On Windows, the difference was also pretty big (unsure how big).
// On an M3 Mac the difference is smalelr (2-3x),
// and ever without `nasm` emilk can play an 8k video at 2x speed.

if cfg!(target_os = "macos") && cfg!(target_arch = "aarch64") {
re_log::warn_once!(
"The native AV1 video decoder is unnecessarily slow. \
Speed it up by compiling Rerun with the `nasm` feature enabled."
);
} else {
// Better to return an error than to be perceived as being slow
return Err(Error::Dav1dWithoutNasm);
}
}

// See https://videolan.videolan.me/dav1d/structDav1dSettings.html for settings docs
Expand Down
5 changes: 5 additions & 0 deletions crates/store/re_video/src/decode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ pub enum Error {
#[cfg(not(target_arch = "wasm32"))]
#[error("dav1d: {0}")]
Dav1d(#[from] dav1d::Error),

#[cfg(feature = "av1")]
#[cfg(not(target_arch = "wasm32"))]
#[error("To enabled native AV1 decoding, compile Rerun with the `nasm` feature enabled.")]
Dav1dWithoutNasm,
}

pub type Result<T = (), E = Error> = std::result::Result<T, E>;
Expand Down
Loading

0 comments on commit 84274e1

Please sign in to comment.