[Piglit] [PATCHv2] gles1: add tests for GL_OES_draw_texture

Chia-I Wu olvaffe at gmail.com
Tue Sep 20 02:39:51 PDT 2011


This is the first GLESv1 tests.  GL_OES_draw_texture is a GLESv1
specific extension.  Because of that, the tests live in tests/gles1
instead of tests/spec.

The tests are added to the newly created all_es1.tests.

Cc: Ian Romanick <idr at freedesktop.org>

Changes since v1:

 - rename the file name to oes_draw_texture.c
 - rename the static variable glDrawTexiOES to piglit_glDrawTexiOES
 - add all_es1.tests for this (and future) GLESv1 tests

---
 tests/all_es1.tests              |   59 ++++++++++
 tests/gles1/CMakeLists.gles1.txt |    4 +
 tests/gles1/oes_draw_texture.c   |  237 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 300 insertions(+), 0 deletions(-)
 create mode 100644 tests/all_es1.tests
 create mode 100644 tests/gles1/oes_draw_texture.c

diff --git a/tests/all_es1.tests b/tests/all_es1.tests
new file mode 100644
index 0000000..a162e3e
--- /dev/null
+++ b/tests/all_es1.tests
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# All GLESv1 tests that come with piglit, using default settings
+
+import re
+
+from framework.core import *
+from framework.exectest import *
+
+######
+# Collecting all tests
+profile = TestProfile()
+
+spec = Group()
+
+# Group OES_draw_texture
+oes_draw_texture = Group()
+spec['OES_draw_texture'] = oes_draw_texture
+add_plain_test(oes_draw_texture, 'oes_draw_texture')
+
+profile.tests['spec'] = spec
+
+#############
+# Some Mesa diagnostic messages that we should probably ignore
+Test.ignoreErrors.append(re.compile("couldn't open libtxc_dxtn.so"))
+Test.ignoreErrors.append(re.compile("compression/decompression available"))
+Test.ignoreErrors.append(re.compile("Mesa: .*build"))
+Test.ignoreErrors.append(re.compile("Mesa: CPU.*"))
+Test.ignoreErrors.append(re.compile("Mesa: .*cpu detected."))
+Test.ignoreErrors.append(re.compile("Mesa: Test.*"))
+Test.ignoreErrors.append(re.compile("Mesa: Yes.*"))
+Test.ignoreErrors.append(re.compile("libGL: XF86DRIGetClientDriverName.*"))
+Test.ignoreErrors.append(re.compile("libGL: OpenDriver: trying.*"))
+Test.ignoreErrors.append(re.compile("libGL: Warning in.*drirc*"))
+Test.ignoreErrors.append(re.compile("ATTENTION.*value of option.*"))
+Test.ignoreErrors.append(re.compile("drmOpen.*"))
+Test.ignoreErrors.append(re.compile("Mesa: Not testing OS support.*"))
+Test.ignoreErrors.append(re.compile("Mesa: User error:.*"))
+Test.ignoreErrors.append(re.compile("Mesa: Initializing .* optimizations"))
+Test.ignoreErrors.append(re.compile("debug_get_.*"))
+Test.ignoreErrors.append(re.compile("util_cpu_caps.*"))
+Test.ignoreErrors.append(re.compile("Mesa: 3Dnow! detected"))
+Test.ignoreErrors.append(re.compile("r300:.*"))
+Test.ignoreErrors.append(re.compile("radeon:.*"))
+Test.ignoreErrors.append(re.compile("Warning:.*"))
+Test.ignoreErrors.append(re.compile("0 errors, .*"))
+Test.ignoreErrors.append(re.compile("Mesa.*"))
+Test.ignoreErrors.append(re.compile("no rrb"))
+Test.ignoreErrors.append(re.compile("; ModuleID.*"))
+Test.ignoreErrors.append(re.compile("%.*"))
+Test.ignoreErrors.append(re.compile(".*failed to translate tgsi opcode.*to SSE"))
+Test.ignoreErrors.append(re.compile(".*falling back to interpreter"))
+Test.ignoreErrors.append(re.compile("GLSL version is .*, but requested version .* is required"))
+Test.ignoreErrors.append(re.compile("kCGErrorIllegalArgument: CGSOrderWindowList"))
+Test.ignoreErrors.append(re.compile("kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint\(\) to catch errors as they are logged."))
+Test.ignoreErrors.append(re.compile("stw_(init|cleanup).*"))
+Test.ignoreErrors.append(re.compile("OpenGLInfo..*"))
+Test.ignoreErrors.append(re.compile("AdapterInfo..*"))
+Test.ignoreErrors.append(re.compile("No memory leaks detected."))
diff --git a/tests/gles1/CMakeLists.gles1.txt b/tests/gles1/CMakeLists.gles1.txt
index e78b487..2442844 100644
--- a/tests/gles1/CMakeLists.gles1.txt
+++ b/tests/gles1/CMakeLists.gles1.txt
@@ -12,4 +12,8 @@ link_libraries(
 	piglitutil_gles1
 	)
 
+add_executable(oes_draw_texture
+	oes_draw_texture.c
+	)
+
 # vim: ft=cmake:
diff --git a/tests/gles1/oes_draw_texture.c b/tests/gles1/oes_draw_texture.c
new file mode 100644
index 0000000..623a40c
--- /dev/null
+++ b/tests/gles1/oes_draw_texture.c
@@ -0,0 +1,237 @@
+/*
+ * Copyright © 2011 LunarG, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Author: Chia-I Wu <olv at lunarg.com>
+ */
+
+/** @file draw-tex.c
+ *
+ * Test GL_OES_draw_texture.
+ */
+
+#include <EGL/egl.h>
+
+#include "piglit-util.h"
+
+#define TEXTURE_SIZE 2
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_ALPHA | GLUT_DEPTH | GLUT_DOUBLE;
+
+/* see piglit_rgbw_texture */
+static const float red[4] =   { 1.0f, 0.0f, 0.0f, 0.0f };
+static const float green[4] = { 0.0f, 1.0f, 0.0f, 0.25f };
+static const float blue[4] =  { 0.0f, 0.0f, 1.0f, 0.50f };
+static const float white[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
+
+static PFNGLDRAWTEXIOESPROC piglit_glDrawTexiOES;
+
+/**
+ * Test the basic use of glDrawTex
+ */
+static int
+test_basic(void)
+{
+	const GLint crop[4] = {
+		0, 0, TEXTURE_SIZE, TEXTURE_SIZE
+	};
+	const int x = piglit_width / 2 - 2;
+	const int y = piglit_height / 2 - 2;
+	int pass;
+
+	glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+
+	/* draw the RGBW texture */
+	piglit_glDrawTexiOES(0, 0, 0, piglit_width, piglit_height);
+
+	pass = piglit_probe_pixel_rgb(x,     y,     red);
+	pass = piglit_probe_pixel_rgb(x + 5, y,     green) && pass;
+	pass = piglit_probe_pixel_rgb(x,     y + 5, blue)  && pass;
+	pass = piglit_probe_pixel_rgb(x + 5, y + 5, white) && pass;
+
+	if (!pass)
+		fprintf(stderr, "glDrawTexiOES() failed\n");
+
+	return pass;
+}
+
+/**
+ * Test glDrawTex with a crop rectangle with negative width/height.
+ */
+static int
+test_negative_crop(void)
+{
+	const GLint crop[4] = {
+		TEXTURE_SIZE, TEXTURE_SIZE, -TEXTURE_SIZE, -TEXTURE_SIZE
+	};
+	const int x = piglit_width / 2 - 2;
+	const int y = piglit_height / 2 - 2;
+	int pass;
+
+	glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+
+	/* draw the RGBW texture with negative crop */
+	piglit_glDrawTexiOES(0, 0, 0, piglit_width, piglit_height);
+
+	pass = piglit_probe_pixel_rgb(x,     y,     white);
+	pass = piglit_probe_pixel_rgb(x + 5, y,     blue)  && pass;
+	pass = piglit_probe_pixel_rgb(x,     y + 5, green) && pass;
+	pass = piglit_probe_pixel_rgb(x + 5, y + 5, red)   && pass;
+
+	if (!pass)
+		fprintf(stderr, "negative crop width/height failed\n");
+
+	return pass;
+}
+
+/**
+ * Test glDrawTex with a small crop rectangle covering only the right-top of
+ * the texture.
+ */
+static int
+test_right_top_crop(void)
+{
+	const GLint crop[4] = {
+		TEXTURE_SIZE / 2, TEXTURE_SIZE / 2,
+		TEXTURE_SIZE / 2, TEXTURE_SIZE / 2
+	};
+	const int x = piglit_width / 2 - 2;
+	const int y = piglit_height / 2 - 2;
+	int pass;
+
+	glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+
+	/* draw the right top quarter of RGBW texture */
+	piglit_glDrawTexiOES(0, 0, 0, piglit_width, piglit_height);
+
+	pass = piglit_probe_pixel_rgb(x,     y,     white);
+	pass = piglit_probe_pixel_rgb(x + 5, y,     white) && pass;
+	pass = piglit_probe_pixel_rgb(x,     y + 5, white) && pass;
+	pass = piglit_probe_pixel_rgb(x + 5, y + 5, white) && pass;
+
+	if (!pass)
+		fprintf(stderr, "sub crop rect failed\n");
+
+	return pass;
+}
+
+/**
+ * Test glDrawTex with non-zero x and y.
+ */
+static int
+test_right_top_win(void)
+{
+	const GLint crop[4] = {
+		0, 0, TEXTURE_SIZE, TEXTURE_SIZE
+	};
+	const int half_width = piglit_width / 2;
+	const int half_height = piglit_height / 2;
+	const int x = half_width + half_width / 2 - 2;
+	const int y = half_height + half_height / 2 - 2;
+	int pass;
+
+	glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+
+	/* draw the RGBW texture at the right top */
+	piglit_glDrawTexiOES(half_width, half_height, 0, half_width, half_height);
+
+	pass = piglit_probe_pixel_rgb(x,     y,     red);
+	pass = piglit_probe_pixel_rgb(x + 5, y,     green) && pass;
+	pass = piglit_probe_pixel_rgb(x,     y + 5, blue)  && pass;
+	pass = piglit_probe_pixel_rgb(x + 5, y + 5, white) && pass;
+
+	if (!pass)
+		fprintf(stderr, "non-zero (x, y) failed\n");
+
+	return pass;
+}
+
+/**
+ * Test glDrawTex with non-zero z.
+ */
+static int
+test_depth(void)
+{
+	const GLint crop[4] = {
+		0, 0, TEXTURE_SIZE, TEXTURE_SIZE
+	};
+	const int x = piglit_width / 2 - 2;
+	const int y = piglit_height / 2 - 2;
+	int pass;
+
+	glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+
+	glEnable(GL_DEPTH_TEST);
+
+	/* draw at near plane */
+	piglit_glDrawTexiOES(0, 0, 0, piglit_width, piglit_height);
+	/* draw at far plane: should be no-op */
+	piglit_glDrawTexiOES(0, 0, 1, piglit_width / 2, piglit_height / 2);
+
+	glDisable(GL_DEPTH_TEST);
+
+	pass = piglit_probe_pixel_rgb(x, y, red);
+
+	if (!pass)
+		fprintf(stderr, "non-zero depth failed\n");
+
+	return pass;
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	GLboolean pass = GL_TRUE;
+
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+	pass = test_basic();
+	pass = test_negative_crop() && pass;
+	pass = test_right_top_win() && pass;
+	pass = test_right_top_crop() && pass;
+	pass = test_depth() && pass;
+
+	glFinish();
+	glutSwapBuffers();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint tex;
+
+	piglit_require_extension("GL_OES_draw_texture");
+	piglit_glDrawTexiOES = (PFNGLDRAWTEXIOESPROC)
+		eglGetProcAddress("glDrawTexiOES");
+	if (!piglit_glDrawTexiOES)
+		piglit_report_result(PIGLIT_FAIL);
+
+	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+	tex = piglit_rgbw_texture(GL_RGBA,
+			TEXTURE_SIZE, TEXTURE_SIZE, GL_FALSE, GL_TRUE, 0);
+
+	glBindTexture(GL_TEXTURE_2D, tex);
+	glEnable(GL_TEXTURE_2D);
+}
-- 
1.7.5.4



More information about the Piglit mailing list