Bug 234824 - Writing gl_FragDepth without depth attachment disables color writes
Summary: Writing gl_FragDepth without depth attachment disables color writes
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: Safari 15
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-01-03 08:59 PST by Ashley Gullen
Modified: 2022-03-30 03:56 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ashley Gullen 2022-01-03 08:59:53 PST
In Safari 15, using the gl_FragDepth feature of WebGL 2 in a fragment shader rendering to a framebuffer without a depth attachment, causes all color writes to fail, resulting in a blank screen.

In Chrome and Firefox on both Windows and Android it works correctly.

Minimal repro: https://downloads.scirra.com/labs/bugs/webglfragdepth/

This is a lightly modified version of the fbo_blit example from WebGL 2 samples (http://webglsamples.org/WebGL2Samples/). This example does not use any depth attachment on the FBO. The only meaningful change is the addition of this line to the fragment shader:

gl_FragDepth = 1.0;

This causes all the color writes to fail, producing a blank screen (tested on Safari 15.2 on macOS 12.1 and iPadOS 15.2). However it renders correctly in Chrome/Firefox on Windows/Android. Removing that line causes rendering to work again in Safari. With no depth attachment, it is expected that all writes to gl_FragDepth would simply have no effect. Instead the observed result is that the color writes stop working producing no rendering at all.

We need this to work in our WebGL engine as we want to use some 2D shaders both with and without a depth buffer in use; however in Safari the presence of gl_FragDepth causes all rendering to fail.
Comment 1 Alexey Proskuryakov 2022-01-03 16:09:22 PST
> Minimal repro: https://downloads.scirra.com/labs/bugs/webglfragdepth/

Is a red/grey checkerboard a pass or a failure on this test? If it’s a pass, this may be fixed on trunk already.
Comment 2 Ashley Gullen 2022-01-04 05:46:24 PST
The correct rendering should match this sample: http://webglsamples.org/WebGL2Samples/#fbo_blit

i.e. if you see a red background with some images, it works.

When it does not work, it's just a black screen with some text at the top.
Comment 3 Alexey Proskuryakov 2022-01-04 10:08:39 PST
Thank you. I'm getting black screen with some text at the top on STP 137; and a checkerboard without images on the iOS build that I have installed. 

So this doesn't appear to be fixed yet.
Comment 4 Radar WebKit Bug Importer 2022-01-04 10:08:55 PST
<rdar://problem/87097485>
Comment 5 Kenneth Russell 2022-01-04 10:48:49 PST
Thanks for reporting this; it's a bug in ANGLE's Metal backend. I've filed it upstream against ANGLE as:

Metal: Writing gl_FragDepth without depth attachment disables color writes
https://bugs.chromium.org/p/angleproject/issues/detail?id=6865

We can perhaps prototype a fix in WebKit's copy of ANGLE, but ideally it'll be fixed upstream and just rolled into WebKit to avoid merge conflicts.
Comment 6 Ashley Gullen 2022-03-30 03:56:03 PDT
The corresponding ANGLE issue is marked fixed, but the issue still reproduces in Safari 15.4 and TP 142. When is it supposed to be fixed?