[Piglit] [PATCH] shader_runner: enable VAO for gl >= 31 before glDrawArrays

Jordan Justen jordan.l.justen at intel.com
Wed May 14 00:45:24 PDT 2014


This fixes attributeless rendering on nvidia's binary driver
and Mesa (as of 1afe3359258a9e89b62c8638761f52d78f6d1cbc).

For example:
 * tests/spec/glsl-1.50/execution/geometry/point-size-out.shader_test

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77162
Cc: "Fu, Ping" <Ping.Fu at amd.com>
Cc: Brian Paul <brianp at vmware.com>
---
 tests/shaders/shader_runner.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 7e4c5b0..a288afa 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -120,6 +120,7 @@ bool vbo_present = false;
 bool link_ok = false;
 bool prog_in_use = false;
 GLchar *prog_err_info = NULL;
+GLuint vao = 0;
 
 enum states {
 	none = 0,
@@ -1850,6 +1851,16 @@ program_must_be_in_use(void)
 
 }
 
+void
+bind_vao_if_supported()
+{
+	if (vao == 0 && gl_version.num >= 31) {
+		glGenVertexArrays(1, &vao);
+		glBindVertexArray(vao);
+	}
+}
+
+
 enum piglit_result
 piglit_display(void)
 {
@@ -1924,6 +1935,7 @@ piglit_display(void)
 				       (unsigned long) num_vbo_rows);
 				piglit_report_result(PIGLIT_FAIL);
 			}
+			bind_vao_if_supported();
 			glDrawArrays(mode, first, count);
 		} else if (string_match("disable", line)) {
 			do_enable_disable(line + 7, false);
@@ -2189,12 +2201,7 @@ piglit_init(int argc, char **argv)
 	link_and_use_shaders();
 	if (link_ok && vertex_data_start != NULL) {
 		program_must_be_in_use();
-		if (gl_version.num >= 31) {
-			GLuint vao;
-
-			glGenVertexArrays(1, &vao);
-			glBindVertexArray(vao);
-		}
+		bind_vao_if_supported();
 
 		num_vbo_rows = setup_vbo_from_text(prog, vertex_data_start,
 						   vertex_data_end);
-- 
2.0.0.rc2



More information about the Piglit mailing list