2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
23 #include "glxclient.h"
24 #include "glx_error.h"
29 __glXQueryRendererInteger(struct glx_screen *psc, int attribute,
32 unsigned int values_for_query = 0;
33 unsigned int buffer[32];
36 /* This probably means the caller is trying to use an extension function
37 * that isn't actually supported.
39 if (psc->vtable->query_renderer_integer == NULL)
43 case GLX_RENDERER_VENDOR_ID_MESA:
44 case GLX_RENDERER_DEVICE_ID_MESA:
47 case GLX_RENDERER_VERSION_MESA:
50 case GLX_RENDERER_ACCELERATED_MESA:
51 case GLX_RENDERER_VIDEO_MEMORY_MESA:
52 case GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA:
53 case GLX_RENDERER_PREFERRED_PROFILE_MESA:
56 case GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA:
57 case GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA:
58 case GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA:
59 case GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA:
67 err = psc->vtable->query_renderer_integer(psc, attribute, buffer);
69 /* If there was no error, copy the correct number of values from the driver
70 * out to the application.
73 memcpy(value, buffer, sizeof(unsigned int) * values_for_query);
79 glXQueryRendererIntegerMESA(Display *dpy, int screen,
80 int renderer, int attribute,
83 struct glx_screen *psc;
88 /* This probably means the caller passed the wrong display pointer or
91 psc = GetGLXScreenConfigs(dpy, screen);
95 /* Right now only a single renderer per display / screen combination is
101 return __glXQueryRendererInteger(psc, attribute, value);
105 glXQueryCurrentRendererIntegerMESA(int attribute, unsigned int *value)
107 struct glx_context *gc = __glXGetCurrentContext();
112 return __glXQueryRendererInteger(gc->psc, attribute, value);
116 __glXQueryRendererString(struct glx_screen *psc, int attribute)
121 /* This probably means the caller is trying to use an extension function
122 * that isn't actually supported.
124 if (psc->vtable->query_renderer_integer == NULL)
128 case GLX_RENDERER_VENDOR_ID_MESA:
129 case GLX_RENDERER_DEVICE_ID_MESA:
135 err = psc->vtable->query_renderer_string(psc, attribute, &value);
136 return (err == 0) ? value : NULL;
139 _X_HIDDEN const char *
140 glXQueryRendererStringMESA(Display *dpy, int screen,
141 int renderer, int attribute)
143 struct glx_screen *psc;
148 /* This probably means the caller passed the wrong display pointer or
151 psc = GetGLXScreenConfigs(dpy, screen);
155 /* Right now only a single renderer per display / screen combination is
161 return __glXQueryRendererString(psc, attribute);
164 _X_HIDDEN const char *
165 glXQueryCurrentRendererStringMESA(int attribute)
167 struct glx_context *gc = __glXGetCurrentContext();
172 return __glXQueryRendererString(gc->psc, attribute);