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

Add fallback rendering for other APIs #357

Merged
merged 4 commits into from
Dec 20, 2022

Conversation

darksylinc
Copy link
Contributor

@darksylinc darksylinc commented Feb 19, 2022

🦟 Bug fix

No ticket has been assigned for this issue.

Order in which PRs must be merged

  1. Add necessary headers for Vulkan QML GUI backend gz-rendering#706
  2. This PR.
    • or optionally, merge this one as part of the next one aka PR 467, which includes it
  3. Add Vulkan QML backend #467
  4. Add CLI to switch to Vulkan & Metal backends gz-sim#1735

Summary

Until we get native API to Qt implemented, fallback system can be used
to transfer GPU (Ogre) -> CPU -> GPU (Qt)

This is important for getting APIs other than OpenGL to work with Qt.

This is slow, but it works.

Signed-off-by: Matias N. Goldberg dark_sylinc@yahoo.com.ar

Dependency

After the CI failed, I realized this PR depends on either gazebosim/gz-rendering#553 or gazebosim/gz-rendering#565 and thus cannot be merged until then.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • 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.

@github-actions github-actions bot added the 🌱 garden Ignition Garden label Feb 19, 2022
@jennuine jennuine added the needs upstream release Blocked by a release of an upstream library label Feb 22, 2022
Copy link
Contributor

@jennuine jennuine left a comment

Choose a reason for hiding this comment

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

Did a first pass and left some minor comments. Is it possible to add a test?

Friendly ping to @ahcorde , @WilliamLewww , or @iche033 to take a look please.

src/plugins/minimal_scene/EngineToQtInterface.cc Outdated Show resolved Hide resolved
src/plugins/minimal_scene/EngineToQtInterface.cc Outdated Show resolved Hide resolved
src/plugins/minimal_scene/EngineToQtInterface.hh Outdated Show resolved Hide resolved
@iche033
Copy link
Contributor

iche033 commented Feb 22, 2022

I did a quick test with just gazebosim/gz-rendering#565 and there are some rendering issues:
qt_fallback

looks like we'll need to test this with ogre 2.3 from gazebosim/gz-rendering#553

@darksylinc
Copy link
Contributor Author

darksylinc commented Feb 23, 2022

I did a quick test with just gazebosim/gz-rendering#565 and there are some rendering issues:

Was gazebosim/gz-rendering#564 merged into gazebosim/gz-rendering#565? We need the copy to work correctly otherwise the download will be problematic. In fact we force RGBA8888 and without #564 it will trigger an out of bounds read due to a preexisting bug.

@iche033
Copy link
Contributor

iche033 commented Feb 23, 2022

Was gazebosim/gz-rendering#564 merged into gazebosim/gz-rendering#565? We need the copy to work correctly otherwise the download will be problematic. In fact we force RGBA8888 and without #564 it will trigger an out of bounds read due to a preexisting bug.

oh I see, I didn't try this with gazebosim/gz-rendering#564 merged into gazebosim/gz-rendering#565. I'll do that first before testing with ogre 2.3

@iche033
Copy link
Contributor

iche033 commented Mar 5, 2022

Testing with just gazebosim/gz-rendering#564 was not enough and I got the same result. I then tested this with gazebosim/gz-rendering#553 + ogre-next v2-3 branch and it's working fine now.

So this depends on gazebosim/gz-rendering#553 so we'll need to have ign-rendering7 + ogre 2.3 ready before merging this.

@chapulina chapulina added the bug Something isn't working label Jul 23, 2022
@chapulina chapulina changed the base branch from main to gz-gui7 August 5, 2022 19:01
@darksylinc
Copy link
Contributor Author

I thought this one was already merged and had a sudden shock when I couldn't see the code in main and worse I couldn't find this PR.

I upgraded the PR to the latest changes; so it's rebased with latest main.

@azeey
Copy link
Contributor

azeey commented Nov 14, 2022

This requires a version bump and it needs to be retargetted to main.

Until we get native API to Qt implemented, fallback system can be used
to transfer GPU (Ogre) -> CPU -> GPU (Qt)

This is slow, but it works.

Also simplify abstractions by merging IgnCameraTextureRhi into
RenderThreadRhi.

Fix codecheck errors

Add documentation

Use GraphicsAPI instead of CurrentGraphicsAPI

Fix CMake project

Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
@darksylinc darksylinc changed the base branch from gz-gui7 to main December 11, 2022 23:32
@darksylinc
Copy link
Contributor Author

Rebased and retarget to main (well, this one was easy. I'd wish they'd all be like that)

@codecov
Copy link

codecov bot commented Dec 11, 2022

Codecov Report

Merging #357 (8a272bf) into main (cc82c6d) will decrease coverage by 0.71%.
The diff coverage is 32.00%.

❗ Current head 8a272bf differs from pull request most recent head 7d77cc0. Consider uploading reports for the commit 7d77cc0 to get more accurate results

@@            Coverage Diff             @@
##             main     #357      +/-   ##
==========================================
- Coverage   69.11%   68.40%   -0.72%     
==========================================
  Files          44       45       +1     
  Lines        4919     4979      +60     
==========================================
+ Hits         3400     3406       +6     
- Misses       1519     1573      +54     
Impacted Files Coverage Δ
src/plugins/minimal_scene/MinimalScene.hh 100.00% <ø> (ø)
src/plugins/minimal_scene/MinimalSceneRhi.hh 100.00% <ø> (ø)
src/plugins/minimal_scene/MinimalSceneRhiOpenGL.hh 100.00% <ø> (ø)
src/plugins/minimal_scene/EngineToQtInterface.cc 17.74% <17.74%> (ø)
src/plugins/minimal_scene/MinimalScene.cc 62.17% <100.00%> (-0.19%) ⬇️
src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc 92.22% <100.00%> (-3.29%) ⬇️

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

{
void *texturePtr = nullptr;
_camera->RenderTextureMetalId(&texturePtr);
this->dataPtr->metalTexture = CFBridgingRelease(texturePtr);
Copy link
Contributor

Choose a reason for hiding this comment

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

homebrew build caught a compile error here:

error: no member named 'metalTexture' in 'gz::gui::plugins::RenderThreadRhiMetalPrivate'

src/plugins/minimal_scene/EngineToQtInterface.cc Outdated Show resolved Hide resolved
Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
}

/////////////////////////////////////////////////
void* RenderThreadRhiMetal::TexturePtr() const
{
return this->dataPtr->texturePtr;
void *texturePtr = CFBridgingRetain(this->dataPtr->metalTexture);
Copy link
Contributor

Choose a reason for hiding this comment

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

homebrew caught another build error here. This fixes the problem for me:

-  void *texturePtr = CFBridgingRetain(this->dataPtr->metalTexture);
+  void *texturePtr = (void *)CFBridgingRetain(this->dataPtr->metalTexture);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Grrrr, thanks.

/////////////////////////////////////////////////
void EngineToQtInterface::DestroyFallbackTexture()
{
glDeleteTextures(1, &this->dataPtr->fallbackTexture);
Copy link
Contributor

Choose a reason for hiding this comment

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

windows build error here. Maybe the following helps

-  glDeleteTextures(1, &this->dataPtr->fallbackTexture);
+  QOpenGLFunctions *glFuncs = this->dataPtr->glContext->functions();
+  glFuncs->glDeleteTextures(1, &this->dataPtr->fallbackTexture);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree! That'd probably be the best solution!

Signed-off-by: Ian Chen <ichen@osrfoundation.org>
@iche033
Copy link
Contributor

iche033 commented Dec 20, 2022

builds fixed in 7d77cc0.

@iche033 iche033 merged commit fce993b into gazebosim:main Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants