[Piglit] [PATCH 09/10] nv_conditional_render: port generatemipmap-test to gles3

Erik Faye-Lund erik.faye-lund at collabora.com
Mon Nov 5 17:23:34 UTC 2018


This test can relatively easily be ported to gles3, so let's do that for
better test-coverage.

Signed-off-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
---
 .../CMakeLists.gles3.txt                      |  1 +
 .../nv_conditional_render/generatemipmap.c    | 44 +++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/tests/spec/nv_conditional_render/CMakeLists.gles3.txt b/tests/spec/nv_conditional_render/CMakeLists.gles3.txt
index 7a7eef651..26097edc0 100644
--- a/tests/spec/nv_conditional_render/CMakeLists.gles3.txt
+++ b/tests/spec/nv_conditional_render/CMakeLists.gles3.txt
@@ -6,5 +6,6 @@ piglit_add_executable (nv_conditional_render-blitframebuffer_gles3 blitframebuff
 piglit_add_executable (nv_conditional_render-clear_gles3 clear.c)
 piglit_add_executable (nv_conditional_render-copyteximage_gles3 copyteximage.c)
 piglit_add_executable (nv_conditional_render-copytexsubimage_gles3 copytexsubimage.c)
+piglit_add_executable (nv_conditional_render-generatemipmap_gles3 generatemipmap.c)
 
 # vim: ft=cmake:
diff --git a/tests/spec/nv_conditional_render/generatemipmap.c b/tests/spec/nv_conditional_render/generatemipmap.c
index 7f29a71a3..87c26d39c 100644
--- a/tests/spec/nv_conditional_render/generatemipmap.c
+++ b/tests/spec/nv_conditional_render/generatemipmap.c
@@ -35,7 +35,12 @@
 
 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 = 30;
+#endif
+
 	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
 	config.khr_no_error_support = PIGLIT_NO_ERRORS;
 	/* Note that this must be half of the texture size,
@@ -46,6 +51,30 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 PIGLIT_GL_TEST_CONFIG_END
 
+#ifndef PIGLIT_USE_OPENGL
+
+static const char *vs_source =
+	"attribute vec4 piglit_vertex;\n"
+	"attribute vec4 piglit_texcoord;\n"
+	"varying vec2 uv;\n"
+	"void main()\n"
+	"{\n"
+	"  gl_Position = piglit_vertex;\n"
+	"  uv = piglit_texcoord.xy;\n"
+	"}\n";
+
+static const char *fs_source_tex =
+	"uniform sampler2D tex;\n"
+	"varying mediump vec2 uv;\n"
+	"void main()\n"
+	"{\n"
+	"  gl_FragColor = texture2D(tex, uv);\n"
+	"}\n";
+
+static GLint prog_tex;
+
+#endif
+
 static void
 fill_level(int level, int size, const GLubyte *color)
 {
@@ -87,10 +116,15 @@ piglit_display(void)
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
 			GL_LINEAR_MIPMAP_NEAREST);
+#ifdef PIGLIT_USE_OPENGL
 	glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+#endif
 
 	for (i = 0; tex_size / (1 << i) > 0; i++)
 		fill_level(i, tex_size / (1 << i), i == 0 ? green_ub : red);
+#ifndef PIGLIT_USE_OPENGL
+	glGenerateMipmap(GL_TEXTURE_2D);
+#endif
 
 	glGenQueries(1, &q);
 
@@ -106,10 +140,16 @@ piglit_display(void)
 	/* This should draw level 1, since starting window size is 32
 	 * and texture is 64.
 	 */
+#ifdef PIGLIT_USE_OPENGL
 	glEnable(GL_TEXTURE_2D);
+#else
+	glUseProgram(prog_tex);
+#endif
 	piglit_draw_rect_tex(-1, -1, 2, 2,
 			     0, 0, 1, 1);
+#ifdef PIGLIT_USE_OPENGL
 	glDisable(GL_TEXTURE_2D);
+#endif
 
 	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
 				      green);
@@ -125,5 +165,9 @@ void
 piglit_init(int argc, char **argv)
 {
 	piglit_require_extension("GL_NV_conditional_render");
+#ifdef PIGLIT_USE_OPENGL
 	piglit_require_extension("GL_EXT_framebuffer_object");
+#else
+	prog_tex = piglit_build_simple_program(vs_source, fs_source_tex);
+#endif
 }
-- 
2.19.1



More information about the Piglit mailing list