<?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>273177</bug_id>
          
          <creation_ts>2024-04-24 03:46:57 -0700</creation_ts>
          <short_desc>[GTK][WPE] Don&apos;t allow depth test and stencil clipping if packed depth stencil is not supported</short_desc>
          <delta_ts>2024-04-30 02:49:19 -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>WebKitGTK</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></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>273473</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Miguel Gomez">magomez</reporter>
          <assigned_to name="Miguel Gomez">magomez</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>fujii</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2030833</commentid>
    <comment_count>0</comment_count>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2024-04-24 03:46:57 -0700</bug_when>
    <thetext>A BitmapTexture can be used as a rendering target by creating a framebuffer object for it. This framebuffer can have a depth buffer to use depth testing, and a stencil buffer to perform stencil clipping. But using both features at the same time, which requires both a depth buffer and a stencil buffer, is only supported when GLES supports using the same buffer for both (called packed depth stencil). This is supported on GLES3 contexts or in GLES2 contexts that have the GL_OES_packed_depth_stencil extension.

We need to modify BitmapTexture to allow using both features at the same time when packed depth stencil is available.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2030834</commentid>
    <comment_count>1</comment_count>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2024-04-24 03:53:29 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/27682</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2030849</commentid>
    <comment_count>2</comment_count>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2024-04-24 05:54:28 -0700</bug_when>
    <thetext>This is going to fix the rendering for the cases where packed depth stencil is supported.

For the rest of the cases, like GLES2 without the GL_OES_packed_depth_stencil extension, stencil clipping won&apos;t work on BitmapTextures where we&apos;re doing depth testing. I&apos;ll work on that next.

My idea for this would be detecting that the call to initializeStencil() in TextureMapper::beginClip() failed to bind a stencilBuffer, and add an special implementation of the stencil clip for that case using an intermediate texture:

- create a new intermediate BitmapTexture with a stencil only buffer and bind it
- perform the stencil clip on the intermediate BitmapTexture
- let the rendering continue on the intermediate BitmapTexture until the matching endClip
- inside endClip, bind back the initial BitmapTexture and render the contents of the intermediate texture into it</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2030851</commentid>
    <comment_count>3</comment_count>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2024-04-24 06:07:38 -0700</bug_when>
    <thetext>(In reply to Miguel Gomez from comment #2)
&gt; This is going to fix the rendering for the cases where packed depth stencil
&gt; is supported.
&gt; 
&gt; For the rest of the cases, like GLES2 without the
&gt; GL_OES_packed_depth_stencil extension, stencil clipping won&apos;t work on
&gt; BitmapTextures where we&apos;re doing depth testing. I&apos;ll work on that next.
&gt; 
&gt; My idea for this would be detecting that the call to initializeStencil() in
&gt; TextureMapper::beginClip() failed to bind a stencilBuffer, and add an
&gt; special implementation of the stencil clip for that case using an
&gt; intermediate texture:
&gt; 
&gt; - create a new intermediate BitmapTexture with a stencil only buffer and
&gt; bind it
&gt; - perform the stencil clip on the intermediate BitmapTexture
&gt; - let the rendering continue on the intermediate BitmapTexture until the
&gt; matching endClip
&gt; - inside endClip, bind back the initial BitmapTexture and render the
&gt; contents of the intermediate texture into it

mmmmm nope, that&apos;s not going to work, as the depth testing won&apos;t be applied to the elements rendered into the intermediate BitmapTexture, so the result may be different than doing both depth testing and stencil clipping at the same time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2032158</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-04-30 00:35:49 -0700</bug_when>
    <thetext>Committed 278159@main (ed286350cfd5): &lt;https://commits.webkit.org/278159@main&gt;

Reviewed commits have been landed. Closing PR #27682 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>