-
Notifications
You must be signed in to change notification settings - Fork 369
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
Introduce image data conversion pipeline, taking over existing YUV conversions #7640
Conversation
// WARNING! Adding anything else to this shader is very likely to push us over a size threshold that | ||
// causes the failure reported in: https://github.com/rerun-io/rerun/issues/3931 | ||
// Make sure any changes are tested in Chrome on Linux using the Intel Mesa driver. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the expectation is that this is no longer the case now.
Is it true though? @jleibs :)
…the converting shader
61d287f
to
1c31cff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful! I love all the comments
LGTM if tested with NV12 and YUV on natie, WebGL and WebGPU (I'm paranoid!)
crates/viewer/re_renderer/shader/conversions/chroma_subsampling_converter.wgsl
Outdated
Show resolved
Hide resolved
|
||
var rgb: vec3f; | ||
|
||
switch (primaries) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wat, wgsl supports switch
!? NICE! That could be useful in crates/viewer/re_renderer/shader/rectangle_fs.wgsl
too 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
learned that today as well 😄. Followed a hunch there - probably I've seen it in the meanwhile somewhere.
I think it didn't back when we started. But Naga & Tint (Dawn's compiler) are happy with it so full steam ahead!
pub enum ChromaSubsamplingPixelFormat { | ||
/// 4:2:0 subsampling with a separate Y plane, followed by a UV plane. | ||
/// | ||
/// Expects single channel texture format. | ||
/// | ||
/// First comes entire image in Y in one plane, | ||
/// followed by a plane with interleaved lines ordered as U0, V0, U1, V1, etc. | ||
/// | ||
/// width | ||
/// __________ | ||
/// | | | ||
/// height | Y | | ||
/// | | | ||
/// |_________| | ||
/// height/2 | U,V,U,… | | ||
/// |_________| | ||
Y_UV12 = 0, | ||
|
||
/// YUV 4:2:2 subsampling, single plane. | ||
/// | ||
/// Expects single channel texture format. | ||
/// | ||
/// The order of the channels is Y0, U0, Y1, V0, all in the same plane. | ||
/// | ||
/// width * 2 | ||
/// __________________ | ||
/// | | | ||
/// height | Y0, U0, Y1, V0… | | ||
/// |_________________| | ||
/// | ||
YUYV16 = 1, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this 🤩
crates/viewer/re_renderer/src/resource_managers/chroma_subsampling_converter.rs
Outdated
Show resolved
Hide resolved
crates/viewer/re_renderer/src/resource_managers/image_data_to_texture.rs
Show resolved
Hide resolved
zeroed_texture_sint, | ||
zeroed_texture_uint, | ||
device, | ||
queue, | ||
inner: Default::default(), | ||
} | ||
} | ||
|
||
/// Creates a new 2D texture resource and schedules data upload to the GPU. | ||
/// TODO(jleibs): All usages of this should be replaced with `get_or_create`, which is strictly preferable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're only using create
in crates/viewer/re_renderer/src/importer/gltf.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this one is surprisingly hard to get rid of because for that we'd to be sure that we get a unique enough description of the mesh without having to resort to a hash of the texture content within it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful! I love all the comments
LGTM if tested with NV12 and YUV on natie, WebGL and WebGPU (I'm paranoid!)
…which widths and heights we're talking about
skipping linux web check for now. still have to do that though! |
What
via
pixi run -e py python ./tests/python/chroma_downsample_image/main.py
:https://rerun.io/viewer/pr/7640?url=https%3A%2F%2Fstatic.rerun.io%2Frrd%2F0.19%2Fchroma_formats_ad9697d05933f4104fbbe66af23073ad4e9e4a58.rrd
The new functionality is tightly integrated into
TextureManager2D
which now ingests all incoming data via a new internal methodtransfer_image_data_to_texture
.This in turn takes care of data upload via
GpuReadCpuWriteBelt
(new! previously, we would usequeue.write_texture
in this case) and may if needed run gpu based conversion.Gpu based conversion is for convenience implemented like a
Renderer
- while it is not used like a typicalRenderer
, the lifecycle (create lazily once, store on context, feed with data bundles [...]) was so similar that it made sense to me to use this existing pattern even though it's not a perfect match.A curious sideeffect of this is that you can now put chroma downsampled textures on custom meshes!
Next steps:
SourceImageDataFormat::WgpuCompatible
. But it's not strictly necessary, this might yet prove a convenient loophole, although its presence makes me a little bit nervous (details see code comments) 🤔Checklist
main
build: rerun.io/viewernightly
build: rerun.io/viewerCHANGELOG.md
and the migration guideTo run all checks from
main
, comment on the PR with@rerun-bot full-check
.