CC: Eric Anholt <e...@anholt.net> CC: Kenneth Graunke <kenn...@whitecape.org> Signed-off-by: Topi Pohjolainen <topi.pohjolai...@intel.com> --- tests/all.py | 5 +++- tests/spec/arb_stencil_texturing/draw.c | 49 +++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 9 deletions(-)
diff --git a/tests/all.py b/tests/all.py index 08e8062..ccf1a5e 100644 --- a/tests/all.py +++ b/tests/all.py @@ -1491,7 +1491,10 @@ import_glsl_parser_tests(spec['ARB_shader_stencil_export'], os.path.join(testsDir, 'spec', 'arb_shader_stencil_export'), ['']) -profile.test_list['spec/ARB_stencil_texturing/draw'] = concurrent_test('arb_stencil_texturing-draw') +stencil_texturing = Group() +spec['ARB_stencil_texturing'] = stencil_texturing +add_concurrent_test(stencil_texturing, 'arb_stencil_texturing-draw texture') +add_concurrent_test(stencil_texturing, 'arb_stencil_texturing-draw texelFetch') # Group ARB_sync arb_sync = Group() diff --git a/tests/spec/arb_stencil_texturing/draw.c b/tests/spec/arb_stencil_texturing/draw.c index 59c9e65..173a982 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,37 +237,69 @@ 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) { @@ -274,5 +307,5 @@ piglit_init(int argc, char **argv) piglit_require_GLSL_version(130); /* for usampler2D */ setup_textures(); - setup_shaders(); + setup_shaders(parse_args(argc, argv)); } -- 1.8.3.1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit