[Piglit] [PATCH] arb_texture_view: convert remainder of rendering_* to work with GLES
Ilia Mirkin
imirkin at alum.mit.edu
Sun Sep 18 02:43:04 UTC 2016
These tests used a mix of GL 1.x and newer functionality. This switches
all of them up to require GL 3.0 to avoid annoyance. All hardware that
can support texture views is GL 3.0-capable.
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
tests/spec/arb_texture_view/CMakeLists.gles3.txt | 3 +
tests/spec/arb_texture_view/common.c | 22 ++--
tests/spec/arb_texture_view/rendering_layers.c | 65 ++++++-----
tests/spec/arb_texture_view/rendering_levels.c | 53 +++++++--
tests/spec/arb_texture_view/rendering_target.c | 137 ++++++++++++++---------
5 files changed, 184 insertions(+), 96 deletions(-)
diff --git a/tests/spec/arb_texture_view/CMakeLists.gles3.txt b/tests/spec/arb_texture_view/CMakeLists.gles3.txt
index c590925..02ce468 100644
--- a/tests/spec/arb_texture_view/CMakeLists.gles3.txt
+++ b/tests/spec/arb_texture_view/CMakeLists.gles3.txt
@@ -1,3 +1,6 @@
link_libraries(piglitutil_${piglit_target_api})
piglit_add_executable(arb_texture_view-rendering-formats_gles3 rendering-formats.c)
+piglit_add_executable(arb_texture_view-rendering-layers_gles3 rendering_layers.c common.c)
+piglit_add_executable(arb_texture_view-rendering-levels_gles3 rendering_levels.c common.c)
+piglit_add_executable(arb_texture_view-rendering-target_gles3 rendering_target.c common.c)
diff --git a/tests/spec/arb_texture_view/common.c b/tests/spec/arb_texture_view/common.c
index dedb411..10d3708 100644
--- a/tests/spec/arb_texture_view/common.c
+++ b/tests/spec/arb_texture_view/common.c
@@ -104,18 +104,14 @@ update_valid_arrays(GLenum *valid, GLenum *invalid, unsigned int numInvalid,
void
draw_3d_depth(float x, float y, float w, float h, int depth)
{
- const GLfloat vertices[12] = {x, y, 0.0,
- x+w, y, 0.0,
- x+w, y+h, 0.0,
- x, y+h, 0.0};
- const GLfloat texcoords[12] = {0.0, 0.0, depth,
- 1.0, 0.0, depth,
- 1.0, 1.0, depth,
- 0.0, 1.0, depth};
+ const GLfloat vertices[16] = {x, y, depth, 0.0,
+ x+w, y, depth, 0.0,
+ x+w, y+h, depth, 0.0,
+ x, y+h, depth, 0.0};
+ const GLfloat texcoords[8] = {0.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 1.0,
+ 0.0, 1.0};
- glVertexPointer(3, GL_FLOAT, 0, vertices);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(3, GL_FLOAT, 0, texcoords);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ piglit_draw_rect_from_arrays(vertices, texcoords, false);
}
diff --git a/tests/spec/arb_texture_view/rendering_layers.c b/tests/spec/arb_texture_view/rendering_layers.c
index a461b08..e122a3a 100644
--- a/tests/spec/arb_texture_view/rendering_layers.c
+++ b/tests/spec/arb_texture_view/rendering_layers.c
@@ -34,7 +34,8 @@
PIGLIT_GL_TEST_CONFIG_BEGIN
- config.supports_gl_compat_version = 20;
+ config.supports_gl_compat_version = 30;
+ config.supports_gl_es_version = 31;
config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
@@ -55,7 +56,7 @@ test_render_layers(void)
GLint l;
GLint numLayers[] = {7, 1, 2, 2};
int expectedLayer;
- GLfloat expected[3];
+ GLfloat expected[4];
int p;
bool pass = true;
@@ -105,9 +106,10 @@ test_render_layers(void)
expected[0] = Colors[expectedLayer][0] / 255.0;
expected[1] = Colors[expectedLayer][1] / 255.0;
expected[2] = Colors[expectedLayer][2] / 255.0;
+ expected[3] = 1.0;
- p = piglit_probe_pixel_rgb(piglit_width/2, piglit_height/2,
- expected);
+ p = piglit_probe_pixel_rgba(piglit_width/2, piglit_height/2,
+ expected);
piglit_present_results();
@@ -148,34 +150,47 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
+#ifdef PIGLIT_USE_OPENGL
+#define GLSL_VERSION "130"
+#else
+#define GLSL_VERSION "310 es"
+#endif
+
+static const char *vs =
+ "#version " GLSL_VERSION "\n"
+ "in vec4 piglit_vertex;\n"
+ "in vec2 piglit_texcoord;\n"
+ "out vec3 texcoord;\n"
+ "void main() { \n"
+ " gl_Position = vec4(piglit_vertex.xy, 0.0, 1.0);\n"
+ " texcoord = vec3(piglit_texcoord, piglit_vertex.z);\n"
+ "}\n";
+
+static const char *fs =
+ "#version " GLSL_VERSION "\n"
+ "#ifdef GL_ES\n"
+ "precision highp float;\n"
+ "precision highp sampler2DArray;\n"
+ "#endif\n"
+ "in vec3 texcoord;\n"
+ "uniform sampler2DArray tex;\n"
+ "out vec4 color;\n"
+ "void main() { \n"
+ " color = vec4(texture(tex, texcoord).xyz, 1.0);\n"
+ "}\n";
+
void
piglit_init(int argc, char **argv)
{
- char *vsCode;
- char *fsCode;
-
+#ifdef PIGLIT_USE_OPENGL
piglit_require_extension("GL_ARB_texture_storage");
piglit_require_extension("GL_ARB_texture_view");
piglit_require_extension("GL_EXT_texture_array");
+#else
+ piglit_require_extension("GL_OES_texture_view");
+#endif
- /* setup shaders and program object for 2DArray rendering */
- (void)!asprintf(&vsCode,
- "void main()\n"
- "{\n"
- " gl_Position = gl_Vertex;\n"
- " gl_TexCoord[0] = gl_MultiTexCoord0;\n"
- "}\n");
- (void)!asprintf(&fsCode,
- "#extension GL_EXT_texture_array : enable\n"
- "uniform sampler2DArray tex;\n"
- "void main()\n"
- "{\n"
- " vec4 color = texture2DArray(tex, gl_TexCoord[0].xyz);\n"
- " gl_FragColor = vec4(color.xyz, 1.0);\n"
- "}\n");
- prog2Darray = piglit_build_simple_program(vsCode, fsCode);
- free(fsCode);
- free(vsCode);
+ prog2Darray = piglit_build_simple_program(vs, fs);
tex_loc_2Darray = glGetUniformLocation(prog2Darray, "tex");
}
diff --git a/tests/spec/arb_texture_view/rendering_levels.c b/tests/spec/arb_texture_view/rendering_levels.c
index 51f5366..728e89a 100644
--- a/tests/spec/arb_texture_view/rendering_levels.c
+++ b/tests/spec/arb_texture_view/rendering_levels.c
@@ -34,7 +34,8 @@
PIGLIT_GL_TEST_CONFIG_BEGIN
- config.supports_gl_compat_version = 20;
+ config.supports_gl_compat_version = 30;
+ config.supports_gl_es_version = 31;
config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
@@ -42,6 +43,36 @@ PIGLIT_GL_TEST_CONFIG_END
static const char *TestName = "arb_texture_view-rendering-levels";
+#ifdef PIGLIT_USE_OPENGL
+#define GLSL_VERSION "130"
+#else
+#define GLSL_VERSION "310 es"
+#endif
+
+static const char *vs =
+ "#version " GLSL_VERSION "\n"
+ "in vec4 piglit_vertex;\n"
+ "in vec2 piglit_texcoord;\n"
+ "out vec2 texcoord;\n"
+ "void main() { \n"
+ " gl_Position = piglit_vertex;\n"
+ " texcoord = piglit_texcoord;\n"
+ "}\n";
+
+static const char *fs =
+ "#version " GLSL_VERSION "\n"
+ "#ifdef GL_ES\n"
+ "precision highp float;\n"
+ "precision highp sampler2D;\n"
+ "#endif\n"
+ "in vec2 texcoord;\n"
+ "uniform sampler2D tex;\n"
+ "out vec4 color;\n"
+ "void main() { \n"
+ " color = texture(tex, texcoord);\n"
+ "}\n";
+
+
/**
* Texture views with varying minimum and number of levels, 2D only
*/
@@ -53,17 +84,14 @@ test_render_levels(void)
GLuint numLevels[] = {3,2,2,1};
GLint l;
int expectedLevel;
- GLfloat expected[3];
+ GLfloat expected[4];
int p;
bool pass = true;
- glUseProgram(0);
-
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexStorage2D(GL_TEXTURE_2D, levels, GL_RGBA8, width, height);
- glEnable(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -92,6 +120,7 @@ test_render_levels(void)
glTextureView(new_tex, GL_TEXTURE_2D, tex, GL_RGBA8, l,
numLevels[l], 0, 1);
glBindTexture(GL_TEXTURE_2D, new_tex);
+ glActiveTexture(GL_TEXTURE0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, levels-1);
glClear(GL_COLOR_BUFFER_BIT);
@@ -103,9 +132,10 @@ test_render_levels(void)
expected[0] = Colors[expectedLevel][0] / 255.0;
expected[1] = Colors[expectedLevel][1] / 255.0;
expected[2] = Colors[expectedLevel][2] / 255.0;
+ expected[3] = 1.0;
- p = piglit_probe_pixel_rgb(piglit_width/(2*(l+3)),
- piglit_height/(2*(l+3)), expected);
+ p = piglit_probe_pixel_rgba(piglit_width/(2*(l+3)),
+ piglit_height/(2*(l+3)), expected);
piglit_present_results();
@@ -141,7 +171,6 @@ test_render_levels(void)
glDeleteTextures(1, &new_tex);
}
- glDisable(GL_TEXTURE_2D);
glDeleteTextures(1, &tex);
return pass;
}
@@ -168,6 +197,14 @@ piglit_display(void)
void
piglit_init(int argc, char **argv)
{
+ GLuint prog;
+#ifdef PIGLIT_USE_OPENGL
piglit_require_extension("GL_ARB_texture_storage");
piglit_require_extension("GL_ARB_texture_view");
+#else
+ piglit_require_extension("GL_OES_texture_view");
+#endif
+
+ prog = piglit_build_simple_program(vs, fs);
+ glUseProgram(prog);
}
diff --git a/tests/spec/arb_texture_view/rendering_target.c b/tests/spec/arb_texture_view/rendering_target.c
index 554d1d7..af050b2 100644
--- a/tests/spec/arb_texture_view/rendering_target.c
+++ b/tests/spec/arb_texture_view/rendering_target.c
@@ -34,15 +34,15 @@
PIGLIT_GL_TEST_CONFIG_BEGIN
- config.supports_gl_compat_version = 20;
+ config.supports_gl_compat_version = 30;
+ config.supports_gl_es_version = 31;
config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
PIGLIT_GL_TEST_CONFIG_END
static const char *TestName = "arb_texture_view-rendering-target";
-static int tex_loc_2Darray, tex_loc_1D;
-static int prog2Darray, prog1D;
+static int prog3D, prog2Darray, prog2D, prog1D;
/**
* Simple views of textures; test rendering with various texture view targets
@@ -55,7 +55,6 @@ test_render_with_targets(GLenum target)
GLint l;
bool pass = true;
- glUseProgram(0);
glGenTextures(1, &tex);
glBindTexture(target, tex);
@@ -137,7 +136,7 @@ test_render_with_targets(GLenum target)
GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
for (l = 0; l < levels; l++) {
- GLfloat expected[3];
+ GLfloat expected[4];
int p;
glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, l);
@@ -148,34 +147,31 @@ test_render_with_targets(GLenum target)
switch (target) {
case GL_TEXTURE_1D:
glUseProgram(prog1D);
- glUniform1i(tex_loc_1D, 0);
piglit_draw_rect_tex(-1.0, -1.0, 2.0, 2.0, 0.0, 0.0,
1.0, 1.0);
break;
case GL_TEXTURE_2D:
- glEnable(target);
+ glUseProgram(prog2D);
piglit_draw_rect_tex(-1.0, -1.0, 2.0, 2.0, 0.0, 0.0,
1.0, 1.0);
- glDisable(target);
break;
case GL_TEXTURE_2D_ARRAY:
glUseProgram(prog2Darray);
- glUniform1i(tex_loc_2Darray, 0);
draw_3d_depth(-1.0, -1.0, 2.0, 2.0, l);
break;
case GL_TEXTURE_3D:
- glEnable(target);
+ glUseProgram(prog3D);
draw_3d_depth(-1.0, -1.0, 2.0, 2.0, l);
- glDisable(target);
break;
}
expected[0] = Colors[l][0] / 255.0;
expected[1] = Colors[l][1] / 255.0;
expected[2] = Colors[l][2] / 255.0;
+ expected[3] = 1.0;
- p = piglit_probe_pixel_rgb(piglit_width/2, piglit_height/2,
- expected);
+ p = piglit_probe_pixel_rgba(piglit_width/2, piglit_height/2,
+ expected);
piglit_present_results();
@@ -210,7 +206,9 @@ enum piglit_result
piglit_display(void)
{
bool pass = true;
+#ifdef PIGLIT_USE_OPENGL
X(test_render_with_targets(GL_TEXTURE_1D), "1D view rendering");
+#endif
X(test_render_with_targets(GL_TEXTURE_2D), "2D view rendering");
X(test_render_with_targets(GL_TEXTURE_3D), "3D view rendering");
X(test_render_with_targets(GL_TEXTURE_2D_ARRAY),
@@ -220,49 +218,88 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
+#ifdef PIGLIT_USE_OPENGL
+#define GLSL_VERSION "130"
+#else
+#define GLSL_VERSION "310 es"
+#endif
+
+static const char *vs =
+ "#version " GLSL_VERSION "\n"
+ "in vec4 piglit_vertex;\n"
+ "in vec2 piglit_texcoord;\n"
+ "out vec3 texcoord;\n"
+ "void main() { \n"
+ " gl_Position = vec4(piglit_vertex.xy, 0.0, 1.0);\n"
+ " texcoord = vec3(piglit_texcoord, piglit_vertex.z);\n"
+ "}\n";
+
+static const char *fs_3d =
+ "#version " GLSL_VERSION "\n"
+ "#ifdef GL_ES\n"
+ "precision highp float;\n"
+ "precision highp sampler3D;\n"
+ "#endif\n"
+ "in vec3 texcoord;\n"
+ "uniform sampler3D tex;\n"
+ "out vec4 color;\n"
+ "void main() { \n"
+ " color = vec4(texture(tex, texcoord).xyz, 1.0);\n"
+ "}\n";
+
+static const char *fs_2darray =
+ "#version " GLSL_VERSION "\n"
+ "#ifdef GL_ES\n"
+ "precision highp float;\n"
+ "precision highp sampler2DArray;\n"
+ "#endif\n"
+ "in vec3 texcoord;\n"
+ "uniform sampler2DArray tex;\n"
+ "out vec4 color;\n"
+ "void main() { \n"
+ " color = vec4(texture(tex, texcoord).xyz, 1.0);\n"
+ "}\n";
+
+static const char *fs_2d =
+ "#version " GLSL_VERSION "\n"
+ "#ifdef GL_ES\n"
+ "precision highp float;\n"
+ "precision highp sampler2D;\n"
+ "#endif\n"
+ "in vec3 texcoord;\n"
+ "uniform sampler2D tex;\n"
+ "out vec4 color;\n"
+ "void main() { \n"
+ " color = vec4(texture(tex, texcoord.xy).xyz, 1.0);\n"
+ "}\n";
+
+#ifdef PIGLIT_USE_OPENGL
+static const char *fs_1d =
+ "#version " GLSL_VERSION "\n"
+ "in vec3 texcoord;\n"
+ "uniform sampler1D tex;\n"
+ "out vec4 color;\n"
+ "void main() { \n"
+ " color = vec4(texture(tex, texcoord.x).xyz, 1.0);\n"
+ "}\n";
+#endif
void
piglit_init(int argc, char **argv)
{
- char *vsCode;
- char *fsCode;
-
+#ifdef PIGLIT_USE_OPENGL
piglit_require_extension("GL_ARB_texture_storage");
piglit_require_extension("GL_ARB_texture_view");
piglit_require_extension("GL_EXT_texture_array");
+#else
+ piglit_require_extension("GL_OES_texture_view");
+#endif
- /* setup shaders and program object for 2DArray rendering */
- (void)!asprintf(&vsCode,
- "void main()\n"
- "{\n"
- " gl_Position = gl_Vertex;\n"
- " gl_TexCoord[0] = gl_MultiTexCoord0;\n"
- "}\n");
- (void)!asprintf(&fsCode,
- "#extension GL_EXT_texture_array : enable\n"
- "uniform sampler2DArray tex;\n"
- "void main()\n"
- "{\n"
- " vec4 color = texture2DArray(tex, gl_TexCoord[0].xyz);\n"
- " gl_FragColor = vec4(color.xyz, 1.0);\n"
- "}\n");
-
- prog2Darray = piglit_build_simple_program(vsCode, fsCode);
- free(fsCode);
- tex_loc_2Darray = glGetUniformLocation(prog2Darray, "tex");
-
- /* setup shaders and program object for 1D rendering */
- (void)!asprintf(&fsCode,
- "#extension GL_EXT_texture_array : enable\n"
- "uniform sampler1D tex;\n"
- "void main()\n"
- "{\n"
- " vec4 color = texture1D(tex, gl_TexCoord[0].x);\n"
- " gl_FragColor = vec4(color.xyz, 1.0);\n"
- "}\n");
- prog1D = piglit_build_simple_program(vsCode, fsCode);
- free(fsCode);
- free(vsCode);
-
- tex_loc_1D = glGetUniformLocation(prog1D, "tex");
+ prog3D = piglit_build_simple_program(vs, fs_3d);
+ prog2Darray = piglit_build_simple_program(vs, fs_2darray);
+ prog2D = piglit_build_simple_program(vs, fs_2d);
+
+#ifdef PIGLIT_USE_OPENGL
+ prog1D = piglit_build_simple_program(vs, fs_1d);
+#endif
}
--
2.7.3
More information about the Piglit
mailing list