WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-213886-20200702180802.patch (text/plain), 15.68 KB, created by
Sergio Villar Senin
on 2020-07-02 09:08:03 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sergio Villar Senin
Created:
2020-07-02 09:08:03 PDT
Size:
15.68 KB
patch
obsolete
>Subversion Revision: 263846 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index e80f4a473b387c67e1bd99616c0d5e7e5953aa76..f9daeae0452255cd91778946f426ace6ed00b785 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,45 @@ >+2020-07-02 Sergio Villar Senin <svillar@igalia.com> >+ >+ [WebXR] Retrieve WebGL framebuffer resolution from XR devices >+ https://bugs.webkit.org/show_bug.cgi?id=213886 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The recommended WebGL framebuffer resolution should be retrieved from the actual XR device being used. >+ Implemented the OpenXR machinery to retrieve it from the XR system. We are also moving the methods that >+ call the platform code to the XRSession as specs define, instead of having them inside the XRWebGLLayer. >+ >+ Finally this patch is also removing a unused definition in OpenXR plaform code and properly initializing >+ a OpenXR struct. The missing initialization was the source of errors when querying api layer properties. >+ The patch is also properly setting the SessionMode::Inline when XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO >+ is found. It used to set SessionMode::ImmersiveAr instead, but that's wrong, we should only care about >+ ImmersiveAr session mode once the WebXR AR module is implemented. >+ >+ * Modules/webxr/WebXRRenderState.cpp: >+ (WebCore::WebXRRenderState::outputCanvas const): Return render state's canvas. >+ * Modules/webxr/WebXRRenderState.h: Added a m_outputCanvas member with its getter. >+ * Modules/webxr/WebXRSession.cpp: >+ (WebCore::WebXRSession::nativeWebGLFramebufferResolution const): Moved from WebXRWebGLLayer and reimplemented. >+ (WebCore::WebXRSession::recommendedWebGLFramebufferResolution const): Ditto. >+ * Modules/webxr/WebXRSession.h: >+ * Modules/webxr/WebXRWebGLLayer.cpp: >+ (WebCore::WebXRWebGLLayer::WebXRWebGLLayer): >+ (WebCore::WebXRWebGLLayer::getNativeFramebufferScaleFactor): Call the session to get native and recommended >+ resolutions. >+ (WebCore::WebXRWebGLLayer::computeNativeWebGLFramebufferResolution): Deleted. >+ (WebCore::WebXRWebGLLayer::computeRecommendedWebGLFramebufferResolution): Ditto. >+ * platform/xr/PlatformXR.h: >+ (PlatformXR::Device::recommendedResolution): New virtual method with default implementation. >+ * platform/xr/openxr/PlatformXROpenXR.cpp: >+ (PlatformXR::Instance::Impl::enumerateApiLayerProperties const): Added initialization of the XrApiLayerProperties >+ objects. The call to xrEnumerateApiLayerProperties succeeds now. >+ (PlatformXR::OpenXRDevice::OpenXRDevice): Call enumerateConfigurationViews(). >+ (PlatformXR::OpenXRDevice::collectSupportedSessionModes): Fill in the m_viewConfigurationProperties map. >+ (PlatformXR::OpenXRDevice::enumerateConfigurationViews): New method that retrieves the XR device views for each >+ supported configuration. >+ (PlatformXR::OpenXRDevice::recommendedResolution): Return the recommended resolution for a given SessionMode. >+ * platform/xr/openxr/PlatformXROpenXR.h: Added some new methods and attributes. >+ > 2020-07-02 Zalan Bujtas <zalan@apple.com> > > [LFC][BFC] Remove redundant margin-border-padding when computing the intrinsic width >diff --git a/Source/WebCore/Modules/webxr/WebXRRenderState.cpp b/Source/WebCore/Modules/webxr/WebXRRenderState.cpp >index c0f895b2b1c59676bdcf5835c08f4bb06e0847c0..b8db70522bea769fbcf2825ce353aba093d6e42a 100644 >--- a/Source/WebCore/Modules/webxr/WebXRRenderState.cpp >+++ b/Source/WebCore/Modules/webxr/WebXRRenderState.cpp >@@ -28,6 +28,7 @@ > > #if ENABLE(WEBXR) > >+#include "HTMLCanvasElement.h" > #include "WebXRWebGLLayer.h" > #include "XRRenderStateInit.h" > #include <wtf/IsoMallocInlines.h> >@@ -75,6 +76,11 @@ RefPtr<WebXRWebGLLayer> WebXRRenderState::baseLayer() const > return m_baseLayer; > } > >+HTMLCanvasElement* WebXRRenderState::outputCanvas() const >+{ >+ return m_outputCanvas; >+} >+ > } // namespace WebCore > > #endif // ENABLE(WEBXR) >diff --git a/Source/WebCore/Modules/webxr/WebXRRenderState.h b/Source/WebCore/Modules/webxr/WebXRRenderState.h >index 95e9656b122bb33ac4c689e0aa82076ef47c8ce2..9403482f01f16862e75f53243c0e2651096dcbb1 100644 >--- a/Source/WebCore/Modules/webxr/WebXRRenderState.h >+++ b/Source/WebCore/Modules/webxr/WebXRRenderState.h >@@ -36,6 +36,7 @@ > > namespace WebCore { > >+class HTMLCanvasElement; > class WebXRWebGLLayer; > struct XRRenderStateInit; > >@@ -49,6 +50,7 @@ public: > double depthFar() const; > Optional<double> inlineVerticalFieldOfView() const; > RefPtr<WebXRWebGLLayer> baseLayer() const; >+ HTMLCanvasElement* outputCanvas() const; > > private: > explicit WebXRRenderState(Optional<double>&& fieldOfView); >@@ -61,6 +63,7 @@ private: > } m_depth; > Optional<double> m_inlineVerticalFieldOfView; // in radians > RefPtr<WebXRWebGLLayer> m_baseLayer; >+ HTMLCanvasElement* m_outputCanvas { nullptr }; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/webxr/WebXRSession.cpp b/Source/WebCore/Modules/webxr/WebXRSession.cpp >index 1ea5ca9fd29f5d63e28036e2051283b52afa9f71..a33131a2e5e07d5a157cb71e2266a9fdb10c9a84 100644 >--- a/Source/WebCore/Modules/webxr/WebXRSession.cpp >+++ b/Source/WebCore/Modules/webxr/WebXRSession.cpp >@@ -238,6 +238,24 @@ void WebXRSession::cancelAnimationFrame(unsigned callbackId) > m_runningCallbacks[position]->cancel(); > } > >+// https://immersive-web.github.io/webxr/#native-webgl-framebuffer-resolution >+IntSize WebXRSession::nativeWebGLFramebufferResolution() const >+{ >+ if (m_mode == XRSessionMode::Inline) { >+ // FIXME: replace the conditional by ASSERTs once we properly initialize the outputCanvas. >+ return m_activeRenderState && m_activeRenderState->outputCanvas() ? m_activeRenderState->outputCanvas()->size() : IntSize(1, 1); >+ } >+ >+ return recommendedWebGLFramebufferResolution(); >+} >+ >+// https://immersive-web.github.io/webxr/#recommended-webgl-framebuffer-resolution >+IntSize WebXRSession::recommendedWebGLFramebufferResolution() const >+{ >+ ASSERT(m_device); >+ return m_device->recommendedResolution(m_mode); >+} >+ > // https://immersive-web.github.io/webxr/#shut-down-the-session > void WebXRSession::shutdown() > { >diff --git a/Source/WebCore/Modules/webxr/WebXRSession.h b/Source/WebCore/Modules/webxr/WebXRSession.h >index 98b9293988f8286ba7f1e72e041af54110bcac30..501e95cc2ee48d5ea7cef36e02034c5b06f0414f 100644 >--- a/Source/WebCore/Modules/webxr/WebXRSession.h >+++ b/Source/WebCore/Modules/webxr/WebXRSession.h >@@ -76,11 +76,13 @@ public: > unsigned requestAnimationFrame(Ref<XRFrameRequestCallback>&&); > void cancelAnimationFrame(unsigned callbackId); > >+ IntSize nativeWebGLFramebufferResolution() const; >+ IntSize recommendedWebGLFramebufferResolution() const; >+ > // EventTarget. > ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); } > > void end(EndPromise&&); >- > bool ended() const { return m_ended; } > > XRSessionMode mode() const { return m_mode; } >diff --git a/Source/WebCore/Modules/webxr/WebXRWebGLLayer.cpp b/Source/WebCore/Modules/webxr/WebXRWebGLLayer.cpp >index d92cf08abfd1cc5fba57b6d2fc6414b738dc662a..86dd11b00143bf80ea81ae2add8de84dc02d033f 100644 >--- a/Source/WebCore/Modules/webxr/WebXRWebGLLayer.cpp >+++ b/Source/WebCore/Modules/webxr/WebXRWebGLLayer.cpp >@@ -91,19 +91,6 @@ ExceptionOr<Ref<WebXRWebGLLayer>> WebXRWebGLLayer::create(Ref<WebXRSession>&& se > ); > } > >-// https://immersive-web.github.io/webxr/#native-webgl-framebuffer-resolution >-IntSize WebXRWebGLLayer::computeNativeWebGLFramebufferResolution() >-{ >- // FIXME: implement this >- return { 1, 1 }; >-} >- >-// https://immersive-web.github.io/webxr/#recommended-webgl-framebuffer-resolution >-IntSize WebXRWebGLLayer::computeRecommendedWebGLFramebufferResolution() >-{ >- return computeNativeWebGLFramebufferResolution(); >-} >- > WebXRWebGLLayer::WebXRWebGLLayer(Ref<WebXRSession>&& session, WebXRRenderingContext&& context, const XRWebGLLayerInit& init) > : WebXRLayer(session->scriptExecutionContext()) > , m_session(WTFMove(session)) >@@ -127,7 +114,7 @@ WebXRWebGLLayer::WebXRWebGLLayer(Ref<WebXRSession>&& session, WebXRRenderingCont > m_antialias = init.antialias; > > // 2. Let framebufferSize be the recommended WebGL framebuffer resolution multiplied by layerInit's framebufferScaleFactor. >- IntSize recommendedSize = computeRecommendedWebGLFramebufferResolution(); >+ IntSize recommendedSize = m_session->recommendedWebGLFramebufferResolution(); > m_framebuffer.width = recommendedSize.width() * init.framebufferScaleFactor; > m_framebuffer.height = recommendedSize.height() * init.framebufferScaleFactor; > >@@ -204,8 +191,8 @@ double WebXRWebGLLayer::getNativeFramebufferScaleFactor(const WebXRSession& sess > if (session.ended()) > return 0.0; > >- IntSize nativeSize = computeNativeWebGLFramebufferResolution(); >- IntSize recommendedSize = computeRecommendedWebGLFramebufferResolution(); >+ IntSize nativeSize = session.nativeWebGLFramebufferResolution(); >+ IntSize recommendedSize = session.recommendedWebGLFramebufferResolution(); > > RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!recommendedSize.isZero()); > return (nativeSize / recommendedSize).width(); >diff --git a/Source/WebCore/platform/xr/PlatformXR.h b/Source/WebCore/platform/xr/PlatformXR.h >index 371023ca1bcf6cb87e0c6768dbb6524dabdb3b6f..6652abd3bdbe546c0bb8c2ef6672bb3546c98bc5 100644 >--- a/Source/WebCore/platform/xr/PlatformXR.h >+++ b/Source/WebCore/platform/xr/PlatformXR.h >@@ -18,6 +18,7 @@ > */ > #pragma once > >+#include "IntSize.h" > #include <memory> > #include <wtf/HashMap.h> > #include <wtf/UniqueRef.h> >@@ -53,6 +54,9 @@ public: > void setEnabledFeatures(SessionMode mode, const ListOfEnabledFeatures& features) { m_enabledFeaturesMap.set(mode, features); } > ListOfEnabledFeatures enabledFeatures(SessionMode mode) const { return m_enabledFeaturesMap.get(mode); } > >+ using IntSize = WebCore::IntSize; >+ virtual IntSize recommendedResolution(SessionMode) { return { 1, 1 }; } >+ > bool supportsOrientationTracking() const { return m_supportsOrientationTracking; } > > protected: >diff --git a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp >index 712c1871daa91f988dd6c3be7b9366205ef0679d..767421193fdd5a045849cc0aa6288184a2efc50c 100644 >--- a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp >+++ b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp >@@ -70,7 +70,6 @@ public: > ~Impl(); > > #if USE_OPENXR >- Optional<Vector<SessionMode>> collectSupportedSessionModes(OpenXRDevice&); > XrInstance xrInstance() const { return m_instance; } > #endif > >@@ -95,8 +94,15 @@ void Instance::Impl::enumerateApiLayerProperties() const > return; > } > >- Vector<XrApiLayerProperties> properties(propertyCountOutput); >- result = xrEnumerateApiLayerProperties(propertyCountOutput, nullptr, properties.data()); >+ Vector<XrApiLayerProperties> properties(propertyCountOutput, >+ [] { >+ XrApiLayerProperties object; >+ std::memset(&object, 0, sizeof(XrApiLayerProperties)); >+ object.type = XR_TYPE_API_LAYER_PROPERTIES; >+ return object; >+ }()); >+ result = xrEnumerateApiLayerProperties(propertyCountOutput, &propertyCountOutput, properties.data()); >+ > RETURN_IF_FAILED(result, "xrEnumerateApiLayerProperties()", m_instance); > LOG(XR, "xrEnumerateApiLayerProperties(): %zu properties\n", properties.size()); > } >@@ -213,6 +219,7 @@ OpenXRDevice::OpenXRDevice(XrSystemId id, XrInstance instance) > LOG(XR, "xrGetSystemProperties(): error %s\n", resultToString(result, m_instance).utf8().data()); > > collectSupportedSessionModes(); >+ enumerateConfigurationViews(); > } > > void OpenXRDevice::collectSupportedSessionModes() >@@ -232,18 +239,56 @@ void OpenXRDevice::collectSupportedSessionModes() > LOG(XR, "xrGetViewConfigurationProperties(): error %s\n", resultToString(result, m_instance).utf8().data()); > continue; > } >- switch (viewConfigurationProperties.viewConfigurationType) { >+ auto configType = viewConfigurationProperties.viewConfigurationType; >+ switch (configType) { > case XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO: >- setEnabledFeatures(SessionMode::ImmersiveAr, { }); >+ setEnabledFeatures(SessionMode::Inline, { }); > break; > case XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO: > setEnabledFeatures(SessionMode::ImmersiveVr, { }); > break; > default: >- break; >+ continue; > }; >+ m_viewConfigurationProperties.add(configType, WTFMove(viewConfigurationProperties)); >+ } >+} >+ >+void OpenXRDevice::enumerateConfigurationViews() >+{ >+ for (auto& config : m_viewConfigurationProperties.values()) { >+ uint32_t viewCount; >+ auto configType = config.viewConfigurationType; >+ XrResult result = xrEnumerateViewConfigurationViews(m_instance, m_systemId, configType, 0, &viewCount, nullptr); >+ if (result != XR_SUCCESS) { >+ LOG(XR, "%s %s: %s\n", __func__, "xrEnumerateViewConfigurationViews", resultToString(result, m_instance).utf8().data()); >+ continue; >+ } >+ >+ Vector<XrViewConfigurationView> configViews(viewCount, >+ [] { >+ XrViewConfigurationView object; >+ std::memset(&object, 0, sizeof(XrViewConfigurationView)); >+ object.type = XR_TYPE_VIEW_CONFIGURATION_VIEW; >+ return object; >+ }()); >+ result = xrEnumerateViewConfigurationViews(m_instance, m_systemId, configType, viewCount, &viewCount, configViews.data()); >+ if (result != XR_SUCCESS) >+ continue; >+ m_configurationViews.add(configType, configViews); > } > } >+ >+IntSize OpenXRDevice::recommendedResolution(SessionMode mode) >+{ >+ XrViewConfigurationType configType = mode == SessionMode::Inline ? XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO : XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO; >+ auto viewsIterator = m_configurationViews.find(configType); >+ if (viewsIterator != m_configurationViews.end()) >+ return { static_cast<int>(viewsIterator->value[0].recommendedImageRectWidth), static_cast<int>(viewsIterator->value[0].recommendedImageRectHeight) }; >+ return Device::recommendedResolution(mode); >+} >+ >+ > #endif // USE_OPENXR > > } // namespace PlatformXR >diff --git a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h >index 5a96d635d8989d4ebea5e6166576cfd940b3f920..26e282b6c652723d2e2e6314f616de5e21ad4e59 100644 >--- a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h >+++ b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h >@@ -22,6 +22,9 @@ > #if ENABLE(WEBXR) > #include "PlatformXR.h" > >+#include <wtf/HashMap.h> >+#include <wtf/Optional.h> >+ > #if USE_OPENXR > #include <openxr/openxr.h> > >@@ -45,6 +48,14 @@ public: > XrSystemId xrSystemId() const { return m_systemId; } > private: > void collectSupportedSessionModes(); >+ void enumerateConfigurationViews(); >+ >+ IntSize recommendedResolution(SessionMode) final; >+ >+ using ViewConfigurationPropertiesMap = WTF::HashMap<XrViewConfigurationType, XrViewConfigurationProperties, WTF::IntHash<XrViewConfigurationType>, WTF::StrongEnumHashTraits<XrViewConfigurationType>>; >+ ViewConfigurationPropertiesMap m_viewConfigurationProperties; >+ using ViewConfigurationViewsMap = WTF::HashMap<XrViewConfigurationType, Vector<XrViewConfigurationView>, WTF::IntHash<XrViewConfigurationType>, WTF::StrongEnumHashTraits<XrViewConfigurationType>>; >+ ViewConfigurationViewsMap m_configurationViews; > > XrSystemId m_systemId; > XrInstance m_instance;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 213886
:
403370
|
403446