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
29
* Device driver interface functions for 3Dfx based cards.
31
* \author Gareth Hughes <gareth@valinux.com> (Original rewrite 29 Sep - 1 Oct 2000)
32
* \author Brian Paul <brianp@valinux.com>
35
#include "tdfx_context.h"
37
#include "tdfx_lock.h"
38
#include "tdfx_pixels.h"
41
#include "main/context.h"
44
/* These are used in calls to FX_grColorMaskv() */
45
const GLboolean false4[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
46
const GLboolean true4[4] = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
50
/* KW: Put the word Mesa in the render string because quakeworld
51
* checks for this rather than doing a glGet(GL_MAX_TEXTURE_SIZE).
54
static const GLubyte *tdfxDDGetString( struct gl_context *ctx, GLenum name )
56
tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
61
/* The renderer string must be per-context state to handle
62
* multihead correctly.
64
char *const buffer = fxMesa->rendererString;
67
LOCK_HARDWARE(fxMesa);
68
strncpy(hardware, fxMesa->Glide.grGetString(GR_HARDWARE),
70
hardware[sizeof(hardware) - 1] = '\0';
71
UNLOCK_HARDWARE(fxMesa);
73
if ((strncmp(hardware, "Voodoo3", 7) == 0)
74
|| (strncmp(hardware, "Voodoo4", 7) == 0)
75
|| (strncmp(hardware, "Voodoo5", 7) == 0)) {
78
else if (strncmp(hardware, "Voodoo Banshee", 14) == 0) {
79
strcpy(&hardware[6], "Banshee");
82
/* unexpected result: replace spaces with hyphens */
84
for (i = 0; i < sizeof(hardware) && hardware[i]; i++) {
85
if (hardware[i] == ' ' || hardware[i] == '\t') {
91
(void) driGetRendererString(buffer, hardware, 0);
92
return (const GLubyte *) buffer;
95
return (const GLubyte *)"VA Linux Systems, Inc.";
103
tdfxBeginQuery(struct gl_context *ctx, struct gl_query_object *q)
105
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
109
if (q->Target == GL_SAMPLES_PASSED_ARB) {
110
LOCK_HARDWARE(fxMesa);
111
fxMesa->Glide.grFinish();
112
fxMesa->Glide.grReset(GR_STATS_PIXELS);
113
UNLOCK_HARDWARE(fxMesa);
119
tdfxEndQuery(struct gl_context *ctx, struct gl_query_object *q)
121
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
126
if (q->Target == GL_SAMPLES_PASSED_ARB) {
127
LOCK_HARDWARE(fxMesa);
128
fxMesa->Glide.grFinish();
130
fxMesa->Glide.grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, sizeof(FxI32),
132
fxMesa->Glide.grGet(GR_STATS_PIXELS_IN, sizeof(FxI32), &total_pixels);
134
q->Result = total_pixels - z_fail_pixels;
136
/* Apparently, people have seen z_fail_pixels > total_pixels under
137
* some conditions on some 3Dfx hardware. The occlusion query spec
138
* requires that we clamp to 0.
146
UNLOCK_HARDWARE(fxMesa);
151
#define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \
152
((vis->redBits == r) && \
153
(vis->greenBits == g) && \
154
(vis->blueBits == b) && \
155
(vis->alphaBits == a))
157
void tdfxDDInitDriverFuncs( const struct gl_config *visual,
158
struct dd_function_table *functions )
160
if ( MESA_VERBOSE & VERBOSE_DRIVER ) {
161
fprintf( stderr, "tdfx: %s()\n", __FUNCTION__ );
164
functions->GetString = tdfxDDGetString;
165
functions->BeginQuery = tdfxBeginQuery;
166
functions->EndQuery = tdfxEndQuery;
170
if ( VISUAL_EQUALS_RGBA(visual, 8, 8, 8, 8) )
172
functions->DrawPixels = tdfx_drawpixels_R8G8B8A8;
173
functions->ReadPixels = tdfx_readpixels_R8G8B8A8;
175
else if ( VISUAL_EQUALS_RGBA(visual, 5, 6, 5, 0) )
177
functions->ReadPixels = tdfx_readpixels_R5G6B5;
183
* These are here for lack of a better place.
187
FX_grColorMaskv(struct gl_context *ctx, const GLboolean rgba[4])
189
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
190
LOCK_HARDWARE(fxMesa);
191
if (ctx->Visual.redBits == 8) {
193
ASSERT( fxMesa->Glide.grColorMaskExt );
194
fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP],
195
rgba[BCOMP], rgba[ACOMP]);
199
/* we never have an alpha buffer */
200
fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP],
203
UNLOCK_HARDWARE(fxMesa);
207
FX_grColorMaskv_NoLock(struct gl_context *ctx, const GLboolean rgba[4])
209
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
210
if (ctx->Visual.redBits == 8) {
212
ASSERT( fxMesa->Glide.grColorMaskExt );
213
fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP],
214
rgba[BCOMP], rgba[ACOMP]);
218
/* we never have an alpha buffer */
219
fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP],