summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTopi Pohjolainen <topi.pohjolainen@intel.com>2014-02-19 11:32:25 +0200
committerTopi Pohjolainen <topi.pohjolainen@intel.com>2016-04-27 09:02:19 +0300
commit1a5ca6bd985973c4f534b03a2bf4b804e06e298c (patch)
treeb21690601afe1968860996a746a97f40db8d6d0c
parent68d981a4752a3cde664d5380c7f0460ce4a51c67 (diff)
stencil_texturing: Allow testing of texelFetch also
CC: Eric Anholt <eric@anholt.net> CC: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
-rw-r--r--tests/all.py3
-rw-r--r--tests/spec/arb_stencil_texturing/draw.c49
2 files changed, 43 insertions, 9 deletions
diff --git a/tests/all.py b/tests/all.py
index 93d64e687..4a3ae4010 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1845,7 +1845,8 @@ with profile.group_manager(
with profile.group_manager(
PiglitGLTest,
grouptools.join('spec', 'ARB_stencil_texturing')) as g:
- g(['arb_stencil_texturing-draw'], 'draw')
+ g(['arb_stencil_texturing-draw'], 'texture')
+ g(['arb_stencil_texturing-draw'], 'texelFetch')
with profile.group_manager(
PiglitGLTest,
diff --git a/tests/spec/arb_stencil_texturing/draw.c b/tests/spec/arb_stencil_texturing/draw.c
index fa6ea42f0..9353240c8 100644
--- a/tests/spec/arb_stencil_texturing/draw.c
+++ b/tests/spec/arb_stencil_texturing/draw.c
@@ -223,8 +223,9 @@ setup_textures(void)
* separate shaders.
*/
static void
-setup_shaders(void)
+setup_shaders(const char *tex_func)
{
+ char *fs;
int loc;
const char *vs =
@@ -236,42 +237,74 @@ setup_shaders(void)
" texcoords = (gl_Vertex.xy + 1.0) / 2.0;\n"
"}\n";
- const char *fs_stencil =
+ const char *fs_stencil_tmpl =
"#version 130\n"
"in vec2 texcoords;\n"
+ "ivec2 texelcoords;\n"
"uniform usampler2D tex;\n"
"void main()\n"
"{\n"
- " uint stencil = texture(tex, texcoords).x;\n"
+ " texelcoords[0] = int(texcoords[0] * 256);\n"
+ " texelcoords[1] = int(texcoords[1] * 256);\n"
+ " uint stencil = %s.x;\n"
" gl_FragColor = vec4(float(stencil) / 255.0, 0, 0, 1);\n"
"}\n";
- const char *fs_depth =
+ const char *fs_depth_tmpl =
"#version 130\n"
"in vec2 texcoords;\n"
+ "ivec2 texelcoords;\n"
"uniform sampler2D tex;\n"
"void main()\n"
"{\n"
- " float depth = texture(tex, texcoords).x;\n"
+ " texelcoords[0] = int(texcoords[0] * 256);\n"
+ " texelcoords[1] = int(texcoords[1] * 256);\n"
+ " float depth = %s.x;\n"
" gl_FragColor = vec4(0, depth, 0, 1);\n"
"}\n";
- stencil_prog = piglit_build_simple_program(vs, fs_stencil);
+ asprintf(&fs, fs_stencil_tmpl, tex_func);
+ stencil_prog = piglit_build_simple_program(vs, fs);
+ free(fs);
loc = glGetUniformLocation(stencil_prog, "tex");
glUseProgram(stencil_prog);
glUniform1i(loc, 0);
- depth_prog = piglit_build_simple_program(vs, fs_depth);
+ asprintf(&fs, fs_depth_tmpl, tex_func);
+ depth_prog = piglit_build_simple_program(vs, fs);
+ free(fs);
loc = glGetUniformLocation(depth_prog, "tex");
glUseProgram(depth_prog);
glUniform1i(loc, 0);
}
+static const char *
+parse_args(int argc, char **argv)
+{
+ if (argc != 2) {
+ printf("Usage: %s <tex_func>\n"
+ " where <tex_func> is a glsl texture function:\n"
+ " texture\n"
+ " texelFetch\n",
+ argv[0]);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ if (strcmp(argv[1], "texture") == 0)
+ return "texture(tex, texcoords)";
+
+ if (strcmp(argv[1], "texelFetch") == 0)
+ return "texelFetch(tex, texelcoords, 0)";
+
+ printf("%s is not supported\n", argv[1]);
+ piglit_report_result(PIGLIT_FAIL);
+}
+
void
piglit_init(int argc, char **argv)
{
piglit_require_extension("GL_ARB_stencil_texturing");
setup_textures();
- setup_shaders();
+ setup_shaders(parse_args(argc, argv));
}