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

Share GPU ressources across render windows #3051

Merged
merged 10 commits into from
Apr 11, 2024

Conversation

bruyeret
Copy link
Contributor

@bruyeret bruyeret commented Apr 3, 2024

Add possibility to share a single context for several render windows.
This enables GPU ressource sharing accross render windows.

This feature uses drawImage from the main WebGL context to the child render window's canvas. It is slow if there are a lot of render windows on Firefox: see this issue.

…ory public API

This method changed the static Map `CLASS_MAPPING` of the
corresponding backend.
It was only used by the API specific render windows. Replace
its usage with what is done everywhere else.
@finetjul finetjul requested a review from sankhesh April 3, 2024 10:06
bruyeret added 4 commits April 3, 2024 16:13
scalarTextureString didn't have a purpose and prevented caching of GPU resources
A new feature will add the ability to use a render window as child of another render window
This change prevents  using a render window where a renderer is needed
@bruyeret bruyeret force-pushed the share-textures branch 3 times, most recently from f500ef1 to 823da53 Compare April 3, 2024 14:53
@bruyeret bruyeret force-pushed the share-textures branch 2 times, most recently from 7b2118a to 1d7dfe0 Compare April 9, 2024 12:15
bruyeret added 3 commits April 9, 2024 14:16
To share resources accross render windows, they need to share a common context
To do so, the render windows can now have a parent that will contain the shared context
The child render windows will proxy some methods of their parent to do the rendering
The content of the parent canvas is then copied to the child canvas using a 2D context
@bruyeret bruyeret marked this pull request as ready for review April 9, 2024 12:18
@bruyeret
Copy link
Contributor Author

bruyeret commented Apr 9, 2024

The picking has been smoke tested and seems to be working fine.
If you want to try the feature and see what the parent render window is doing, you can run ManyRenderWindows example and add this code to the example:

const mainCanvas = mainRenderWindowView.getCanvas();
mainCanvas.style.width = '500px';
document.body.appendChild(mainCanvas);

@finetjul
Copy link
Member

finetjul commented Apr 9, 2024

@sankhesh can you please review when you get a chance

Copy link
Member

@finetjul finetjul left a comment

Choose a reason for hiding this comment

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

LGTM

@finetjul finetjul added this pull request to the merge queue Apr 11, 2024
Merged via the queue into Kitware:master with commit 21534d1 Apr 11, 2024
3 checks passed
Copy link

🎉 This PR is included in version 30.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Automated label label Apr 11, 2024
@bruyeret bruyeret deleted the share-textures branch April 12, 2024 07:39
@sankhesh
Copy link
Collaborator

@bruyeret Sorry, I missed the review period but the changes look good to me. Excellent work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Automated label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants