~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/tdfx/tdfx_dd.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c; c-basic-offset: 3 -*-
2
 
 *
3
 
 * Copyright 2000 VA Linux Systems Inc., Fremont, California.
4
 
 *
5
 
 * All Rights Reserved.
6
 
 *
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:
13
 
 *
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
16
 
 * Software.
17
 
 *
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
24
 
 * SOFTWARE.
25
 
 */
26
 
 
27
 
/**
28
 
 * \file tdfx_dd.c
29
 
 * Device driver interface functions for 3Dfx based cards.
30
 
 * 
31
 
 * \author Gareth Hughes <gareth@valinux.com> (Original rewrite 29 Sep - 1 Oct 2000)
32
 
 * \author Brian Paul <brianp@valinux.com>
33
 
 */
34
 
 
35
 
#include "tdfx_context.h"
36
 
#include "tdfx_dd.h"
37
 
#include "tdfx_lock.h"
38
 
#include "tdfx_pixels.h"
39
 
 
40
 
#include "utils.h"
41
 
#include "main/context.h"
42
 
 
43
 
 
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 };
47
 
 
48
 
 
49
 
 
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).
52
 
 * Why?
53
 
 */
54
 
static const GLubyte *tdfxDDGetString( struct gl_context *ctx, GLenum name )
55
 
{
56
 
   tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
57
 
 
58
 
   switch (name) {
59
 
   case GL_RENDERER:
60
 
   {
61
 
      /* The renderer string must be per-context state to handle
62
 
       * multihead correctly.
63
 
       */
64
 
      char *const buffer = fxMesa->rendererString;
65
 
      char hardware[64];
66
 
 
67
 
      LOCK_HARDWARE(fxMesa);
68
 
      strncpy(hardware, fxMesa->Glide.grGetString(GR_HARDWARE),
69
 
              sizeof(hardware));
70
 
      hardware[sizeof(hardware) - 1] = '\0';
71
 
      UNLOCK_HARDWARE(fxMesa);
72
 
 
73
 
      if ((strncmp(hardware, "Voodoo3", 7) == 0)
74
 
          || (strncmp(hardware, "Voodoo4", 7) == 0)
75
 
          || (strncmp(hardware, "Voodoo5", 7) == 0)) {
76
 
         hardware[7] = '\0';
77
 
      }
78
 
      else if (strncmp(hardware, "Voodoo Banshee", 14) == 0) {
79
 
         strcpy(&hardware[6], "Banshee");
80
 
      }
81
 
      else {
82
 
         /* unexpected result: replace spaces with hyphens */
83
 
         int i;
84
 
         for (i = 0; i < sizeof(hardware) && hardware[i]; i++) {
85
 
            if (hardware[i] == ' ' || hardware[i] == '\t') {
86
 
               hardware[i] = '-';
87
 
            }
88
 
         }
89
 
      }
90
 
 
91
 
      (void) driGetRendererString(buffer, hardware, 0);
92
 
      return (const GLubyte *) buffer;
93
 
   }
94
 
   case GL_VENDOR:
95
 
      return (const GLubyte *)"VA Linux Systems, Inc.";
96
 
   default:
97
 
      return NULL;
98
 
   }
99
 
}
100
 
 
101
 
 
102
 
static void
103
 
tdfxBeginQuery(struct gl_context *ctx, struct gl_query_object *q)
104
 
{
105
 
   tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
106
 
 
107
 
   (void) q;
108
 
 
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);
114
 
   }
115
 
}
116
 
 
117
 
 
118
 
static void
119
 
tdfxEndQuery(struct gl_context *ctx, struct gl_query_object *q)
120
 
{
121
 
   tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
122
 
   FxI32 total_pixels;
123
 
   FxI32 z_fail_pixels;
124
 
 
125
 
 
126
 
   if (q->Target == GL_SAMPLES_PASSED_ARB) {
127
 
      LOCK_HARDWARE(fxMesa);
128
 
      fxMesa->Glide.grFinish();
129
 
 
130
 
      fxMesa->Glide.grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, sizeof(FxI32),
131
 
                          &z_fail_pixels);
132
 
      fxMesa->Glide.grGet(GR_STATS_PIXELS_IN, sizeof(FxI32), &total_pixels);
133
 
 
134
 
      q->Result = total_pixels - z_fail_pixels;
135
 
      
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.
139
 
       */
140
 
      if (q->Result < 0) {
141
 
         q->Result = 0;
142
 
      }
143
 
 
144
 
      q->Ready = GL_TRUE;
145
 
 
146
 
      UNLOCK_HARDWARE(fxMesa);
147
 
   }
148
 
}
149
 
 
150
 
 
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))
156
 
 
157
 
void tdfxDDInitDriverFuncs( const struct gl_config *visual,
158
 
                            struct dd_function_table *functions )
159
 
{
160
 
   if ( MESA_VERBOSE & VERBOSE_DRIVER ) {
161
 
      fprintf( stderr, "tdfx: %s()\n", __FUNCTION__ );
162
 
   }
163
 
 
164
 
   functions->GetString         = tdfxDDGetString;
165
 
   functions->BeginQuery        = tdfxBeginQuery;
166
 
   functions->EndQuery          = tdfxEndQuery;
167
 
 
168
 
   /* Accelerated paths
169
 
    */
170
 
   if ( VISUAL_EQUALS_RGBA(visual, 8, 8, 8, 8) )
171
 
   {
172
 
      functions->DrawPixels     = tdfx_drawpixels_R8G8B8A8;
173
 
      functions->ReadPixels     = tdfx_readpixels_R8G8B8A8;
174
 
   }
175
 
   else if ( VISUAL_EQUALS_RGBA(visual, 5, 6, 5, 0) )
176
 
   {
177
 
      functions->ReadPixels     = tdfx_readpixels_R5G6B5;
178
 
   }
179
 
}
180
 
 
181
 
 
182
 
/*
183
 
 * These are here for lack of a better place.
184
 
 */
185
 
 
186
 
void
187
 
FX_grColorMaskv(struct gl_context *ctx, const GLboolean rgba[4])
188
 
{
189
 
   tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
190
 
   LOCK_HARDWARE(fxMesa);
191
 
   if (ctx->Visual.redBits == 8) {
192
 
      /* 32bpp mode */
193
 
      ASSERT( fxMesa->Glide.grColorMaskExt );
194
 
      fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP],
195
 
                                   rgba[BCOMP], rgba[ACOMP]);
196
 
   }
197
 
   else {
198
 
      /* 16 bpp mode */
199
 
      /* we never have an alpha buffer */
200
 
      fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP],
201
 
                                GL_FALSE);
202
 
   }
203
 
   UNLOCK_HARDWARE(fxMesa);
204
 
}
205
 
 
206
 
void
207
 
FX_grColorMaskv_NoLock(struct gl_context *ctx, const GLboolean rgba[4])
208
 
{
209
 
   tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
210
 
   if (ctx->Visual.redBits == 8) {
211
 
      /* 32bpp mode */
212
 
      ASSERT( fxMesa->Glide.grColorMaskExt );
213
 
      fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP],
214
 
                                   rgba[BCOMP], rgba[ACOMP]);
215
 
   }
216
 
   else {
217
 
      /* 16 bpp mode */
218
 
      /* we never have an alpha buffer */
219
 
      fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP],
220
 
                                GL_FALSE);
221
 
   }
222
 
}