[Piglit] [PATCH] texwrap: minor assorted changes
Marek Olšák
maraeo at gmail.com
Mon Jul 14 12:39:27 PDT 2014
By removing offset++, you left some empty if statements in there.
Other than that:
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Mon, Jul 14, 2014 at 4:37 PM, Brian Paul <brianp at vmware.com> wrote:
> Always draw a (mode, filter) test pattern at the same window position,
> regardless of border mode, supported, etc. This makes it a little
> easier to do visual inspections.
>
> In non-auto mode, print names of wrap modes to help identify the
> test patterns. Ideally, we'd print this in the window instead of
> the terminal but piglit doesn't have a text-drawing feature.
> ---
> tests/texturing/texwrap.c | 53 ++++++++++++++++++++++++---------------------
> 1 file changed, 28 insertions(+), 25 deletions(-)
>
> diff --git a/tests/texturing/texwrap.c b/tests/texturing/texwrap.c
> index 383681e..21e49ac 100644
> --- a/tests/texturing/texwrap.c
> +++ b/tests/texturing/texwrap.c
> @@ -807,11 +807,25 @@ static GLboolean skip_test(GLenum mode, GLenum filter)
> return test_border_color;
> }
>
> +/**
> + * For a given wrap mode index, filter mode index and npot flag, return
> + * the (x,y) position for drawing the test pattern.
> + */
> +static void
> +test_to_xy(unsigned mode, unsigned filter, unsigned npot, int *x, int *y)
> +{
> + assert(mode < ARRAY_SIZE(wrap_modes));
> + assert(filter < 2);
> + assert(npot < 2);
> + *x = mode * (TILE_SIZE(npot) + TILE_SPACE) + 5;
> + *y = filter * (TILE_SIZE(npot) + TILE_SPACE) + 35;
> +}
> +
> +
> static void draw(const struct format_desc *format,
> GLboolean npot, GLboolean texproj)
> {
> unsigned i, j;
> - int offset;
> int num_filters = format->type == FLOAT_TYPE ? 2 : 1;
> int bits = get_int_format_bits(format);
> float scale[4];
> @@ -840,13 +854,12 @@ static void draw(const struct format_desc *format,
> for (i = 0; i < num_filters; i++) {
> GLenum filter = i ? GL_LINEAR : GL_NEAREST;
>
> - offset = 0;
> -
> glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, filter);
> glTexParameteri(texture_target, GL_TEXTURE_MAG_FILTER, filter);
>
> /* Loop over wrap modes. */
> for (j = 0; wrap_modes[j].mode != 0; j++) {
> + int xpos, ypos;
> float x0 = 0;
> float y0 = 0;
> float x1 = TILE_SIZE(npot);
> @@ -858,13 +871,13 @@ static void draw(const struct format_desc *format,
> float q = 1;
> float ts0 = s0, ts1 = s1, tt0 = t0, tt1 = t1, tr = 0.5;
>
> - if (!wrap_modes[j].supported)
> + if (!wrap_modes[j].supported) {
> continue;
> + }
>
> if (skip_test(wrap_modes[j].mode, filter)) {
> if (skip_test(wrap_modes[j].mode, GL_LINEAR) !=
> skip_test(wrap_modes[j].mode, GL_NEAREST)) {
> - offset++;
> }
> continue;
> }
> @@ -895,10 +908,8 @@ static void draw(const struct format_desc *format,
> wrap_modes[j].mode);
>
> glPushMatrix();
> - glTranslatef(offset * (TILE_SIZE(npot) + TILE_SPACE) + 5,
> - i * (TILE_SIZE(npot) + TILE_SPACE) + 35,
> - 0);
> - offset++;
> + test_to_xy(j, i, npot, &xpos, &ypos);
> + glTranslatef(xpos, ypos, 0.0);
>
> glEnable(texture_target);
> glColor3f(1, 1, 1);
> @@ -939,21 +950,14 @@ static void draw(const struct format_desc *format,
>
> glDisable(texture_target);
> glColor3f(1, 1, 1);
> - offset = 0;
>
> if (!piglit_automatic) {
> + printf("modes: ");
> for (i = 0; wrap_modes[i].mode != 0; i++) {
> - if (wrap_modes[i].supported) {
> - if (skip_test(wrap_modes[i].mode, GL_LINEAR) &&
> - skip_test(wrap_modes[i].mode, GL_NEAREST)) {
> - continue;
> - }
> -
> - glWindowPos2iARB(offset * (TILE_SIZE(npot) + TILE_SPACE) + 5,
> - 5 + ((offset & 1) * 15));
> - offset++;
> - }
> + printf("%s, ",
> + piglit_get_gl_enum_name(wrap_modes[i].mode));
> }
> + printf("\n");
> }
> }
>
> @@ -978,7 +982,6 @@ static GLboolean probe_pixels(const struct format_desc *format, GLboolean npot,
> unsigned deltamax[4] = {0};
> unsigned deltamax_swizzled[4] = {0};
> unsigned *deltamax_lut = i ? linear_deltamax : nearest_deltamax;
> - unsigned offset = 0;
>
> /* Get the deltamax for each channel. */
> if (format->intensity) {
> @@ -1012,17 +1015,17 @@ static GLboolean probe_pixels(const struct format_desc *format, GLboolean npot,
> /* Loop over all wrap modes. */
> for (j = 0; wrap_modes[j].mode != 0; j++) {
> unsigned char expected[4];
> - int x0 = offset * (TILE_SIZE(npot) + TILE_SPACE) + 5;
> - int y0 = i * (TILE_SIZE(npot) + TILE_SPACE) + 35;
> + int x0, y0;
> int a, b;
>
> + test_to_xy(j, i, npot, &x0, &y0);
> +
> if (!wrap_modes[j].supported)
> continue;
>
> if (skip_test(wrap_modes[j].mode, filter)) {
> if (skip_test(wrap_modes[j].mode, GL_LINEAR) !=
> skip_test(wrap_modes[j].mode, GL_NEAREST)) {
> - offset++;
> }
> continue;
> }
> @@ -1047,7 +1050,7 @@ static GLboolean probe_pixels(const struct format_desc *format, GLboolean npot,
> }
>
> tile_done:
> - offset++;
> + ;
> }
> }
>
> --
> 1.7.10.4
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list