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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ogre2DepthCamera on macOS (Fortress) #797

Merged

Conversation

darksylinc
Copy link
Contributor

@darksylinc darksylinc commented Dec 24, 2022

馃 Bug fix

Fixes #332 (again) for macOS and possibly any OS/HW/Driver combination.
Fixes #369

Summary

For a very long time macOS (and possibly other OS/HW/Driver combination) would fail the tests because the shader code was doing (simplified, in C to convey the explanation):

uint32_t valueToStore = r << 24 | g << 16 | b << 8 | a;
float output;
output = (float*)&valueToStore;
return output;

In ticket #332 I made a deep analysis and found out that given the wrong conditions, the bit pattern would result in either a denormal or a NaN in floating point; which risks being flushed to 0 (or set all types of NaN to the same type bit pattern of NaN).

Although the ticket was closed and tagged as "fixed", on some OS/HW/Driver combinations (e.g. macOS + Metal) this error would reappear.

This isn't just a mere test failure. This is an actual bug. Running DepthCamera in macOS could result in wrong readings.

This PR fixes the problem for good by using RGBA32_UINT instead of RGBA32_FLOAT; and having uints be reinterpreted to floats and back when needed; which is well-defined and much more stable as far as GPU shader compilers go.

The same fix is also part of PR #785 which targets Garden and includes other changes.

This PR is a backport specific for Fortress.

Checklist

  • Signed all commits for DCO
  • 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)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

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

Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
@codecov
Copy link

codecov bot commented Dec 24, 2022

Codecov Report

Merging #797 (1bf08df) into ign-rendering6 (ceec441) will not change coverage.
The diff coverage is n/a.

@@               Coverage Diff               @@
##           ign-rendering6     #797   +/-   ##
===============================================
  Coverage           77.83%   77.83%           
===============================================
  Files                 146      146           
  Lines               13416    13416           
===============================================
  Hits                10442    10442           
  Misses               2974     2974           
Impacted Files Coverage 螖
ogre2/src/Ogre2DepthCamera.cc 88.37% <酶> (酶)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Core development automation moved this from Inbox to In review Dec 28, 2022
@iche033 iche033 merged commit 41be240 into gazebosim:ign-rendering6 Dec 28, 2022
Core development automation moved this from In review to Done Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃彲 fortress Ignition Fortress
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants