[Piglit] [PATCH v2] miptree: test ability to use upside down miptree

Mark Janes mark.a.janes at intel.com
Mon Dec 3 18:01:55 UTC 2018


It's preferable to push piglit tests first, and produce the CI test
failure.  CI staff will track the failure, and attribute it to the
piglit patch.  When the subsequent mesa patch is pushed, we track the
resolution.  The process gives us artifacts in git that help to analyze
driver differences between stable releases.

-Mark

andrey simiklit <asimiklit.work at gmail.com> writes:

> Hello,
>
> If this patch is acceptable by everybody then
> I guess that we need to push the following mesa patch before this one
> to avoid errors from Intel CI because the fix for an issue which is tested
> by this test is still there.
>
> https://patchwork.freedesktop.org/patch/254397/
> One of the last comment from Kenneth Graunke <kenneth at whitecape.org>:
>
>>    ".................
>>     So, back to Reviewed-by.  I think once we get a Piglit test, I'm happy
>>     to land this patch.
>>
>>    --Ken"
>>
>
> Thanks,
> Andrii.
>
> On Mon, Dec 3, 2018 at 5:07 PM <asimiklit.work at gmail.com> wrote:
>
>> From: Andrii Simiklit <andrii.simiklit at globallogic.com>
>>
>> Test that usage of upside down miptree doesn't cause assertion
>>
>> The miptree:
>>
>> level 0 = 1x1
>> level 1 = 2x2
>> level 2 = 4x4
>> ...
>> level n = NxN
>>
>> should be acceptable for case when we don't use a min filter.
>>
>> v2: - Unnecessary function calls were removed
>>     - The 'glClearColor' call was moved to 'piglit_display' function
>>     - The program creation was moved to 'piglit_init' function
>>     - The requirements check was moved to 'piglit_init' function
>>                ( Erik Faye-Lund <erik.faye-lund at collabora.com> )
>>
>>     - Fixed a leak of texture which is created in 'setup_texture'
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107987
>> Signed-off-by: Andrii Simiklit <andrii.simiklit at globallogic.com>
>> Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
>> ---
>>  tests/opengl.py                           |   1 +
>>  tests/texturing/CMakeLists.gl.txt         |   1 +
>>  tests/texturing/tex-upside-down-miptree.c | 171 ++++++++++++++++++++++
>>  3 files changed, 173 insertions(+)
>>  create mode 100644 tests/texturing/tex-upside-down-miptree.c
>>
>> diff --git a/tests/opengl.py b/tests/opengl.py
>> index f7e408cd5..f6a38e40e 100644
>> --- a/tests/opengl.py
>> +++ b/tests/opengl.py
>> @@ -704,6 +704,7 @@ with profile.test_list.group_manager(
>>      g(['getteximage-targets', '1D'])
>>      g(['getteximage-targets', '2D'])
>>      g(['teximage-scale-bias'])
>> +    g(['tex-upside-down-miptree'])
>>      add_msaa_visual_plain_tests(g, ['draw-pixels'])
>>      add_msaa_visual_plain_tests(g, ['read-front'], run_concurrent=False)
>>      add_msaa_visual_plain_tests(g, ['read-front', 'clear-front-first'],
>> diff --git a/tests/texturing/CMakeLists.gl.txt
>> b/tests/texturing/CMakeLists.gl.txt
>> index e5d41e432..02b572c79 100644
>> --- a/tests/texturing/CMakeLists.gl.txt
>> +++ b/tests/texturing/CMakeLists.gl.txt
>> @@ -98,5 +98,6 @@ piglit_add_executable (texture-al texture-al.c)
>>  piglit_add_executable (texture-rg texture-rg.c)
>>  piglit_add_executable (teximage-colors teximage-colors.c)
>>  piglit_add_executable (zero-tex-coord zero-tex-coord.c)
>> +piglit_add_executable (tex-upside-down-miptree tex-upside-down-miptree.c)
>>
>>  # vim: ft=cmake:
>> diff --git a/tests/texturing/tex-upside-down-miptree.c
>> b/tests/texturing/tex-upside-down-miptree.c
>> new file mode 100644
>> index 000000000..8e8f7154b
>> --- /dev/null
>> +++ b/tests/texturing/tex-upside-down-miptree.c
>> @@ -0,0 +1,171 @@
>> +/*
>> + * Copyright (c) 2018 Andrii Simiklit
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the
>> "Software"),
>> + * to deal in the Software without restriction, including without
>> limitation
>> + * the rights to use, copy, modify, merge, publish, distribute,
>> sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the
>> next
>> + * paragraph) shall be included in all copies or substantial portions of
>> the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>> EXPRESS OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
>> SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
>> OTHER
>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
>> DEALINGS
>> + * IN THE SOFTWARE.
>> + *
>> + * Authors:
>> + *    Andrii Simiklit <asimiklit.work at gmail.com>
>> + *
>> + */
>> +
>> +/**
>> + * Test what there no an assertion when we use upside down miptree and
>> + * GL_TEXTURE_MIN_FILTER is GL_LINEAR, base level is not 0
>> + * Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107987
>> + */
>> +
>> +#include "piglit-util-gl.h"
>> +#define TW 64
>> +#define TH 64
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +
>> +       config.supports_gl_compat_version = 10;
>> +
>> +       config.window_visual = PIGLIT_GL_VISUAL_RGBA |
>> PIGLIT_GL_VISUAL_DOUBLE;
>> +       config.khr_no_error_support = PIGLIT_NO_ERRORS;
>> +
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +GLuint prog = 0;
>> +GLuint texture = 0;
>> +static unsigned nlevels = 0;
>> +static const char *fragShaderText =
>> +       "uniform sampler2D tex;\n"
>> +       "void main()\n"
>> +       "{\n"
>> +       "   gl_FragColor = texture2D(tex, gl_TexCoord[0].xy).rgba;\n"
>> +       "}\n";
>> +
>> +static void
>> +get_rect_bounds(int pos, int *x, int *y, int *w, int *h)
>> +{
>> +       *x = pos * (piglit_width / 3) + 5;
>> +       *y = 5;
>> +       *w = piglit_width / 3 - 10;
>> +       *h = piglit_height - 10;
>> +}
>> +
>> +
>> +static void
>> +draw_rect(int pos)
>> +{
>> +       int x, y, w, h;
>> +       get_rect_bounds(pos, &x, &y, &w, &h);
>> +       piglit_draw_rect_tex(x, y, w, h, 0, 0, 1, 1);
>> +}
>> +
>> +
>> +static GLboolean
>> +probe_pos(int pos, const GLfloat expected[4])
>> +{
>> +       int x, y, w, h;
>> +       get_rect_bounds(pos, &x, &y, &w, &h);
>> +       return piglit_probe_rect_rgba(x, y, w, h, expected);
>> +}
>> +
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> +       GLboolean pass = GL_TRUE;
>> +       unsigned level;
>> +       const GLfloat oneby255 = (1.0 / 255.0);
>> +       const GLfloat expected[4] = { oneby255 * 255.0,
>> +
>>              oneby255 * 128.0,
>> +
>>              oneby255 * 64.0,
>> +
>>              oneby255 * 32.0 };
>> +       GLint tex;
>> +       int pos = 0;
>> +
>> +       glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
>> +       piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
>> +       glUseProgram(prog);
>> +       tex = glGetUniformLocation(prog, "tex");
>> +       glUniform1i(tex, 0);
>> +
>> +       for(level = 1; level < nlevels && pass; ++level)
>> +       {
>> +               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL,
>> level);
>> +               glClear(GL_COLOR_BUFFER_BIT);
>> +               /* If we the draw_rect function doesn't cause
>> crash/assertion
>> +               * it means everything is okay and test will be marked
>> +               * as pass
>> +               */
>> +               draw_rect(pos);
>> +               /** Just in case we check it
>> +                */
>> +               pass = pass && probe_pos(pos, expected);
>> +       }
>> +
>> +       glUseProgram(0);
>> +       glDeleteProgram(prog);
>> +       glDeleteTextures(1, &texture);
>> +       piglit_present_results();
>> +
>> +       return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>> +}
>> +
>> +
>> +static void
>> +setup_texture(void)
>> +{
>> +       GLubyte img[TH][TW][4];
>> +       int i, j, w, h;
>> +
>> +       for (i = 0; i < TH; i++) {
>> +               for (j = 0; j < TW; j++) {
>> +                       img[i][j][0] = 255;
>> +                       img[i][j][1] = 128;
>> +                       img[i][j][2] = 64;
>> +                       img[i][j][3] = 32;
>> +               }
>> +       }
>> +
>> +       /* make an abnormal upside down miptree
>> +        */
>> +       glGenTextures(1, &texture);
>> +       glBindTexture(GL_TEXTURE_2D, texture);
>> +       w = TW;
>> +       h = TH;
>> +       for (nlevels = 0; w > 0 && h > 0; nlevels++) {
>> +               w /= 2;
>> +               h /= 2;
>> +       }
>> +       w = TW;
>> +       h = TH;
>> +       for (i = 0; w > 0 && h > 0; i++) {
>> +               glTexImage2D(GL_TEXTURE_2D, nlevels - 1 - i, GL_RGBA, w,
>> h, 0,
>> +                            GL_RGBA, GL_UNSIGNED_BYTE, img);
>> +               w /= 2;
>> +               h /= 2;
>> +       }
>> +
>> +       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
>> +}
>> +
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> +       piglit_require_GLSL_version(110);
>> +       prog = piglit_build_simple_program(NULL, fragShaderText);
>> +       setup_texture();
>> +}
>> --
>> 2.17.1
>>
>>


More information about the Piglit mailing list