-
-
Notifications
You must be signed in to change notification settings - Fork 23.8k
[Web] Fix checking for OpenGL extensions with Emscripten 3.1.51 and later #93560
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we have any guarantee that this will actually list all supported extensions?
The code you linked in the issue report (https://github.com/emscripten-core/emscripten/blob/3.1.61/src/library_webgl.js#L145) has me a little concerned. it says:
Which makes me think that the authors of Emscripten don't even realize what extensions they do and don't support.
I've tried to follow the history of this breaking change on Github and it is a little confusing. One of the maintainers links this document which says that "OVR_multiview2" is not supported ("OVR_multiview" and "OCULUS_multiview" are not even listed).
It looks like they are just cherrypicking extensions to the allow list now (seemingly at random?) emscripten-core/emscripten#21185
I can't find any documentation of
emscripten_webgl_get_supported_extensions()including what it promises to return. I suspect at some point the devs of emscripten are going to breakemscripten_webgl_get_supported_extensions()the same way they brokeglGetStringi()Uh oh!
There was an error while loading. Please reload this page.
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.
I guess there are no guarantees, they can change anything at any time.
But
emscripten_webgl_get_supported_extensions()has always (since it was introduced in June 2020) simply called GLctx.getSupportedExtensions(). That's 4 years of being a simple one-line forwarding call to the underlying WebGL function.So, I feel more confident about them not breaking this function, than
glGetStringi(GL_EXTENSIONS, i)which is an attempt to emulate the OpenGL API, and hence a little open to interpretation.Yeah, it depends on their definition of "support", which is varying. They do "support" almost all WebGL extensions, in that they'll forward calls to them. But they only "support" deeply emulating the OpenGL API of a much smaller set of extensions.
Only
OVR_multiview2is a standardized WebGL extension.OVR_multiview(without the2) is only available on OpenGL (not WebGL). AndOCULUS_multiviewis a non-standard extension only implemented by the Meta Browser (which does the same thing asOVR_multiview2plus support for MSAA, which the standard extension doesn't have).In any case, the latest version of Emscripten does "support"
OVR_multiview2, but we're not using that in order to be compatible with older versions of Emscripten, and instead have our own thing over inplatforms/web/js/libs/library_godot_webgl2.js. (But, even with their "support" of it, they still won't report it as enabled viaglGetStringi(GL_EXTENSIONS, i)in Emscripten 3.1.51 or later.)Anyway, this bit is kind of a tangent! But hopefully that helps clear up the confusion :-)
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.
Thank you for your answer. I am left a little bit more confused on one point:
getSupportedExtensions()is defined immediately under the line you linked earlier. It explicitly only returns that limited list of extensions that emscripten says it supports. Which means that it won't report support forOVR_multiview2,OVR_multiview,orOCULUS_multiview.https://github.com/emscripten-core/emscripten/blob/67fa4c16496b157a7fc3377afd69ee0445e8a6e3/src/library_webgl.js#L198
If that is right, then it doesn't seem to do anything different from
glGetStringi(GL_EXTENSIONS, i)Is the original problem coming from
glGetStringi(GL_EXTENSIONS, i)reporting support for an extension that shouldn't be enabled? Or do we have some other fallback code that I am unaware of?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.
You know, if we wanted to, we could add our own version of
emscripten_webgl_get_supported_extensions()over in platforms/web/js/libs/library_godot_webgl2.js?Then Emscripten can't change it, or take it away.
However, I guess I'd prefer to wait to do that until they actually do change it or take it away, because if we do it for that one, it begs the question: why don't we do that for all Emscription functions? This one in particular doesn't seem more likely to break than any other.
But we do have that option available, either for now or for the future!
Uh oh!
There was an error while loading. Please reload this page.
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.
That line isn't defining
getSupportedExtensions()(which is a standard WebGL function, it's not from Emscripten). What it's doing is callinggetSupportedExtensions()(which will return all supported extensions) but then filtering it to remove all but the extensions in the fixed list of "supported" extensions from above.So, in the example of
OVR_multiview2, even if the browser reports it as supported, it will get removed because it's not on Emscripten's list.The definition of
emscripten_webgl_get_supported_extensions()is actually here:https://github.com/emscripten-core/emscripten/blob/67fa4c16496b157a7fc3377afd69ee0445e8a6e3/src/library_html5_webgl.js#L422-L426
Which is just one-liner, calling to the standard WebGL getSupportedExtensions() function.
No, it's that
glGetStringi(GL_EXTENSIONS, i)isn't reporting all extensions that are actually supported. It's filtering the list of supported extensions to remove all but a fixed list of extensions that Emscripten has arbitrarily decided should be listed as supported.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.
Ooooh, thank you for the explanation. That makes more sense now!
It's too bad that we are having to add a hack just to do the thing they are trying to stop us from doing.