[Piglit] [PATCH 2/2] ext_framebuffer_multisample: Use glDrawArrays in place of glDrawElements

Anuj Phogat anuj.phogat at gmail.com
Mon Aug 25 17:03:56 PDT 2014


Patch fixes an issue about generating the reference images in accuracy
tests.
In my view this patch should not make any change in test output. But,
it fixes the failures in 'accuracy' tests when run with 'all_samples'
and {depth_draw, depth_resolve, stencil_draw, stencil_resolve}
options. Tests with 'color' option continued passing with no changes
in output on NVIDIA drivers.

Without this patch, above tests failed with similar output (missing
reference images) on both i965 and NVIDIA proprietary linux drivers
(331.38). That rules out the possibility of driver bug. I spent some
time debugging it but couldn't figure out what's wrong with using
GL_ELEMENT_ARRAY_BUFFER and glDrawElements in these tests.
Setting element array buffers in two places, first in ManifestDepth
/ ManifestStencil and than in DownsampleProg, is causing some
problem.

I don't want to spend more time debugging this. So, I would like to
go ahead with this patch, even though it doesn't explain the problem
with using glDrawElements. Please let me know if you don't agree or
if you've some explanation of the observed behavior.

Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
 tests/util/piglit-test-pattern.cpp | 32 ++++++--------------------------
 1 file changed, 6 insertions(+), 26 deletions(-)

diff --git a/tests/util/piglit-test-pattern.cpp b/tests/util/piglit-test-pattern.cpp
index f037053..2f51666 100644
--- a/tests/util/piglit-test-pattern.cpp
+++ b/tests/util/piglit-test-pattern.cpp
@@ -806,8 +806,8 @@ ManifestStencil::compile()
 	float vertex_data[4][2] = {
 		{ -1, -1 },
 		{ -1,  1 },
-		{  1,  1 },
-		{  1, -1 }
+		{  1, -1 },
+		{  1,  1 }
 	};
 	glGenVertexArrays(1, &vertex_buf);
 	glBindBuffer(GL_ARRAY_BUFFER, vertex_buf);
@@ -816,16 +816,6 @@ ManifestStencil::compile()
 	glEnableVertexAttribArray(0);
 	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_data[0]),
 			      (void *) 0);
-
-	/* Set up element input buffer to tessellate a quad into
-	 * triangles
-	 */
-	unsigned int indices[6] = { 0, 1, 2, 0, 2, 3 };
-	GLuint element_buf;
-	glGenBuffers(1, &element_buf);
-	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, element_buf);
-	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices,
-		     GL_STATIC_DRAW);
 }
 
 void
@@ -856,7 +846,7 @@ ManifestStencil::run()
 	for (int i = 0; i < 8; ++i) {
 		glStencilFunc(GL_EQUAL, i, 0xff);
 		glUniform4fv(color_loc, 1, colors[i]);
-		glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, (void *) 0);
+		glDrawArrays(GL_TRIANGLE_STRIP, 0, 6);
 	}
 
 	glDisable(GL_STENCIL_TEST);
@@ -907,8 +897,8 @@ ManifestDepth::compile()
 	float vertex_data[4][2] = {
 		{ -1, -1 },
 		{ -1,  1 },
-		{  1,  1 },
-		{  1, -1 }
+		{  1, -1 },
+		{  1,  1 }
 	};
 	glGenVertexArrays(1, &vertex_buf);
 	glBindBuffer(GL_ARRAY_BUFFER, vertex_buf);
@@ -917,16 +907,6 @@ ManifestDepth::compile()
 	glEnableVertexAttribArray(0);
 	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_data[0]),
 			      (void *) 0);
-
-	/* Set up element input buffer to tessellate a quad into
-	 * triangles
-	 */
-	unsigned int indices[6] = { 0, 1, 2, 0, 2, 3 };
-	GLuint element_buf;
-	glGenBuffers(1, &element_buf);
-	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, element_buf);
-	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices,
-		     GL_STATIC_DRAW);
 }
 
 void
@@ -960,7 +940,7 @@ ManifestDepth::run()
 	for (int i = 0; i < 8; ++i) {
 		glUniform4fv(color_loc, 1, colors[i]);
 		glUniform1f(depth_loc, float(7 - 2*i)/8);
-		glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, (void *) 0);
+		glDrawArrays(GL_TRIANGLE_STRIP, 0, 6);
 	}
 
 	glDisable(GL_STENCIL_TEST);
-- 
1.9.3



More information about the Piglit mailing list