-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Support EXT_disjoint_timer_query_webgl2 #9652
Support EXT_disjoint_timer_query_webgl2 #9652
Conversation
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.
Thanks @mosra!
I don't know enough for the GL aspects here, but I had some general comments. Also, I think we should add a test for at some of this, as it seems we have nothing for queries atm.
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.
If you build an app with USE_WEBGL2, but then it creates a WebGL 1 context (perhaps because it is on a WebGL 1 browser), is it supposed to still work? I think it is, but there are some places in this patch where I think it may not.
If tests are added then it shouldn't be too hard to test with USE_WEBGL2 but still creating a WebGL 1 context.
@kainino0x Apologies -- I wasn't aware creating a WebGL 1 context with
Thank you! EDIT: Oh and re tests -- there's a problem that Firefox exposes the extension only under a flag (not sure how you can enable that on the CIs), and both chrome and firefox report 0s unless the results are queried async. It could check for GL errors at least, tho. |
I'm not 100% sure it is, but I think it is. Hoping @juj would chime in. I can look into it though.
(FYI, I believe this is a Spectre mitigation.)
Yup, that's intended behavior. A test can just use emscripten_set_main_loop or similar to allow the browser to update the value. |
It's also very valuable to have tests even if we have to run them manually/locally, so it would be great to have them. |
Testing with a firefox pref is possible, see here where we already set up a few prefs: emscripten/.circleci/config.yml Line 131 in ea3209a
|
Tried a basic emscripten_webgl_init_context_attributes with USE_WEBGL2=1 and attrs.majorVersion = 1, and that works on Safari (which doesn't have WebGL 2). Didn't try anything more complex. |
I think simply with conditionals like |
Sorry for the silence on my end -- had two extremely busy weeks. Hoping to get back to this over the weekend or early next week. |
Emscripten support for timestamp queries is incomplete emscripten-core/emscripten#9652
Emscripten support for timestamp queries is incomplete emscripten-core/emscripten#9652
The deletion of the Re-opening and re-targeting to master. |
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
Including a workaround for Firefox, which exposes EXT_disjoint_timer_query on WebGL 2 as well.
Sorry for the over-a-year-long delay, finally found the time to wrap this up (also a bit frightened that nobody else needed this functionality yet, huh). I rethought the original idea a bit and the actual change in functionality is a lot smaller than before:
What isn't in the tests here is 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.
Haven't had a chance to read through the tests yet, but I think this looks good! Great work with the thorough testing, based on your description - that really helps be confident things work and won't break later.
def test_webgl_timer_query(self): | ||
for args in [ | ||
# EXT query entrypoints on WebGL 1.0 | ||
['-s', 'MAX_WEBGL_VERSION'], |
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'm not sure, is this the same as MAX_WEBGL_VERSION=1
? Could we just explicitly specify =1
?
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.
Honestly I have no idea. Copypasted it from another occurence in this file which led me to believe it indeed is an implicit =1
:)
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.
Yes, emcc allows -s X
instead of -s X=1
.
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.
Sorry for the delay on this. Tests LGTM, though I had an idea about how we could make them a little more thorough. Thanks again for working on this!
Let us know if you won't have time to do this and I think I could pick up the change I suggested.
Thank you! |
Continuation of #4575 (from 2016), I just ran into this today when adding support for this extension into Magnum.
Until now, most of the extension worked when using the core query APIs, except for
glQueryCounterEXT()
andglGetQueryObjecti64vEXT()
-- there the functions assumedglGenQueriesEXT()
was called that populated the internal id-to-object mapping array (and notglGenQueries()
). So I added branches there that do the correct thing under WebGL 2.Moreover, the
queryCounterEXT
property was undefined because the code asked forEXT_disjoint_time_query
on WebGL 2 (which isn't exposed there). The code now asks forEXT_disjoint_timer_query_webgl2
there, which makesqueryCounterEXT
available.Finally, because code coming from GLES may expect the EXT-suffixed versions still being available on WebGL 2 builds as well (since you can use the EXT-suffixed
glGenQueriesEXT()
etc. withEXT_disjoint_time_query
on ES3 well), those are now aliases to the core APIs.I did quite an extensive testing with Magnum's GL tests (both WebGL 1 and WebGL 2), but it may happen that this change will affect some Emscripten tests. Also, if there's any test file that I could update to cover the now-working APIs for WebGL 2, let me know.
EDIT: upon discovering that Firefox doesn't actually implement the
_webgl2
version on WebGL 2 (https://bugzilla.mozilla.org/show_bug.cgi?id=1328882), I added a fallback to the WebGL 1 extension string. As far as my testing goes, the entry points work correctly, so it's just about the extension string.Thank you!