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

Issue 2456213002: WebVR: implement SetSurfaceHandleCHROMIUM extension for gvr_device.

Created:
4 years, 1 month ago by klausw
Modified:
3 years, 11 months ago
Reviewers:
bajones, piman
CC:
chromium-reviews, piman+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

WebVR: implement SetSurfaceHandleCHROMIUM extension for gvr_device. This extension supports attaching an offscreen GL rendering context to a native Android Surface for drawing, and restoring it to the original offscreen context again later. This is based on bajones@'s "Temp plumbing for the surface swap" patch. BUG=655722 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: 8

Patch Set 2 : Code review changes re bajones #8,#9: #

Total comments: 4

Patch Set 3 : bajones #16, #19: Use struct for state, fix BUILD deps #

Total comments: 27

Patch Set 4 : piman #23 (partial) refactoring and fixes #

Total comments: 8

Patch Set 5 : piman #25: fix surface handling and sizing #

Patch Set 6 : rebase (no other changes) to 3221c79f5ec3a472048ad3adbe05b77c36e6197e #

Patch Set 7 : Rebase to 356cd8379b3f2b06bd17716f88a2568791b4c60a #

Patch Set 8 : Rebase, set dependency. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+554 lines, -153 lines) Patch
M content/renderer/renderer_blink_platform_impl.cc View 1 2 3 4 5 6 7 1 chunk +18 lines, -5 lines 0 comments Download
M gpu/GLES2/gl2chromium_autogen.h View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/build_gles2_cmd_buffer.py View 1 2 3 4 5 6 1 chunk +7 lines, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_c_lib_autogen.h View 1 2 3 4 5 6 2 chunks +7 lines, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_cmd_helper_autogen.h View 1 2 3 4 5 6 1 chunk +8 lines, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_implementation_autogen.h View 1 2 3 4 5 6 1 chunk +2 lines, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_implementation_impl_autogen.h View 1 2 3 4 5 6 1 chunk +8 lines, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_interface_autogen.h View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_interface_stub_autogen.h View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_trace_implementation_autogen.h View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h View 1 2 3 4 5 6 1 chunk +5 lines, -0 lines 0 comments Download
M gpu/command_buffer/cmd_buffer_functions.txt View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/common/gles2_cmd_format_autogen.h View 1 2 3 4 5 6 1 chunk +33 lines, -0 lines 0 comments Download
M gpu/command_buffer/common/gles2_cmd_format_test_autogen.h View 1 2 3 4 5 6 1 chunk +11 lines, -0 lines 0 comments Download
M gpu/command_buffer/common/gles2_cmd_ids_autogen.h View 1 2 3 4 5 6 1 chunk +2 lines, -1 line 0 comments Download
M gpu/command_buffer/common/gles2_cmd_utils.h View 1 2 3 4 5 6 7 2 chunks +2 lines, -1 line 0 comments Download
M gpu/command_buffer/common/gles2_cmd_utils.cc View 1 2 3 4 5 6 7 1 chunk +2 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/BUILD.gn View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder.cc View 1 2 3 4 5 6 7 10 chunks +333 lines, -145 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder_autogen.h View 1 2 3 4 5 6 1 chunk +11 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doer_prototypes.h View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc View 1 2 3 4 5 6 1 chunk +5 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder_passthrough_handlers_autogen.cc View 1 2 3 4 5 6 1 chunk +14 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/service_utils.cc View 1 2 3 4 5 6 7 1 chunk +3 lines, -0 lines 0 comments Download
M gpu/ipc/common/gpu_command_buffer_traits_multi.h View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M gpu/ipc/service/gpu_command_buffer_stub.cc View 1 2 3 4 5 6 7 1 chunk +23 lines, -1 line 0 comments Download
M third_party/WebKit/Source/modules/webgl/WebGLContextAttributeHelpers.cpp View 1 2 3 4 5 6 7 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp View 1 2 3 4 5 6 7 2 chunks +10 lines, -0 lines 0 comments Download
M third_party/WebKit/public/platform/Platform.h View 1 2 3 4 5 6 7 1 chunk +6 lines, -0 lines 0 comments Download
M ui/gl/gl_context.h View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M ui/gl/gl_context_egl.cc View 1 2 3 4 5 6 7 2 chunks +12 lines, -0 lines 0 comments Download
M ui/gl/gl_surface_egl.cc View 1 2 3 4 5 6 7 4 chunks +16 lines, -0 lines 0 comments Download
M ui/gl/init/gl_factory.h View 1 2 3 4 5 6 7 1 chunk +2 lines, -0 lines 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 30 (12 generated)
klausw
Here's the updated extension code, I've slimmed it down to just the extension itself. The ...
4 years, 1 month ago (2016-10-28 00:21:06 UTC) #3
bajones
https://codereview.chromium.org/2456213002/diff/1/gpu/command_buffer/build_gles2_cmd_buffer.py File gpu/command_buffer/build_gles2_cmd_buffer.py (right): https://codereview.chromium.org/2456213002/diff/1/gpu/command_buffer/build_gles2_cmd_buffer.py#newcode2390 gpu/command_buffer/build_gles2_cmd_buffer.py:2390: }, This is totally my fault, and it's a ...
4 years, 1 month ago (2016-10-28 00:41:22 UTC) #8
bajones
https://codereview.chromium.org/2456213002/diff/1/gpu/command_buffer/service/gles2_cmd_decoder.cc File gpu/command_buffer/service/gles2_cmd_decoder.cc (right): https://codereview.chromium.org/2456213002/diff/1/gpu/command_buffer/service/gles2_cmd_decoder.cc#newcode16820 gpu/command_buffer/service/gles2_cmd_decoder.cc:16820: void GLES2DecoderImpl::DoSetSurfaceHandleCHROMIUM(GLint surface_handle) { Oh, and I also realized ...
4 years, 1 month ago (2016-10-28 16:47:46 UTC) #9
klausw
https://codereview.chromium.org/2456213002/diff/1/gpu/command_buffer/build_gles2_cmd_buffer.py File gpu/command_buffer/build_gles2_cmd_buffer.py (right): https://codereview.chromium.org/2456213002/diff/1/gpu/command_buffer/build_gles2_cmd_buffer.py#newcode2390 gpu/command_buffer/build_gles2_cmd_buffer.py:2390: }, On 2016/10/28 00:41:21, bajones wrote: > This is ...
4 years, 1 month ago (2016-11-08 02:18:30 UTC) #10
klausw
FYI, the trybot fails due to forbidden include. What would be the cleanest way to ...
4 years, 1 month ago (2016-11-08 02:31:49 UTC) #15
bajones
On 2016/11/08 02:31:49, klausw wrote: > FYI, the trybot fails due to forbidden include. What ...
4 years, 1 month ago (2016-11-08 05:12:19 UTC) #16
bajones
On 2016/11/08 02:18:30, klausw wrote: > Done, and added an #else to raise a GL_INVALID_OPERATION ...
4 years, 1 month ago (2016-11-08 05:13:48 UTC) #17
bajones
Pulling in piman@, as I think he's got a far better grasp on the care ...
4 years, 1 month ago (2016-11-08 05:17:01 UTC) #19
klausw
BTW, is the size increase for the command decoder impl an issue? It's just a ...
4 years, 1 month ago (2016-11-08 08:21:10 UTC) #20
klausw
On 2016/11/08 05:12:19, bajones wrote: > On 2016/11/08 02:31:49, klausw wrote: > > FYI, the ...
4 years, 1 month ago (2016-11-08 18:00:13 UTC) #21
klausw
PTAL. I've switched it to using a direct_render_state_ struct which looks cleaner. Please sanity check ...
4 years, 1 month ago (2016-11-08 18:45:06 UTC) #22
piman
Sorry for the delay - a bunch of comments. Many are somewhat cosmetic, but the ...
4 years, 1 month ago (2016-11-09 17:50:07 UTC) #23
klausw
Partial update to address comments. The following issues are still open: - extension documentation and ...
4 years, 1 month ago (2016-11-09 21:21:56 UTC) #24
piman
https://codereview.chromium.org/2456213002/diff/40001/gpu/command_buffer/service/gles2_cmd_decoder.cc File gpu/command_buffer/service/gles2_cmd_decoder.cc (right): https://codereview.chromium.org/2456213002/diff/40001/gpu/command_buffer/service/gles2_cmd_decoder.cc#newcode17007 gpu/command_buffer/service/gles2_cmd_decoder.cc:17007: // callers must do so themselves as needed. On ...
4 years, 1 month ago (2016-11-09 22:26:10 UTC) #25
klausw
Thanks for the explanations, I'm still rather confused by GL's surface/buffer/binding logic. The open issues ...
4 years, 1 month ago (2016-11-10 02:28:08 UTC) #26
klausw
Please see suggestions below with a proposal to address the layering and security issues. piman@, ...
4 years, 1 month ago (2016-11-11 00:04:10 UTC) #27
piman
On 2016/11/11 00:04:10, klausw wrote: > Please see suggestions below with a proposal to address ...
4 years, 1 month ago (2016-11-11 20:51:06 UTC) #28
piman
4 years, 1 month ago (2016-11-11 23:58:35 UTC) #29
Just updating on the questions below.

On Wed, Nov 9, 2016 at 6:28 PM, <klausw@chromium.org> wrote:

> Thanks for the explanations, I'm still rather confused by GL's
> surface/buffer/binding logic. The open issues mentioned in my previous
> update
> are still open.
>
>
> https://codereview.chromium.org/2456213002/diff/40001/gpu/
> command_buffer/service/gles2_cmd_decoder.cc
> File gpu/command_buffer/service/gles2_cmd_decoder.cc (right):
>
> https://codereview.chromium.org/2456213002/diff/40001/gpu/
> command_buffer/service/gles2_cmd_decoder.cc#newcode17007
> gpu/command_buffer/service/gles2_cmd_decoder.cc:17007: // callers must
> do so themselves as needed.
> On 2016/11/09 22:26:09, piman wrote:
> > On 2016/11/09 21:21:55, klausw wrote:
> > > On 2016/11/09 17:50:06, piman wrote:
> > > > We should keep a consistent state. If the default framebuffer (0)
> is bound
> > we
> > > > should make sure the new surface is taken into account. Among
> others it
> > means
> > > we
> > > > should MakeCurrent to the new surface.
> > >
> > > I've added MakeCurrent and am applying glViewport and glScissor. Any
> > additional
> > > "among others" it should be doing?
> > >
> > > > Beyond this, there are some states whose value depends on whether
> the
> > default
> > > > framebuffer is a FBO or a surface - I'm thinking in particular the
> read
> > buffer
> > > > and the draw buffers (see DoReadBuffer and DoDrawBuffersEXT).
> These states
> > > need
> > > > to be reset to the proper value.
> > >
> > > I've attempted to fix this, as far as I can tell I don't need to do
> > > anything for a user-bound FBO, GL_NONE remains valid, but I need to
> > > map GL_BACK <=> GL_COLOR_ATTACHMENT0. Does that sound right?
> >
> > Correct.
> >
> > >
> > > On second thought, do I actually need to do this? Lots of places in
> > > the code call CheckBoundDrawFramebufferValid and equivalent, and as
> > > far as I can tell that does this fixup internally as a side effect.
> >
> > It'll only change the draw buffer if the back buffer needs to be
> cleared, and it
> > is *not* GL_BACK - it does that so that the draw buffer correctly
> targets the
> > buffer we want to clear, and then resets it. It's an implementation
> detail of
> > that function... but either way, it won't fix up the draw buffer in
> the general
> > case - nor the read buffer.
> >
> > >
> > > I haven't tested the read buffer, but the draw buffer appeared to
> work fine
> > > without the fixup.
> >
>
> Acknowledged.
>
> https://codereview.chromium.org/2456213002/diff/60001/gpu/
> command_buffer/service/gles2_cmd_decoder.cc
> File gpu/command_buffer/service/gles2_cmd_decoder.cc (right):
>
> https://codereview.chromium.org/2456213002/diff/60001/gpu/
> command_buffer/service/gles2_cmd_decoder.cc#newcode17050
> gpu/command_buffer/service/gles2_cmd_decoder.cc:17050:
> context_->MakeCurrent(surface_.get());
> On 2016/11/09 22:26:09, piman wrote:
> > You need to do the MakeCurrent before the
> ApplySurfaceAttributesAndGetAlphaBits,
> > otherwise the queries will return properties of the old surface.
> >
> > Either way, you want to do the MakeCurrent regardless of whether
> there's a bound
> > FBO or not, otherwise if the client unbinds the FBO and tries to draw,
> it'll go
> > to the wrong surface.
>
> Done, I was misunderstanding how MakeCurrent interacts with FBOs. So
> MakeCurrent basically maps the default backbuffer destination to the
> specified surface, even if you're not currently using the default
> backbuffer due to a bound FBO?
>

That's correct. The default framebuffer is special and a bit anachronistic
(well you have to go back to the origins of GL to understand where it comes
from), but yeah, you make a context current together with a surface, and
that's what defines the bind buffer when no FBO is bound (i.e. you bind 0).

>
>
> https://codereview.chromium.org/2456213002/diff/60001/gpu/
> command_buffer/service/gles2_cmd_decoder.cc#newcode17052
> gpu/command_buffer/service/gles2_cmd_decoder.cc:17052: // dimensions.
> Re-apply the settings from the current state.
> On 2016/11/09 22:26:09, piman wrote:
> > Actually, MakeCurrent only sets viewport/scissor on a new context, not
> a new
> > surface, so I don't think you need this.
>
> Done.
>
> https://codereview.chromium.org/2456213002/diff/60001/gpu/
> command_buffer/service/gles2_cmd_decoder.cc#newcode17089
> gpu/command_buffer/service/gles2_cmd_decoder.cc:17089:
> ApplySurfaceAttributesAndGetAlphaBits(true, attrib_helper_);
> On 2016/11/09 22:26:10, piman wrote:
> > You probably want to MakeCurrent here to the offscreen surface too. It
> doesn't
> > exactly matter for correctness, but as long as the direct surface is
> current, it
> > won't be freed.
>
> Done.
>
> https://codereview.chromium.org/2456213002/diff/60001/gpu/
> command_buffer/service/gles2_cmd_decoder.cc#newcode17094
> gpu/command_buffer/service/gles2_cmd_decoder.cc:17094:
> gfx::Size(state_.viewport_width, state_.viewport_height))) {
> On 2016/11/09 22:26:09, piman wrote:
> > You want to use offscreen_size_, not the viewport size, which is
> orthogonal to
> > the back buffer size.
> > Actually, what is the expectation relative to the back buffer size, if
> it was
> > resized while a separate surface was attached, and we go back to the
> offscreen
> > one? I.e. should we reset offscreen_size_ to direct_surface->GetSize()
> ?
>
> Changed, I think the most intuitive behavior would be to copy the
> current size from offscreen to surface on activation and the reverse
> on deactivation.
>

Sounds very reasonable, thanks!


>
> https://codereview.chromium.org/2456213002/
>

-- 
You received this message because you are subscribed to the Google Groups
"Chromium-reviews" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698