Changeset 263346 in webkit
- Timestamp:
- Jun 22, 2020 5:28:08 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r263343 r263346 1 2020-06-10 Sergio Villar Senin <svillar@igalia.com> 2 3 [WebXR] Add a preliminary implementation of XRWebGLLayer 4 https://bugs.webkit.org/show_bug.cgi?id=213022 5 6 Reviewed by Carlos Garcia Campos. 7 8 * platform/wpe/TestExpectations: Added 2 more tests that are passing now. 9 1 10 2020-06-22 Carlos Garcia Campos <cgarcia@igalia.com> 2 11 -
trunk/LayoutTests/imported/w3c/ChangeLog
r263345 r263346 1 2020-06-10 Sergio Villar Senin <svillar@igalia.com> 2 3 [WebXR] Add a preliminary implementation of XRWebGLLayer 4 https://bugs.webkit.org/show_bug.cgi?id=213022 5 6 Reviewed by Carlos Garcia Campos. 7 8 Added new expectations. 9 10 * web-platform-tests/webxr/xrWebGLLayer_constructor.https-expected.txt: Added. 11 * web-platform-tests/webxr/xrWebGLLayer_framebuffer_sameObject.https-expected.txt: Added. 12 1 13 2020-06-22 Rob Buis <rbuis@igalia.com> 2 14 -
trunk/LayoutTests/platform/wpe/TestExpectations
r263265 r263346 942 942 webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/ar-module/xrDevice_isSessionSupported_immersive-ar.https.html [ Pass ] 943 943 webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/ar-module/xrDevice_requestSession_immersive-ar.https.html [ Pass ] 944 webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrWebGLLayer_constructor.https.html [ Pass ] 945 webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrWebGLLayer_framebuffer_sameObject.https.html [ Pass ] 944 946 945 947 # Passing since r259532. -
trunk/Source/WebCore/ChangeLog
r263345 r263346 1 2020-06-10 Sergio Villar Senin <svillar@igalia.com> 2 3 [WebXR] Add a preliminary implementation of XRWebGLLayer 4 https://bugs.webkit.org/show_bug.cgi?id=213022 5 6 Reviewed by Carlos Garcia Campos. 7 8 Added a preliminary implementation of XRWebGLLayer. It does not have any functionality at the moment so 9 it cannot be used to render WebXR stuff. This patch adds all the machinery required to create and properly 10 initialize the layer according to the spec. 11 12 Two new wpt tests are passing now. 13 14 * Modules/webxr/WebXRSession.h: Expose session mode. 15 * Modules/webxr/WebXRWebGLLayer.cpp: 16 (WebCore::WebXRWebGLLayer::create): Implemented spec for XRWebGLLayer creation. 17 (WebCore::WebXRWebGLLayer::computeNativeWebGLFramebufferResolution): Added with mock implementation. 18 (WebCore::WebXRWebGLLayer::computeRecommendedWebGLFramebufferResolution): Added. 19 (WebCore::WebXRWebGLLayer::WebXRWebGLLayer): 20 (WebCore::WebXRWebGLLayer::framebuffer const): Returned type should be a pointer. 21 (WebCore::WebXRWebGLLayer::framebufferWidth const): Return framebuffer width if available, otherwise return 22 the base context width. 23 (WebCore::WebXRWebGLLayer::framebufferHeight const): Ditto but with heights. 24 (WebCore::WebXRWebGLLayer::getNativeFramebufferScaleFactor): Implemented. 25 * Modules/webxr/WebXRWebGLLayer.h: New methods and type adjustments. 26 1 27 2020-06-22 Rob Buis <rbuis@igalia.com> 2 28 -
trunk/Source/WebCore/Modules/webxr/WebXRSession.h
r263256 r263346 81 81 bool ended() const { return m_ended; } 82 82 83 XRSessionMode mode() const { return m_mode; } 84 83 85 private: 84 86 WebXRSession(Document&, WebXRSystem&, XRSessionMode, PlatformXR::Device&); -
trunk/Source/WebCore/Modules/webxr/WebXRWebGLLayer.cpp
r258498 r263346 29 29 #if ENABLE(WEBXR) 30 30 31 #include "IntSize.h" 31 32 #include "WebGLFramebuffer.h" 32 33 #include "WebGLRenderingContext.h" … … 34 35 #include "WebGL2RenderingContext.h" 35 36 #endif 37 #include "WebGLRenderingContextBase.h" 36 38 #include "WebXRSession.h" 37 39 #include "WebXRViewport.h" 38 40 #include "XRWebGLLayerInit.h" 41 #include <wtf/Scope.h> 39 42 40 43 namespace WebCore { 41 44 42 ExceptionOr<Ref<WebXRWebGLLayer>> WebXRWebGLLayer::create(const WebXRSession& session, WebXRRenderingContext&& context, const XRWebGLLayerInit& init) 43 { 44 // The XRWebGLLayer(session, context, layerInit) constructor MUST perform the following steps when invoked: 45 // 1. Let layer be a new XRWebGLLayer 46 47 // 2. If session’s ended value is true, throw an InvalidStateError and abort these steps. 45 // https://immersive-web.github.io/webxr/#dom-xrwebgllayer-xrwebgllayer 46 ExceptionOr<Ref<WebXRWebGLLayer>> WebXRWebGLLayer::create(WebXRSession& session, WebXRRenderingContext&& context, const XRWebGLLayerInit& init) 47 { 48 // 1. Let layer be a new XRWebGLLayer 49 // 2. If session’s ended value is true, throw an InvalidStateError and abort these steps. 48 50 if (session.ended()) 49 51 return Exception { InvalidStateError }; 50 52 51 // 3. If context is lost, throw an InvalidStateError and abort these steps. 52 // 4. If context’s XR compatible boolean is false, throw an InvalidStateError and abort these steps. 53 // FIXME: TODO 54 55 // 5. Initialize layer’s context to context. 56 // 6. Initialize layer’s antialias to layerInit’s antialias value. 57 // 7. If layerInit’s ignoreDepthValues value is false and the XR Compositor will make use of depth values, Initialize layer’s ignoreDepthValues to false. 58 // 8. Else Initialize layer’s ignoreDepthValues to true 59 // 9. Initialize layer’s framebuffer to a new opaque framebuffer created with context. 60 // 10. Initialize the layer’s swap chain. 61 // 11. If layer’s swap chain was unable to be created for any reason, throw an OperationError and abort these steps. 62 // FIXME: TODO 63 64 // 12. Return layer. 65 return adoptRef(*new WebXRWebGLLayer(session, WTFMove(context), init)); 66 } 67 68 WebXRWebGLLayer::WebXRWebGLLayer(const WebXRSession&, WebXRRenderingContext&& context, const XRWebGLLayerInit& init) 69 : m_context(WTFMove(context)) 70 , m_antialias(init.antialias) 71 , m_ignoreDepthValues(init.ignoreDepthValues) 72 { 73 m_framebuffer.object = WTF::switchOn(m_context, 74 [](const RefPtr<WebGLRenderingContext>& context) 53 // 3. If context is lost, throw an InvalidStateError and abort these steps. 54 // 4. If session is an immersive session and context’s XR compatible boolean is false, throw 55 // an InvalidStateError and abort these steps. 56 return WTF::switchOn(context, 57 [&](const RefPtr<WebGLRenderingContextBase>& baseContext) -> ExceptionOr<Ref<WebXRWebGLLayer>> 75 58 { 76 RefPtr<WebGLFramebuffer> frameBuffer = WebGLFramebuffer::create(*context); 77 return frameBuffer; 59 if (baseContext->isContextLost()) 60 return Exception { InvalidStateError }; 61 62 auto mode = session.mode(); 63 if ((mode == XRSessionMode::ImmersiveAr || mode == XRSessionMode::ImmersiveVr) && !baseContext->isXRCompatible()) 64 return Exception { InvalidStateError }; 65 66 67 // 5. Initialize layer’s context to context. (see constructor) 68 // 6. Initialize layer’s session to session. (see constructor) 69 // 7. Initialize layer’s ignoreDepthValues as follows. (see constructor) 70 // 8. Initialize layer’s composition disabled boolean as follows. (see constructor) 71 // 9. (see constructor except for the resources initialization step which is handled in the if block below) 72 auto layer = adoptRef(*new WebXRWebGLLayer(session, WTFMove(context), init)); 73 74 if (layer->m_isCompositionDisabled) { 75 // 9.4. Allocate and initialize resources compatible with session’s XR device, including GPU accessible memory buffers, 76 // as required to support the compositing of layer. 77 // 9.5. If layer’s resources were unable to be created for any reason, throw an OperationError and abort these steps. 78 // TODO: Initialize layer's resources or issue an OperationError. 79 } 80 81 // 10. Return layer. 82 return layer; 78 83 }, 79 #if ENABLE(WEBGL2)80 [](const RefPtr<WebGL2RenderingContext>& context)81 {82 RefPtr<WebGLFramebuffer> frameBuffer = WebGLFramebuffer::create(*context);83 return frameBuffer;84 },85 #endif86 84 [](WTF::Monostate) { 87 85 ASSERT_NOT_REACHED(); 88 return nullptr;86 return Exception { InvalidStateError }; 89 87 } 90 88 ); 91 89 } 92 90 91 // https://immersive-web.github.io/webxr/#native-webgl-framebuffer-resolution 92 IntSize WebXRWebGLLayer::computeNativeWebGLFramebufferResolution() 93 { 94 // FIXME: implement this 95 return { 1, 1 }; 96 } 97 98 // https://immersive-web.github.io/webxr/#recommended-webgl-framebuffer-resolution 99 IntSize WebXRWebGLLayer::computeRecommendedWebGLFramebufferResolution() 100 { 101 return computeNativeWebGLFramebufferResolution(); 102 } 103 104 WebXRWebGLLayer::WebXRWebGLLayer(WebXRSession& session, WebXRRenderingContext&& context, const XRWebGLLayerInit& init) 105 : m_session(makeRef(session)) 106 , m_context(WTFMove(context)) 107 { 108 // 7. Initialize layer’s ignoreDepthValues as follows: 109 // 7.1 If layerInit’s ignoreDepthValues value is false and the XR Compositor will make use of depth values, 110 // Initialize layer’s ignoreDepthValues to false. 111 // 7.2. Else Initialize layer’s ignoreDepthValues to true 112 // TODO: ask XR compositor for depth value usages 113 m_ignoreDepthValues = init.ignoreDepthValues; 114 115 // 8. Initialize layer's composition disabled boolean as follows: 116 // If session is an inline session -> Initialize layer's composition disabled to true 117 // Otherwise -> Initialize layer's composition disabled boolean to false 118 m_isCompositionDisabled = m_session->mode() == XRSessionMode::Inline; 119 120 // 9. If layer’s composition disabled boolean is false: 121 if (m_isCompositionDisabled) { 122 // 1. Initialize layer’s antialias to layerInit’s antialias value. 123 m_antialias = init.antialias; 124 125 // 2. Let framebufferSize be the recommended WebGL framebuffer resolution multiplied by layerInit's framebufferScaleFactor. 126 IntSize recommendedSize = computeRecommendedWebGLFramebufferResolution(); 127 m_framebuffer.width = recommendedSize.width() * init.framebufferScaleFactor; 128 m_framebuffer.height = recommendedSize.height() * init.framebufferScaleFactor; 129 130 // 3. Initialize layer’s framebuffer to a new opaque framebuffer with the dimensions framebufferSize 131 // created with context, session initialized to session, and layerInit’s depth, stencil, and alpha values. 132 // For steps 4 & 5 see the create() method as resources initialization is handled outside the constructor as it might trigger 133 // an OperationError. 134 // FIXME: create a proper opaque framebuffer. 135 m_framebuffer.object = WTF::switchOn(m_context, 136 [](const RefPtr<WebGLRenderingContextBase>& baseContext) 137 { 138 return WebGLFramebuffer::create(*baseContext); 139 } 140 ); 141 } else { 142 // 1. Initialize layer’s antialias to layer’s context's actual context parameters antialias value. 143 m_antialias = WTF::switchOn(m_context, 144 [](const RefPtr<WebGLRenderingContextBase>& context) 145 { 146 if (auto attributes = context->getContextAttributes()) 147 return attributes.value().antialias; 148 return false; 149 } 150 ); 151 // 2. Initialize layer’s framebuffer to null. 152 m_framebuffer.object = nullptr; 153 } 154 } 155 93 156 WebXRWebGLLayer::~WebXRWebGLLayer() = default; 94 157 … … 103 166 } 104 167 105 const WebGLFramebuffer&WebXRWebGLLayer::framebuffer() const106 { 107 return *m_framebuffer.object;168 WebGLFramebuffer* WebXRWebGLLayer::framebuffer() const 169 { 170 return m_framebuffer.object.get(); 108 171 } 109 172 110 173 unsigned WebXRWebGLLayer::framebufferWidth() const 111 174 { 112 return m_framebuffer.width; 175 if (m_framebuffer.object) 176 return m_framebuffer.width; 177 return WTF::switchOn(m_context, 178 [&](const RefPtr<WebGLRenderingContextBase>& baseContext) { 179 return baseContext->drawingBufferWidth(); 180 }); 113 181 } 114 182 115 183 unsigned WebXRWebGLLayer::framebufferHeight() const 116 184 { 117 return m_framebuffer.height; 185 if (m_framebuffer.object) 186 return m_framebuffer.height; 187 return WTF::switchOn(m_context, 188 [&](const RefPtr<WebGLRenderingContextBase>& baseContext) { 189 return baseContext->drawingBufferHeight(); 190 }); 118 191 } 119 192 … … 123 196 } 124 197 125 double WebXRWebGLLayer::getNativeFramebufferScaleFactor(const WebXRSession&) 126 { 127 return 1.0; 198 double WebXRWebGLLayer::getNativeFramebufferScaleFactor(const WebXRSession& session) 199 { 200 if (session.ended()) 201 return 0.0; 202 203 IntSize nativeSize = computeNativeWebGLFramebufferResolution(); 204 IntSize recommendedSize = computeRecommendedWebGLFramebufferResolution(); 205 206 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!recommendedSize.isZero()); 207 return (nativeSize / recommendedSize).width(); 128 208 } 129 209 -
trunk/Source/WebCore/Modules/webxr/WebXRWebGLLayer.h
r259190 r263346 37 37 namespace WebCore { 38 38 39 class IntSize; 39 40 class WebGLFramebuffer; 40 41 class WebGLRenderingContext; … … 49 50 class WebXRWebGLLayer : public RefCounted<WebXRWebGLLayer> { 50 51 public: 51 52 52 53 using WebXRRenderingContext = WTF::Variant< 53 54 RefPtr<WebGLRenderingContext> … … 57 58 >; 58 59 59 static ExceptionOr<Ref<WebXRWebGLLayer>> create( constWebXRSession&, WebXRRenderingContext&&, const XRWebGLLayerInit&);60 static ExceptionOr<Ref<WebXRWebGLLayer>> create(WebXRSession&, WebXRRenderingContext&&, const XRWebGLLayerInit&); 60 61 ~WebXRWebGLLayer(); 61 62 … … 63 64 bool ignoreDepthValues() const; 64 65 65 const WebGLFramebuffer&framebuffer() const;66 WebGLFramebuffer* framebuffer() const; 66 67 unsigned framebufferWidth() const; 67 68 unsigned framebufferHeight() const; … … 72 73 73 74 private: 74 WebXRWebGLLayer( constWebXRSession&, WebXRRenderingContext&&, const XRWebGLLayerInit&);75 WebXRWebGLLayer(WebXRSession&, WebXRRenderingContext&&, const XRWebGLLayerInit&); 75 76 77 static IntSize computeNativeWebGLFramebufferResolution(); 78 static IntSize computeRecommendedWebGLFramebufferResolution(); 79 80 Ref<WebXRSession> m_session; 76 81 WebXRRenderingContext m_context; 77 82 bool m_antialias { false }; 78 83 bool m_ignoreDepthValues { false }; 84 bool m_isCompositionDisabled { false }; 79 85 80 86 struct {
Note: See TracChangeset
for help on using the changeset viewer.