1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
/*
* (c) Copyright IBM Corporation 2002
* All Rights Reserved.
*
* 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
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
* VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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:
* Ian Romanick <idr@us.ibm.com>
*/
/* $XFree86:$ */
#include <string.h>
#include <stdlib.h>
#include "mtypes.h"
#include "extensions.h"
#include "utils.h"
#if !defined( DRI_NEW_INTERFACE_ONLY ) && !defined( _SOLO )
#include "xf86dri.h" /* For XF86DRIQueryVersion prototype. */
#endif
#if defined(USE_X86_ASM)
#include "x86/common_x86_asm.h"
#endif
unsigned
driParseDebugString( const char * debug,
const struct dri_debug_control * control )
{
unsigned flag;
flag = 0;
if ( debug != NULL ) {
while( control->string != NULL ) {
if ( !strcmp( debug, "all" ) ||
strstr( debug, control->string ) != NULL ) {
flag |= control->flag;
}
control++;
}
}
return flag;
}
unsigned
driGetRendererString( char * buffer, const char * hardware_name,
const char * driver_date, GLuint agp_mode )
{
#ifdef USE_X86_ASM
char * x86_str = "";
char * mmx_str = "";
char * tdnow_str = "";
char * sse_str = "";
#endif
unsigned offset;
offset = sprintf( buffer, "Mesa DRI %s %s", hardware_name, driver_date );
/* Append any AGP-specific information.
*/
switch ( agp_mode ) {
case 1:
case 2:
case 4:
case 8:
offset += sprintf( & buffer[ offset ], " AGP %ux", agp_mode );
break;
default:
break;
}
/* Append any CPU-specific information.
*/
#ifdef USE_X86_ASM
if ( _mesa_x86_cpu_features ) {
x86_str = " x86";
}
# ifdef USE_MMX_ASM
if ( cpu_has_mmx ) {
mmx_str = (cpu_has_mmxext) ? "/MMX+" : "/MMX";
}
# endif
# ifdef USE_3DNOW_ASM
if ( cpu_has_3dnow ) {
tdnow_str = (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!";
}
# endif
# ifdef USE_SSE_ASM
if ( cpu_has_xmm ) {
sse_str = (cpu_has_xmm2) ? "/SSE2" : "/SSE";
}
# endif
offset += sprintf( & buffer[ offset ], "%s%s%s%s",
x86_str, mmx_str, tdnow_str, sse_str );
#elif defined(USE_SPARC_ASM)
offset += sprintf( & buffer[ offset ], " Sparc" );
#endif
return offset;
}
void driInitExtensions( GLcontext * ctx,
const char * const extensions_to_enable[],
GLboolean enable_imaging )
{
unsigned i;
if ( enable_imaging ) {
_mesa_enable_imaging_extensions( ctx );
}
for ( i = 0 ; extensions_to_enable[i] != NULL ; i++ ) {
_mesa_enable_extension( ctx, extensions_to_enable[i] );
}
}
#ifndef DRI_NEW_INTERFACE_ONLY
/**
* Utility function used by drivers to test the verions of other components.
*
* \deprecated
* All drivers using the new interface should use \c driCheckDriDdxVersions2
* instead. This function is implemented using a call that is not available
* to drivers using the new interface. Furthermore, the information gained
* by this call (the DRI and DDX version information) is already provided to
* the driver via the new interface.
*/
GLboolean
driCheckDriDdxDrmVersions(__DRIscreenPrivate *sPriv,
const char * driver_name,
int dri_major, int dri_minor,
int ddx_major, int ddx_minor,
int drm_major, int drm_minor)
{
static const char format[] = "%s DRI driver expected %s version %d.%d.x "
"but got version %d.%d.%d";
int major, minor, patch;
#ifndef _SOLO
/* Check the DRI version */
if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
if (major != dri_major || minor < dri_minor) {
__driUtilMessage(format, driver_name, "DRI", dri_major, dri_minor,
major, minor, patch);
return GL_FALSE;
}
}
/* Check that the DDX driver version is compatible */
if (sPriv->ddxMajor != ddx_major || sPriv->ddxMinor < ddx_minor) {
__driUtilMessage(format, driver_name, "DDX", ddx_major, ddx_minor,
sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
return GL_FALSE;
}
#else
(void)major;(void)minor;(void)patch;
#endif
/* Check that the DRM driver version is compatible */
if (sPriv->drmMajor != drm_major || sPriv->drmMinor < drm_minor) {
__driUtilMessage(format, driver_name, "DRM", drm_major, drm_minor,
sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
return GL_FALSE;
}
return GL_TRUE;
}
#endif /* DRI_NEW_INTERFACE_ONLY */
/**
* Utility function used by drivers to test the verions of other components.
*
* If one of the version requirements is not met, a message is logged using
* \c __driUtilMessage.
*
* \param driver_name Name of the driver. Used in error messages.
* \param driActual Actual DRI version supplied __driCreateNewScreen.
* \param driExpected Minimum DRI version required by the driver.
* \param ddxActual Actual DDX version supplied __driCreateNewScreen.
* \param ddxExpected Minimum DDX version required by the driver.
* \param drmActual Actual DRM version supplied __driCreateNewScreen.
* \param drmExpected Minimum DRM version required by the driver.
*
* \returns \c GL_TRUE if all version requirements are met. Otherwise,
* \c GL_FALSE is returned.
*
* \sa __driCreateNewScreen, driCheckDriDdxDrmVersions, __driUtilMessage
*/
GLboolean
driCheckDriDdxDrmVersions2(const char * driver_name,
const __DRIversion * driActual,
const __DRIversion * driExpected,
const __DRIversion * ddxActual,
const __DRIversion * ddxExpected,
const __DRIversion * drmActual,
const __DRIversion * drmExpected)
{
static const char format[] = "%s DRI driver expected %s version %d.%d.x "
"but got version %d.%d.%d";
/* Check the DRI version */
if ( (driActual->major != driExpected->major)
|| (driActual->minor < driExpected->minor) ) {
__driUtilMessage(format, driver_name, "DRI",
driExpected->major, driExpected->minor,
driActual->major, driActual->minor, driActual->patch);
return GL_FALSE;
}
/* Check that the DDX driver version is compatible */
if ( (ddxActual->major != ddxExpected->major)
|| (ddxActual->minor < ddxExpected->minor) ) {
__driUtilMessage(format, driver_name, "DDX",
ddxExpected->major, ddxExpected->minor,
ddxActual->major, ddxActual->minor, ddxActual->patch);
return GL_FALSE;
}
/* Check that the DRM driver version is compatible */
if ( (drmActual->major != drmExpected->major)
|| (drmActual->minor < drmExpected->minor) ) {
__driUtilMessage(format, driver_name, "DRM",
drmExpected->major, drmExpected->minor,
drmActual->major, drmActual->minor, drmActual->patch);
return GL_FALSE;
}
return GL_TRUE;
}
GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
GLint *x, GLint *y,
GLsizei *width, GLsizei *height )
{
/* left clipping */
if (*x < buffer->_Xmin) {
*width -= (buffer->_Xmin - *x);
*x = buffer->_Xmin;
}
/* right clipping */
if (*x + *width > buffer->_Xmax)
*width -= (*x + *width - buffer->_Xmax - 1);
if (*width <= 0)
return GL_FALSE;
/* bottom clipping */
if (*y < buffer->_Ymin) {
*height -= (buffer->_Ymin - *y);
*y = buffer->_Ymin;
}
/* top clipping */
if (*y + *height > buffer->_Ymax)
*height -= (*y + *height - buffer->_Ymax - 1);
if (*height <= 0)
return GL_FALSE;
return GL_TRUE;
}
|