Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1146)

Issue 2627323007: Migrate WebGL contexts on backgrounded tabs to the integrated GPU.

Created:
3 years, 11 months ago by Ken Russell (switch to Gerrit)
Modified:
3 years, 11 months ago
CC:
chromium-reviews, krit, drott+blinkwatch_chromium.org, blink-reviews-platform-graphics_chromium.org, Stephen Chennney, dshwang, pdr+graphicswatchlist_chromium.org, jbroman, Justin Novosad, Rik, f(malita), blink-reviews, piman+watch_chromium.org, kinuko+watch, ajuma+watch_chromium.org, danakj+watch_chromium.org, rwlbuis, shrike, erikchen
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Migrate WebGL contexts on backgrounded tabs to the integrated GPU. Use the canvas element's PageVisibilityObserver to detect when the tab is moved to the background, and for WebGL contexts, give a hint that they should use low power mode. This causes the CGLPixelFormatObj which was causing the context to use the discrete GPU to be released. It's not clear whether this is legal. In the past, problems were seen where the discrete GPU on macOS supported certain resource formats (textures, renderbuffers, etc.) that the integrated GPU didn't. It's not clear what happens to these resources if the system switches from the discrete to the integrated GPU. Lightly tested this manually with Google Maps, ShaderToy, and the WebGL Aquarium. The cost of switching GPUs appears to be low though not insignificant, but no obviously incorrect rendering was observed. BUG=681341 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+260 lines, -11 lines) Patch
M gpu/GLES2/gl2chromium_autogen.h View 1 chunk +1 line, -0 lines 0 comments Download
M gpu/GLES2/gl2extchromium.h View 1 chunk +10 lines, -0 lines 0 comments Download
M gpu/command_buffer/build_gles2_cmd_buffer.py View 2 chunks +15 lines, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_c_lib_autogen.h View 2 chunks +7 lines, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_cmd_helper_autogen.h View 1 chunk +8 lines, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_implementation_autogen.h View 1 chunk +2 lines, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_implementation_impl_autogen.h View 1 chunk +8 lines, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_interface_autogen.h View 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_interface_stub_autogen.h View 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h View 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_trace_implementation_autogen.h View 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h View 1 chunk +5 lines, -0 lines 0 comments Download
M gpu/command_buffer/cmd_buffer_functions.txt View 1 chunk +3 lines, -0 lines 0 comments Download
M gpu/command_buffer/common/gles2_cmd_format_autogen.h View 1 chunk +33 lines, -0 lines 0 comments Download
M gpu/command_buffer/common/gles2_cmd_format_test_autogen.h View 1 chunk +11 lines, -0 lines 0 comments Download
M gpu/command_buffer/common/gles2_cmd_ids_autogen.h View 1 chunk +2 lines, -1 line 0 comments Download
M gpu/command_buffer/common/gles2_cmd_utils_autogen.h View 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h View 2 chunks +19 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder.cc View 2 chunks +17 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder_autogen.h View 1 chunk +15 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doer_prototypes.h View 1 chunk +2 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc View 1 chunk +6 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder_passthrough_handlers_autogen.cc View 1 chunk +14 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_validation_autogen.h View 1 chunk +6 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h View 1 chunk +11 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp View 1 chunk +3 lines, -0 lines 0 comments Download
M ui/gl/gl_bindings.h View 1 chunk +10 lines, -0 lines 0 comments Download
M ui/gl/gl_context.h View 1 chunk +2 lines, -0 lines 0 comments Download
M ui/gl/gl_context.cc View 1 chunk +3 lines, -0 lines 0 comments Download
M ui/gl/gl_context_cgl.h View 2 chunks +4 lines, -0 lines 0 comments Download
M ui/gl/gl_context_cgl.cc View 3 chunks +31 lines, -10 lines 2 comments Download
M ui/gl/gpu_preference.h View 1 chunk +7 lines, -0 lines 0 comments Download

Messages

Total messages: 7 (2 generated)
Ken Russell (switch to Gerrit)
All: this CL is only for discussion and further testing; I don't intend to land ...
3 years, 11 months ago (2017-01-15 03:45:54 UTC) #3
jbauman
https://codereview.chromium.org/2627323007/diff/1/ui/gl/gl_context_cgl.cc File ui/gl/gl_context_cgl.cc (right): https://codereview.chromium.org/2627323007/diff/1/ui/gl/gl_context_cgl.cc#newcode313 ui/gl/gl_context_cgl.cc:313: AllocateDiscretePixelFormat(); I'm not sure this would actually switch the ...
3 years, 11 months ago (2017-01-19 01:13:14 UTC) #4
ccameron
The structure looks good, but, yeah, it'll need some thorough manual testing (and fixes for ...
3 years, 11 months ago (2017-01-20 00:39:26 UTC) #5
Ken Russell (switch to Gerrit)
https://codereview.chromium.org/2627323007/diff/1/ui/gl/gl_context_cgl.cc File ui/gl/gl_context_cgl.cc (right): https://codereview.chromium.org/2627323007/diff/1/ui/gl/gl_context_cgl.cc#newcode313 ui/gl/gl_context_cgl.cc:313: AllocateDiscretePixelFormat(); On 2017/01/19 01:13:14, jbauman wrote: > I'm not ...
3 years, 11 months ago (2017-01-20 04:34:52 UTC) #6
jbauman
3 years, 11 months ago (2017-01-20 06:24:47 UTC) #7
On 2017/01/20 04:34:52, Ken Russell OOO-till-Jan-27 wrote:
> https://codereview.chromium.org/2627323007/diff/1/ui/gl/gl_context_cgl.cc
> File ui/gl/gl_context_cgl.cc (right):
> 
>
https://codereview.chromium.org/2627323007/diff/1/ui/gl/gl_context_cgl.cc#new...
> ui/gl/gl_context_cgl.cc:313: AllocateDiscretePixelFormat();
> On 2017/01/19 01:13:14, jbauman wrote:
> > I'm not sure this would actually switch the context onto the discrete GPU.
> Once
> > an offscreen context is created it seems like it's stuck to a GPU until
> > GLContextCGL::ForceGpuSwitchIfNeeded does CGLSetVirtualScreen, and it won't
do
> > that call if discrete_pixelformat_ exists.
> > 
> > See also
> >
>
https://chromium.googlesource.com/chromium/src/+/97419c0f3a44da99c730fc572011...
> > for the issues we've had in the past with switching contexts from the
> integrated
> > GPU to the discrete GPU.
> 
> Thanks for tracking down that change. I'd remembered it vaguely but not done
the
> code archaeology.
> 
> This CL definitely causes gfxCardStatus to think that the machine has switched
> back to the integrated GPU, regardless of whether we're calling
> CGLSetVirtualScreen. I'm not really sure exactly what effect it has and what
> resources are being migrated between GPUs. We are hoping to get some more
> details from Apple's OpenGL team about how integrated/discrete GPU transitions
> work and exactly what is allowed, and needed, in order to save power in this
> area.

I think this code will migrate the context from the discrete GPU to the
integrated GPU, but not vice versa. I think that's hard to detect, besides
checking the performance of WebGL aquarium or something.

Powered by Google App Engine
This is Rietveld 408576698