summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2018-10-24 15:58:49 +0200
committerErik Faye-Lund <erik.faye-lund@collabora.com>2018-11-21 12:42:39 +0100
commit8bc777cf8b9f28cb5cd184d56901aa10691e67e6 (patch)
tree29fd64e3ebcbb74d095c64c1a40852423c9cc146
parentf653e12d1acffb82a64ec58e674f0d151998a210 (diff)
s3tc-teximage: port to gles2
This specification is also supported on gles2, so let's add support for gles2 to the test also. Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
-rw-r--r--tests/texturing/CMakeLists.gles2.txt5
-rw-r--r--tests/texturing/s3tc-teximage.c48
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/texturing/CMakeLists.gles2.txt b/tests/texturing/CMakeLists.gles2.txt
new file mode 100644
index 000000000..de4c1a53c
--- /dev/null
+++ b/tests/texturing/CMakeLists.gles2.txt
@@ -0,0 +1,5 @@
+link_libraries(piglitutil_${piglit_target_api})
+
+piglit_add_executable (s3tc-teximage_gles2 s3tc-teximage.c)
+
+# vim: ft=cmake:
diff --git a/tests/texturing/s3tc-teximage.c b/tests/texturing/s3tc-teximage.c
index a7225f6f0..1b65f6ce1 100644
--- a/tests/texturing/s3tc-teximage.c
+++ b/tests/texturing/s3tc-teximage.c
@@ -36,7 +36,11 @@
PIGLIT_GL_TEST_CONFIG_BEGIN
+#ifdef PIGLIT_USE_OPENGL
config.supports_gl_compat_version = 11;
+#else // PIGLIT_USE_OPENGL_ES2
+ config.supports_gl_es_version = 20;
+#endif
config.window_width = 500;
config.window_height = 600;
@@ -52,12 +56,45 @@ const float green[4] = {0.0, 1.0, 0.0, 1.0};
const float blue[4] = {0.0, 0.0, 1.0, 1.0};
const float white[4] = {1.0, 1.0, 1.0, 1.0};
+#ifdef PIGLIT_USE_OPENGL_ES2
+
+const char *vs_source =
+ "#version 100\n"
+ "attribute vec4 piglit_vertex;\n"
+ "attribute vec2 piglit_texcoord;\n"
+ "varying mediump vec2 tex_coord;\n"
+ "uniform mat4 proj;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = proj * piglit_vertex;\n"
+ " tex_coord = piglit_texcoord;\n"
+ "}\n";
+
+const char *fs_source =
+ "#version 100\n"
+ "varying mediump vec2 tex_coord;\n"
+ "uniform sampler2D tex;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = texture2D(tex, tex_coord);\n"
+ "}\n";
+
+#include "piglit-matrix.h"
+
+GLint tex_program;
+
+#endif
+
static void
display_mipmaps(int start_x, int start_y)
{
int i;
+#ifdef PIGLIT_USE_OPENGL
glEnable(GL_TEXTURE_2D);
+#endif
/* Disply all the mipmap levels */
for (i = SIZE; i > 0; i /= 2) {
@@ -144,5 +181,16 @@ piglit_init(int argc, char **argv)
{
piglit_require_extension("GL_EXT_texture_compression_s3tc");
+#ifdef PIGLIT_USE_OPENGL
+
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+#else // PIGLIT_USE_OPENGL_ES2
+
+ tex_program = piglit_build_simple_program(vs_source, fs_source);
+ glUseProgram(tex_program);
+ GLint proj_loc = glGetUniformLocation(tex_program, "proj");
+ piglit_ortho_uniform(proj_loc, piglit_width, piglit_height);
+
+#endif
}