Bug 93761 - A conditional discard in a fragment shader causes no depth writing at all
Summary: A conditional discard in a fragment shader causes no depth writing at all
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/radeonsi (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Default DRI bug account
QA Contact: Default DRI bug account
Depends on:
Reported: 2016-01-18 18:08 UTC by James Legg
Modified: 2016-02-25 14:11 UTC (History)
0 users

See Also:
i915 platform:
i915 features:

Test case (4.86 KB, text/plain)
2016-01-18 18:08 UTC, James Legg

Description James Legg 2016-01-18 18:08:25 UTC
Created attachment 121116 [details]
Test case

When rendering to an FBO with only a GL_DEPTH_COMPONENT16 depth buffer, with depth testing enabled, if a fragment shader has a conditional discard, nothing is written to the depth buffer for pixels which should not be discarded.

Platform: Fedora 22 x86_64
Mesa version: tested both git eaf7ec9 (from griever-mesa-git copr) and 10.6.9 (the default mesa package with Fedora 22). The bug occurred on both.
GL Renderer string: Gallium 0.4 on AMD PITCAIRN (DRM 2.43.0, LLVM 3.7.1)
GPU: AMD R9 270 with 2GB VRAM

Workaround: If you write to gl_FragDepth, only the intentionally discarded pixels are discarded.

I've attached a test case demonstrating the problem. It will fail an assertion on the machine with this bug. It should draw only on the even columns of pixels in the depth buffer, but nothing is drawn.
Comment 1 Nicolai Hähnle 2016-01-19 16:02:30 UTC
Hi James, bug reports with attached test cases are awesome :)
I can confirm the problem with latest Mesa and LLVM master and am going to investigate.
Comment 2 Nicolai Hähnle 2016-01-19 20:21:12 UTC
Here's a fix: http://patchwork.freedesktop.org/patch/71068/

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.