Changeset 278295 in webkit
- Timestamp:
- May 31, 2021, 9:52:51 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
Modules/webxr/WebXROpaqueFramebuffer.cpp (modified) (9 diffs)
-
Modules/webxr/WebXROpaqueFramebuffer.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r278294 r278295 1 2021-05-31 Dean Jackson <dino@apple.com> 2 3 [WebXR] Attach IOSurface to WebXROpaqueFramebuffer 4 https://bugs.webkit.org/show_bug.cgi?id=225896 5 <rdar://problem/78128289> 6 7 Reviewed by Sam Weinig. 8 9 Implement binding of incoming IOSurfaces (via FrameData) 10 into the WebGL framebuffer that the page will use as 11 a rendering target. 12 13 Currently only single-sample (non-antialiased) buffers 14 are supported and the canvas context must be WebGL 2. 15 16 * Modules/webxr/WebXROpaqueFramebuffer.cpp: 17 (WebCore::WebXROpaqueFramebuffer::startFrame): Create a texture if necessary, then 18 bind its backing store to the incoming IOSurface, then hook it up to the framebuffer. 19 (WebCore::WebXROpaqueFramebuffer::endFrame): Release the Pbuffer we used in startFrame. 20 (WebCore::WebXROpaqueFramebuffer::setupFramebuffer): Add Cocoa+ANGLE specific implementation. 21 * Modules/webxr/WebXROpaqueFramebuffer.h: Keep a member variable for the Pbuffer. 22 1 23 2021-05-31 Alan Bujtas <zalan@apple.com> 2 24 -
trunk/Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp
r278259 r278295 51 51 #include <wtf/Scope.h> 52 52 53 #if USE(IOSURFACE_FOR_XR_LAYER_DATA) 54 #include "ANGLEHeaders.h" 55 #include "GraphicsContextGLOpenGL.h" 56 #endif 57 53 58 namespace WebCore { 54 59 … … 112 117 113 118 #if USE(IOSURFACE_FOR_XR_LAYER_DATA) 114 UNUSED_PARAM(data); 119 auto gCGL = static_cast<GraphicsContextGLOpenGL*>(m_context.graphicsContextGL()); 120 GCGLenum textureTarget = GraphicsContextGLOpenGL::drawingBufferTextureTarget(); 121 122 auto size = data.surface->size(); 123 124 if (!m_opaqueTexture) 125 m_opaqueTexture = gCGL->createTexture(); 126 127 gCGL->bindTexture(textureTarget, m_opaqueTexture); 128 gCGL->texParameteri(textureTarget, GL::TEXTURE_MAG_FILTER, GL::LINEAR); 129 gCGL->texParameteri(textureTarget, GL::TEXTURE_MIN_FILTER, GL::LINEAR); 130 gCGL->texParameteri(textureTarget, GL::TEXTURE_WRAP_S, GL::CLAMP_TO_EDGE); 131 gCGL->texParameteri(textureTarget, GL::TEXTURE_WRAP_T, GL::CLAMP_TO_EDGE); 132 133 // Tell the GraphicsContextGL to use the IOSurface as the backing store for m_opaqueTexture. 134 m_ioSurfaceTextureHandle = gCGL->createPbufferAndAttachIOSurface(textureTarget, GraphicsContextGLOpenGL::PbufferAttachmentUsage::Write, GL::BGRA, size.width(), size.height(), GL::UNSIGNED_BYTE, data.surface->surface(), 0); 135 if (!m_ioSurfaceTextureHandle && m_opaqueTexture) { 136 gCGL->deleteTexture(m_opaqueTexture); 137 return; 138 } 139 140 // FIXME: This is assuming multisampling is turned off and we're rendering directly into the framebuffer. 141 142 // Now set up the framebuffer to use the textures/renderbuffers we have created. 143 gl.framebufferTexture2D(GL::FRAMEBUFFER, GL::COLOR_ATTACHMENT0, GL::TEXTURE_2D, m_opaqueTexture, 0); 144 145 if (m_attributes.stencil) 146 gl.framebufferRenderbuffer(GL::FRAMEBUFFER, GL::STENCIL_ATTACHMENT, GL::RENDERBUFFER, m_depthStencilBuffer); 147 if (m_attributes.depth) 148 gl.framebufferRenderbuffer(GL::FRAMEBUFFER, GL::DEPTH_ATTACHMENT, GL::RENDERBUFFER, m_depthStencilBuffer); 149 150 // At this point the framebuffer should be "complete". 151 ASSERT(gl.checkFramebufferStatus(GL::FRAMEBUFFER) == GL::FRAMEBUFFER_COMPLETE); 115 152 #else 116 153 m_opaqueTexture = data.opaqueTexture; 117 #endif118 154 119 155 #if USE(OPENGL_ES) … … 127 163 if (!m_multisampleColorBuffer) 128 164 gl.framebufferTexture2D(GL::FRAMEBUFFER, GL::COLOR_ATTACHMENT0, GL::TEXTURE_2D, m_opaqueTexture, 0); 165 #endif 129 166 } 130 167 … … 135 172 if (!m_context.graphicsContextGL()) 136 173 return; 174 137 175 auto& gl = *m_context.graphicsContextGL(); 176 177 #if USE(IOSURFACE_FOR_XR_LAYER_DATA) 178 // FIXME: We have to call finish rather than flush because we only want to disconnect 179 // the IOSurface and signal the DeviceProxy when we know the content has been rendered. 180 // It might be possible to set this up so the completion of the rendering triggers 181 // the endFrame call. 182 gl.finish(); 183 184 if (m_ioSurfaceTextureHandle) { 185 auto gCGL = static_cast<GraphicsContextGLOpenGL*>(&gl); 186 gCGL->destroyPbufferAndDetachIOSurface(m_ioSurfaceTextureHandle); 187 } 188 #else 138 189 139 190 if (m_multisampleColorBuffer) { … … 163 214 gl.blitFramebuffer(0, 0, m_width, m_height, 0, 0, m_width, m_height, GL::COLOR_BUFFER_BIT, GL::LINEAR); 164 215 } 165 216 166 217 gl.flush(); 218 #endif 167 219 } 168 220 … … 185 237 // Set up color, depth and stencil formats 186 238 bool useDepthStencil = m_attributes.stencil || m_attributes.depth; 187 auto colorFormat = m_attributes.alpha ? G raphicsContextGL::RGBA8 : GraphicsContextGL::RGB8;239 auto colorFormat = m_attributes.alpha ? GL::RGBA8 : GL::RGB8; 188 240 #if USE(OPENGL_ES) 189 241 auto& extensions = reinterpret_cast<ExtensionsGLOpenGLES&>(gl.getExtensions()); … … 192 244 auto stencilFormat = GL::STENCIL_INDEX8; 193 245 #elif USE(ANGLE) 194 // FIXME: These values were chosen just to get this to compile successfully. 195 // Make sure they are correct. 196 bool supportsPackedDepthStencil = false; 246 bool supportsPackedDepthStencil = true; 197 247 auto depthFormat = supportsPackedDepthStencil ? GL::DEPTH24_STENCIL8 : GL::DEPTH_COMPONENT; 198 248 auto stencilFormat = GL::STENCIL_INDEX8; … … 209 259 GCGLint maxSampleCount; 210 260 #if USE(ANGLE) 211 // FIXME: This probably is not correct. 212 maxSampleCount = 0; 261 gl.getIntegerv(GL::MAX_SAMPLES, makeGCGLSpan(&maxSampleCount, 1)); 213 262 #else 214 263 gl.getIntegerv(ExtensionsGL::MAX_SAMPLES, makeGCGLSpan(&maxSampleCount, 1)); 215 264 #endif 216 // Using more than 4 samples might be overhead.265 // Cap the maxiumum multisample count at 4. Any more than this is likely overkill and will impact performance. 217 266 m_sampleCount = std::min(4, maxSampleCount); 218 267 } … … 252 301 253 302 if (m_attributes.antialias && m_context.isWebGL2()) { 254 // Use an extra FBO for multisample if multisampled_render_to_texture is not supported.255 303 m_resolvedFBO = gl.createFramebuffer(); 256 304 m_multisampleColorBuffer = gl.createRenderbuffer(); -
trunk/Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.h
r276962 r278295 78 78 GCGLint m_sampleCount { 0 }; 79 79 PlatformGLObject m_opaqueTexture { 0 }; 80 #if USE(IOSURFACE_FOR_XR_LAYER_DATA) 81 void* m_ioSurfaceTextureHandle { nullptr }; 82 #endif 80 83 }; 81 84
Note:
See TracChangeset
for help on using the changeset viewer.