RESOLVED FIXED 226422
[WebXR] invalidateFramebuffer is not the same as clearing contents
https://bugs.webkit.org/show_bug.cgi?id=226422
Summary [WebXR] invalidateFramebuffer is not the same as clearing contents
Dean Jackson
Reported 2021-05-29 12:38:34 PDT
[WebXR] invalidateFramebuffer is not the same as clearing contents
Attachments
Patch (2.86 KB, patch)
2021-05-29 12:46 PDT, Dean Jackson
sam: review+
Dean Jackson
Comment 1 2021-05-29 12:40:06 PDT
The WebXR specification says that buffer contents must be cleared before each frame. The code currently does glInvalidateFramebuffer to wipe the attachments, which isn't the same thing (and produces an error since it tries to invalidate attachments that don't exist).
Radar WebKit Bug Importer
Comment 2 2021-05-29 12:42:44 PDT
Dean Jackson
Comment 3 2021-05-29 12:46:48 PDT
Sam Weinig
Comment 4 2021-05-29 13:41:36 PDT
Comment on attachment 430104 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=430104&action=review > Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:112 > - gl.bindFramebuffer(GL::FRAMEBUFFER, m_framebuffer->object()); > + gl.bindFramebuffer(GraphicsContextGL::FRAMEBUFFER, m_framebuffer->object()); > // https://immersive-web.github.io/webxr/#opaque-framebuffer > - // The buffers attached to an opaque framebuffer MUST be cleared to the values in the table below when first created, > + // The buffers attached to an opaque framebuffer MUST be cleared to the values in the provided table when first created, > // or prior to the processing of each XR animation frame. > - std::array<const GCGLenum, 3> attachments = { GL::COLOR_ATTACHMENT0, GL::STENCIL_ATTACHMENT, GL::DEPTH_ATTACHMENT }; > - gl.invalidateFramebuffer(GL::FRAMEBUFFER, makeGCGLSpan(attachments.data(), attachments.size())); > + // FIXME: Actually do the clearing (not using invalidateFramebuffer). This will have to be done after we've attached > + // the textures/renderbuffers. We should also probably abstract this away from specific GL at some point so it can support WebGPU framebuffers as well.
Dean Jackson
Comment 5 2021-05-30 12:43:48 PDT
Comment on attachment 430104 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=430104&action=review >> Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:112 >> + // the textures/renderbuffers. > > We should also probably abstract this away from specific GL at some point so it can support WebGPU framebuffers as well. Agreed.
Dean Jackson
Comment 6 2021-05-30 12:45:29 PDT
Imanol Fernandez
Comment 7 2021-05-31 02:32:18 PDT
> > We should also probably abstract this away from specific GL at some point so > it can support WebGPU framebuffers as well. In theory the Opaque Framebuffer approach is kind of deprecated and the path forward is the WebXR Layers API, specifically the XRProjectionLayer for this use case. The UAs will provide "Opaque Textures" and the framebuffer creation complexity will me moved to JS and WebGL/WebGPU side. So it's probably better to focus on that path since I dont expect that a WebGPU Opaque Framebuffer will be added to the spec
Sam Weinig
Comment 8 2021-06-01 09:43:09 PDT
(In reply to Imanol Fernandez from comment #7) > > > > We should also probably abstract this away from specific GL at some point so > > it can support WebGPU framebuffers as well. > > In theory the Opaque Framebuffer approach is kind of deprecated and the path > forward is the WebXR Layers API, specifically the XRProjectionLayer for this > use case. The UAs will provide "Opaque Textures" and the framebuffer > creation complexity will me moved to JS and WebGL/WebGPU side. > > So it's probably better to focus on that path since I dont expect that a > WebGPU Opaque Framebuffer will be added to the spec Gotcha. Can you point me wo where XRProjectionLayer is being spec'd? I couldn't find it in https://immersive-web.github.io/webxr/.
Imanol Fernandez
Comment 9 2021-06-01 14:12:26 PDT
> > Gotcha. Can you point me wo where XRProjectionLayer is being spec'd? I > couldn't find it in https://immersive-web.github.io/webxr/. It's spec'd here https://immersive-web.github.io/layers/#xrprojectionlayertype
Note You need to log in before you can comment on or make changes to this bug.