swrast: Remove unused solve_plane_recip().
[mesa.git] / src / glx / dri2_query_renderer.c
1 /*
2 * Copyright © 2013 Intel Corporation
3 *
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:
10 *
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
13 * Software.
14 *
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.
22 */
23
24 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
25
26 #include "glxclient.h"
27 #include "glx_error.h"
28 #include "dri2.h"
29 #include "dri_interface.h"
30 #include "dri2_priv.h"
31 #if defined(HAVE_DRI3)
32 #include "dri3_priv.h"
33 #endif
34
35 static int
36 dri2_convert_glx_query_renderer_attribs(int attribute)
37 {
38 switch (attribute) {
39 case GLX_RENDERER_VENDOR_ID_MESA:
40 return __DRI2_RENDERER_VENDOR_ID;
41 case GLX_RENDERER_DEVICE_ID_MESA:
42 return __DRI2_RENDERER_DEVICE_ID;
43 case GLX_RENDERER_VERSION_MESA:
44 return __DRI2_RENDERER_VERSION;
45 case GLX_RENDERER_ACCELERATED_MESA:
46 return __DRI2_RENDERER_ACCELERATED;
47 case GLX_RENDERER_VIDEO_MEMORY_MESA:
48 return __DRI2_RENDERER_VIDEO_MEMORY;
49 case GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA:
50 return __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE;
51 case GLX_RENDERER_PREFERRED_PROFILE_MESA:
52 return __DRI2_RENDERER_PREFERRED_PROFILE;
53 case GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA:
54 return __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION;
55 case GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA:
56 return __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION;
57 case GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA:
58 return __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION;
59 case GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA:
60 return __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION;
61 default:
62 return -1;
63 }
64 }
65
66 _X_HIDDEN int
67 dri2_query_renderer_integer(struct glx_screen *base, int attribute,
68 unsigned int *value)
69 {
70 struct dri2_screen *const psc = (struct dri2_screen *) base;
71
72 /* Even though there are invalid values (and
73 * dri2_convert_glx_query_renderer_attribs may return -1), the higher level
74 * GLX code is required to perform the filtering. Assume that we got a
75 * good value.
76 */
77 const int dri_attribute = dri2_convert_glx_query_renderer_attribs(attribute);
78
79 if (psc->rendererQuery == NULL)
80 return -1;
81
82 return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute,
83 value);
84 }
85
86 _X_HIDDEN int
87 dri2_query_renderer_string(struct glx_screen *base, int attribute,
88 const char **value)
89 {
90 struct dri2_screen *const psc = (struct dri2_screen *) base;
91
92 /* Even though queryString only accepts a subset of the possible GLX
93 * queries, the higher level GLX code is required to perform the filtering.
94 * Assume that we got a good value.
95 */
96 const int dri_attribute = dri2_convert_glx_query_renderer_attribs(attribute);
97
98 if (psc->rendererQuery == NULL)
99 return -1;
100
101 return psc->rendererQuery->queryString(psc->driScreen, dri_attribute, value);
102 }
103
104 #if defined(HAVE_DRI3)
105 _X_HIDDEN int
106 dri3_query_renderer_integer(struct glx_screen *base, int attribute,
107 unsigned int *value)
108 {
109 struct dri3_screen *const psc = (struct dri3_screen *) base;
110
111 /* Even though there are invalid values (and
112 * dri2_convert_glx_query_renderer_attribs may return -1), the higher level
113 * GLX code is required to perform the filtering. Assume that we got a
114 * good value.
115 */
116 const int dri_attribute = dri2_convert_glx_query_renderer_attribs(attribute);
117
118 if (psc->rendererQuery == NULL)
119 return -1;
120
121 return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute,
122 value);
123 }
124
125 _X_HIDDEN int
126 dri3_query_renderer_string(struct glx_screen *base, int attribute,
127 const char **value)
128 {
129 struct dri3_screen *const psc = (struct dri3_screen *) base;
130
131 /* Even though queryString only accepts a subset of the possible GLX
132 * queries, the higher level GLX code is required to perform the filtering.
133 * Assume that we got a good value.
134 */
135 const int dri_attribute = dri2_convert_glx_query_renderer_attribs(attribute);
136
137 if (psc->rendererQuery == NULL)
138 return -1;
139
140 return psc->rendererQuery->queryString(psc->driScreen, dri_attribute, value);
141 }
142 #endif /* HAVE_DRI3 */
143
144 #endif /* GLX_DIRECT_RENDERING */