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
use webgl2 when available #1891
Conversation
Bundle size report: Size Change: -411 B
ℹ️ View Details
|
3dc59b1
to
b8caa7a
Compare
What's the benefit of this, until we actually use WebGL2 features? |
@JannikGM The reason this came up is that I'm using a custom 3D layer and some shader features that were working in plain threejs (which defaults to webgl2) were failing in my MapLibre layer and vice versa. |
I would also suggest using WebGL2 by default. It might be needed for VAOs available in WebGL2 only and easy state switching between several custom layers. |
I'd assume that any WebGL2 capable browser would also expose maplibre-gl-js/src/gl/context.ts Line 71 in 8449998
If extensions want to use VAOs, they should probably also support WebGL with that extension for wider compatibility. Edit: |
@JannikGM Could you give this a quick look? How do I tell whether users of the WebGL timing functions are getting the right results? |
Would be amazing to take this into v3 release. People from DeckGL wanted to switch to WebGL2 as well - FYI @HarelM |
@klokan I'm watching this PR closely, but a) it's still in draft b) it incorporates a lot of small fixes that should not be part of this PR. |
9321800
to
4ccbab6
Compare
Please make sure to add the relevant unit tests to the added functionality. |
I'm not intending to add any functionality in this PR. I only want to make sure existing functionality continues to work with both WebGL1 and WebGL2. Could you help me out with the testing? I can't figure out how to make the unit tests run on different browser engines. Even the dev dependency |
There are changes in |
Can you help me write a test to check that the |
Check out the info here: |
@HarelM Every single unit test around That |
Unfortunately, I don't know the answer of which tests exists to cover the classes you changed. |
@rotu where are we on this PR? What's missing in order to merge this? |
I've been exploring moving our tests to WebGL2, which requires us to swap JSDOM and all the browser mocking with a headless browser like puppeteer or playwright, because there is no maintained node implementations of WebGL2 we can use. For the longest time WebGL2 wasn't widely supported, due to lacking safari support, but it's finally getting there. Currently webgl2's support is ~93.96%, but growing as iPhones get updated - for reference await is at 95.07%, which we don't compile away with the current config, so we're not currently at 100% anyway. What I wonder is, could we simply move to webgl2 entirely (similar to how MapLibre Native recently moved to OpenGL ES 3) as the support becomes sufficient, and thus save all this conditional logic and all the gl1/gl2 checks? Would there be any downsides to that? |
The downside would be the support of old devices and old browsers. |
@HarelM it's a good point to try to keep the logic of each graphics backend isolated, also with webgpu on the horizon, somewhat similar to the modularization effort on Native. I'd love to see some benchmarks of this PR, as that would be the main selling point of introducing webgl 2. As long as we stay compatible with webgl 1, we might not be able to opt in tomany of the optimizations from webgl 2, so I wonder what the results would be. Here is the PR from MapLibre Native that has most of the webgl 2 shader changes: https://github.com/maplibre/maplibre-gl-native/pull/995/files#diff-524519fde8010b2a448977ac84de5feefa300da4983495a0a2bbdc30a62d2bd8 |
If almost everybody has webgl2 and this opts for that when available, I'm concerned about merging this before having the ability to test webgl2. |
The changes to map.ts has to be resolved for this to proceed. @rotu , would it be possible for you to have a look at the merge conflict? We are getting closer to having some webgl2 tests in place, but I can't tests it against this PR due to the conflicts in map.ts. |
@rotu, the render test suite is now webgl2 compatible. Also the github test workflows has been refactored so it's broken into separate workflows so it's easier to dive into. It does require rebasing these changes to main though. |
I wonder what happened with the |
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.
Overall approved, Thanks for all the hard work.
I left a very small comment about a variable that I'm not sure is being used.
If it is being used feel free to merge, if not, please remove it and merge.
I can't unresolve conversations, so I'm linking for exposure:
Other than that, new code looks okay to me. 👍 |
I'll make a follow up PR to simplify the type narrowing / add types to the getContext(), and remove this unused emptyTexture |
Use WebGL2 rendering context when available.
Launch Checklist
CHANGELOG.md
under the## main
section.