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

Issue 2461803002: Enable creation of offscreen contexts which own their backing surface. (Closed)

Created:
4 years, 1 month ago by bajones
Modified:
3 years, 10 months ago
CC:
chromium-reviews, mlamouri+watch-content_chromium.org, jam, haraken, dglazkov+blink, darin-cc_chromium.org, blink-reviews, piman+watch_chromium.org, blink-reviews-api_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Enable creation of offscreen contexts which own their backing surface. Uses this flag with WebGL contexts when WebVR is enabled, to allow the surface to be swapped out with a compatible one if used for VR presentation. BUG=389343 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 #

Patch Set 2 : Pushing more context creation attributes across the IPC boundary #

Patch Set 3 : Fixed crash on non-Android devices #

Patch Set 4 : Fixed upstream branch to drop unnecessary changes #

Patch Set 5 : Drop unnecessary dependent patch #

Total comments: 13
Unified diffs Side-by-side diffs Delta from patch set Stats (+140 lines, -23 lines) Patch
M content/renderer/renderer_blink_platform_impl.cc View 1 2 1 chunk +18 lines, -7 lines 0 comments Download
M gpu/command_buffer/common/gles2_cmd_utils.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/common/gles2_cmd_utils.cc View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M gpu/ipc/common/gpu_command_buffer_traits_multi.h View 1 chunk +1 line, -0 lines 0 comments Download
M gpu/ipc/service/gpu_command_buffer_stub.cc View 1 2 1 chunk +23 lines, -1 line 3 comments Download
M third_party/WebKit/Source/modules/webgl/WebGLContextAttributeHelpers.cpp View 1 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp View 1 2 2 chunks +12 lines, -0 lines 2 comments Download
M third_party/WebKit/public/platform/Platform.h View 1 1 chunk +5 lines, -0 lines 0 comments Download
M ui/gl/gl_surface.h View 1 2 1 chunk +2 lines, -0 lines 2 comments Download
M ui/gl/gl_surface_egl.cc View 1 2 3 chunks +13 lines, -0 lines 0 comments Download
M ui/gl/init/gl_factory.h View 1 2 1 chunk +4 lines, -0 lines 2 comments Download
M ui/gl/init/gl_factory_android.cc View 1 2 3 4 1 chunk +13 lines, -4 lines 2 comments Download
M ui/gl/init/gl_factory_mac.cc View 1 2 3 4 1 chunk +12 lines, -3 lines 0 comments Download
M ui/gl/init/gl_factory_ozone.cc View 1 2 1 chunk +5 lines, -0 lines 2 comments Download
M ui/gl/init/gl_factory_win.cc View 1 2 3 4 1 chunk +13 lines, -4 lines 0 comments Download
M ui/gl/init/gl_factory_x11.cc View 1 2 3 4 1 chunk +13 lines, -4 lines 0 comments Download

Messages

Total messages: 20 (15 generated)
bajones
dcheng@ or mkwst@: PTAL at gpu_command_buffer_traits_multi.h and Platform.h kbr@chromium.org: Please review WebGL changes piman@chromium.org: Please ...
4 years, 1 month ago (2016-11-16 00:07:59 UTC) #15
piman
https://codereview.chromium.org/2461803002/diff/80001/gpu/ipc/service/gpu_command_buffer_stub.cc File gpu/ipc/service/gpu_command_buffer_stub.cc (right): https://codereview.chromium.org/2461803002/diff/80001/gpu/ipc/service/gpu_command_buffer_stub.cc#newcode580 gpu/ipc/service/gpu_command_buffer_stub.cc:580: << depth << " to base format " << ...
4 years, 1 month ago (2016-11-16 00:44:03 UTC) #16
dcheng
https://codereview.chromium.org/2461803002/diff/80001/gpu/ipc/service/gpu_command_buffer_stub.cc File gpu/ipc/service/gpu_command_buffer_stub.cc (right): https://codereview.chromium.org/2461803002/diff/80001/gpu/ipc/service/gpu_command_buffer_stub.cc#newcode580 gpu/ipc/service/gpu_command_buffer_stub.cc:580: << depth << " to base format " << ...
4 years, 1 month ago (2016-11-17 01:17:00 UTC) #17
Ken Russell (switch to Gerrit)
https://codereview.chromium.org/2461803002/diff/80001/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp File third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp (right): https://codereview.chromium.org/2461803002/diff/80001/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp#newcode609 third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp:609: contextAttributes.ownOffscreenSurface = true; I haven't reviewed the rest of ...
4 years ago (2016-11-29 05:09:07 UTC) #18
klausw
3 years, 11 months ago (2017-01-05 02:17:44 UTC) #20
I'm revisiting this patch in two parts:

https://crrev.com/2616723002 "Refactor GL surface format handling" should
functionally be a no-op, but changes
the GLSurface::Format handling to prepare for more flexible
formats.

https://crrev.com/2586803003 "Enable creation of offscreen contexts which own
their backing surface" is an updated
version of this patch based on the refactored Format handling.

Can we move future discussion there?

https://codereview.chromium.org/2461803002/diff/80001/gpu/ipc/service/gpu_com...
File gpu/ipc/service/gpu_command_buffer_stub.cc (right):

https://codereview.chromium.org/2461803002/diff/80001/gpu/ipc/service/gpu_com...
gpu/ipc/service/gpu_command_buffer_stub.cc:580: << depth << " to base format "
<< surface_format;
On 2016/11/17 01:17:00, dcheng wrote:
> On 2016/11/16 00:44:02, piman wrote:
> > Should we fail initialization here, then? I.e. return false.
> 
> +1, this is coming from the renderer right? We need to gracefully handle
invalid
> or otherwise impossible combinations here.

Please see the new logic, I think it's much cleaner now that it's
using a GLSurfaceFormat structure with Get/SetDepthBits() and related
accessors.

https://codereview.chromium.org/2461803002/diff/80001/third_party/WebKit/Sour...
File third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
(right):

https://codereview.chromium.org/2461803002/diff/80001/third_party/WebKit/Sour...
third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp:609:
contextAttributes.ownOffscreenSurface = true;
On 2016/11/29 05:09:06, Ken Russell wrote:
> I haven't reviewed the rest of the patch in depth, but how does this interact
> with WebGL's DrawingBuffer and in particular its allocation of its backing
> store? I'm concerned about interactions with the code path gated by
> DrawingBuffer::shouldUseChromiumImage().
> 
> Is the offscreen canvas's storage actually used? Or is the surface's format
the
> only significant aspect? WebGL's been using the DrawingBuffer for its back
> buffer for a long time and it would be a step backward to use the offscreen
> context's default framebuffer for anything significant.
> 
> Can DrawingBuffer abstract the VR-specific surface, similarly to its
> GL_CHROMIUM_image path?

For context, the point of this change is to prepare for a WebVR
optimization to let a WebGL DrawingBuffer render directly to a
separately provided Surface, this can then be consumed cross-process
(without copying) as a SurfaceTexture for use with the VR device.

The followup CL https://codereview.chromium.org/2456213 internally
uses SetSurface and requires an output surface that's compatible 
with WebGL drawing, and this generally requires depth buffer and
other features that aren't currently available. This does not work
with offscreen drawing unfortunately, Android's SurfaceTexture 
needs a real surface to draw on.

https://codereview.chromium.org/2461803002/diff/80001/ui/gl/gl_surface.h
File ui/gl/gl_surface.h (right):

https://codereview.chromium.org/2461803002/diff/80001/ui/gl/gl_surface.h#newc...
ui/gl/gl_surface.h:47: SURFACE_RGB565_DEPTH24,
On 2016/11/16 00:44:02, piman - On leave - No reviews wrote:
> It seems like this won't scale to more depth bits or more surface formats.
> We could either:
> - explicitly add depth bits to GLSurface::Initialize
> - change GLSurface::Initialize to take a GLSurfaceAttribs struct instead of
> GLSurface::Format that can specify the color format, but also the depth and
> stencil bits, MSAA samples, etc. over time as we need them.

See https://codereview.chromium.org/2616723002 for a new approach,
now using a GLSurfaceFormat class which replaces the custom format
types.

https://codereview.chromium.org/2461803002/diff/80001/ui/gl/init/gl_factory.h
File ui/gl/init/gl_factory.h (right):

https://codereview.chromium.org/2461803002/diff/80001/ui/gl/init/gl_factory.h...
ui/gl/init/gl_factory.h:75: const gfx::Size& size);
On 2016/11/16 00:44:02, piman - On leave - No reviews wrote:
> So, it sounds like the only reason you want to not initialize is so that you
can
> specify the format. Maybe a better API would be
> CreateOffscreenGLSurfaceWithFormat(const gfx::Size& size, GLSurface::Format
> format).
> 
> Separately, it would be nice to refactor the logic a bit so that
> CreateOffscreenGLSurface(size) is equivalent to
> CreateOffscreenGLSurfaceWithFormat(size, SURFACE_DEFAULT). This could be a
> separate change:
> - make SURFACE_DEFAULT its own value (as opposed to SURFACE_ARGB8888)

I briefly tried this but it caused a bunch of complications,
it would need careful conversion in GetFormat and other places
to ensure that comparisons would work as expected. The new
approach uses a GLSurfaceFormat class and moves non-default
properties to appropriate subtype initialization.

> - make GLSurface::Initialize() (the 0 parameter version) non-virtual and
remove
> overloads

Done.

> - in each of the GLSurface::Initialize(GLSurface::Format), explicitly handle
> SURFACE_DEFAULT and convert to the right format (i.e. SURFACE_ARGB8888 almost
> everywhere, except PbufferGLSurfaceEGL and SurfacelessEGL which have a special
> Initialize() overload - that logic would move to
Initialize(GLSurface::Format))

Handled a bit differently, using merging of properties on the
GLSurfaceFormat class instead of directly overwriting.

https://codereview.chromium.org/2461803002/diff/80001/ui/gl/init/gl_factory_a...
File ui/gl/init/gl_factory_android.cc (right):

https://codereview.chromium.org/2461803002/diff/80001/ui/gl/init/gl_factory_a...
ui/gl/init/gl_factory_android.cc:138: if (surface && GetGLImplementation() !=
kGLImplementationMockGL)
On 2016/11/16 00:44:03, piman - On leave - No reviews wrote:
> Here and other places: no need to check against kGLImplementationMockGL - the
> reason we didn't call InitializeGLSurface on GLSurfaceStub is not so much that
> it's wrong, but that it's a noop. But it would simplify to always call
> Initialize on it.

Moot, no longer applicable in the new refactor.

https://codereview.chromium.org/2461803002/diff/80001/ui/gl/init/gl_factory_o...
File ui/gl/init/gl_factory_ozone.cc (right):

https://codereview.chromium.org/2461803002/diff/80001/ui/gl/init/gl_factory_o...
ui/gl/init/gl_factory_ozone.cc:151: return CreateOffscreenGLSurface(size);
On 2016/11/16 00:44:03, piman - On leave - No reviews wrote:
> That will return an initialized surface, and it will be incorrect to call
> Initialize on it again.

Moot, now using CreateOffscreenGLSurfaceWithFormat.

Powered by Google App Engine
This is Rietveld 408576698