[06/10] nv_conditional_render: port clear-test to gles3

Submitted by Erik Faye-Lund on Nov. 5, 2018, 5:23 p.m.

Details

Message ID 20181105172335.17229-7-erik.faye-lund@collabora.com
State New
Headers show
Series "port NV_conditional_render tests to GLES3" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Erik Faye-Lund Nov. 5, 2018, 5:23 p.m.
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@collabora.com>
---
 .../CMakeLists.gles3.txt                      |  1 +
 tests/spec/nv_conditional_render/clear.c      | 34 ++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/tests/spec/nv_conditional_render/CMakeLists.gles3.txt b/tests/spec/nv_conditional_render/CMakeLists.gles3.txt
index 47884c340..f1b515eb2 100644
--- a/tests/spec/nv_conditional_render/CMakeLists.gles3.txt
+++ b/tests/spec/nv_conditional_render/CMakeLists.gles3.txt
@@ -3,5 +3,6 @@  link_libraries(piglitutil_${piglit_target_api})
 piglit_add_executable (nv_conditional_render-begin-while-active_gles3 begin-while-active.c)
 piglit_add_executable (nv_conditional_render-begin-zero_gles3 begin-zero.c)
 piglit_add_executable (nv_conditional_render-blitframebuffer_gles3 blitframebuffer.c)
+piglit_add_executable (nv_conditional_render-clear_gles3 clear.c)
 
 # vim: ft=cmake:
diff --git a/tests/spec/nv_conditional_render/clear.c b/tests/spec/nv_conditional_render/clear.c
index 288239d06..5c9cf62a9 100644
--- a/tests/spec/nv_conditional_render/clear.c
+++ b/tests/spec/nv_conditional_render/clear.c
@@ -42,12 +42,36 @@ 
 
 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;
 
 PIGLIT_GL_TEST_CONFIG_END
 
+#ifndef PIGLIT_USE_OPENGL
+
+static const char *vs_source =
+	"attribute vec4 piglit_vertex;\n"
+	"void main()\n"
+	"{\n"
+	"  gl_Position = piglit_vertex;\n"
+	"}\n";
+
+static const char *fs_source_green =
+	"void main()\n"
+	"{\n"
+	"  gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);\n"
+	"}\n";
+
+static GLint prog_green;
+
+#endif
+
 enum piglit_result
 piglit_display(void)
 {
@@ -61,8 +85,12 @@  piglit_display(void)
 	glGenQueries(1, &q);
 
 	/* Generate query pass: draw top half of screen. */
-	glColor4f(0.0, 1.0, 0.0, 0.0);
 	glBeginQuery(GL_SAMPLES_PASSED, q);
+#ifdef PIGLIT_USE_OPENGL
+	glColor4f(0.0, 1.0, 0.0, 0.0);
+#else
+	glUseProgram(prog_green);
+#endif
 	piglit_draw_rect(-1, 0, 2, 1);
 	glEndQuery(GL_SAMPLES_PASSED);
 
@@ -96,4 +124,8 @@  void
 piglit_init(int argc, char **argv)
 {
 	piglit_require_extension("GL_NV_conditional_render");
+
+#ifndef PIGLIT_USE_OPENGL
+	prog_green = piglit_build_simple_program(vs_source, fs_source_green);
+#endif
 }