diff options
author | Topi Pohjolainen <topi.pohjolainen@intel.com> | 2014-02-19 11:32:25 +0200 |
---|---|---|
committer | Topi Pohjolainen <topi.pohjolainen@intel.com> | 2016-05-19 23:35:59 +0300 |
commit | 1e38407baefb1e2fda9c6aa09eb47d9da8c760a4 (patch) | |
tree | 9de9e7ea37e4a71492e097958f3d47d02f3b447c | |
parent | 1cc4003d3d1d90746be03820696406c125a06772 (diff) |
stencil_texturing: Allow testing of texelFetch also
CC: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
-rw-r--r-- | tests/all.py | 3 | ||||
-rw-r--r-- | tests/spec/arb_stencil_texturing/draw.c | 49 |
2 files changed, 43 insertions, 9 deletions
diff --git a/tests/all.py b/tests/all.py index e804891bf..b5d5f63ba 100644 --- a/tests/all.py +++ b/tests/all.py @@ -1847,7 +1847,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'], 'draw-texture') + g(['arb_stencil_texturing-draw', 'texelFetch'], '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)); } |