Commit 30f128d4 authored by Patrick To's avatar Patrick To Committed by Commit Bot

Add support for the xrCompatible flag in WebGL2

WebGL2 already supports makeXRCompatible() from the implementation in
WebGLRenderingContextBase, but has a separate factory create method to
handle the context attributes. This change handles the xrCompatible flag
in a similar way to WebGL1.

Web tests for WebGL2 will be added before enabling xr compatibility
by default.

Bug: 1087356
Change-Id: Ie80755663485aa2cf98129d4e4f264154ae1ad2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2402129Reviewed-by: default avatarBrandon Jones <bajones@chromium.org>
Commit-Queue: Patrick To <patrto@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#805562}
parent 1257ea7e
......@@ -71,15 +71,31 @@ static bool ShouldCreateContext(WebGraphicsContext3DProvider* context_provider,
CanvasRenderingContext* WebGL2RenderingContext::Factory::Create(
CanvasRenderingContextHost* host,
const CanvasContextCreationAttributesCore& attrs) {
// Create a copy of attrs so flags can be modified if needed before passing
// into the WebGL2RenderingContext constructor.
CanvasContextCreationAttributesCore attribs = attrs;
// The xr_compatible attribute needs to be handled before creating the context
// because the GPU process may potentially be restarted in order to be XR
// compatible. This scenario occurs if the GPU process is not using the GPU
// that the VR headset is plugged into. If the GPU process is restarted, the
// WebGraphicsContext3DProvider must be created using the new one.
if (attribs.xr_compatible &&
!WebGLRenderingContextBase::MakeXrCompatibleSync(host)) {
// If xr compatibility is requested and we can't be xr compatible, return a
// context with the flag set to false.
attribs.xr_compatible = false;
}
bool using_gpu_compositing;
std::unique_ptr<WebGraphicsContext3DProvider> context_provider(
CreateWebGraphicsContext3DProvider(
host, attrs, Platform::kWebGL2ContextType, &using_gpu_compositing));
host, attribs, Platform::kWebGL2ContextType, &using_gpu_compositing));
if (!ShouldCreateContext(context_provider.get(), host))
return nullptr;
WebGL2RenderingContext* rendering_context =
MakeGarbageCollected<WebGL2RenderingContext>(
host, std::move(context_provider), using_gpu_compositing, attrs);
host, std::move(context_provider), using_gpu_compositing, attribs);
if (!rendering_context->GetDrawingBuffer()) {
host->HostDispatchEvent(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment