[Piglit] [PATCH 5/5] textureSize: Add support for running with core GL.

Eric Anholt eric at anholt.net
Thu Nov 1 11:36:57 PDT 2012


This lets the textureSize tests for TBOs run on i965.
---
 tests/spec/arb_texture_buffer_object/formats.c |    1 +
 tests/texturing/shaders/textureSize.c          |   18 ++++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/tests/spec/arb_texture_buffer_object/formats.c b/tests/spec/arb_texture_buffer_object/formats.c
index d1ff57d..05a6e2c 100644
--- a/tests/spec/arb_texture_buffer_object/formats.c
+++ b/tests/spec/arb_texture_buffer_object/formats.c
@@ -538,6 +538,7 @@ piglit_display(void)
 	glGenBuffers(1, &vbo);
 	glBindBuffer(GL_ARRAY_BUFFER_ARB, vbo);
 	if (piglit_get_gl_version() >= 31) {
+		GLuint vao;
 		glGenVertexArrays(1, &vao);
 		glBindVertexArray(vao);
 	}
diff --git a/tests/texturing/shaders/textureSize.c b/tests/texturing/shaders/textureSize.c
index 98191b8..9168458 100644
--- a/tests/texturing/shaders/textureSize.c
+++ b/tests/texturing/shaders/textureSize.c
@@ -49,6 +49,7 @@
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 10;
+	config.supports_gl_core_version = 31;
 
 	config.window_width = 150;
 	config.window_height = 30;
@@ -98,11 +99,25 @@ piglit_display()
 		 1,  1,
 		 1, -1,
 	};
+	GLuint vbo;
 
 	glClearColor(0.5, 0.5, 0.5, 1.0);
 	glClear(GL_COLOR_BUFFER_BIT);
 
-	glVertexAttribPointer(vertex_location, 2, GL_FLOAT, GL_FALSE, 0, verts);
+	/* For GL core, we need to have a vertex array object bound.
+	 * Otherwise, we don't particularly have to.  Always use a
+	 * vertex buffer object, though.
+	 */
+	if (piglit_get_gl_version() >= 31) {
+		GLuint vao;
+		glGenVertexArrays(1, &vao);
+		glBindVertexArray(vao);
+	}
+	glGenBuffers(1, &vbo);
+	glBindBuffer(GL_ARRAY_BUFFER, vbo);
+	glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STREAM_DRAW);
+
+	glVertexAttribPointer(vertex_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
 	glEnableVertexAttribArray(vertex_location);
 
 	/* Draw consecutive squares for each mipmap level */
@@ -130,7 +145,6 @@ piglit_display()
 	}
 
 	glDisableVertexAttribArray(vertex_location);
-
 	piglit_present_results();
 
 	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
-- 
1.7.10.4



More information about the Piglit mailing list