-
Notifications
You must be signed in to change notification settings - Fork 51
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
Fix FSAA in UI and lower VRAM consumption #313
Fix FSAA in UI and lower VRAM consumption #313
Conversation
2b43a63
to
36a94a9
Compare
FSAA was being requested however due to how the compositor was setup, this effect was not taking effect. Additionally, the Compositor setup was improved to lower memory consumption. Originally the setup was taken from Ogre samples which assume they will ultimately be rendering to a window. However this is not the case and thus IGN was creating 3 render targets (two for ping-ponging between postprocess FXs + one for storing the final result) This was optimized so that we only create 2 render targets: two for ping-ponging between postprocess FXs and we pick at runtime which one is storing the final result via the new variable renderTargetResultsIdx Further performance optimizations could be made in Ogre 2.2 to improve unnecessary MSAA resolving when doing postprocess, though considering there's currently only one postprocessing effect (the Gaussian filter) I doubt this optimization would make much of a difference Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
36a94a9
to
3ef8156
Compare
Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
Converting this PR back to DRAFT since multiple issues were found |
As a bonus this new method breaks ABI far less. Fix leak: DestroyCompositor would often not be called Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
48b035b
to
a1c1968
Compare
I fixed the issues I found so it's no longer a draft again. However I wanted to see if the ABI checker would tell me Are there instructions on how to run it locally? |
@osrf-jenkins run tests please |
something is wring with this particular build machine. I've triggered the build again on a different machine:
We don't have public instructions I think. We use abi-compliance-checker. You can probably extract the cmds that we use by looking at the console output of one of the successful ABI builds:
The contents of |
Sigh. I guess I'll have to get my hands dirty. I hope it's easy. This tool is too useful for this project and my computer is vastly faster than the CI machine. Thanks for highlighting the commands though |
When merging to newer branches that can break the ABI, revert this commit Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
Apparently But I could use a 2nd pair of eyes. If everything's ok it should be ready for merge PS. I managed to use abi-compatibility-checker in my machine :) Thanks for the help. It just worked! |
can you take a look at the latest ABI report from our CI? It found a few more issues: Usually the |
/// We didn't do it to preserve ABI. | ||
/// Look in commit history for '#Ogre2IsRenderWindowABI' to | ||
/// see changes made and revert | ||
public: bool isRenderWindow() const; |
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.
capitalize I
, i.e. IsRenderWindow
const std::vector<RenderPassPtr> &_renderPasses, | ||
bool _recreateNodes, | ||
Ogre::Texture *(*_ogreTextures)[2], | ||
bool _isRenderWindow); |
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.
add doxygen comments for these new params
we'll need to keep the existing function since adding the args here breaks API/ABI.
Mmm....
Removal of
Became this:
From a vtable point of view nothing relevant changed (calling Ogre2RenderTarget::RenderTarget() should still work), but trying to directly call Ogre2RenderTexture::RenderTarget() (i.e. bypassing the vtable) would fail. I can play on the safe side here and reimplement Ogre2RenderTexture::RenderTarget. Btw I'm a bit worried about this error:
|
We can deprecate old function but instead of making it throw, just print a warning msg to tell users to use the new function (Ignition has a no throw policy which is probably not well documented). We can do something like this to prevent the warning msg being printed out repeatedly: https://github.com/ignitionrobotics/ign-gazebo/blob/ign-gazebo5/include/ignition/gazebo/components/Component.hh#L124-L132
In the
We've seen this before and the consensus is that it that we need to fix this issue to avoid unexpected crashes. My guess is that it's related to changes done to the
This is one thing I would try first to see if it helps fix the v-table issue. The ABI checker also picked up issues with the new Fixing ABI is not fun and usually involves many workarounds :/ I can also take a look at fixing some of these ABI issues later this week if you haven't gotten to it yet. |
I gave up on commit undoing It's clear that on the next release, Ogre2RenderTarget and Ogre2RenderTexture need to be merged together. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
I updated the code to be ABI compatible. Maaan I'm beat. This is 20% work, 80% figuring out ABI issues. My ABI checker says 100% compatibility. Let's cross fingers CI agrees. |
a095aba
to
3bffe08
Compare
Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
3bffe08
to
10d493f
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.
this should get rid of the build warnings:
diff --git a/ogre2/src/Ogre2RenderTarget.cc b/ogre2/src/Ogre2RenderTarget.cc
index a0e8fda6..59b66397 100644
--- a/ogre2/src/Ogre2RenderTarget.cc
+++ b/ogre2/src/Ogre2RenderTarget.cc
@@ -647,10 +647,11 @@ void Ogre2RenderTarget::UpdateRenderPassChain()
//////////////////////////////////////////////////
void Ogre2RenderTarget::UpdateRenderPassChain(
- Ogre::CompositorWorkspace *_workspace, const std::string &_workspaceDefName,
- const std::string &_baseNode, const std::string &_finalNode,
- const std::vector<RenderPassPtr> &_renderPasses,
- bool _recreateNodes)
+ Ogre::CompositorWorkspace * /*_workspace*/,
+ const std::string & /*_workspaceDefName*/,
+ const std::string & /*_baseNode*/, const std::string & /*_finalNode*/,
+ const std::vector<RenderPassPtr> & /*_renderPasses*/,
+ bool /*_recreateNodes*/)
{
ignwarn << "Warning: This Ogre2RenderTarget::UpdateRenderPassChain "
<< "overload is deprecated" << std::endl;
@@ -856,9 +857,12 @@ void Ogre2RenderTarget::SyncOgreTextureVars()
//////////////////////////////////////////////////
// Ogre2RenderTexture
//////////////////////////////////////////////////
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
Ogre2RenderTexture::Ogre2RenderTexture()
{
}
+#pragma GCC diagnostic pop
//////////////////////////////////////////////////
Ogre2RenderTexture::~Ogre2RenderTexture()
@@ -917,7 +921,10 @@ Ogre::RenderTarget *Ogre2RenderTexture::RenderTarget() const
//////////////////////////////////////////////////
void Ogre2RenderTexture::SetOgreTexture(Ogre::Texture *_ogreTexture)
{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
this->ogreTexture = _ogreTexture;
+#pragma GCC diagnostic pop
}
/////////////////////////////////////////////////
looking at the data type problem description and the vtable, I think the issue could be due to |
Confirmed that the FSAA issue is fixed. Thanks for iterating!
sure, if the changes are looking like they are not trivial to make to a release version without breaking ABI, you can target |
Hopefully this will prevent ABI breakage Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
I suspect the same. It passed on my machine, but it seems it's not consistent. Just to be sure I made it pure virtual again and let's see what the abi checker says this time. |
Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
latest ABI build is green :) the INTEGRATION_render_pass test failed in the latest ubuntu build. I haven't seen that before. I just retriggered another build and it failed again. I haven't been able to reproduce it locally - could be a timing issue. This led me to try out running the ogre2_demo in examples again and noticed that the mouse movement is laggy / jumpy. See gif below. I don't see this happen on |
It may mean that this patch accidentally tries to show the wrong texture, containing uninitialized or old results, which would explain why the error fails (i.e. it contains whatever was in memory)
This further fuels this theory, if the same texture is shown twice. Definitely worth taking a look. Thanks! |
I'm afraid I couldn't repro any of your problems:
I tried ogre2_demo on the following machines:
I noticed the Intel i7 machine keeps randomly complaining about a double free / mem. corruption (sometimes it complains at startup and crashes before the windows comes up, other times it complains during shutdown, other times it doesn't complain at all) but that may have been some build mistake which I am going to make a clean build now to be sure. If problem persists it may be worth looking into for me. But overall I could not repro none of the two problems :( Update: i7 machine still compiling, ran Valgrind on the AMD machine and it found 2 things worth looking into (may not be related with my changes):
Update 2: The invalid write is a new bug introduced by me. Update 3: ASAN discovered another bug. in |
This was causing heap corruption. At best it would crash. At worst it would manifeset in subtle weird behaviors Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
@iche033 Although I could not repro the bug you mentioned, I fixed a heap corruption that could definitely cause the behavior you were seeing on your machine. Could you try again? As for the other two bugs I found, they're unrelated to my fixes so I'll create a PR. I think I'll split it into two more PRs because both are simple, but one of them may break ABI (I'm not sure how we can avoid ABI breakage there, the root of the problem is in the syntax declaration) |
Codecov Report
@@ Coverage Diff @@
## ign-rendering5 #313 +/- ##
==================================================
+ Coverage 52.52% 57.80% +5.28%
==================================================
Files 143 161 +18
Lines 13274 15851 +2577
==================================================
+ Hits 6972 9163 +2191
- Misses 6302 6688 +386
Continue to review full report at Codecov.
|
ok thanks for looking into the I did more testing and found that I was also able to reproduce the problem in latest In any case, since it's not introduced by this PR, the changes look good here. The |
Yyyyeeeeessss!! This PR was starting to drive me a little nuts.
Ahh!!! This reminds me that I noticed That could be causing the lag. I was going to investigate that, then forgot. Apparently it would always hit this:
|
that's it! I've created a PR to fix it: #342 |
Awesome! I would've probably taken longer to figure that out. And yeah, it makes sense because shadow node's textures kept being recreated. Resource creation is expensive |
* Fix floating point precision bug handling alpha channel (#332) (#333) Fixes #332 Fixes #108 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Test re-enabling depth camera integration test on mac (#335) * Fix floating point precision bug handling alpha channel (#332) Fixes #332 Fixes #108 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * test reenabling depth camera test on mac Signed-off-by: Ian Chen <ichen@osrfoundation.org> Co-authored-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix new [] / delete mismatch (#338) Using a custom deallocator to avoid breaking ABI Alternatively C++17 supports the following syntax, which was not used: `typedef std::shared_ptr<unsigned char[]> DataPtr;` Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix heap overflow when reading (#337) PF_RGB is 3 bytes. But later on Ogre2SelectionBuffer::OnSelectionClick will try to read 4 bytes from it. Fixed by ensuring it's always at least 4 bytes and zero-initializing those 4 bytes. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> Co-authored-by: Ian Chen <ichen@osrfoundation.org> * Fix floating point precision bug handling alpha channel (#332) (#333) Fixes #332 Fixes #108 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix depth alpha (#316) * update test Signed-off-by: Ian Chen <ichen@osrfoundation.org> * reenable macos test Signed-off-by: Ian Chen <ichen@osrfoundation.org> * fix typo Signed-off-by: Ian Chen <ichen@osrfoundation.org> * cherry pick f9f1820 and fix conflicts Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Fix FSAA in UI and lower VRAM consumption (#313) * Fix FSAA in UI and lower VRAM consumption FSAA was being requested however due to how the compositor was setup, this effect was not taking effect. Additionally, the Compositor setup was improved to lower memory consumption. Originally the setup was taken from Ogre samples which assume they will ultimately be rendering to a window. However this is not the case and thus IGN was creating 3 render targets (two for ping-ponging between postprocess FXs + one for storing the final result) This was optimized so that we only create 2 render targets: two for ping-ponging between postprocess FXs and we pick at runtime which one is storing the final result via the new variable renderTargetResultsIdx Further performance optimizations could be made in Ogre 2.2 to improve unnecessary MSAA resolving when doing postprocess, though considering there's currently only one postprocessing effect (the Gaussian filter) I doubt this optimization would make much of a difference Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Add Ogre2RenderTarget::RenderTarget back Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Rewrote the compositor changes to support RenderWindows As a bonus this new method breaks ABI far less. Fix leak: DestroyCompositor would often not be called Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Mantain ABI compatibility #Ogre2IsRenderWindowABI When merging to newer branches that can break the ABI, revert this commit Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix ABI problems I gave up on commit undoing It's clear that on the next release, Ogre2RenderTarget and Ogre2RenderTexture need to be merged together. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix camel case convention Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Make Ogre2RenderTarget::RenderTarget pure virtual again Hopefully this will prevent ABI breakage Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix deprecation warnings during build Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix invalid write of size 8 This was causing heap corruption. At best it would crash. At worst it would manifeset in subtle weird behaviors Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> Co-authored-by: Ian Chen <ichen@osrfoundation.org> * Backport memory fixes found by ASAN (#340) * Fix heap overflow when reading (#337) PF_RGB is 3 bytes. But later on Ogre2SelectionBuffer::OnSelectionClick will try to read 4 bytes from it. Fixed by ensuring it's always at least 4 bytes and zero-initializing those 4 bytes. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> Co-authored-by: Ian Chen <ichen@osrfoundation.org> * Fix new [] / delete mismatch (#338) Using a custom deallocator to avoid breaking ABI Alternatively C++17 supports the following syntax, which was not used: `typedef std::shared_ptr<unsigned char[]> DataPtr;` Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> Co-authored-by: darksylinc <dark_sylinc@yahoo.com.ar> * recreate node only when needed (#342) Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Fix custom shaders uniforms ign version number (#343) Signed-off-by: Ian Chen <ichen@osrfoundation.org> * relax gaussian test tolerance (#344) Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Update light map tutorial (#346) * apply changes Signed-off-by: Ian Chen <ichen@osrfoundation.org> * remove line Signed-off-by: Ian Chen <ichen@osrfoundation.org> * add ifdef for apple in integration test Signed-off-by: Ian Chen <ichen@osrfoundation.org> * 🎈 4.8.0 (#348) Signed-off-by: Louise Poubel <louise@openrobotics.org> * update ign-rendering version in custom shaders uniform sample Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Remove problematic leftover files from 2.1 The mere presence of these files can cause incorrect shader generation or unknown visual bugs. IMPORTANT: The installation folder (i.e. CMAKE_INSTALL_PREFIX) must remove them as well. `make install` won't be enough because it won't remove files, only add new ones or update existing ones. This folder is usually installed in ign/install/share/ignition/ignition-rendering6/ogre2/media/Hlms Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Do not crash on shutdown - ogreRoot may be nullptr - Do not destroy textures already scheduled for destruction Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Restore FSAA support in 2.2 branch Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix changing background color not always taking immediate effect Changed pass_clear in favour of LoadAction::Clear which is more efficient on very modern GPUs and specially TBDR ones. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Changed pass_clear in favour of LoadAction::Clear which is more efficient on very modern GPUs and specially TBDR ones. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Missing public keyword Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Save VRAM when FSAA is used and no postprocessing There's an unused texture when these conditions are met (which are fairly common) This memory optimization could not be performed in Ogre 2.1, it needs Ogre 2.2+ Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Remove code deprecated in ign-rendering5 Syntax cosmetic changes for consistency Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Remove code deprecated in ign-rendering5 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Code style fixes Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Undo VRAM saving optimization: It cannot be applied The "Final Composition" node requires both textures to be resident. Thus 2nd texture must always be resident. The optimization could still be applied if we create two Final Composition nodes (one for when 2 textures are needed, another for when only MSAA + 1 texture is needed) but this would: 1. Hurt code readability too much (i.e. what is going on?) 2. Increase debuggability difficulty too much because codepaths taken would differ depending on whether optimization was applied. Also certain bugs could remain hidden until compositors are toggled. This was causing ogre2_demo to fail. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> Co-authored-by: Ian Chen <ichen@osrfoundation.org> Co-authored-by: Louise Poubel <louise@openrobotics.org>
* Ogre2.2 Signed-off-by: ahcorde <ahcorde@gmail.com> * Added media files Signed-off-by: ahcorde <ahcorde@gmail.com> * Added Headless mode Signed-off-by: ahcorde <ahcorde@gmail.com> * Added feedback Signed-off-by: ahcorde <ahcorde@gmail.com> * Added feedback Signed-off-by: ahcorde <ahcorde@gmail.com> * Add OGRE2.2 to dependencies Signed-off-by: Michael Carroll <michael@openrobotics.org> * Fixed GPUray and depthCamera test Co-authored-by: Michael Carroll <michael@openrobotics.org> Signed-off-by: ahcorde <ahcorde@gmail.com> * cast based on pf Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Fix cleanup with packaged debs Signed-off-by: Michael Carroll <michael@openrobotics.org> * fix copy raw data Signed-off-by: Ian Chen <ichen@osrfoundation.org> * fix material test Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Lint and compiler warning Signed-off-by: Michael Carroll <michael@openrobotics.org> * Trim whitespace Signed-off-by: Michael Carroll <michael@openrobotics.org> * Apply gamma correction to sky Signed-off-by: ahcorde <ahcorde@gmail.com> * Test fixes to Ogre2.2 branch (#279) Signed-off-by: Michael Carroll <michael@openrobotics.org> * Revert gamma correction in the sky Signed-off-by: ahcorde <ahcorde@gmail.com> * enable grayscale albedo map to fix red color highlights and disable hardware gamma to fix dark sky color Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Local updates for Ogre2.2 against main branch (#317) * Local updates for Ogre2.2 against main branch Signed-off-by: Ian Chen <ichen@osrfoundation.org> Co-authored-by: Ian Chen <ichen@osrfoundation.org> * Fix merge Signed-off-by: ahcorde <ahcorde@gmail.com> * fix shadows in ogre 2.2 Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Lint Signed-off-by: Michael Carroll <michael@openrobotics.org> * fix toggling sky Signed-off-by: Ian Chen <ichen@osrfoundation.org> * fix camera test Signed-off-by: Ian Chen <ichen@osrfoundation.org> * make linters happy Signed-off-by: ahcorde <ahcorde@gmail.com> * make linters happy Signed-off-by: ahcorde <ahcorde@gmail.com> * Fix small regression from merge Signed-off-by: Michael Carroll <michael@openrobotics.org> * Remove problematic leftover files from 2.1 The mere presence of these files can cause incorrect shader generation or unknown visual bugs. IMPORTANT: The installation folder (i.e. CMAKE_INSTALL_PREFIX) must remove them as well. `make install` won't be enough because it won't remove files, only add new ones or update existing ones. This folder is usually installed in ign/install/share/ignition/ignition-rendering6/ogre2/media/Hlms Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Do not crash on shutdown - ogreRoot may be nullptr - Do not destroy textures already scheduled for destruction Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Remove problematic leftover files from 2.1 (#354) The mere presence of these files can cause incorrect shader generation or unknown visual bugs. IMPORTANT: The installation folder (i.e. CMAKE_INSTALL_PREFIX) must remove them as well. `make install` won't be enough because it won't remove files, only add new ones or update existing ones. This folder is usually installed in ign/install/share/ignition/ignition-rendering6/ogre2/media/Hlms Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Do not crash on shutdown (#355) - ogreRoot may be nullptr - Do not destroy textures already scheduled for destruction Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Removed unused variable Signed-off-by: ahcorde <ahcorde@gmail.com> * Restore FSAA support in 2.2 branch Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix changing background color not always taking immediate effect Changed pass_clear in favour of LoadAction::Clear which is more efficient on very modern GPUs and specially TBDR ones. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Changed pass_clear in favour of LoadAction::Clear which is more efficient on very modern GPUs and specially TBDR ones. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Missing public keyword Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Save VRAM when FSAA is used and no postprocessing There's an unused texture when these conditions are met (which are fairly common) This memory optimization could not be performed in Ogre 2.1, it needs Ogre 2.2+ Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Remove code deprecated in ign-rendering5 Syntax cosmetic changes for consistency Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Remove code deprecated in ign-rendering5 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Code style fixes Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Undo VRAM saving optimization: It cannot be applied The "Final Composition" node requires both textures to be resident. Thus 2nd texture must always be resident. The optimization could still be applied if we create two Final Composition nodes (one for when 2 textures are needed, another for when only MSAA + 1 texture is needed) but this would: 1. Hurt code readability too much (i.e. what is going on?) 2. Increase debuggability difficulty too much because codepaths taken would differ depending on whether optimization was applied. Also certain bugs could remain hidden until compositors are toggled. This was causing ogre2_demo to fail. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Merge main branch into Ogre 2.2 and fixes (#359) * Fix floating point precision bug handling alpha channel (#332) (#333) Fixes #332 Fixes #108 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Test re-enabling depth camera integration test on mac (#335) * Fix floating point precision bug handling alpha channel (#332) Fixes #332 Fixes #108 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * test reenabling depth camera test on mac Signed-off-by: Ian Chen <ichen@osrfoundation.org> Co-authored-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix new [] / delete mismatch (#338) Using a custom deallocator to avoid breaking ABI Alternatively C++17 supports the following syntax, which was not used: `typedef std::shared_ptr<unsigned char[]> DataPtr;` Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix heap overflow when reading (#337) PF_RGB is 3 bytes. But later on Ogre2SelectionBuffer::OnSelectionClick will try to read 4 bytes from it. Fixed by ensuring it's always at least 4 bytes and zero-initializing those 4 bytes. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> Co-authored-by: Ian Chen <ichen@osrfoundation.org> * Fix floating point precision bug handling alpha channel (#332) (#333) Fixes #332 Fixes #108 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix depth alpha (#316) * update test Signed-off-by: Ian Chen <ichen@osrfoundation.org> * reenable macos test Signed-off-by: Ian Chen <ichen@osrfoundation.org> * fix typo Signed-off-by: Ian Chen <ichen@osrfoundation.org> * cherry pick f9f1820 and fix conflicts Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Fix FSAA in UI and lower VRAM consumption (#313) * Fix FSAA in UI and lower VRAM consumption FSAA was being requested however due to how the compositor was setup, this effect was not taking effect. Additionally, the Compositor setup was improved to lower memory consumption. Originally the setup was taken from Ogre samples which assume they will ultimately be rendering to a window. However this is not the case and thus IGN was creating 3 render targets (two for ping-ponging between postprocess FXs + one for storing the final result) This was optimized so that we only create 2 render targets: two for ping-ponging between postprocess FXs and we pick at runtime which one is storing the final result via the new variable renderTargetResultsIdx Further performance optimizations could be made in Ogre 2.2 to improve unnecessary MSAA resolving when doing postprocess, though considering there's currently only one postprocessing effect (the Gaussian filter) I doubt this optimization would make much of a difference Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Add Ogre2RenderTarget::RenderTarget back Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Rewrote the compositor changes to support RenderWindows As a bonus this new method breaks ABI far less. Fix leak: DestroyCompositor would often not be called Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Mantain ABI compatibility #Ogre2IsRenderWindowABI When merging to newer branches that can break the ABI, revert this commit Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix ABI problems I gave up on commit undoing It's clear that on the next release, Ogre2RenderTarget and Ogre2RenderTexture need to be merged together. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix camel case convention Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Make Ogre2RenderTarget::RenderTarget pure virtual again Hopefully this will prevent ABI breakage Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix deprecation warnings during build Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix invalid write of size 8 This was causing heap corruption. At best it would crash. At worst it would manifeset in subtle weird behaviors Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> Co-authored-by: Ian Chen <ichen@osrfoundation.org> * Backport memory fixes found by ASAN (#340) * Fix heap overflow when reading (#337) PF_RGB is 3 bytes. But later on Ogre2SelectionBuffer::OnSelectionClick will try to read 4 bytes from it. Fixed by ensuring it's always at least 4 bytes and zero-initializing those 4 bytes. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> Co-authored-by: Ian Chen <ichen@osrfoundation.org> * Fix new [] / delete mismatch (#338) Using a custom deallocator to avoid breaking ABI Alternatively C++17 supports the following syntax, which was not used: `typedef std::shared_ptr<unsigned char[]> DataPtr;` Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> Co-authored-by: darksylinc <dark_sylinc@yahoo.com.ar> * recreate node only when needed (#342) Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Fix custom shaders uniforms ign version number (#343) Signed-off-by: Ian Chen <ichen@osrfoundation.org> * relax gaussian test tolerance (#344) Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Update light map tutorial (#346) * apply changes Signed-off-by: Ian Chen <ichen@osrfoundation.org> * remove line Signed-off-by: Ian Chen <ichen@osrfoundation.org> * add ifdef for apple in integration test Signed-off-by: Ian Chen <ichen@osrfoundation.org> * 🎈 4.8.0 (#348) Signed-off-by: Louise Poubel <louise@openrobotics.org> * update ign-rendering version in custom shaders uniform sample Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Remove problematic leftover files from 2.1 The mere presence of these files can cause incorrect shader generation or unknown visual bugs. IMPORTANT: The installation folder (i.e. CMAKE_INSTALL_PREFIX) must remove them as well. `make install` won't be enough because it won't remove files, only add new ones or update existing ones. This folder is usually installed in ign/install/share/ignition/ignition-rendering6/ogre2/media/Hlms Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Do not crash on shutdown - ogreRoot may be nullptr - Do not destroy textures already scheduled for destruction Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Restore FSAA support in 2.2 branch Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix changing background color not always taking immediate effect Changed pass_clear in favour of LoadAction::Clear which is more efficient on very modern GPUs and specially TBDR ones. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Changed pass_clear in favour of LoadAction::Clear which is more efficient on very modern GPUs and specially TBDR ones. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Missing public keyword Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Save VRAM when FSAA is used and no postprocessing There's an unused texture when these conditions are met (which are fairly common) This memory optimization could not be performed in Ogre 2.1, it needs Ogre 2.2+ Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Remove code deprecated in ign-rendering5 Syntax cosmetic changes for consistency Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Remove code deprecated in ign-rendering5 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Code style fixes Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Undo VRAM saving optimization: It cannot be applied The "Final Composition" node requires both textures to be resident. Thus 2nd texture must always be resident. The optimization could still be applied if we create two Final Composition nodes (one for when 2 textures are needed, another for when only MSAA + 1 texture is needed) but this would: 1. Hurt code readability too much (i.e. what is going on?) 2. Increase debuggability difficulty too much because codepaths taken would differ depending on whether optimization was applied. Also certain bugs could remain hidden until compositors are toggled. This was causing ogre2_demo to fail. Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> Co-authored-by: Ian Chen <ichen@osrfoundation.org> Co-authored-by: Louise Poubel <louise@openrobotics.org> * Began work on Heightmaps with Ogre2. Very WIP Hardcoded some paths in CMakeLists to get Terra compiling Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Register HlmsTerra Add its Hlms data files Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Update all Terras and show them on screen (WIP) Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Update to latest Terra to get Z-up support Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Better calculation of heightmap size (WIP) Fix crash when heightmap is deleted Update to latest Terra for setCustomSkirtMinHeight Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix shader compiler error Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix alignment issues in terrain Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Move Terra to its own folder and project Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Enable assert that was accidentally disabled Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Customize Terra for Ignition's requirements Fix barrier assert Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Use custom blending modes to adjust to ign Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * HeightmapTexture::Size is in meters, it's not a scale Now it looks close to the reference in ogre1 No longer normalize weights, it's not needed anymore Also fix bug when 5 texture maps could not be supported Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Use same blending algorithm for roughness & metalness Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Deal with edge case where terrain skirts could be above ground Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix wrong indentation Remove dead code Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Forgot to push this change Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Disable alpha blending of detail maps for Terrain Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Add terrain shadows to normal objects Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix copyright year Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Re-enable ImageHeightmap It shouldn't have been disabled Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Cosmetic changes Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Move Terra's source code into ogre2/src It is ogre2 specific Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Support ogre1 heightmaps via cropping and warn about it Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Support both ogre2 & ogre engines in heightmap sample Default to ogre2 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Force-disable JSON parts of Terra It's not used by ignition. This avoids detecting rapidjson during ign build Fix Windows build Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Add license to Terra files Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Update to latest version of Terra Adds spotlight & point shadow map support (not working/set yet) Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Add terrain shadows from spot & point lights Use unique_ptr instead of raw ptrs when possible Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Skip Terra headers in cppcheck They should be treated as external code Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * fixing tests Signed-off-by: Ian Chen <ichen@osrfoundation.org> * add ifdef Signed-off-by: Ian Chen <ichen@osrfoundation.org> * suppress warnings Signed-off-by: Ian Chen <ichen@osrfoundation.org> * update syntax Signed-off-by: Ian Chen <ichen@osrfoundation.org> * update syntax Signed-off-by: Ian Chen <ichen@osrfoundation.org> * Fix crash on shutdown due to ptr destroyed too late It should be destroyed before Ogre Root Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Update to latest Terra to fix bug from upstream Upstream OGRECave/ogre-next@d0a01d2 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Update to latest Hlms from upstream This fixes some compiler bugs with Terra Also adds supports for HlmsPbs::setShadowReceiversInPixelShader which was written specifically for Gazebo Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix compiler warning Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix Terra shadows on Spot and Point lights Update Terra to latest from upstream Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix Terra's point light shadows Terra's workspace listener was being executed before the camera is rotated for cubemap rendering Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * Fix documentation Silence warnings from external code to pass build checks Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> * fixing CI Signed-off-by: Ian Chen <ichen@osrfoundation.org> * add include path Signed-off-by: Ian Chen <ichen@osrfoundation.org> * windows warning Signed-off-by: Ian Chen <ichen@osrfoundation.org> * fix Signed-off-by: Ian Chen <ichen@osrfoundation.org> Co-authored-by: ahcorde <ahcorde@gmail.com> Co-authored-by: Michael Carroll <michael@openrobotics.org> Co-authored-by: Ian Chen <ichen@osrfoundation.org> Co-authored-by: Louise Poubel <louise@openrobotics.org>
PR NOTE 1
This fixes a regression from ign-rendering4.
In ign-rendering4 FSAA worked fine because it was relying on compositor scripts. This broke when the compositor script was replaced with C++ code.
The VRAM consumption issue affects both branches, but I think it's just fine to make it ign-rendering5 and onwards only
PR NOTE 2 (important)
How do I test the camera gaussian filter? It's affected directly (i.e. if renderTargetResultsIdx is set to the wrong value then the image won't look like the filter was applied, or some other similar issue) and I had no idea how to test it.Update:
CI says gaussian filter test failed. How shocking. I should check that test locallyUpdate 2: Found the bug and fixed it.
Though DepthGaussianNoise test is still failing and I'm still looking into itUpdate 3: DepthGaussianNoise is failing in my machine because the test is buggy. Opened Ticket #315
PR NOTE 3
Affected classes are mostly Ogre2RenderTarget, Ogre2RenderTexture and Ogre2DepthCamera
PR NOTE 4
Currently fixing ABI breakage.
Before vs After
Comments
FSAA was being requested however due to how the compositor was setup,
this effect was not taking effect.
Additionally, the Compositor setup was improved to lower memory
consumption. Originally the setup was taken from Ogre samples which
assume they will ultimately be rendering to a window.
However this is not the case and thus IGN was creating 3 render targets
(two for ping-ponging between postprocess FXs + one for storing the
final result)
This was optimized so that we only create 2 render targets: two for
ping-ponging between postprocess FXs and we pick at runtime which one is
storing the final result via the new variable renderTargetResultsIdx
Further performance optimizations could be made in Ogre 2.2 to improve
unnecessary MSAA resolving when doing postprocess, though considering
there's currently only one postprocessing effect (the Gaussian filter) I
doubt this optimization would make much of a difference
Signed-off-by: Matias N. Goldberg dark_sylinc@yahoo.com.ar
Summary
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge