From: Ian Romanick <ian.d.roman...@intel.com> All of the tests for this extension will require a bunch of function pointers, etc. This patch adds a function to get these function pointers and some macros to wrap calls using them.
Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> --- .../query-renderer-common.c | 70 +++++++++++++++++++++ .../query-renderer-common.h | 72 ++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 tests/spec/glx_mesa_query_renderer/query-renderer-common.c create mode 100644 tests/spec/glx_mesa_query_renderer/query-renderer-common.h diff --git a/tests/spec/glx_mesa_query_renderer/query-renderer-common.c b/tests/spec/glx_mesa_query_renderer/query-renderer-common.c new file mode 100644 index 0000000..429f360 --- /dev/null +++ b/tests/spec/glx_mesa_query_renderer/query-renderer-common.c @@ -0,0 +1,70 @@ +/* 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" + +PFNGLXQUERYRENDERERSTRINGMESAPROC __piglit_glXQueryRendererStringMESA = NULL; +PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC __piglit_glXQueryCurrentRendererStringMESA = NULL; +PFNGLXQUERYRENDERERINTEGERMESAPROC __piglit_glXQueryRendererIntegerMESA = NULL; +PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC __piglit_glXQueryCurrentRendererIntegerMESA = NULL; +PFNGLXCREATECONTEXTATTRIBSARBPROC __piglit_glXCreateContextAttribsARB = NULL; + +static void * +get_and_verify_proc(const char *name) +{ + void *func; + + func = glXGetProcAddress((GLubyte *) name); + if (func == NULL) { + fprintf(stderr, "Could not get function pointer for %s\n", + name); + piglit_report_result(PIGLIT_FAIL); + } + + return func; +} + +void +initialize_function_pointers(Display *dpy) +{ + piglit_require_glx_extension(dpy, "GLX_MESA_query_renderer"); + + __piglit_glXQueryRendererStringMESA = + (PFNGLXQUERYRENDERERSTRINGMESAPROC) + get_and_verify_proc("glXQueryRendererStringMESA"); + __piglit_glXQueryCurrentRendererStringMESA = + (PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) + get_and_verify_proc("glXQueryCurrentRendererStringMESA"); + __piglit_glXQueryRendererIntegerMESA = + (PFNGLXQUERYRENDERERINTEGERMESAPROC) + get_and_verify_proc("glXQueryRendererIntegerMESA"); + __piglit_glXQueryCurrentRendererIntegerMESA = + (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) + get_and_verify_proc("glXQueryCurrentRendererIntegerMESA"); + + piglit_require_glx_extension(dpy, "GLX_ARB_create_context"); + + __piglit_glXCreateContextAttribsARB = + (PFNGLXCREATECONTEXTATTRIBSARBPROC) + get_and_verify_proc("glXCreateContextAttribsARB"); +} diff --git a/tests/spec/glx_mesa_query_renderer/query-renderer-common.h b/tests/spec/glx_mesa_query_renderer/query-renderer-common.h new file mode 100644 index 0000000..4dc0b0a --- /dev/null +++ b/tests/spec/glx_mesa_query_renderer/query-renderer-common.h @@ -0,0 +1,72 @@ +/* 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. + */ + +#pragma once +#ifndef QUERY_RENDERER_COMMON_H +#define QUERY_RENDERER_COMMON_H + +#ifndef GLX_MESA_query_renderer +#define GLX_MESA_query_renderer 1 + +#define GLX_RENDERER_VENDOR_ID_MESA 0x8183 +#define GLX_RENDERER_DEVICE_ID_MESA 0x8184 +#define GLX_RENDERER_VERSION_MESA 0x8185 +#define GLX_RENDERER_ACCELERATED_MESA 0x8186 +#define GLX_RENDERER_VIDEO_MEMORY_MESA 0x8187 +#define GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA 0x8188 +#define GLX_RENDERER_PREFERRED_PROFILE_MESA 0x8189 +#define GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA 0x818A +#define GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA 0x818B +#define GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA 0x818C +#define GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA 0x818D +#define GLX_RENDERER_ID_MESA 0x818E + +typedef Bool (*PFNGLXQUERYRENDERERINTEGERMESAPROC) (Display *dpy, int screen, int renderer, int attribute, unsigned int *value); +typedef Bool (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value); +typedef const char *(*PFNGLXQUERYRENDERERSTRINGMESAPROC) (Display *dpy, int screen, int renderer, int attribute); +typedef const char *(*PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) (int attribute); +#endif /* GLX_MESA_query_renderer */ + +PFNGLXQUERYRENDERERSTRINGMESAPROC __piglit_glXQueryRendererStringMESA; +PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC __piglit_glXQueryCurrentRendererStringMESA; +PFNGLXQUERYRENDERERINTEGERMESAPROC __piglit_glXQueryRendererIntegerMESA; +PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC __piglit_glXQueryCurrentRendererIntegerMESA; +PFNGLXCREATECONTEXTATTRIBSARBPROC __piglit_glXCreateContextAttribsARB; + +#define glXQueryRendererStringMESA(dpy, screen, renderer, attribute) \ + (*__piglit_glXQueryRendererStringMESA)(dpy, screen, renderer, attribute) + +#define glXQueryCurrentRendererStringMESA(attribute) \ + (*__piglit_glXQueryCurrentRendererStringMESA)(attribute) + +#define glXQueryRendererIntegerMESA(dpy, screen, renderer, attribute, value) \ + (*__piglit_glXQueryRendererIntegerMESA)(dpy, screen, renderer, attribute, value) + +#define glXQueryCurrentRendererIntegerMESA(attribute, value) \ + (*__piglit_glXQueryCurrentRendererIntegerMESA)(attribute, value) + +#define glXCreateContextAttribsARB(dpy, fbconfig, share, direct, attrib) \ + (*__piglit_glXCreateContextAttribsARB)(dpy, fbconfig, share, direct, attrib) + +void initialize_function_pointers(Display *); + +#endif /* QUERY_RENDERER_COMMON_H */ -- 1.8.1.4 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit