3dbd24d49b7ccb412f70b070fc14249f48d8506c
1 /* -*- mode: c; c-basic-offset: 3 -*-
3 * Copyright 2000 VA Linux Systems Inc., Fremont, California.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 /* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_dd.c,v 1.10 2002/10/30 12:52:00 alanh Exp $ */
30 * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
33 * Gareth Hughes <gareth@valinux.com>
34 * Brian Paul <brianp@valinux.com>
38 #include "tdfx_context.h"
40 #include "tdfx_lock.h"
42 #include "tdfx_pixels.h"
46 #include "framebuffer.h"
47 #include "swrast/swrast.h"
48 #if defined(USE_X86_ASM)
49 #include "x86/common_x86_asm.h"
53 #define TDFX_DATE "20040719"
56 /* These are used in calls to FX_grColorMaskv() */
57 const GLboolean false4
[4] = { GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
};
58 const GLboolean true4
[4] = { GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
};
62 /* KW: Put the word Mesa in the render string because quakeworld
63 * checks for this rather than doing a glGet(GL_MAX_TEXTURE_SIZE).
66 static const GLubyte
*tdfxDDGetString( GLcontext
*ctx
, GLenum name
)
68 tdfxContextPtr fxMesa
= (tdfxContextPtr
) ctx
->DriverCtx
;
73 /* The renderer string must be per-context state to handle
74 * multihead correctly.
76 char *buffer
= fxMesa
->rendererString
;
79 LOCK_HARDWARE(fxMesa
);
80 strcpy( hardware
, fxMesa
->Glide
.grGetString(GR_HARDWARE
) );
81 UNLOCK_HARDWARE(fxMesa
);
83 strcpy( buffer
, "Mesa DRI " );
84 strcat( buffer
, TDFX_DATE
);
85 strcat( buffer
, " " );
87 if ( strcmp( hardware
, "Voodoo3 (tm)" ) == 0 ) {
88 strcat( buffer
, "Voodoo3" );
90 else if ( strcmp( hardware
, "Voodoo Banshee (tm)" ) == 0 ) {
91 strcat( buffer
, "VoodooBanshee" );
93 else if ( strcmp( hardware
, "Voodoo4 (tm)" ) == 0 ) {
94 strcat( buffer
, "Voodoo4" );
96 else if ( strcmp( hardware
, "Voodoo5 (tm)" ) == 0 ) {
97 strcat( buffer
, "Voodoo5" );
100 /* unexpected result: replace spaces with hyphens */
102 for ( i
= 0 ; hardware
[i
] && i
< 60 ; i
++ ) {
103 if ( hardware
[i
] == ' ' || hardware
[i
] == '\t' )
106 strcat( buffer
, hardware
);
109 /* Append any CPU-specific information.
112 if ( _mesa_x86_cpu_features
) {
113 strncat( buffer
, " x86", 4 );
118 strncat( buffer
, "/MMX", 4 );
122 if ( cpu_has_3dnow
) {
123 strncat( buffer
, "/3DNow!", 7 );
128 strncat( buffer
, "/SSE", 4 );
131 return (const GLubyte
*) buffer
;
134 return (const GLubyte
*)"VA Linux Systems, Inc.";
141 /* Return uptodate buffer size information.
143 static void tdfxDDGetBufferSize( GLframebuffer
*buffer
,
144 GLuint
*width
, GLuint
*height
)
146 GET_CURRENT_CONTEXT(ctx
);
147 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
149 LOCK_HARDWARE( fxMesa
);
150 *width
= fxMesa
->width
;
151 *height
= fxMesa
->height
;
152 UNLOCK_HARDWARE( fxMesa
);
156 #define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \
157 ((vis->redBits == r) && \
158 (vis->greenBits == g) && \
159 (vis->blueBits == b) && \
160 (vis->alphaBits == a))
162 void tdfxDDInitDriverFuncs( const __GLcontextModes
*visual
,
163 struct dd_function_table
*functions
)
165 if ( MESA_VERBOSE
& VERBOSE_DRIVER
) {
166 fprintf( stderr
, "tdfx: %s()\n", __FUNCTION__
);
169 functions
->GetString
= tdfxDDGetString
;
170 functions
->GetBufferSize
= tdfxDDGetBufferSize
;
171 functions
->ResizeBuffers
= _mesa_resize_framebuffer
;
175 if ( VISUAL_EQUALS_RGBA(visual
, 8, 8, 8, 8) )
177 functions
->DrawPixels
= tdfx_drawpixels_R8G8B8A8
;
178 functions
->ReadPixels
= tdfx_readpixels_R8G8B8A8
;
180 else if ( VISUAL_EQUALS_RGBA(visual
, 5, 6, 5, 0) )
182 functions
->ReadPixels
= tdfx_readpixels_R5G6B5
;
188 * These are here for lack of a better place.
192 FX_grColorMaskv(GLcontext
*ctx
, const GLboolean rgba
[4])
194 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
195 LOCK_HARDWARE(fxMesa
);
196 if (ctx
->Visual
.redBits
== 8) {
198 ASSERT( fxMesa
->Glide
.grColorMaskExt
);
199 fxMesa
->Glide
.grColorMaskExt(rgba
[RCOMP
], rgba
[GCOMP
],
200 rgba
[BCOMP
], rgba
[ACOMP
]);
204 /* we never have an alpha buffer */
205 fxMesa
->Glide
.grColorMask(rgba
[RCOMP
] || rgba
[GCOMP
] || rgba
[BCOMP
],
208 UNLOCK_HARDWARE(fxMesa
);
212 FX_grColorMaskv_NoLock(GLcontext
*ctx
, const GLboolean rgba
[4])
214 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
215 if (ctx
->Visual
.redBits
== 8) {
217 ASSERT( fxMesa
->Glide
.grColorMaskExt
);
218 fxMesa
->Glide
.grColorMaskExt(rgba
[RCOMP
], rgba
[GCOMP
],
219 rgba
[BCOMP
], rgba
[ACOMP
]);
223 /* we never have an alpha buffer */
224 fxMesa
->Glide
.grColorMask(rgba
[RCOMP
] || rgba
[GCOMP
] || rgba
[BCOMP
],