<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Any comment on this patch series? </div><div><br></div><div>It would be nice to get tests/spec/gles-2.0 going.<br><br>Regards,<div>Tom</div><div><br class="webkit-block-placeholder"></div></div><div><br>Begin forwarded message:<br><br></div><blockquote type="cite"><div><b>From:</b> Tom Gall <<a href="mailto:tom.gall@linaro.org">tom.gall@linaro.org</a>><br><b>Date:</b> December 2, 2012, 7:55:38 AM EST<br><b>To:</b> <a href="mailto:piglit@lists.freedesktop.org">piglit@lists.freedesktop.org</a><br><b>Cc:</b> Tom Gall <<a href="mailto:tom.gall@linaro.org">tom.gall@linaro.org</a>><br><b>Subject:</b> <b>[PATCH 1/4] gles2: add sanity test</b><br><br></div></blockquote><blockquote type="cite"><div><span>new gles2 sanity test which very simply renders a triangle fan and</span><br><span> validates it was rendered correctly via a newly added</span><br><span> piglit_probe_rect_rgba_ubyte util function.</span><br><span></span><br><span>Signed-off-by: Tom Gall <<a href="mailto:tom.gall@linaro.org">tom.gall@linaro.org</a>></span><br><span>---</span><br><span> tests/all_es2.tests | 4 +</span><br><span> tests/spec/CMakeLists.txt | 1 +</span><br><span> tests/spec/gles-2.0/CMakeLists.gles2.txt | 15 ++++</span><br><span> tests/spec/gles-2.0/CMakeLists.txt | 1 +</span><br><span> tests/spec/gles-2.0/gles2_sanity_test.c | 140 ++++++++++++++++++++++++++++++</span><br><span> tests/util/piglit-util-gl-common.c | 32 +++++++</span><br><span> tests/util/piglit-util-gl-common.h | 1 +</span><br><span> 7 files changed, 194 insertions(+)</span><br><span> create mode 100644 tests/spec/gles-2.0/CMakeLists.gles2.txt</span><br><span> create mode 100644 tests/spec/gles-2.0/CMakeLists.txt</span><br><span> create mode 100644 tests/spec/gles-2.0/gles2_sanity_test.c</span><br><span></span><br><span>diff --git a/tests/all_es2.tests b/tests/all_es2.tests</span><br><span>index ac1b636..f5dc1da 100644</span><br><span>--- a/tests/all_es2.tests</span><br><span>+++ b/tests/all_es2.tests</span><br><span>@@ -21,4 +21,8 @@ oes_compressed_etc1_rgb8_texture = Group()</span><br><span> spec['OES_compressed_ETC1_RGB8_texture'] = oes_compressed_etc1_rgb8_texture</span><br><span> oes_compressed_etc1_rgb8_texture['miptree'] = PlainExecTest(['oes_compressed_etc1_rgb8_texture-miptree', '-auto'])</span><br><span></span><br><span>+gles2_tests = Group()</span><br><span>+spec['gles2_tests'] = gles2_tests</span><br><span>+gles2_tests['gles2_sanity_test'] = PlainExecTest(['gles2_sanity_test', '-auto'])</span><br><span>+</span><br><span> profile.tests['spec'] = spec</span><br><span>diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt</span><br><span>index c2a7886..ed76f39 100644</span><br><span>--- a/tests/spec/CMakeLists.txt</span><br><span>+++ b/tests/spec/CMakeLists.txt</span><br><span>@@ -51,6 +51,7 @@ add_subdirectory (gl-2.0)</span><br><span> add_subdirectory (gl-2.1)</span><br><span> add_subdirectory (gl-3.0)</span><br><span> add_subdirectory (gl-3.1)</span><br><span>+add_subdirectory (gles-2.0)</span><br><span> add_subdirectory (glx_arb_create_context)</span><br><span> add_subdirectory (glx_ext_import_context)</span><br><span> add_subdirectory (glx_oml_sync_control)</span><br><span>diff --git a/tests/spec/gles-2.0/CMakeLists.gles2.txt b/tests/spec/gles-2.0/CMakeLists.gles2.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..fe512aa</span><br><span>--- /dev/null</span><br><span>+++ b/tests/spec/gles-2.0/CMakeLists.gles2.txt</span><br><span>@@ -0,0 +1,15 @@</span><br><span>+#add_definitions(-DSOURCE_DIR="${piglit_SOURCE_DIR}/")</span><br><span>+</span><br><span>+include_directories(</span><br><span>+ ${OPENGL_INCLUDE_PATH}</span><br><span>+ )</span><br><span>+</span><br><span>+link_libraries(</span><br><span>+ ${OPENGL_gles2_LIBRARY}</span><br><span>+ ${OPENGL_egl_LIBRARY}</span><br><span>+ piglitutil_gles2</span><br><span>+ )</span><br><span>+</span><br><span>+piglit_add_executable(gles2_sanity_test gles2_sanity_test.c)</span><br><span>+</span><br><span>+# vim: ft=cmake:</span><br><span>diff --git a/tests/spec/gles-2.0/CMakeLists.txt b/tests/spec/gles-2.0/CMakeLists.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..144a306</span><br><span>--- /dev/null</span><br><span>+++ b/tests/spec/gles-2.0/CMakeLists.txt</span><br><span>@@ -0,0 +1 @@</span><br><span>+piglit_include_target_api()</span><br><span>diff --git a/tests/spec/gles-2.0/gles2_sanity_test.c b/tests/spec/gles-2.0/gles2_sanity_test.c</span><br><span>new file mode 100644</span><br><span>index 0000000..d1c74a1</span><br><span>--- /dev/null</span><br><span>+++ b/tests/spec/gles-2.0/gles2_sanity_test.c</span><br><span>@@ -0,0 +1,140 @@</span><br><span>+/*</span><br><span>+ * Copyright © 2012 Linaro Inc</span><br><span>+ *</span><br><span>+ * Permission is hereby granted, free of charge, to any person obtaining a</span><br><span>+ * copy of this software and associated documentation files (the "Software"),</span><br><span>+ * to deal in the Software without restriction, including without limitation</span><br><span>+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,</span><br><span>+ * and/or sell copies of the Software, and to permit persons to whom the</span><br><span>+ * Software is furnished to do so, subject to the following conditions:</span><br><span>+ *</span><br><span>+ * The above copyright notice and this permission notice (including the next</span><br><span>+ * paragraph) shall be included in all copies or substantial portions of the</span><br><span>+ * Software.</span><br><span>+ *</span><br><span>+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span><br><span>+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span><br><span>+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</span><br><span>+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span><br><span>+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</span><br><span>+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</span><br><span>+ * DEALINGS IN THE SOFTWARE.</span><br><span>+ */</span><br><span>+</span><br><span>+/**</span><br><span>+ * A simple triange test for OpenGL ES 2.0.</span><br><span>+ *</span><br><span>+ * \author Tom Gall <<a href="mailto:tom.gall@linaro.org">tom.gall@linaro.org</a>></span><br><span>+ */</span><br><span>+</span><br><span>+#define _GNU_SOURCE</span><br><span>+</span><br><span>+#include <stdlib.h></span><br><span>+#include <stdio.h></span><br><span>+#include "piglit-util-gl-common.h"</span><br><span>+</span><br><span>+PIGLIT_GL_TEST_CONFIG_BEGIN</span><br><span>+</span><br><span>+ config.supports_gl_es2 = true;</span><br><span>+ config.requires_displayed_window = true;</span><br><span>+</span><br><span>+ config.window_width = 320;</span><br><span>+ config.window_height = 200;</span><br><span>+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DEPTH;</span><br><span>+</span><br><span>+PIGLIT_GL_TEST_CONFIG_END</span><br><span>+</span><br><span>+GLuint prog;</span><br><span>+GLuint frag;</span><br><span>+GLuint vert;</span><br><span>+</span><br><span>+char vertex_shader [] =</span><br><span>+"attribute vec4 vPosition;\n"</span><br><span>+"void main()\n"</span><br><span>+"{\n"</span><br><span>+" gl_Position = vPosition;\n"</span><br><span>+"}";</span><br><span>+</span><br><span>+char fragment_shader [] =</span><br><span>+"precision mediump float;\n"</span><br><span>+"void main()\n"</span><br><span>+"{\n"</span><br><span>+" gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"</span><br><span>+"}";</span><br><span>+</span><br><span>+enum piglit_result</span><br><span>+validate_results()</span><br><span>+{</span><br><span>+ GLubyte red[4] = {0xff, 0x00, 0x00, 0xff};</span><br><span>+ GLubyte black[4] = {0x00, 0x00, 0x00, 0xff};</span><br><span>+</span><br><span>+ /* check that the square was rendered correctly */</span><br><span>+ if (!piglit_probe_rect_rgba_ubyte(80,50,159,97, red))</span><br><span>+ return PIGLIT_FAIL;</span><br><span>+</span><br><span>+ /* check that the remaining area is black */</span><br><span>+ if (!piglit_probe_rect_rgba_ubyte(0,0,320,49, black))</span><br><span>+ return PIGLIT_FAIL;</span><br><span>+ if (!piglit_probe_rect_rgba_ubyte(0,50,79,98, black))</span><br><span>+ return PIGLIT_FAIL;</span><br><span>+ if (!piglit_probe_rect_rgba_ubyte(240,50,80,98, black))</span><br><span>+ return PIGLIT_FAIL;</span><br><span>+ if (!piglit_probe_rect_rgba_ubyte(0,150,320,49, black))</span><br><span>+ return PIGLIT_FAIL;</span><br><span>+</span><br><span>+ return PIGLIT_PASS;</span><br><span>+}</span><br><span>+</span><br><span>+void</span><br><span>+link_and_use_shaders(void)</span><br><span>+{</span><br><span>+ prog = glCreateProgram();</span><br><span>+</span><br><span>+ vert=piglit_compile_shader_text(GL_VERTEX_SHADER,vertex_shader);</span><br><span>+ frag=piglit_compile_shader_text(GL_FRAGMENT_SHADER,fragment_shader);</span><br><span>+</span><br><span>+ glAttachShader(prog, vert);</span><br><span>+ glAttachShader(prog, frag);</span><br><span>+</span><br><span>+ glLinkProgram(prog);</span><br><span>+ if (!(piglit_link_check_status(prog))) {</span><br><span>+ piglit_report_result(PIGLIT_FAIL);</span><br><span>+ return;</span><br><span>+ }</span><br><span>+</span><br><span>+ glDeleteShader(vert);</span><br><span>+ glDeleteShader(frag);</span><br><span>+</span><br><span>+ glUseProgram(prog);</span><br><span>+ if (!piglit_check_gl_error(0)) {</span><br><span>+ piglit_report_result(PIGLIT_FAIL);</span><br><span>+ return;</span><br><span>+ }</span><br><span>+}</span><br><span>+</span><br><span>+enum piglit_result</span><br><span>+piglit_display(void)</span><br><span>+{</span><br><span>+ GLfloat vVertices[] = { 0.5, -0.5, 0.0,</span><br><span>+ 0.5, 0.5, 0.0,</span><br><span>+ -0.5, 0.5, 0.0,</span><br><span>+ -0.5, -0.5, 0.0 };</span><br><span>+</span><br><span>+ /* Clear the color buffer */</span><br><span>+ glClear(GL_COLOR_BUFFER_BIT);</span><br><span>+</span><br><span>+ /* Load the vertex data */</span><br><span>+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vVertices);</span><br><span>+ glEnableVertexAttribArray(0);</span><br><span>+</span><br><span>+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);</span><br><span>+ piglit_swap_buffers();</span><br><span>+</span><br><span>+ return validate_results();</span><br><span>+}</span><br><span>+</span><br><span>+void</span><br><span>+piglit_init(int argc, char *argv[])</span><br><span>+{</span><br><span>+ link_and_use_shaders();</span><br><span>+}</span><br><span>diff --git a/tests/util/piglit-util-gl-common.c b/tests/util/piglit-util-gl-common.c</span><br><span>index 9000673..c8e9b8e 100644</span><br><span>--- a/tests/util/piglit-util-gl-common.c</span><br><span>+++ b/tests/util/piglit-util-gl-common.c</span><br><span>@@ -224,6 +224,38 @@ void piglit_reset_gl_error(void)</span><br><span> }</span><br><span> }</span><br><span></span><br><span>+int</span><br><span>+piglit_probe_rect_rgba_ubyte(int x, int y, int w, int h, const GLubyte *expected)</span><br><span>+{</span><br><span>+ int i, j, p;</span><br><span>+ GLubyte *probe;</span><br><span>+ GLubyte *pixels = malloc(w*h*4*sizeof(GLubyte));</span><br><span>+</span><br><span>+ glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);</span><br><span>+</span><br><span>+ for (j = 0; j < h; j++) {</span><br><span>+ for (i = 0; i < w; i++) {</span><br><span>+ probe = &pixels[(j*w+i)*4];</span><br><span>+</span><br><span>+ for (p = 0; p < 4; ++p) {</span><br><span>+ if (probe[p] - expected[p]) {</span><br><span>+ printf("Probe at (%i,%i)\n", x+i, y+j);</span><br><span>+ printf(" Expected: %x %x %x %x\n",</span><br><span>+ expected[0], expected[1], expected[2], expected[3]);</span><br><span>+ printf(" Observed: %x %x %x %x\n",</span><br><span>+ probe[0], probe[1], probe[2], probe[3]);</span><br><span>+</span><br><span>+ free(pixels);</span><br><span>+ return 0;</span><br><span>+ }</span><br><span>+ }</span><br><span>+ }</span><br><span>+ }</span><br><span>+</span><br><span>+ free(pixels);</span><br><span>+ return 1;</span><br><span>+}</span><br><span>+</span><br><span> /* These texture coordinates should have 1 or -1 in the major axis selecting</span><br><span> * the face, and a nearly-1-or-negative-1 value in the other two coordinates</span><br><span> * which will be used to produce the s,t values used to sample that face's</span><br><span>diff --git a/tests/util/piglit-util-gl-common.h b/tests/util/piglit-util-gl-common.h</span><br><span>index 2d6bb1a..defbe11 100644</span><br><span>--- a/tests/util/piglit-util-gl-common.h</span><br><span>+++ b/tests/util/piglit-util-gl-common.h</span><br><span>@@ -111,6 +111,7 @@ int piglit_probe_rect_rgb_silent(int x, int y, int w, int h, const float *expect</span><br><span> int piglit_probe_rect_rgba(int x, int y, int w, int h, const float* expected);</span><br><span> int piglit_probe_rect_rgba_int(int x, int y, int w, int h, const int* expected);</span><br><span> int piglit_probe_rect_rgba_uint(int x, int y, int w, int h, const unsigned int* expected);</span><br><span>+int piglit_probe_rect_rgba_ubyte(int x, int y, int w, int h, const GLubyte* expected);</span><br><span> void piglit_compute_probe_tolerance(GLenum format, float *tolerance);</span><br><span> int piglit_compare_images_color(int x, int y, int w, int h, int num_components,</span><br><span> const float *tolerance,</span><br><span>-- </span><br><span>1.7.10.4</span><br><span></span><br></div></blockquote></body></html>