emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.65k stars 3.29k forks source link

Change WebGL powerPreference default to high-performance? #10000

Open kripken opened 4 years ago

kripken commented 4 years ago

Browsers are moving to change the default WebGL powerPreference from high-performance to low-power (e.g. coming soon in Chrome 80). In practice this change of default means that some users (with 2 GPUs) might see the lower-end one used, and for something like a game engine that could be noticeably slower.

When creating the WebGL context, perhaps Emscripten should default to high-performance? I'd guess most of our users are running higher-end content. However, I'm not totally happy about such a change either, as browsers are preferring the opposite in general.

Other options:

Thoughts?

cc @juj @kenrussell @kainino0x

kainino0x commented 4 years ago
  • Emit a warning in ASSERTIONS mode if high-performance is not set, but by default that's likely excessive.

Another option: emit a warning if neither high-performance nor low-power is set. (i.e. powerPreference is EM_WEBGL_POWER_PREFERENCE_DEFAULT). I'm pretty sure low-power is always no-worse than DEFAULT if the app is happy with integrated gpus (Ken, check me on this statement).

kainino0x commented 4 years ago

And hey, congrats on #10000 :P

kenrussell commented 4 years ago

Many of the graphical Emscripten applications I've seen do draw fairly complex 3D scenes, so a default to high-performance might be warranted.

An easy way to change the default when invoking the compiler (which would then change the generated JavaScript) would be helpful. Adding command line flags to be able to force either the low-power or high-performance GPU would be good, if that's the direction chosen, to insulate against future changes of Emscripten's default.

Agree that if the application runs well on an integrated GPU, then explicitly specifying a low-power powerPreference should be no worse than using the default.

juj commented 4 years ago

Browsers are moving to change the default WebGL powerPreference from high-performance to low-power (e.g. coming soon in Chrome 80).

* Just document this more.

+1 for this. I think we should honor the default that browsers take, and solve it via documentation. Not all browsers have the same default.

* Emit a warning in ASSERTIONS mode if `high-performance` is not set, but by default that's likely excessive.

I think rather, in GL_ASSERTIONS || GL_DEBUG mode, print an affirmative non-warning print "Created a WebGL [low-power|high-performance] context with alpha/depth/stencil/whatever flags one got." to highlight what got created?

@kainino0x: remind me, if I create a GL context with either unset, or explicitly opted high-performance or low-power flag, can I afterwards query which type of context I actually got? I do have function emscripten_webgl_get_context_attributes() that does pull down powerPreference (https://github.com/emscripten-core/emscripten/blob/599b402ee6cd97cc3f4862254101fb044f10bec9/src/library_html5.js#L2601), but does that get filled by the browser?

juj commented 4 years ago

(and noooo I was eyeing on grabbing #10000 last night, but we were still one too much away from that!)

kenrussell commented 4 years ago

@juj the powerPreference will currently be passed back to the application unchanged - default won't be lowered to low-power or high-performance. These are actually requests, and conceivably might not be honored by the user agent.

stale[bot] commented 3 years ago

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.

Nitrillo commented 3 years ago

Maybe I'm wrong but using emscripten_webgl_init_context_attributes to set the power preference doesn't seem to be working with SDL, is any of the other options implemented? thanks!

kainino0x commented 3 years ago

Most browsers don't actually do anything in response to the powerPreference right now. I think it is obeyed by Chrome on Mac, and possibly Safari, but not others. I might be wrong about the exact status.

stale[bot] commented 2 years ago

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.