[Piglit] [PATCH 2/2] query_renderer: Add test that compares values from glXQueryRendererIntegerMESA et al

Paul Berry stereotype441 at gmail.com
Mon Nov 11 13:57:48 PST 2013


On 25 October 2013 11:13, Ian Romanick <idr at freedesktop.org> wrote:

> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Verifies that all values from glXQueryRendererIntegerMESA,
> glXQueryCurrentRendererIntegerMESA, glXQueryRendererStringMESA, and
> glXQueryCurrentRendererStringMESA can be queried.  It also verifies that
> each of the Current and non-Current versions returns the same value for
> each query.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> This test currently fails on Mesa master with the
> GLX_MESA_query_renderer patches on the mesa-dev list.  It appears that
> Adam's d101204 commit breaks some calls to glXMakeContextCurrent.  I'm
> tracking down the root cause of that problem now.  With that patch
> reverted, everything here passes.
>
>  tests/all.tests                                    |   4 +
>  tests/spec/CMakeLists.txt                          |   1 +
>  .../spec/glx_mesa_query_renderer/CMakeLists.gl.txt |  28 +++
>  tests/spec/glx_mesa_query_renderer/CMakeLists.txt  |   1 +
>  tests/spec/glx_mesa_query_renderer/coverage.c      | 275
> +++++++++++++++++++++
>  5 files changed, 309 insertions(+)
>  create mode 100644 tests/spec/glx_mesa_query_renderer/CMakeLists.gl.txt
>  create mode 100644 tests/spec/glx_mesa_query_renderer/CMakeLists.txt
>  create mode 100644 tests/spec/glx_mesa_query_renderer/coverage.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index e5e63e4..1d2a916 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -468,6 +468,10 @@ oml_sync_control['swapbuffersmsc-return swap_interval
> 0'] = concurrent_test('glx
>  oml_sync_control['swapbuffersmsc-return swap_interval 1'] =
> concurrent_test('glx-oml-sync-control-swapbuffersmsc-return 1')
>  oml_sync_control['waitformsc'] =
> concurrent_test('glx-oml-sync-control-waitformsc')
>
> +mesa_query_renderer = Group()
> +glx['GLX_MESA_query_renderer'] = mesa_query_renderer
> +mesa_query_renderer['coverage'] =
> concurrent_test('glx-query-renderer-coverage')
> +
>  def texwrap_test(args):
>      test = PlainExecTest(['texwrap', '-fbo', '-auto'] + args)
>      test.runConcurrent = True
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index 18b846d..a2903d8 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -77,6 +77,7 @@ add_subdirectory (gles-2.0)
>  add_subdirectory (gles-3.0)
>  add_subdirectory (glx_arb_create_context)
>  add_subdirectory (glx_ext_import_context)
> +add_subdirectory (glx_mesa_query_renderer)
>  add_subdirectory (glx_oml_sync_control)
>  add_subdirectory (arb_vertex_type_2_10_10_10_rev)
>  add_subdirectory (ext_texture_array)
> diff --git a/tests/spec/glx_mesa_query_renderer/CMakeLists.gl.txt
> b/tests/spec/glx_mesa_query_renderer/CMakeLists.gl.txt
> new file mode 100644
> index 0000000..f51ceff
> --- /dev/null
> +++ b/tests/spec/glx_mesa_query_renderer/CMakeLists.gl.txt
> @@ -0,0 +1,28 @@
> +
> +include_directories(
> +       ${GLEXT_INCLUDE_DIR}
> +       ${OPENGL_INCLUDE_PATH}
> +)
> +
> +if(PIGLIT_BUILD_GLX_TESTS)
> +    link_libraries (
> +        piglitglxutil
> +    )
> +endif(PIGLIT_BUILD_GLX_TESTS)
> +
> +link_libraries (
> +       ${OPENGL_gl_LIBRARY}
> +       ${OPENGL_glu_LIBRARY}
> +)
> +
> +IF(PIGLIT_BUILD_GLX_TESTS)
> +       include_directories(
> +               ${GLPROTO_INCLUDE_DIRS}
> +       )
> +       link_libraries (
> +               ${X11_X11_LIB}
> +       )
> +       piglit_add_executable (glx-query-renderer-coverage coverage.c
> query-renderer-common.c)
> +ENDIF(PIGLIT_BUILD_GLX_TESTS)
> +
> +# vim: ft=cmake:
> diff --git a/tests/spec/glx_mesa_query_renderer/CMakeLists.txt
> b/tests/spec/glx_mesa_query_renderer/CMakeLists.txt
> new file mode 100644
> index 0000000..144a306
> --- /dev/null
> +++ b/tests/spec/glx_mesa_query_renderer/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/spec/glx_mesa_query_renderer/coverage.c
> b/tests/spec/glx_mesa_query_renderer/coverage.c
> new file mode 100644
> index 0000000..2f5367c
> --- /dev/null
> +++ b/tests/spec/glx_mesa_query_renderer/coverage.c
> @@ -0,0 +1,275 @@
> +/* Copyright © 2013 Intel Corporation
> + *
> + * 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.
> + */
> +#include "piglit-util-gl-common.h"
> +#include "piglit-glx-util.h"
> +#include "query-renderer-common.h"
> +
> +struct test_vector {
> +       const char *name_string;
> +       int attribute;
> +       int value_count;
> +};
> +
> +#define ENUM(name, count) { # name, name, count }
> +
> +static const struct test_vector all_valid_integer_enums[] = {
> +        ENUM(GLX_RENDERER_VENDOR_ID_MESA, 1),
> +        ENUM(GLX_RENDERER_DEVICE_ID_MESA, 1),
> +        ENUM(GLX_RENDERER_VERSION_MESA, 3),
> +        ENUM(GLX_RENDERER_ACCELERATED_MESA, 1),
> +        ENUM(GLX_RENDERER_VIDEO_MEMORY_MESA, 1),
> +        ENUM(GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA, 1),
> +        ENUM(GLX_RENDERER_PREFERRED_PROFILE_MESA, 1),
> +        ENUM(GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA, 2),
> +        ENUM(GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA, 2),
> +        ENUM(GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA, 2),
> +        ENUM(GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA, 2),
> +};
> +
> +static const struct test_vector all_valid_string_enums[] = {
> +        ENUM(GLX_RENDERER_VENDOR_ID_MESA, 0),
> +        ENUM(GLX_RENDERER_DEVICE_ID_MESA, 0),
> +};
> +
> +static bool
> +verify_integer_values(const char *name, Bool success,
> +                     const struct test_vector *test,
> +                     const unsigned *buffer, unsigned buffer_size,
> +                     bool silent)
> +{
> +       char text[512];
> +       unsigned text_size;
> +       bool pass = true;
> +       unsigned j;
> +
> +       if (!success) {
> +               fprintf(stderr, "%s(%s) failed.\n", name,
> test->name_string);
> +
> +               /* If the call failed, don't bother checking that the
> correct
> +                * number of values were written.
> +                */
> +               return false;
> +       }
> +
> +       if (!silent) {
> +               text_size = snprintf(text, sizeof(text), "%s(%s) values:\n
>    ",
> +                                    name,
> +                                    test->name_string);
> +               for (j = 0; j < test->value_count; j++) {
> +                       text_size += snprintf(&text[text_size],
> +                                             sizeof(text) - text_size,
> +                                             "%d ",
> +                                             buffer[j]);
> +               }
> +
> +               printf("%s\n", text);
> +       }
> +
> +       for (j = 0; j < test->value_count; j++) {
> +               if (buffer[j] == 0xDEADBEEF) {
> +                       fprintf(stderr,
> +                               "%s(%s) only wrote %d values, expected
> %d.\n",
> +                               name,
> +                               test->name_string,
> +                               j + 1,
>

This should just be "j".


> +                               test->value_count);
> +                       pass = false;
> +                       break;
> +               }
> +       }
> +
> +       for (j = test->value_count; j < buffer_size; j++) {
> +               if (buffer[j] != 0xDEADBEEF) {
> +                       fprintf(stderr,
> +                               "%s(%s) only wrote %d values, expected
> %d.\n",
> +                               name,
> +                               test->name_string,
> +                               j + 1,
> +                               test->value_count);
>

This is a misleading message, since you're not actually measuring the
number of values that got written--you're just checking whether the values
that *shouldn't* have been written are preserved.  How about printf("%s(%s)
wrote more than %d values.", ..., test->value_count)?


> +                       pass = false;
> +                       break;
> +               }
> +       }
>

Alternatively, you might want to consider restructuring this code so that
it measures the number of values that got written, and then displays an
error if that value doesn't equal test->value_count.


> +
> +       return pass;
> +}
>

With that addressed, this patch is:

Reviewed-by: Paul Berry <stereotype441 at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20131111/883618e3/attachment-0001.html>


More information about the Piglit mailing list