[Piglit] [PATCH] gl-1.0/swapbuffers-behavior: Try avoid reading from real front v2

Thomas Hellstrom thellstrom at vmware.com
Wed Jun 21 16:29:59 UTC 2017

Window systems (read dri3) that allocate a fake frontbuffer on demand will
effectively read out from the real front before the first swapbuffers after
fake front creation, and the real front buffer content is subject to errors
caused by, among other things, window reparenting. So increase the likelyhood
of not reading out from the real front by advertizing early that we will
access the front buffer. After all, real front consistency is not the objective
of this test.

Fixes sporadic failures due to window reparenting on dri3/vmwgfx.

v2: Address review comments from Brian Paul.

Cc: Brian Paul <brianp at vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
 tests/spec/gl-1.0/swapbuffers-behavior.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tests/spec/gl-1.0/swapbuffers-behavior.c b/tests/spec/gl-1.0/swapbuffers-behavior.c
index d914020..8d20bad 100644
--- a/tests/spec/gl-1.0/swapbuffers-behavior.c
+++ b/tests/spec/gl-1.0/swapbuffers-behavior.c
@@ -41,7 +41,7 @@ PIGLIT_GL_TEST_CONFIG_END
 static const float blue[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
 static const float green[4] = { 0.0f, 1.0f, 0.0f, 0.0f };
+static const float red[4] = { 1.0f, 0.0f, 0.0f, 0.0f };
 static bool
 match(const float c1[4], const float c2[4])
@@ -65,6 +65,17 @@ piglit_display(void)
 	glClearColor(green[0], green[1], green[2], green[3]);
+	/* Clear front buffer to red. This is done to trigger the creation
+	 * of a fake front buffer on GLX/dri3.
+	 * Without this we'll be effectively probing the real front buffer
+	 * later on, and its contents may have been modified by reparenting.
+	 */
+	glDrawBuffer(GL_FRONT);
+	glClearColor(red[0], red[1], red[2], red[3]);
+	glFlush();
+	glDrawBuffer(GL_BACK);
         /* First swap */

More information about the Piglit mailing list