[Piglit] [PATCH v2] Implement piglit to test GL_EXT_buffer_storage.

Ryan Houdek sonicadvance1 at gmail.com
Wed Nov 4 10:41:19 PST 2015


This has been tested on the Nvidia proprietary driver and llvmpipe.
This piglit requires GLES 3.1 support due to glMemoryBarrier.
To test Mesa I temporarily moved glMemoryBarrier as a ES 3.0 function.
---
 tests/all.py                                       | 17 ++--
 tests/spec/arb_buffer_storage/CMakeLists.gles3.txt |  4 +
 tests/spec/arb_buffer_storage/bufferstorage.c      | 91 +++++++++++++++++++++-
 3 files changed, 102 insertions(+), 10 deletions(-)
 create mode 100644 tests/spec/arb_buffer_storage/CMakeLists.gles3.txt

diff --git a/tests/all.py b/tests/all.py
index 60bcb2c..6cd40aa 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3989,14 +3989,15 @@ with profile.group_manager(
 with profile.group_manager(
         PiglitGLTest,
         grouptools.join('spec', 'arb_buffer_storage')) as g:
-    g(['bufferstorage-persistent', 'draw'])
-    g(['bufferstorage-persistent', 'draw', 'coherent'])
-    g(['bufferstorage-persistent', 'draw', 'client-storage'])
-    g(['bufferstorage-persistent', 'draw', 'coherent', 'client-storage'])
-    g(['bufferstorage-persistent', 'read'])
-    g(['bufferstorage-persistent', 'read', 'coherent'])
-    g(['bufferstorage-persistent', 'read', 'client-storage'])
-    g(['bufferstorage-persistent', 'read', 'coherent', 'client-storage'])
+    for mode in ['read', 'draw']:
+        g(['bufferstorage-persistent', mode])
+        g(['bufferstorage-persistent', mode, 'coherent'])
+        g(['bufferstorage-persistent', mode, 'client-storage'])
+        g(['bufferstorage-persistent', mode, 'coherent', 'client-storage'])
+        g(['bufferstorage-persistent_gles3', mode])
+        g(['bufferstorage-persistent_gles3', mode, 'coherent'])
+        g(['bufferstorage-persistent_gles3', mode, 'client-storage'])
+        g(['bufferstorage-persistent_gles3', mode, 'coherent', 'client-storage'])
 
 with profile.group_manager(
         PiglitGLTest,
diff --git a/tests/spec/arb_buffer_storage/CMakeLists.gles3.txt b/tests/spec/arb_buffer_storage/CMakeLists.gles3.txt
new file mode 100644
index 0000000..b5e96fd
--- /dev/null
+++ b/tests/spec/arb_buffer_storage/CMakeLists.gles3.txt
@@ -0,0 +1,4 @@
+link_libraries(piglitutil_${piglit_target_api})
+piglit_add_executable (bufferstorage-persistent_${piglit_target_api} bufferstorage.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/arb_buffer_storage/bufferstorage.c b/tests/spec/arb_buffer_storage/bufferstorage.c
index 316a10f..927c7f8 100644
--- a/tests/spec/arb_buffer_storage/bufferstorage.c
+++ b/tests/spec/arb_buffer_storage/bufferstorage.c
@@ -34,7 +34,14 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
+#ifdef PIGLIT_USE_OPENGL
 	config.supports_gl_compat_version = 10;
+#else // PIGLIT_USE_OPENGL_ES3
+       config.supports_gl_es_version = 31;
+       config.window_width = 100;
+       config.window_height = 100;
+#endif
+
 	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
@@ -45,6 +52,26 @@ enum test_flag {
 	DRAW
 };
 
+#ifdef PIGLIT_USE_OPENGL_ES3
+const char *vs_source = {
+       "#version 300 es\n"
+       "in vec2 vertex;\n"
+       "void main() {\n"
+       "       gl_Position = vec4(vertex.xy, 0, 1);\n"
+       "}\n"
+};
+
+const char *fs_source = {
+       "#version 300 es\n"
+       "out highp vec4 ocol;\n"
+       "void main() {\n"
+       "       ocol = vec4(1, 1, 1, 1);\n"
+       "}\n"
+};
+
+static GLuint vao;
+#endif
+
 static GLuint buffer;
 static GLfloat *map;
 static GLboolean coherent, client_storage;
@@ -84,6 +111,7 @@ piglit_init(int argc, char **argv)
 		piglit_report_result(PIGLIT_FAIL);
 	}
 
+#ifdef PIGLIT_USE_OPENGL
 	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
 	piglit_require_gl_version(15);
@@ -96,6 +124,16 @@ piglit_init(int argc, char **argv)
 	if (!coherent) { /* for MemoryBarrier */
 		piglit_require_extension("GL_ARB_shader_image_load_store");
 	}
+#else // PIGLIT_USE_OPENGL_ES3
+       GLuint program;
+       GLuint vertex_index;
+
+       piglit_require_extension("GL_EXT_buffer_storage");
+
+       /* Create program */
+       program = piglit_build_simple_program(vs_source, fs_source);
+       glUseProgram(program);
+#endif
 
 	glGenBuffers(1, &buffer);
 	glBindBuffer(GL_ARRAY_BUFFER, buffer);
@@ -117,6 +155,20 @@ piglit_init(int argc, char **argv)
 
 	if (!map)
 		piglit_report_result(PIGLIT_FAIL);
+#ifdef PIGLIT_USE_OPENGL_ES3
+	/* Gen VAO */
+	glGenVertexArrays(1, &vao);
+	glBindVertexArray(vao);
+
+	/* Retrieve indices from vs */
+	vertex_index = glGetAttribLocation(program, "vertex");
+
+	/* Enable vertex attrib array */
+	glEnableVertexAttribArray(vertex_index);
+	glVertexAttribPointer(vertex_index, 3, GL_FLOAT, GL_FALSE, 0, 0);
+
+	piglit_check_gl_error(GL_NO_ERROR);
+#endif
 
 	glBindBuffer(GL_ARRAY_BUFFER, 0);
 }
@@ -124,9 +176,11 @@ piglit_init(int argc, char **argv)
 enum piglit_result
 piglit_display(void)
 {
-	float white[4] = {1.0, 1.0, 1.0, 0.0};
+	float white[4] = {1.0, 1.0, 1.0, 1.0};
 	GLboolean pass = GL_TRUE;
 	int i;
+
+#ifdef PIGLIT_USE_OPENGL
 	float array[] = {
 		17, 13, 0,
 		17, 18, 0,
@@ -145,14 +199,40 @@ piglit_display(void)
 		42, 13, 0,
 		42, 18, 0
 	};
-
+#else // PIGLIT_USE_OPENGL_ES3
+	float array[] = {
+		1.00, 0.75, 0.0,
+		1.00, 1.00, 0.0,
+		0.75, 0.75, 0.0,
+		0.75, 1.00, 0.0,
+
+		0.50, 0.75, 0.0,
+		0.50, 1.00, 0.0,
+		0.25, 0.75, 0.0,
+		0.25, 1.00, 0.0,
+
+		0.00, 0.75, 0.0,
+		0.00, 1.00, 0.0,
+		-0.25, 0.75, 0.0,
+		-0.25, 1.00, 0.0,
+
+		-0.50, 0.75, 0.0,
+		-0.50, 1.00, 0.0,
+		-0.75, 0.75, 0.0,
+		-0.75, 1.00, 0.0,
+       };
+#endif
 	glClear(GL_COLOR_BUFFER_BIT);
 
 	if (test == DRAW) {
+#ifdef PIGLIT_USE_OPENGL
 		glEnableClientState(GL_VERTEX_ARRAY);
 		glBindBuffer(GL_ARRAY_BUFFER, buffer);
 		glVertexPointer(3, GL_FLOAT, 0, 0);
 		glBindBuffer(GL_ARRAY_BUFFER, 0);
+#else // PIGLIT_USE_OPENGL_ES3
+		glBindVertexArray(vao);
+#endif
 
 		memcpy(map, array, 12 * sizeof(float));
 		if (!coherent)
@@ -180,12 +260,19 @@ piglit_display(void)
 
 		piglit_check_gl_error(0);
 
+#ifdef PIGLIT_USE_OPENGL
 		pass = pass && piglit_probe_pixel_rgb(15, 15, white);
 		pass = pass && piglit_probe_pixel_rgb(25, 15, white);
 		pass = pass && piglit_probe_pixel_rgb(35, 15, white);
 		pass = pass && piglit_probe_pixel_rgb(45, 15, white);
 
 		glDisableClientState(GL_VERTEX_ARRAY);
+#else // PIGLIT_USE_OPENGL_ES3
+		pass = pass && piglit_probe_pixel_rgba(13, 87, white);
+		pass = pass && piglit_probe_pixel_rgba(39, 87, white);
+		pass = pass && piglit_probe_pixel_rgba(65, 87, white);
+		pass = pass && piglit_probe_pixel_rgba(91, 87, white);
+#endif
 	}
 	else if (test == READ) {
 		GLuint srcbuf;
-- 
1.9.1



More information about the Piglit mailing list