diff options
author | Topi Pohjolainen <topi.pohjolainen@intel.com> | 2014-03-04 20:14:12 +0200 |
---|---|---|
committer | Topi Pohjolainen <topi.pohjolainen@intel.com> | 2016-04-27 10:16:39 +0300 |
commit | d5a82b0f5fe958284c9d83650dd6676353ca9c3e (patch) | |
tree | d3dd86b63292b878d099be22361e406144e90a96 | |
parent | 31628a9854034f9afd83ab0d63e9bde3fa6e3c4b (diff) |
command line arguments
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
-rw-r--r-- | tests/spec/arb_stencil_texturing/draw_layered_miptree.c | 86 |
1 files changed, 58 insertions, 28 deletions
diff --git a/tests/spec/arb_stencil_texturing/draw_layered_miptree.c b/tests/spec/arb_stencil_texturing/draw_layered_miptree.c index cc3246cbe..cab123739 100644 --- a/tests/spec/arb_stencil_texturing/draw_layered_miptree.c +++ b/tests/spec/arb_stencil_texturing/draw_layered_miptree.c @@ -39,21 +39,24 @@ #include <inttypes.h> #include "piglit-util-gl-common.h" -#define TEX_BASE_WIDTH 256 -#define TEX_BASE_HEIGHT 256 -#define NUM_LEVELS 8 +#define MAX_TEX_BASE_WIDTH 256 +#define MAX_TEX_BASE_HEIGHT 256 +#define MAX_NUM_LEVELS 8 #define BORDER_WIDTH 2 PIGLIT_GL_TEST_CONFIG_BEGIN config.supports_gl_compat_version = 20; config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE; - config.window_width = TEX_BASE_WIDTH * 2 + BORDER_WIDTH; - config.window_height = TEX_BASE_HEIGHT * 2 + - (NUM_LEVELS - 1) * BORDER_WIDTH; + config.window_width = MAX_TEX_BASE_WIDTH * 2 + BORDER_WIDTH; + config.window_height = MAX_TEX_BASE_HEIGHT * 2 + + (MAX_NUM_LEVELS - 1) * BORDER_WIDTH; PIGLIT_GL_TEST_CONFIG_END +unsigned tex_width; +unsigned tex_height; +unsigned num_levels; int loc_level; int loc_layer; int loc_width; @@ -65,7 +68,7 @@ get_level_draw_offset(unsigned level) unsigned offset = 0; while (level--) - offset += ((TEX_BASE_HEIGHT >> level) + BORDER_WIDTH); + offset += ((MAX_TEX_BASE_HEIGHT >> level) + BORDER_WIDTH); return offset; } @@ -74,8 +77,8 @@ static bool draw_level_and_probe(unsigned level) { const unsigned y = get_level_draw_offset(level); - const unsigned w = TEX_BASE_WIDTH >> level; - const unsigned h = TEX_BASE_HEIGHT >> level; + const unsigned w = tex_width >> level; + const unsigned h = tex_height >> level; float *horiz_expected = calloc(w * h, 3 * sizeof(float)); float *vert_expected = calloc(w * h, 3 * sizeof(float)); bool pass = true; @@ -101,10 +104,10 @@ draw_level_and_probe(unsigned level) } glUniform1i(loc_layer, 1); - glViewport(TEX_BASE_WIDTH + BORDER_WIDTH, y, w, h); + glViewport(MAX_TEX_BASE_WIDTH + BORDER_WIDTH, y, w, h); piglit_draw_rect(-1, -1, 2, 2); - if (!piglit_probe_image_rgb(TEX_BASE_WIDTH + BORDER_WIDTH, y, w, h, - vert_expected)) { + if (!piglit_probe_image_rgb(MAX_TEX_BASE_WIDTH + BORDER_WIDTH, y, + w, h, vert_expected)) { printf(" FAIL: (level %u, layer 1).\n", level); pass = false; } @@ -119,12 +122,12 @@ enum piglit_result piglit_display(void) { unsigned i; - bool pass; + bool pass = true; glClearColor(0.0, 0.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); - for (i = 0; i < NUM_LEVELS; ++i) + for (i = 0; i < num_levels; ++i) pass = draw_level_and_probe(i) && pass; piglit_present_results(); @@ -135,11 +138,11 @@ piglit_display(void) /******************************************************************************/ static void -setup_texture(void) +setup_texture(unsigned w, unsigned h) { GLuint tex = piglit_depth_texture(GL_TEXTURE_2D_ARRAY, GL_DEPTH24_STENCIL8, - 256, 256, 2, GL_TRUE, + w, h, 2, GL_TRUE, DEPTH_GRAD_X, DEPTH_GRAD_X); if (!piglit_check_gl_error(GL_NO_ERROR)) piglit_report_result(PIGLIT_FAIL); @@ -200,11 +203,12 @@ setup_shader(const char *tex_func) glUniform1i(loc, 0); } -static const char * -parse_args(int argc, char **argv) +void +parse_args(int argc, char **argv, + unsigned *w, unsigned *h, unsigned *n, const char **f) { - if (argc != 2) { - printf("Usage: %s <tex_func>\n" + if (argc != 5) { + printf("Usage: %s <width> <height> <num_levels> <tex_func>\n" " where <tex_func> is a glsl texture function:\n" " texture\n" " texelFetch\n", @@ -212,23 +216,49 @@ parse_args(int argc, char **argv) piglit_report_result(PIGLIT_FAIL); } - if (strcmp(argv[1], "texture") == 0) - return "texture(tex, texcoords)"; + *w = strtoul(argv[1], NULL, 0); + if (!*w || *w > MAX_TEX_BASE_WIDTH) { + printf("invalid width=%u [1,%u]\n", *w, MAX_TEX_BASE_WIDTH); + piglit_report_result(PIGLIT_FAIL); + } - if (strcmp(argv[1], "texelFetch") == 0) - return "texelFetch(tex, texelcoords, level)"; + *h = strtoul(argv[2], NULL, 0); + if (!*h || *h > MAX_TEX_BASE_HEIGHT) { + printf("invalid height=%u [1,%u]\n", *h, MAX_TEX_BASE_HEIGHT); + piglit_report_result(PIGLIT_FAIL); + } - printf("%s is not supported\n", argv[1]); - piglit_report_result(PIGLIT_FAIL); + *n = strtoul(argv[3], NULL, 0); + if (!*n || *n > MAX_NUM_LEVELS) { + printf("invalid width=%u [1,%u]\n", *n, MAX_NUM_LEVELS); + piglit_report_result(PIGLIT_FAIL); + } + + *f = NULL; + if (strcmp(argv[4], "texture") == 0) + *f = "texture(tex, texcoords)"; + + if (strcmp(argv[4], "texelFetch") == 0) + *f = "texelFetch(tex, texelcoords, level)"; + + if (!*f) { + printf("%s is not supported\n", argv[4]); + piglit_report_result(PIGLIT_FAIL); + } } void piglit_init(int argc, char **argv) { + const char *tex_func; + piglit_require_extension("GL_ARB_stencil_texturing"); piglit_require_extension("GL_EXT_texture_array"); piglit_require_GLSL_version(130); /* for usampler2D */ - setup_texture(); - setup_shader(parse_args(argc, argv)); + parse_args(argc, argv, + &tex_width, &tex_height, &num_levels, &tex_func); + + setup_texture(tex_width, tex_height); + setup_shader(tex_func); } |