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

Simplify ImageCache #1551

Merged
merged 6 commits into from
Mar 13, 2023
Merged

Simplify ImageCache #1551

merged 6 commits into from
Mar 13, 2023

Conversation

jleibs
Copy link
Member

@jleibs jleibs commented Mar 10, 2023

Simplify the ImageCache to only be responsible for converting Tensor -> ColorImage. This includes color-mapping, application of annotation context, and conversion to srgb.

The re_renderer TextureCaching is now moved to the TextureManager.

As the color-mapping / data conversion pieces are moved to the GPU, this cache can ultimately go away and we should be able to just converge on streaming Tensor -> Texture.

This gets rid of usage of DynamicImage everywhere except for the Histogram.

The retained image is still kept around in this cache because moving to re_renderer for all images is a bigger chunk of work.

Checklist

@jleibs jleibs force-pushed the jleibs/simplify_image_cache branch from bd538cd to 2aed7c1 Compare March 11, 2023 01:00
@jleibs jleibs added the 📉 performance Optimization, memory use, etc label Mar 12, 2023
@jleibs jleibs force-pushed the jleibs/simplify_image_cache branch from 2aed7c1 to b339041 Compare March 12, 2023 20:40
@jleibs jleibs marked this pull request as ready for review March 12, 2023 20:50
@emilk emilk self-requested a review March 13, 2023 14:05
@jleibs jleibs force-pushed the jleibs/simplify_image_cache branch from b339041 to 3033cd5 Compare March 13, 2023 14:10
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.

Nice!

crates/re_viewer/src/misc/caches/tensor_image_cache.rs Outdated Show resolved Hide resolved
crates/re_viewer/src/misc/caches/tensor_image_cache.rs Outdated Show resolved Hide resolved
self.key.hash(&mut s);
let texture_key = std::hash::Hasher::finish(&s);

let debug_name = format!("tensor {:?}", self.tensor.shape());
Copy link
Member

Choose a reason for hiding this comment

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

it would be nice to use the entity path as the debug name

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, except we don't currently have easy access to that information and I'm not inclined to plumb it through right now. This is something that would be really nice to generally add to all Component structs.

crates/re_viewer/src/misc/caches/tensor_image_cache.rs Outdated Show resolved Hide resolved

// TODO(emilk): support histograms of non-RGB images too
if let image::DynamicImage::ImageRgb8(rgb_image) = dynamic_img {
if let image::DynamicImage::ImageRgba8(rgb_image) = dynamic_img {
Copy link
Member

Choose a reason for hiding this comment

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

intentional to switch from rgb to rgba? Won't this break histogram for RGB images (e.g. jpegs)?

Copy link
Member Author

Choose a reason for hiding this comment

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

The DynamicImage is now derived from the cached RGBA ColorImage. I'd like to re-implement the histogram directly on top of the raw tensor so it always represents raw values, but going to save that for a future PR.

Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

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

checked on renderer bits, small comment; looks good!

Base automatically changed from jleibs/image_decode_cache to main March 13, 2023 14:33
@jleibs jleibs force-pushed the jleibs/simplify_image_cache branch from 3033cd5 to 1dd2c3d Compare March 13, 2023 17:46
@jleibs jleibs merged commit bc9352d into main Mar 13, 2023
@jleibs jleibs deleted the jleibs/simplify_image_cache branch March 13, 2023 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📉 performance Optimization, memory use, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants