Bug 111170

Summary: comparison between same depths from glClearDepthf and fragment depth will fail
Product: Mesa Reporter: xu xing <xing.xu>
Component: Drivers/DRI/i965Assignee: Intel 3D Bugs Mailing List <intel-3d-bugs>
Status: RESOLVED DUPLICATE QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: xinghua.cao, yang.gu
Version: 19.1   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: test case binary

Description xu xing 2019-07-19 05:57:58 UTC
Created attachment 144822 [details]
test case binary

****************************************
Issue analyze:
Take case “MaskedScissoredClearTest.Test/ES2_OpenGL_clear_cd” as an example. 

Summary of this case:
1),  Preset the depth buffer with value 0.5f, name it Zb, buffer depth
kClearDepth        = 0.5f;
glClearDepthf(kClearDepth);
2),  Draw quad with depth of 0.0f, name it Zf, fragment depth
drawQuad(depthTestProgram, essl1_shaders::PositionAttrib(), maskDepth ? 1.0f : 0.0f);

In theory, the depth 0.5f of glClearDepthf equals(GL_EQUAL) the depth of drawQuad 0.0f. There is an equation between these two depths:
Zb = 0.5 x Zf + 0.5

On NVidia’s platform, we observed what we expected. On Intel platform, didn’t.

I also did below tests with different buffer depth and different depth func (GL_GREATER and GL_LESS), you can easily see the relationship between Zf (0.0) and Zb(0.5) on Intel platform(You may also refer to attachment zbzf_testdata.png):
Zb	Zf  > (GL_GREATER)	< (GL_LESS)
0.5	0.0  	√	x
0.499	0.0  	√	x
0.501	0.0  	x	√


****************************************
Reproduce steps (You may try the attached binary to reproduce):
1. Download angle source and install deps:
(https://github.com/google/angle/blob/master/doc/DevSetup.md)
git clone https://chromium.googlesource.com/angle/angle
cd angle
python scripts/bootstrap.py
gclient sync
git checkout master
./build/install-build-deps.sh
gn gen out/Release

2. Edit code(To enable the skipped test case)
--- a/src/tests/gl_tests/ClearTest.cpp
+++ b/src/tests/gl_tests/ClearTest.cpp
@@ -1248,7 +1248,7 @@ void MaskedScissoredClearTestBase::MaskedScissoredColorDepthStencilClear(
                                                   &maskColor, &maskDepth, &maskStencil, &scissor);

     // clearDepth && !maskDepth fails on Intel Ubuntu 19.04 Mesa 19.0.2 GL. http://anglebug.com/3614
-    ANGLE_SKIP_TEST_IF(IsLinux() && IsIntel() && IsDesktopOpenGL() && clearDepth && !maskDepth);
+    // ANGLE_SKIP_TEST_IF(IsLinux() && IsIntel() && IsDesktopOpenGL() && clearDepth && !maskDepth);


3. Build
ninja -C out/Release


4.  Run test case
./out/Release/angle_end2end_tests --gtest_filter=MaskedScissoredClearTest.Test/ES2_OpenGL_clear_cd


I have reproduced this issue on below platform:
Mesa 19.1.1/Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller (rev 06)/Ubuntu 18.04

I can not reproduce this on:
OpenGL version string: 4.6.0 NVIDIA 430.26/GeForce GTX 1060/Ubuntu 18.04.
Windows 10/Intel UHD 630/



****************************************
The failed logs on Intel:
[----------] 1 test from MaskedScissoredClearTest
[ RUN  	] MaskedScissoredClearTest.Test/ES2_OpenGL_clear_cd
../../src/tests/gl_tests/ClearTest.cpp:1355: Failure
The difference between (expectedCenterColorRGB.R) and pixel[0] is 51, which exceeds 1, where
(expectedCenterColorRGB.R) evaluates to 0,
pixel[0] evaluates to 51, and
1 evaluates to 1.
../../src/tests/gl_tests/ClearTest.cpp:1355: Failure
The difference between (expectedCenterColorRGB.G) and pixel[1] is 102, which exceeds 1, where
(expectedCenterColorRGB.G) evaluates to 0,
pixel[1] evaluates to 102, and
1 evaluates to 1.
…
…
...
1 evaluates to 1.
[  FAILED  ] MaskedScissoredClearTest.Test/ES2_OpenGL_clear_cd, where GetParam() = (ES2_OpenGL, 1, 1, 0, false) (38 ms)
[----------] 1 test from MaskedScissoredClearTest (38 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (38 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] MaskedScissoredClearTest.Test/ES2_OpenGL_clear_cd, where GetParam() = (ES2_OpenGL, 1, 1, 0, false)

 1 FAILED TEST


****************************************
The pass logs on NV:

[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from MaskedScissoredClearTest
[ RUN  	] MaskedScissoredClearTest.Test/ES2_OpenGL_clear_cd
[   	OK ] MaskedScissoredClearTest.Test/ES2_OpenGL_clear_cd (90 ms)
[----------] 1 test from MaskedScissoredClearTest (90 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (90 ms total)
[  PASSED  ] 1 test.
Comment 1 Sergii Romantsov 2019-07-19 10:19:45 UTC
Seems that is duplicate of https://bugs.freedesktop.org/show_bug.cgi?id=111113

Initial fix: https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1329

Now thinking about extended test and, probably, better solution.
Comment 2 Paul 2019-08-05 13:33:58 UTC

*** This bug has been marked as a duplicate of bug 111113 ***
Comment 3 Paul 2019-08-05 15:42:13 UTC
I've rechecked the issue with the latest master version of the mesa - test has also passed.

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.