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

Lift point cloud size limitations #5192

Merged
merged 9 commits into from Feb 14, 2024
Merged

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Feb 14, 2024

What

Removes the old limitation of 4mio points caused by fixed "data texture" size.

We now allocate dynamically for the needed amount of points. This means that we use less memory when there's less points and support as many points in a single DrawData as the maximum texture size. This is at least 16.5mio points on mobile webgl (4096 is a common max texture size on Android) and about 265mio points on a typical desktop machine & WebGPU (common max texture size is 16k).
With this change we share a single DrawData per visualizer execution, meaning the limit applies to the total of each 2D & 3D points in a single space view.

image
Scene with 35 mio points. Renders on my desktop with a bit under 300ms per frame since we still re-upload data every frame.

Note that this change is also the first step towards secondary caching, i.e. not re-uploading (and preparing) all the data for the gpu every frame: we can now use as many independent point cloud draw data as we want at a relatively small allocation & bind group setting overhead without having to fear excessive memory use. (I haven't measured, but the overhead for new draw data shouldn't be entirely insignificant, which is why I still keep the number down in this PR, putting the results an entire visualizer a single one)

Line renderer limitations will be addressed in a follow-up PR.

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG
  • If applicable, add a new check to the release checklist!

Comment on lines 249 to 251
// TODO(andreas/cmc): Use cached code path for this.
// This is right now a bit harder to do and requires knowing all queried components.
// The only thing we really want to pass here are the POV components.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @teh-cmc maybe this is easier than I thought? Had trouble using the cache here and figured it's not that important anyways for my usecases (profiler says it really isn't)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're not deserializing nor joining anything you are much better off with a raw query anyway 👍

@Wumpf Wumpf added 🔺 re_renderer affects re_renderer itself include in changelog labels Feb 14, 2024
@Wumpf Wumpf marked this pull request as draft February 14, 2024 10:46
@Wumpf
Copy link
Member Author

Wumpf commented Feb 14, 2024

drafted: found a crash when enabling visible history

resolved

@Wumpf Wumpf marked this pull request as ready for review February 14, 2024 11:08
Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data_texture_size confuses the hell out of me, otherwise LGTM

crates/re_renderer/src/renderer/point_cloud.rs Outdated Show resolved Hide resolved
crates/re_renderer/src/renderer/point_cloud.rs Outdated Show resolved Hide resolved
crates/re_renderer/src/renderer/point_cloud.rs Outdated Show resolved Hide resolved
crates/re_renderer/src/renderer/point_cloud.rs Outdated Show resolved Hide resolved
crates/re_renderer/src/renderer/point_cloud.rs Outdated Show resolved Hide resolved
@Wumpf Wumpf requested a review from emilk February 14, 2024 15:36
Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, now it is crystal clear ⭐

@Wumpf
Copy link
Member Author

Wumpf commented Feb 14, 2024

tested on Chrome & Firefox on Windows with a bunch of point containing scenes. seems all fine

@Wumpf Wumpf merged commit 21c5bd6 into main Feb 14, 2024
40 of 41 checks passed
@Wumpf Wumpf deleted the andreas/dynamically-sized-point-drawdata branch February 14, 2024 17:48
Wumpf added a commit that referenced this pull request Feb 19, 2024
### What

* follow-up of #5192 
* Fixes #3076
* Fixes #4844
* _technically_ there's still limits (see #5192 ) but they are machine
dependent making this relatively hard to query. Overall I'd argue we
removed the previous limits so there's no need for this in the original
sense.

<img width="1252" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/512be197-9817-4f5a-8054-e3661346d361">
(note that we haven't spend a lot of time optimizing the collection of
lines, large amounts of lines don't perform all that well so far)


Applies the same principles as on the previous PR that fixes the point
cloud limits.
The key difference here is that we use lines in *a lot* of places,
making this a bigger refactor than originally assumed.

---

~The need to know both strip & vertex count for lines ahead of time is a
bit problematic and isn't always as easy as it was with points. We err
on the side of generating more draw data bundles, but to limit this (a
single drawdata for a single line is extremely wasteful as we have to
allocate a bunch of textures, buffers, bind groups, etc. etc.) I had to
introduce `LineDrawableBuilderAllocator` which is a very simplistic
Vec-like allocator (minus the increase in size) for
`LineDrawableBuilder` (previously called `LineStripSeriesBuilder`).
I'm not super happy with this construct overall, but it's the best I
could come up with in the short-term and things seem to be fairly robust
and at least not overly complicated.~

~In the future it would be nice to reconcile
`LineDrawableBuilderAllocator` and `LineDrawableBuilder` into a single
construct, likely still with the limitations that the size of a batch
(think named unit with a transform) needs to be known ahead of time,
which is practically always the case!~

---

Second iteration: There's now `DataTextureSource` (ideas for better
names?) which is essentially a thing where you can throw data in and get
a data texture out! It handles all the copies and dynamic sizings for
you. This makes everything awesome because now we can handle `reserve`
call just as an optimization without requiring them and without being on
a bad path if you don't! <3

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5207/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5207/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5207/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] Test misc examples on WebGL
* [x] Test misc examples on WebGPU

- [PR Build Summary](https://build.rerun.io/pr/5207)
- [Docs
preview](https://rerun.io/preview/012ab21d8acbf86f8d45bfdba3737f8ebe989784/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/012ab21d8acbf86f8d45bfdba3737f8ebe989784/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants