Bug 273177 - [GTK][WPE] Don't allow depth test and stencil clipping if packed depth stencil is not supported
Summary: [GTK][WPE] Don't allow depth test and stencil clipping if packed depth stenci...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Miguel Gomez
URL:
Keywords:
Depends on:
Blocks: 273473
  Show dependency treegraph
 
Reported: 2024-04-24 03:46 PDT by Miguel Gomez
Modified: 2024-04-30 02:49 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Miguel Gomez 2024-04-24 03:46:57 PDT
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.
Comment 1 Miguel Gomez 2024-04-24 03:53:29 PDT
Pull request: https://github.com/WebKit/WebKit/pull/27682
Comment 2 Miguel Gomez 2024-04-24 05:54:28 PDT
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't work on BitmapTextures where we're doing depth testing. I'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
Comment 3 Miguel Gomez 2024-04-24 06:07:38 PDT
(In reply to Miguel Gomez from comment #2)
> 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't work on
> BitmapTextures where we're doing depth testing. I'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

mmmmm nope, that's not going to work, as the depth testing won'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.
Comment 4 EWS 2024-04-30 00:35:49 PDT
Committed 278159@main (ed286350cfd5): <https://commits.webkit.org/278159@main>

Reviewed commits have been landed. Closing PR #27682 and removing active labels.