Skip to content

fix: Use R16_UNORM as internal render format if output is PF_L16#1294

Open
jmachowinski wants to merge 2 commits into
gazebosim:mainfrom
cellumation:main
Open

fix: Use R16_UNORM as internal render format if output is PF_L16#1294
jmachowinski wants to merge 2 commits into
gazebosim:mainfrom
cellumation:main

Conversation

@jmachowinski

@jmachowinski jmachowinski commented May 12, 2026

Copy link
Copy Markdown

🦟 Bug fix

Summary

This fixes a major performance regression, if a camera uses int16 as output format. The improvement comes from skipping an expensive texture conversion inside from SRGB to INT16 by rendering native to the wanted output format.

Backport Policy

  • This is safe to backport to the following versions:
    • Jetty
    • Ionic
    • Harmonic
    • Fortress
  • This should not be backported
  • I am not sure
  • Other (fill in yourself)

Checklist

  • Signed all commits for DCO
  • Added a screen capture or video to the PR description that demonstrates the fix (as needed)
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • Updated Bazel files (if adding new files). Created an issue otherwise.
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

Backports: If this is a backport, please use Rebase and Merge instead.

@github-project-automation github-project-automation Bot moved this from Inbox to In review in Core development May 13, 2026

@azeey azeey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Would you mind updating the PR description by filling out the template provided?

Also, from the Zulip conversation, this significantly improves performance. Would you be able to provide some benchmark results here?

@jmachowinski

jmachowinski commented Jun 25, 2026

Copy link
Copy Markdown
Author

We render 2 depth sensors with the spec of a SICK Visonary-T Mini (512 × 424 pixels) depth and intensity image

Without the patch

At RTF 1.0 : 72-27% RTF 90% CPU usage

At RTF 3.0 : max 105-110% RTF

grafik

With the patch

At RTF 1.0: 99.8% RTF 64.5% cpu usage

At RTF 3.0 : max 215-220% RTF
grafik

These tests were performed on a Ryzen 7800X3D with a Geforce 3700

Note, here are a some other performance patches applied to our gazebo, I just reverted this particular patch for the test.

@caguero caguero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the patch!

I wonder if we should create a helper function to handle all formats in one place. Something like:

Ogre::PixelFormatGpu InternalRenderFormat(PixelFormat _format)
  {
    switch (_format)
    {
      case PF_L8:
      case PF_L16:
        return Ogre2Conversions::Convert(_format);
      default:
        return Ogre::PFG_RGBA8_UNORM_SRGB;
    }
  }

That way we not only handle the PF_L16 case and we use a single source of truth.

Comment thread ogre2/src/Ogre2RenderTarget.cc Outdated
Janosch Machowinski added 2 commits July 1, 2026 13:10
This fixes a major performance regression, if a camera uses int16 as
output format. The improvement comes from skipping an expensive
texture conversion inside from SRGB to INT16 by rendering native to
the wanted output format.

Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

4 participants