<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>226422</bug_id>
          
          <creation_ts>2021-05-29 12:38:34 -0700</creation_ts>
          <short_desc>[WebXR] invalidateFramebuffer is not the same as clearing contents</short_desc>
          <delta_ts>2021-06-01 14:12:26 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Dean Jackson">dino</reporter>
          <assigned_to name="Dean Jackson">dino</assigned_to>
          <cc>adachan</cc>
    
    <cc>ifernandez</cc>
    
    <cc>sam</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1765106</commentid>
    <comment_count>0</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2021-05-29 12:38:34 -0700</bug_when>
    <thetext>[WebXR] invalidateFramebuffer is not the same as clearing contents</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1765107</commentid>
    <comment_count>1</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2021-05-29 12:40:06 -0700</bug_when>
    <thetext>The WebXR specification says that buffer contents must be cleared before each frame. The code currently does glInvalidateFramebuffer to wipe the attachments, which isn&apos;t the same thing (and produces an error since it tries to invalidate attachments that don&apos;t exist).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1765108</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-05-29 12:42:44 -0700</bug_when>
    <thetext>&lt;rdar://problem/78652351&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1765109</commentid>
    <comment_count>3</comment_count>
      <attachid>430104</attachid>
    <who name="Dean Jackson">dino</who>
    <bug_when>2021-05-29 12:46:48 -0700</bug_when>
    <thetext>Created attachment 430104
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1765118</commentid>
    <comment_count>4</comment_count>
      <attachid>430104</attachid>
    <who name="Sam Weinig">sam</who>
    <bug_when>2021-05-29 13:41:36 -0700</bug_when>
    <thetext>Comment on attachment 430104
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430104&amp;action=review

&gt; Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:112
&gt; -    gl.bindFramebuffer(GL::FRAMEBUFFER, m_framebuffer-&gt;object());
&gt; +    gl.bindFramebuffer(GraphicsContextGL::FRAMEBUFFER, m_framebuffer-&gt;object());
&gt;      // https://immersive-web.github.io/webxr/#opaque-framebuffer
&gt; -    // The buffers attached to an opaque framebuffer MUST be cleared to the values in the table below when first created,
&gt; +    // The buffers attached to an opaque framebuffer MUST be cleared to the values in the provided table when first created,
&gt;      // or prior to the processing of each XR animation frame.
&gt; -    std::array&lt;const GCGLenum, 3&gt; attachments = { GL::COLOR_ATTACHMENT0, GL::STENCIL_ATTACHMENT, GL::DEPTH_ATTACHMENT };
&gt; -    gl.invalidateFramebuffer(GL::FRAMEBUFFER, makeGCGLSpan(attachments.data(), attachments.size()));
&gt; +    // FIXME: Actually do the clearing (not using invalidateFramebuffer). This will have to be done after we&apos;ve attached
&gt; +    // the textures/renderbuffers.

We should also probably abstract this away from specific GL at some point so it can support WebGPU framebuffers as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1765239</commentid>
    <comment_count>5</comment_count>
      <attachid>430104</attachid>
    <who name="Dean Jackson">dino</who>
    <bug_when>2021-05-30 12:43:48 -0700</bug_when>
    <thetext>Comment on attachment 430104
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430104&amp;action=review

&gt;&gt; Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:112
&gt;&gt; +    // the textures/renderbuffers.
&gt; 
&gt; We should also probably abstract this away from specific GL at some point so it can support WebGPU framebuffers as well.

Agreed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1765240</commentid>
    <comment_count>6</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2021-05-30 12:45:29 -0700</bug_when>
    <thetext>Committed r278256 (238293@main): &lt;https://commits.webkit.org/238293@main&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1765366</commentid>
    <comment_count>7</comment_count>
    <who name="Imanol Fernandez">ifernandez</who>
    <bug_when>2021-05-31 02:32:18 -0700</bug_when>
    <thetext>&gt;
&gt; We should also probably abstract this away from specific GL at some point so
&gt; 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 &quot;Opaque Textures&quot; and the framebuffer creation complexity will me moved to JS and WebGL/WebGPU side.

So it&apos;s probably better to focus on that path since I dont expect that a WebGPU Opaque Framebuffer will be added to the spec</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1765645</commentid>
    <comment_count>8</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2021-06-01 09:43:09 -0700</bug_when>
    <thetext>(In reply to Imanol Fernandez from comment #7)
&gt; &gt;
&gt; &gt; We should also probably abstract this away from specific GL at some point so
&gt; &gt; it can support WebGPU framebuffers as well.
&gt; 
&gt; In theory the Opaque Framebuffer approach is kind of deprecated and the path
&gt; forward is the WebXR Layers API, specifically the XRProjectionLayer for this
&gt; use case. The UAs will provide &quot;Opaque Textures&quot; and the framebuffer
&gt; creation complexity will me moved to JS and WebGL/WebGPU side.
&gt; 
&gt; So it&apos;s probably better to focus on that path since I dont expect that a
&gt; WebGPU Opaque Framebuffer will be added to the spec

Gotcha. Can you point me wo where XRProjectionLayer is being spec&apos;d? I couldn&apos;t find it in https://immersive-web.github.io/webxr/.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1765752</commentid>
    <comment_count>9</comment_count>
    <who name="Imanol Fernandez">ifernandez</who>
    <bug_when>2021-06-01 14:12:26 -0700</bug_when>
    <thetext>&gt; 
&gt; Gotcha. Can you point me wo where XRProjectionLayer is being spec&apos;d? I
&gt; couldn&apos;t find it in https://immersive-web.github.io/webxr/.

It&apos;s spec&apos;d here https://immersive-web.github.io/layers/#xrprojectionlayertype</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>430104</attachid>
            <date>2021-05-29 12:46:48 -0700</date>
            <delta_ts>2021-05-30 12:43:48 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-226422-20210530054646.patch</filename>
            <type>text/plain</type>
            <size>2928</size>
            <attacher name="Dean Jackson">dino</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjc4MjQwCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggNzFmZDZkYmU5MDNlMGVk
ZDU4ZmFmZTg3M2U4MGEzYjgxNTJlOTFhZi4uOGM1Njg4MjFmODkzMDMwNDk4OWNjYWRiZmVhYjU1
ZjBhYTc3YzUzNyAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDI1IEBACisyMDIx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IGF0dGFjaG1lbnRzLnNpemUoKSkpOworICAgIC8vIEZJWE1FOiBB
Y3R1YWxseSBkbyB0aGUgY2xlYXJpbmcgKG5vdCB1c2luZyBpbnZhbGlkYXRlRnJhbWVidWZmZXIp
LiBUaGlzIHdpbGwgaGF2ZSB0byBiZSBkb25lIGFmdGVyIHdlJ3ZlIGF0dGFjaGVkCisgICAgLy8g
dGhlIHRleHR1cmVzL3JlbmRlcmJ1ZmZlcnMuCiAKICNpZiBVU0UoT1BFTkdMX0VTKQogICAgIGF1
dG8mIGV4dGVuc2lvbnMgPSByZWludGVycHJldF9jYXN0PEV4dGVuc2lvbnNHTE9wZW5HTEVTJj4o
Z2wuZ2V0RXh0ZW5zaW9ucygpKTsK
</data>
<flag name="review"
          id="451455"
          type_id="1"
          status="+"
          setter="sam"
    />
          </attachment>
      

    </bug>

</bugzilla>