Changeset 264215 in webkit
- Timestamp:
- Jul 10, 2020 4:08:12 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r264214 r264215 1 2020-07-02 Sergio Villar Senin <svillar@igalia.com> 2 3 [WebXR] Retrieve WebGL framebuffer resolution from XR devices 4 https://bugs.webkit.org/show_bug.cgi?id=213886 5 6 Reviewed by Carlos Garcia Campos. 7 8 The recommended WebGL framebuffer resolution should be retrieved from the actual XR device being used. 9 Implemented the OpenXR machinery to retrieve it from the XR system. We are also moving the methods that 10 call the platform code to the XRSession as specs define, instead of having them inside the XRWebGLLayer. 11 12 Finally this patch is also removing a unused definition in OpenXR plaform code and properly initializing 13 a OpenXR struct. The missing initialization was the source of errors when querying api layer properties. 14 The patch is also properly setting the SessionMode::Inline when XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO 15 is found. It used to set SessionMode::ImmersiveAr instead, but that's wrong, we should only care about 16 ImmersiveAr session mode once the WebXR AR module is implemented. 17 18 * Modules/webxr/WebXRRenderState.cpp: 19 (WebCore::WebXRRenderState::outputCanvas const): Return render state's canvas. 20 * Modules/webxr/WebXRRenderState.h: Added a m_outputCanvas member with its getter. 21 * Modules/webxr/WebXRSession.cpp: 22 (WebCore::WebXRSession::nativeWebGLFramebufferResolution const): Moved from WebXRWebGLLayer and reimplemented. 23 (WebCore::WebXRSession::recommendedWebGLFramebufferResolution const): Ditto. 24 * Modules/webxr/WebXRSession.h: 25 * Modules/webxr/WebXRWebGLLayer.cpp: 26 (WebCore::WebXRWebGLLayer::WebXRWebGLLayer): 27 (WebCore::WebXRWebGLLayer::getNativeFramebufferScaleFactor): Call the session to get native and recommended 28 resolutions. 29 (WebCore::WebXRWebGLLayer::computeNativeWebGLFramebufferResolution): Deleted. 30 (WebCore::WebXRWebGLLayer::computeRecommendedWebGLFramebufferResolution): Ditto. 31 * platform/xr/PlatformXR.h: 32 (PlatformXR::Device::recommendedResolution): New virtual method with default implementation. 33 * platform/xr/openxr/PlatformXROpenXR.cpp: 34 (PlatformXR::Instance::Impl::enumerateApiLayerProperties const): Added initialization of the XrApiLayerProperties 35 objects. The call to xrEnumerateApiLayerProperties succeeds now. 36 (PlatformXR::OpenXRDevice::OpenXRDevice): Call enumerateConfigurationViews(). 37 (PlatformXR::OpenXRDevice::collectSupportedSessionModes): Fill in the m_viewConfigurationProperties map. 38 (PlatformXR::OpenXRDevice::enumerateConfigurationViews): New method that retrieves the XR device views for each 39 supported configuration. 40 (PlatformXR::OpenXRDevice::recommendedResolution): Return the recommended resolution for a given SessionMode. 41 * platform/xr/openxr/PlatformXROpenXR.h: Added some new methods and attributes. 42 1 43 2020-07-10 Zalan Bujtas <zalan@apple.com> 2 44 -
trunk/Source/WebCore/Modules/webxr/WebXRRenderState.cpp
r261863 r264215 29 29 #if ENABLE(WEBXR) 30 30 31 #include "HTMLCanvasElement.h" 31 32 #include "WebXRWebGLLayer.h" 32 33 #include "XRRenderStateInit.h" … … 76 77 } 77 78 79 HTMLCanvasElement* WebXRRenderState::outputCanvas() const 80 { 81 return m_outputCanvas.get(); 82 } 83 78 84 } // namespace WebCore 79 85 -
trunk/Source/WebCore/Modules/webxr/WebXRRenderState.h
r261863 r264215 34 34 #include <wtf/RefCounted.h> 35 35 #include <wtf/RefPtr.h> 36 #include <wtf/WeakPtr.h> 36 37 37 38 namespace WebCore { 38 39 40 class HTMLCanvasElement; 39 41 class WebXRWebGLLayer; 40 42 struct XRRenderStateInit; … … 50 52 Optional<double> inlineVerticalFieldOfView() const; 51 53 RefPtr<WebXRWebGLLayer> baseLayer() const; 54 HTMLCanvasElement* outputCanvas() const; 52 55 53 56 private: … … 62 65 Optional<double> m_inlineVerticalFieldOfView; // in radians 63 66 RefPtr<WebXRWebGLLayer> m_baseLayer; 67 WeakPtr<HTMLCanvasElement> m_outputCanvas; 64 68 }; 65 69 -
trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp
r263503 r264215 239 239 } 240 240 241 // https://immersive-web.github.io/webxr/#native-webgl-framebuffer-resolution 242 IntSize WebXRSession::nativeWebGLFramebufferResolution() const 243 { 244 if (m_mode == XRSessionMode::Inline) { 245 // FIXME: replace the conditional by ASSERTs once we properly initialize the outputCanvas. 246 return m_activeRenderState && m_activeRenderState->outputCanvas() ? m_activeRenderState->outputCanvas()->size() : IntSize(1, 1); 247 } 248 249 return recommendedWebGLFramebufferResolution(); 250 } 251 252 // https://immersive-web.github.io/webxr/#recommended-webgl-framebuffer-resolution 253 IntSize WebXRSession::recommendedWebGLFramebufferResolution() const 254 { 255 ASSERT(m_device); 256 return m_device->recommendedResolution(m_mode); 257 } 258 241 259 // https://immersive-web.github.io/webxr/#shut-down-the-session 242 260 void WebXRSession::shutdown() -
trunk/Source/WebCore/Modules/webxr/WebXRSession.h
r263403 r264215 77 77 void cancelAnimationFrame(unsigned callbackId); 78 78 79 IntSize nativeWebGLFramebufferResolution() const; 80 IntSize recommendedWebGLFramebufferResolution() const; 81 79 82 // EventTarget. 80 83 ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); } 81 84 82 85 void end(EndPromise&&); 83 84 86 bool ended() const { return m_ended; } 85 87 -
trunk/Source/WebCore/Modules/webxr/WebXRWebGLLayer.cpp
r263403 r264215 92 92 } 93 93 94 // https://immersive-web.github.io/webxr/#native-webgl-framebuffer-resolution95 IntSize WebXRWebGLLayer::computeNativeWebGLFramebufferResolution()96 {97 // FIXME: implement this98 return { 1, 1 };99 }100 101 // https://immersive-web.github.io/webxr/#recommended-webgl-framebuffer-resolution102 IntSize WebXRWebGLLayer::computeRecommendedWebGLFramebufferResolution()103 {104 return computeNativeWebGLFramebufferResolution();105 }106 107 94 WebXRWebGLLayer::WebXRWebGLLayer(Ref<WebXRSession>&& session, WebXRRenderingContext&& context, const XRWebGLLayerInit& init) 108 95 : WebXRLayer(session->scriptExecutionContext()) … … 128 115 129 116 // 2. Let framebufferSize be the recommended WebGL framebuffer resolution multiplied by layerInit's framebufferScaleFactor. 130 IntSize recommendedSize = computeRecommendedWebGLFramebufferResolution();117 IntSize recommendedSize = m_session->recommendedWebGLFramebufferResolution(); 131 118 m_framebuffer.width = recommendedSize.width() * init.framebufferScaleFactor; 132 119 m_framebuffer.height = recommendedSize.height() * init.framebufferScaleFactor; … … 205 192 return 0.0; 206 193 207 IntSize nativeSize = computeNativeWebGLFramebufferResolution();208 IntSize recommendedSize = computeRecommendedWebGLFramebufferResolution();194 IntSize nativeSize = session.nativeWebGLFramebufferResolution(); 195 IntSize recommendedSize = session.recommendedWebGLFramebufferResolution(); 209 196 210 197 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!recommendedSize.isZero()); -
trunk/Source/WebCore/platform/xr/PlatformXR.h
r263503 r264215 19 19 #pragma once 20 20 21 #include "IntSize.h" 21 22 #include <memory> 22 23 #include <wtf/HashMap.h> … … 54 55 ListOfEnabledFeatures enabledFeatures(SessionMode mode) const { return m_enabledFeaturesMap.get(mode); } 55 56 57 virtual WebCore::IntSize recommendedResolution(SessionMode) { return { 1, 1 }; } 58 56 59 bool supportsOrientationTracking() const { return m_supportsOrientationTracking; } 57 60 -
trunk/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp
r263516 r264215 71 71 72 72 #if USE_OPENXR 73 Optional<Vector<SessionMode>> collectSupportedSessionModes(OpenXRDevice&);74 73 XrInstance xrInstance() const { return m_instance; } 75 74 #endif … … 96 95 } 97 96 98 Vector<XrApiLayerProperties> properties(propertyCountOutput); 99 result = xrEnumerateApiLayerProperties(propertyCountOutput, nullptr, properties.data()); 97 Vector<XrApiLayerProperties> properties(propertyCountOutput, 98 [] { 99 XrApiLayerProperties object; 100 std::memset(&object, 0, sizeof(XrApiLayerProperties)); 101 object.type = XR_TYPE_API_LAYER_PROPERTIES; 102 return object; 103 }()); 104 result = xrEnumerateApiLayerProperties(propertyCountOutput, &propertyCountOutput, properties.data()); 105 100 106 RETURN_IF_FAILED(result, "xrEnumerateApiLayerProperties()", m_instance); 101 107 LOG(XR, "xrEnumerateApiLayerProperties(): %zu properties\n", properties.size()); … … 214 220 215 221 collectSupportedSessionModes(); 222 enumerateConfigurationViews(); 216 223 } 217 224 … … 233 240 continue; 234 241 } 235 switch (viewConfigurationProperties.viewConfigurationType) { 242 auto configType = viewConfigurationProperties.viewConfigurationType; 243 switch (configType) { 236 244 case XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO: 237 setEnabledFeatures(SessionMode::I mmersiveAr, { });245 setEnabledFeatures(SessionMode::Inline, { }); 238 246 break; 239 247 case XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO: … … 241 249 break; 242 250 default: 243 break;251 continue; 244 252 }; 245 } 246 } 253 m_viewConfigurationProperties.add(configType, WTFMove(viewConfigurationProperties)); 254 } 255 } 256 257 void OpenXRDevice::enumerateConfigurationViews() 258 { 259 for (auto& config : m_viewConfigurationProperties.values()) { 260 uint32_t viewCount; 261 auto configType = config.viewConfigurationType; 262 auto result = xrEnumerateViewConfigurationViews(m_instance, m_systemId, configType, 0, &viewCount, nullptr); 263 if (result != XR_SUCCESS) { 264 LOG(XR, "%s %s: %s\n", __func__, "xrEnumerateViewConfigurationViews", resultToString(result, m_instance).utf8().data()); 265 continue; 266 } 267 268 Vector<XrViewConfigurationView> configViews(viewCount, 269 [] { 270 XrViewConfigurationView object; 271 std::memset(&object, 0, sizeof(XrViewConfigurationView)); 272 object.type = XR_TYPE_VIEW_CONFIGURATION_VIEW; 273 return object; 274 }()); 275 result = xrEnumerateViewConfigurationViews(m_instance, m_systemId, configType, viewCount, &viewCount, configViews.data()); 276 if (result != XR_SUCCESS) 277 continue; 278 m_configurationViews.add(configType, WTFMove(configViews)); 279 } 280 } 281 282 WebCore::IntSize OpenXRDevice::recommendedResolution(SessionMode mode) 283 { 284 auto configType = mode == SessionMode::Inline ? XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO : XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO; 285 auto viewsIterator = m_configurationViews.find(configType); 286 if (viewsIterator != m_configurationViews.end()) 287 return { static_cast<int>(viewsIterator->value[0].recommendedImageRectWidth), static_cast<int>(viewsIterator->value[0].recommendedImageRectHeight) }; 288 return Device::recommendedResolution(mode); 289 } 290 291 247 292 #endif // USE_OPENXR 248 293 -
trunk/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h
r263503 r264215 23 23 #include "PlatformXR.h" 24 24 25 #include <wtf/HashMap.h> 26 25 27 #if USE_OPENXR 26 28 #include <openxr/openxr.h> … … 46 48 private: 47 49 void collectSupportedSessionModes(); 50 void enumerateConfigurationViews(); 51 52 WebCore::IntSize recommendedResolution(SessionMode) final; 53 54 using ViewConfigurationPropertiesMap = HashMap<XrViewConfigurationType, XrViewConfigurationProperties, IntHash<XrViewConfigurationType>, WTF::StrongEnumHashTraits<XrViewConfigurationType>>; 55 ViewConfigurationPropertiesMap m_viewConfigurationProperties; 56 using ViewConfigurationViewsMap = HashMap<XrViewConfigurationType, Vector<XrViewConfigurationView>, IntHash<XrViewConfigurationType>, WTF::StrongEnumHashTraits<XrViewConfigurationType>>; 57 ViewConfigurationViewsMap m_configurationViews; 48 58 49 59 XrSystemId m_systemId;
Note: See TracChangeset
for help on using the changeset viewer.