| 1 | /* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Mesa 3-D graphics library
|
|---|
| 5 | * Version: 3.1
|
|---|
| 6 | *
|
|---|
| 7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
|---|
| 8 | *
|
|---|
| 9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
|---|
| 10 | * copy of this software and associated documentation files (the "Software"),
|
|---|
| 11 | * to deal in the Software without restriction, including without limitation
|
|---|
| 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|---|
| 13 | * and/or sell copies of the Software, and to permit persons to whom the
|
|---|
| 14 | * Software is furnished to do so, subject to the following conditions:
|
|---|
| 15 | *
|
|---|
| 16 | * The above copyright notice and this permission notice shall be included
|
|---|
| 17 | * in all copies or substantial portions of the Software.
|
|---|
| 18 | *
|
|---|
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|---|
| 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|---|
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|---|
| 22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|---|
| 23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|---|
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|---|
| 25 | *
|
|---|
| 26 | *
|
|---|
| 27 | * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
|
|---|
| 28 | * terms stated above.
|
|---|
| 29 | *
|
|---|
| 30 | * Thank you for your contribution, David!
|
|---|
| 31 | *
|
|---|
| 32 | * Please make note of the above copyright/license statement. If you
|
|---|
| 33 | * contributed code or bug fixes to this code under the previous (GNU
|
|---|
| 34 | * Library) license and object to the new license, your code will be
|
|---|
| 35 | * removed at your request. Please see the Mesa docs/COPYRIGHT file
|
|---|
| 36 | * for more information.
|
|---|
| 37 | *
|
|---|
| 38 | * Additional Mesa/3Dfx driver developers:
|
|---|
| 39 | * Daryll Strauss <daryll@precisioninsight.com>
|
|---|
| 40 | * Keith Whitwell <keith@precisioninsight.com>
|
|---|
| 41 | *
|
|---|
| 42 | * See fxapi.h for more revision/author details.
|
|---|
| 43 | */
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | /* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | #ifdef HAVE_CONFIG_H
|
|---|
| 50 | #include "conf.h"
|
|---|
| 51 | #endif
|
|---|
| 52 |
|
|---|
| 53 | #if defined(FX)
|
|---|
| 54 |
|
|---|
| 55 | #include "fxdrv.h"
|
|---|
| 56 |
|
|---|
| 57 | #ifdef _MSC_VER
|
|---|
| 58 | #ifdef _WIN32
|
|---|
| 59 | #pragma warning( disable : 4090 4022 )
|
|---|
| 60 | /* 4101 : "different 'const' qualifier"
|
|---|
| 61 | * 4022 : "pointer mistmatch for actual parameter 'n'
|
|---|
| 62 | */
|
|---|
| 63 | #endif
|
|---|
| 64 | #endif
|
|---|
| 65 |
|
|---|
| 66 | /************************************************************************/
|
|---|
| 67 | /***** Span functions *****/
|
|---|
| 68 | /************************************************************************/
|
|---|
| 69 |
|
|---|
| 70 | static void fxDDWriteRGBASpan(const GLcontext *ctx,
|
|---|
| 71 | GLuint n, GLint x, GLint y,
|
|---|
| 72 | const GLubyte rgba[][4], const GLubyte mask[])
|
|---|
| 73 | {
|
|---|
| 74 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
|---|
| 75 | GLuint i;
|
|---|
| 76 | GLint bottom=fxMesa->height-1;
|
|---|
| 77 |
|
|---|
| 78 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
|---|
| 79 | fprintf(stderr,"fxmesa: fxDDWriteRGBASpan(...)\n");
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | if (mask) {
|
|---|
| 83 | int span=0;
|
|---|
| 84 |
|
|---|
| 85 | for (i=0;i<n;i++) {
|
|---|
| 86 | if (mask[i]) {
|
|---|
| 87 | ++span;
|
|---|
| 88 | } else {
|
|---|
| 89 | if (span > 0) {
|
|---|
| 90 | grLfbWriteRegion( fxMesa->currentFB, x+i-span, bottom-y,
|
|---|
| 91 | GR_LFB_SRC_FMT_8888, span, 1, 0, (void *) rgba[i-span] );
|
|---|
| 92 | span = 0;
|
|---|
| 93 | }
|
|---|
| 94 | }
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | if (span > 0)
|
|---|
| 98 | grLfbWriteRegion( fxMesa->currentFB, x+n-span, bottom-y,
|
|---|
| 99 | GR_LFB_SRC_FMT_8888, span, 1, 0, (void *) rgba[n-span] );
|
|---|
| 100 | } else
|
|---|
| 101 | grLfbWriteRegion( fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888,
|
|---|
| 102 | n, 1, 0, (void *) rgba );
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 | static void fxDDWriteRGBSpan(const GLcontext *ctx,
|
|---|
| 107 | GLuint n, GLint x, GLint y,
|
|---|
| 108 | const GLubyte rgb[][3], const GLubyte mask[])
|
|---|
| 109 | {
|
|---|
| 110 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
|---|
| 111 | GLuint i;
|
|---|
| 112 | GLint bottom=fxMesa->height-1;
|
|---|
| 113 | GLubyte rgba[MAX_WIDTH][4];
|
|---|
| 114 |
|
|---|
| 115 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
|---|
| 116 | fprintf(stderr,"fxmesa: fxDDWriteRGBSpan()\n");
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | if (mask) {
|
|---|
| 120 | int span=0;
|
|---|
| 121 |
|
|---|
| 122 | for (i=0;i<n;i++) {
|
|---|
| 123 | if (mask[i]) {
|
|---|
| 124 | rgba[span][0] = rgb[i][0];
|
|---|
| 125 | rgba[span][1] = rgb[i][1];
|
|---|
| 126 | rgba[span][2] = rgb[i][2];
|
|---|
| 127 | rgba[span][3] = 255;
|
|---|
| 128 | ++span;
|
|---|
| 129 | } else {
|
|---|
| 130 | if (span > 0) {
|
|---|
| 131 | grLfbWriteRegion( fxMesa->currentFB, x+i-span, bottom-y,
|
|---|
| 132 | GR_LFB_SRC_FMT_8888, span, 1, 0, (void *) rgba );
|
|---|
| 133 | span = 0;
|
|---|
| 134 | }
|
|---|
| 135 | }
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | if (span > 0)
|
|---|
| 139 | grLfbWriteRegion( fxMesa->currentFB, x+n-span, bottom-y,
|
|---|
| 140 | GR_LFB_SRC_FMT_8888, span, 1, 0, (void *) rgba );
|
|---|
| 141 | } else {
|
|---|
| 142 | for (i=0;i<n;i++) {
|
|---|
| 143 | rgba[i][0]=rgb[i][0];
|
|---|
| 144 | rgba[i][1]=rgb[i][1];
|
|---|
| 145 | rgba[i][2]=rgb[i][2];
|
|---|
| 146 | rgba[i][3]=255;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | grLfbWriteRegion( fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888,
|
|---|
| 150 | n, 1, 0, (void *) rgba );
|
|---|
| 151 | }
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 | static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
|
|---|
| 156 | GLuint n, GLint x, GLint y,
|
|---|
| 157 | const GLubyte mask[])
|
|---|
| 158 | {
|
|---|
| 159 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
|---|
| 160 | GLuint i;
|
|---|
| 161 | GLint bottom=fxMesa->height-1;
|
|---|
| 162 | GLuint data[MAX_WIDTH];
|
|---|
| 163 |
|
|---|
| 164 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
|---|
| 165 | fprintf(stderr,"fxmesa: fxDDWriteMonoRGBASpan(...)\n");
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | if (mask) {
|
|---|
| 169 | int span=0;
|
|---|
| 170 |
|
|---|
| 171 | for (i=0;i<n;i++) {
|
|---|
| 172 | if (mask[i]) {
|
|---|
| 173 | data[span] = (GLuint) fxMesa->color;
|
|---|
| 174 | ++span;
|
|---|
| 175 | } else {
|
|---|
| 176 | if (span > 0) {
|
|---|
| 177 | grLfbWriteRegion( fxMesa->currentFB, x+i-span, bottom-y,
|
|---|
| 178 | GR_LFB_SRC_FMT_8888, span, 1, 0,
|
|---|
| 179 | (void *) data );
|
|---|
| 180 | span = 0;
|
|---|
| 181 | }
|
|---|
| 182 | }
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | if (span > 0)
|
|---|
| 186 | grLfbWriteRegion( fxMesa->currentFB, x+n-span, bottom-y,
|
|---|
| 187 | GR_LFB_SRC_FMT_8888, span, 1, 0,
|
|---|
| 188 | (void *) data );
|
|---|
| 189 | } else {
|
|---|
| 190 | for (i=0;i<n;i++) {
|
|---|
| 191 | data[i]=(GLuint) fxMesa->color;
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | grLfbWriteRegion( fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888,
|
|---|
| 195 | n, 1, 0, (void *) data );
|
|---|
| 196 | }
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 | static void fxDDReadRGBASpan(const GLcontext *ctx,
|
|---|
| 201 | GLuint n, GLint x, GLint y, GLubyte rgba[][4])
|
|---|
| 202 | {
|
|---|
| 203 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
|---|
| 204 | GLushort data[MAX_WIDTH];
|
|---|
| 205 | GLuint i;
|
|---|
| 206 | GLint bottom=fxMesa->height-1;
|
|---|
| 207 |
|
|---|
| 208 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
|---|
| 209 | fprintf(stderr,"fxmesa: fxDDReadRGBASpan(...)\n");
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | assert(n < MAX_WIDTH);
|
|---|
| 213 |
|
|---|
| 214 | grLfbReadRegion( fxMesa->currentFB, x, bottom-y, n, 1, 0, data);
|
|---|
| 215 | for (i=0;i<n;i++) {
|
|---|
| 216 | rgba[i][RCOMP]=(data[i] & 0x001f) << 3;
|
|---|
| 217 | rgba[i][GCOMP]=(data[i] & 0x07e0) >> 3;
|
|---|
| 218 | rgba[i][BCOMP]=(data[i] & 0xf800) >> 8;
|
|---|
| 219 | rgba[i][ACOMP]=255;
|
|---|
| 220 | }
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | /************************************************************************/
|
|---|
| 224 | /***** Pixel functions *****/
|
|---|
| 225 | /************************************************************************/
|
|---|
| 226 |
|
|---|
| 227 | static void fxDDWriteRGBAPixels(const GLcontext *ctx,
|
|---|
| 228 | GLuint n, const GLint x[], const GLint y[],
|
|---|
| 229 | CONST GLubyte rgba[][4], const GLubyte mask[])
|
|---|
| 230 | {
|
|---|
| 231 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
|---|
| 232 | GLuint i;
|
|---|
| 233 | GLint bottom=fxMesa->height-1;
|
|---|
| 234 |
|
|---|
| 235 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
|---|
| 236 | fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n");
|
|---|
| 237 | }
|
|---|
| 238 |
|
|---|
| 239 | for(i=0;i<n;i++)
|
|---|
| 240 | if(mask[i])
|
|---|
| 241 | grLfbWriteRegion(fxMesa->currentFB,x[i],bottom-y[i],
|
|---|
| 242 | GR_LFB_SRC_FMT_8888,1,1,0,(void *) rgba[i]);
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx,
|
|---|
| 246 | GLuint n, const GLint x[], const GLint y[],
|
|---|
| 247 | const GLubyte mask[])
|
|---|
| 248 | {
|
|---|
| 249 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
|---|
| 250 | GLuint i;
|
|---|
| 251 | GLint bottom=fxMesa->height-1;
|
|---|
| 252 |
|
|---|
| 253 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
|---|
| 254 | fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n");
|
|---|
| 255 | }
|
|---|
| 256 |
|
|---|
| 257 | for(i=0;i<n;i++)
|
|---|
| 258 | if(mask[i])
|
|---|
| 259 | grLfbWriteRegion(fxMesa->currentFB,x[i],bottom-y[i],
|
|---|
| 260 | GR_LFB_SRC_FMT_8888,1,1,0,(void *) fxMesa->color);
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | static void fxDDReadRGBAPixels(const GLcontext *ctx,
|
|---|
| 264 | GLuint n, const GLint x[], const GLint y[],
|
|---|
| 265 | GLubyte rgba[][4], const GLubyte mask[])
|
|---|
| 266 | {
|
|---|
| 267 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
|---|
| 268 | GLuint i;
|
|---|
| 269 | GLint bottom=fxMesa->height-1;
|
|---|
| 270 | GLushort data;
|
|---|
| 271 |
|
|---|
| 272 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
|---|
| 273 | fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n");
|
|---|
| 274 | }
|
|---|
| 275 |
|
|---|
| 276 | for(i=0;i<n;i++)
|
|---|
| 277 | if(mask[i]) {
|
|---|
| 278 | grLfbReadRegion(fxMesa->currentFB,x[i],bottom-y[i],1,1,0,&data);
|
|---|
| 279 | rgba[i][RCOMP]=(data & 0x001f) << 3;
|
|---|
| 280 | rgba[i][GCOMP]=(data & 0x07e0) >> 3;
|
|---|
| 281 | rgba[i][BCOMP]=(data & 0xf800) >> 8;
|
|---|
| 282 |
|
|---|
| 283 | /* the alpha value should be read from the auxiliary buffer when required */
|
|---|
| 284 |
|
|---|
| 285 | rgba[i][ACOMP]=255;
|
|---|
| 286 | }
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | /************************************************************************/
|
|---|
| 290 | /***** Depth functions *****/
|
|---|
| 291 | /************************************************************************/
|
|---|
| 292 |
|
|---|
| 293 | static void fxDDReadDepthSpanFloat(GLcontext *ctx,
|
|---|
| 294 | GLuint n, GLint x, GLint y, GLfloat depth[])
|
|---|
| 295 | {
|
|---|
| 296 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
|---|
| 297 | GLuint i;
|
|---|
| 298 | GLint bottom=fxMesa->height-1;
|
|---|
| 299 | GLushort data[MAX_WIDTH];
|
|---|
| 300 |
|
|---|
| 301 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
|---|
| 302 | fprintf(stderr,"fxmesa: fxDDReadDepthSpanFloat(...)\n");
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,data);
|
|---|
| 306 |
|
|---|
| 307 | /*
|
|---|
| 308 | convert the read values to float values [0.0 .. 1.0].
|
|---|
| 309 | */
|
|---|
| 310 | for(i=0;i<n;i++)
|
|---|
| 311 | depth[i]=data[i]/65535.0f;
|
|---|
| 312 | }
|
|---|
| 313 |
|
|---|
| 314 | static void fxDDReadDepthSpanInt(GLcontext *ctx,
|
|---|
| 315 | GLuint n, GLint x, GLint y, GLdepth depth[])
|
|---|
| 316 | {
|
|---|
| 317 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
|---|
| 318 | GLint bottom=fxMesa->height-1;
|
|---|
| 319 |
|
|---|
| 320 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
|---|
| 321 | fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depth);
|
|---|
| 325 | }
|
|---|
| 326 |
|
|---|
| 327 | static GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx,
|
|---|
| 328 | GLuint n, GLint x, GLint y, const GLdepth z[],
|
|---|
| 329 | GLubyte mask[])
|
|---|
| 330 | {
|
|---|
| 331 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
|---|
| 332 | GLushort depthdata[MAX_WIDTH];
|
|---|
| 333 | GLdepth *zptr=depthdata;
|
|---|
| 334 | GLubyte *m=mask;
|
|---|
| 335 | GLuint i;
|
|---|
| 336 | GLuint passed=0;
|
|---|
| 337 | GLint bottom=fxMesa->height-1;
|
|---|
| 338 |
|
|---|
| 339 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
|---|
| 340 | fprintf(stderr,"fxmesa: fxDDDepthTestSpanGeneric(...)\n");
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depthdata);
|
|---|
| 344 |
|
|---|
| 345 | /* switch cases ordered from most frequent to less frequent */
|
|---|
| 346 | switch (ctx->Depth.Func) {
|
|---|
| 347 | case GL_LESS:
|
|---|
| 348 | if (ctx->Depth.Mask) {
|
|---|
| 349 | /* Update Z buffer */
|
|---|
| 350 | for (i=0; i<n; i++,zptr++,m++) {
|
|---|
| 351 | if (*m) {
|
|---|
| 352 | if (z[i] < *zptr) {
|
|---|
| 353 | /* pass */
|
|---|
| 354 | *zptr = z[i];
|
|---|
| 355 | passed++;
|
|---|
| 356 | } else {
|
|---|
| 357 | /* fail */
|
|---|
| 358 | *m = 0;
|
|---|
| 359 | }
|
|---|
| 360 | }
|
|---|
| 361 | }
|
|---|
| 362 | } else {
|
|---|
| 363 | /* Don't update Z buffer */
|
|---|
| 364 | for (i=0; i<n; i++,zptr++,m++) {
|
|---|
| 365 | if (*m) {
|
|---|
| 366 | if (z[i] < *zptr) {
|
|---|
| 367 | /* pass */
|
|---|
| 368 | passed++;
|
|---|
| 369 | } else {
|
|---|
| 370 | *m = 0;
|
|---|
| 371 | }
|
|---|
| 372 | }
|
|---|
| 373 | }
|
|---|
| 374 | }
|
|---|
| 375 | break;
|
|---|
| 376 | case GL_LEQUAL:
|
|---|
| 377 | if (ctx->Depth.Mask) {
|
|---|
| 378 | /* Update Z buffer */
|
|---|
| 379 | for (i=0;i<n;i++,zptr++,m++) {
|
|---|
| 380 | if (*m) {
|
|---|
| 381 | if (z[i] <= *zptr) {
|
|---|
| 382 | *zptr = z[i];
|
|---|
| 383 | passed++;
|
|---|
| 384 | } else {
|
|---|
| 385 | *m = 0;
|
|---|
| 386 | }
|
|---|
| 387 | }
|
|---|
| 388 | }
|
|---|
| 389 | } else {
|
|---|
| 390 | /* Don't update Z buffer */
|
|---|
| 391 | for (i=0;i<n;i++,zptr++,m++) {
|
|---|
| 392 | if (*m) {
|
|---|
| 393 | if (z[i] <= *zptr) {
|
|---|
| 394 | /* pass */
|
|---|
| 395 | passed++;
|
|---|
| 396 | } else {
|
|---|
| 397 | *m = 0;
|
|---|
| 398 | }
|
|---|
| 399 | }
|
|---|
| 400 | }
|
|---|
| 401 | }
|
|---|
| 402 | break;
|
|---|
| 403 | case GL_GEQUAL:
|
|---|
| 404 | if (ctx->Depth.Mask) {
|
|---|
| 405 | /* Update Z buffer */
|
|---|
| 406 | for (i=0;i<n;i++,zptr++,m++) {
|
|---|
| 407 | if (*m) {
|
|---|
| 408 | if (z[i] >= *zptr) {
|
|---|
| 409 | *zptr = z[i];
|
|---|
| 410 | passed++;
|
|---|
| 411 | } else {
|
|---|
| 412 | *m = 0;
|
|---|
| 413 | }
|
|---|
| 414 | }
|
|---|
| 415 | }
|
|---|
| 416 | } else {
|
|---|
| 417 | /* Don't update Z buffer */
|
|---|
| 418 | for (i=0;i<n;i++,zptr++,m++) {
|
|---|
| 419 | if (*m) {
|
|---|
| 420 | if (z[i] >= *zptr) {
|
|---|
| 421 | /* pass */
|
|---|
| 422 | passed++;
|
|---|
| 423 | } else {
|
|---|
| 424 | *m = 0;
|
|---|
| 425 | }
|
|---|
| 426 | }
|
|---|
| 427 | }
|
|---|
| 428 | }
|
|---|
| 429 | break;
|
|---|
| 430 | case GL_GREATER:
|
|---|
| 431 | if (ctx->Depth.Mask) {
|
|---|
| 432 | /* Update Z buffer */
|
|---|
| 433 | for (i=0;i<n;i++,zptr++,m++) {
|
|---|
| 434 | if (*m) {
|
|---|
| 435 | if (z[i] > *zptr) {
|
|---|
| 436 | *zptr = z[i];
|
|---|
| 437 | passed++;
|
|---|
| 438 | } else {
|
|---|
| 439 | *m = 0;
|
|---|
| 440 | }
|
|---|
| 441 | }
|
|---|
| 442 | }
|
|---|
| 443 | } else {
|
|---|
| 444 | /* Don't update Z buffer */
|
|---|
| 445 | for (i=0;i<n;i++,zptr++,m++) {
|
|---|
| 446 | if (*m) {
|
|---|
| 447 | if (z[i] > *zptr) {
|
|---|
| 448 | /* pass */
|
|---|
| 449 | passed++;
|
|---|
| 450 | } else {
|
|---|
| 451 | *m = 0;
|
|---|
| 452 | }
|
|---|
| 453 | }
|
|---|
| 454 | }
|
|---|
| 455 | }
|
|---|
| 456 | break;
|
|---|
| 457 | case GL_NOTEQUAL:
|
|---|
| 458 | if (ctx->Depth.Mask) {
|
|---|
| 459 | /* Update Z buffer */
|
|---|
| 460 | for (i=0;i<n;i++,zptr++,m++) {
|
|---|
| 461 | if (*m) {
|
|---|
| 462 | if (z[i] != *zptr) {
|
|---|
| 463 | *zptr = z[i];
|
|---|
| 464 | passed++;
|
|---|
| 465 | } else {
|
|---|
| 466 | *m = 0;
|
|---|
| 467 | }
|
|---|
| 468 | }
|
|---|
| 469 | }
|
|---|
| 470 | } else {
|
|---|
| 471 | /* Don't update Z buffer */
|
|---|
| 472 | for (i=0;i<n;i++,zptr++,m++) {
|
|---|
| 473 | if (*m) {
|
|---|
| 474 | if (z[i] != *zptr) {
|
|---|
| 475 | /* pass */
|
|---|
| 476 | passed++;
|
|---|
| 477 | } else {
|
|---|
| 478 | *m = 0;
|
|---|
| 479 | }
|
|---|
| 480 | }
|
|---|
| 481 | }
|
|---|
| 482 | }
|
|---|
| 483 | break;
|
|---|
| 484 | case GL_EQUAL:
|
|---|
| 485 | if (ctx->Depth.Mask) {
|
|---|
| 486 | /* Update Z buffer */
|
|---|
| 487 | for (i=0;i<n;i++,zptr++,m++) {
|
|---|
| 488 | if (*m) {
|
|---|
| 489 | if (z[i] == *zptr) {
|
|---|
| 490 | *zptr = z[i];
|
|---|
| 491 | passed++;
|
|---|
| 492 | } else {
|
|---|
| 493 | *m =0;
|
|---|
| 494 | }
|
|---|
| 495 | }
|
|---|
| 496 | }
|
|---|
| 497 | } else {
|
|---|
| 498 | /* Don't update Z buffer */
|
|---|
| 499 | for (i=0;i<n;i++,zptr++,m++) {
|
|---|
| 500 | if (*m) {
|
|---|
| 501 | if (z[i] == *zptr) {
|
|---|
| 502 | /* pass */
|
|---|
| 503 | passed++;
|
|---|
| 504 | } else {
|
|---|
| 505 | *m =0;
|
|---|
| 506 | }
|
|---|
| 507 | }
|
|---|
| 508 | }
|
|---|
| 509 | }
|
|---|
| 510 | break;
|
|---|
| 511 | case GL_ALWAYS:
|
|---|
| 512 | if (ctx->Depth.Mask) {
|
|---|
| 513 | /* Update Z buffer */
|
|---|
| 514 | for (i=0;i<n;i++,zptr++,m++) {
|
|---|
| 515 | if (*m) {
|
|---|
| 516 | *zptr = z[i];
|
|---|
| 517 | passed++;
|
|---|
| 518 | }
|
|---|
| 519 | }
|
|---|
| 520 | } else {
|
|---|
| 521 | /* Don't update Z buffer or mask */
|
|---|
| 522 | passed = n;
|
|---|
| 523 | }
|
|---|
| 524 | break;
|
|---|
| 525 | case GL_NEVER:
|
|---|
| 526 | for (i=0;i<n;i++) {
|
|---|
| 527 | mask[i] = 0;
|
|---|
| 528 | }
|
|---|
| 529 | break;
|
|---|
| 530 | default:
|
|---|
| 531 | ;
|
|---|
| 532 | } /*switch*/
|
|---|
| 533 |
|
|---|
| 534 | if(passed)
|
|---|
| 535 | grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,GR_LFB_SRC_FMT_ZA16,n,1,0,depthdata);
|
|---|
| 536 |
|
|---|
| 537 | return passed;
|
|---|
| 538 | }
|
|---|
| 539 |
|
|---|
| 540 | static void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
|
|---|
| 541 | GLuint n, const GLint x[], const GLint y[],
|
|---|
| 542 | const GLdepth z[], GLubyte mask[])
|
|---|
| 543 | {
|
|---|
| 544 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
|---|
| 545 | GLdepth zval;
|
|---|
| 546 | GLuint i;
|
|---|
| 547 | GLint bottom=fxMesa->height-1;
|
|---|
| 548 |
|
|---|
| 549 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
|---|
| 550 | fprintf(stderr,"fxmesa: fxDDDepthTestPixelsGeneric(...)\n");
|
|---|
| 551 | }
|
|---|
| 552 |
|
|---|
| 553 | /* switch cases ordered from most frequent to less frequent */
|
|---|
| 554 | switch (ctx->Depth.Func) {
|
|---|
| 555 | case GL_LESS:
|
|---|
| 556 | if (ctx->Depth.Mask) {
|
|---|
| 557 | /* Update Z buffer */
|
|---|
| 558 | for (i=0; i<n; i++) {
|
|---|
| 559 | if (mask[i]) {
|
|---|
| 560 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 561 | if (z[i] < zval) {
|
|---|
| 562 | /* pass */
|
|---|
| 563 | grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,&z[i]);
|
|---|
| 564 | } else {
|
|---|
| 565 | /* fail */
|
|---|
| 566 | mask[i] = 0;
|
|---|
| 567 | }
|
|---|
| 568 | }
|
|---|
| 569 | }
|
|---|
| 570 | } else {
|
|---|
| 571 | /* Don't update Z buffer */
|
|---|
| 572 | for (i=0; i<n; i++) {
|
|---|
| 573 | if (mask[i]) {
|
|---|
| 574 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 575 | if (z[i] < zval) {
|
|---|
| 576 | /* pass */
|
|---|
| 577 | }
|
|---|
| 578 | else {
|
|---|
| 579 | /* fail */
|
|---|
| 580 | mask[i] = 0;
|
|---|
| 581 | }
|
|---|
| 582 | }
|
|---|
| 583 | }
|
|---|
| 584 | }
|
|---|
| 585 | break;
|
|---|
| 586 | case GL_LEQUAL:
|
|---|
| 587 | if (ctx->Depth.Mask) {
|
|---|
| 588 | /* Update Z buffer */
|
|---|
| 589 | for (i=0; i<n; i++) {
|
|---|
| 590 | if (mask[i]) {
|
|---|
| 591 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 592 | if (z[i] <= zval) {
|
|---|
| 593 | /* pass */
|
|---|
| 594 | grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,&z[i]);
|
|---|
| 595 | } else {
|
|---|
| 596 | /* fail */
|
|---|
| 597 | mask[i] = 0;
|
|---|
| 598 | }
|
|---|
| 599 | }
|
|---|
| 600 | }
|
|---|
| 601 | } else {
|
|---|
| 602 | /* Don't update Z buffer */
|
|---|
| 603 | for (i=0; i<n; i++) {
|
|---|
| 604 | if (mask[i]) {
|
|---|
| 605 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 606 | if (z[i] <= zval) {
|
|---|
| 607 | /* pass */
|
|---|
| 608 | } else {
|
|---|
| 609 | /* fail */
|
|---|
| 610 | mask[i] = 0;
|
|---|
| 611 | }
|
|---|
| 612 | }
|
|---|
| 613 | }
|
|---|
| 614 | }
|
|---|
| 615 | break;
|
|---|
| 616 | case GL_GEQUAL:
|
|---|
| 617 | if (ctx->Depth.Mask) {
|
|---|
| 618 | /* Update Z buffer */
|
|---|
| 619 | for (i=0; i<n; i++) {
|
|---|
| 620 | if (mask[i]) {
|
|---|
| 621 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 622 | if (z[i] >= zval) {
|
|---|
| 623 | /* pass */
|
|---|
| 624 | grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,&z[i]);
|
|---|
| 625 | } else {
|
|---|
| 626 | /* fail */
|
|---|
| 627 | mask[i] = 0;
|
|---|
| 628 | }
|
|---|
| 629 | }
|
|---|
| 630 | }
|
|---|
| 631 | } else {
|
|---|
| 632 | /* Don't update Z buffer */
|
|---|
| 633 | for (i=0; i<n; i++) {
|
|---|
| 634 | if (mask[i]) {
|
|---|
| 635 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 636 | if (z[i] >= zval) {
|
|---|
| 637 | /* pass */
|
|---|
| 638 | } else {
|
|---|
| 639 | /* fail */
|
|---|
| 640 | mask[i] = 0;
|
|---|
| 641 | }
|
|---|
| 642 | }
|
|---|
| 643 | }
|
|---|
| 644 | }
|
|---|
| 645 | break;
|
|---|
| 646 | case GL_GREATER:
|
|---|
| 647 | if (ctx->Depth.Mask) {
|
|---|
| 648 | /* Update Z buffer */
|
|---|
| 649 | for (i=0; i<n; i++) {
|
|---|
| 650 | if (mask[i]) {
|
|---|
| 651 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 652 | if (z[i] > zval) {
|
|---|
| 653 | /* pass */
|
|---|
| 654 | grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,&z[i]);
|
|---|
| 655 | } else {
|
|---|
| 656 | /* fail */
|
|---|
| 657 | mask[i] = 0;
|
|---|
| 658 | }
|
|---|
| 659 | }
|
|---|
| 660 | }
|
|---|
| 661 | } else {
|
|---|
| 662 | /* Don't update Z buffer */
|
|---|
| 663 | for (i=0; i<n; i++) {
|
|---|
| 664 | if (mask[i]) {
|
|---|
| 665 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 666 | if (z[i] > zval) {
|
|---|
| 667 | /* pass */
|
|---|
| 668 | } else {
|
|---|
| 669 | /* fail */
|
|---|
| 670 | mask[i] = 0;
|
|---|
| 671 | }
|
|---|
| 672 | }
|
|---|
| 673 | }
|
|---|
| 674 | }
|
|---|
| 675 | break;
|
|---|
| 676 | case GL_NOTEQUAL:
|
|---|
| 677 | if (ctx->Depth.Mask) {
|
|---|
| 678 | /* Update Z buffer */
|
|---|
| 679 | for (i=0; i<n; i++) {
|
|---|
| 680 | if (mask[i]) {
|
|---|
| 681 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 682 | if (z[i] != zval) {
|
|---|
| 683 | /* pass */
|
|---|
| 684 | grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,&z[i]);
|
|---|
| 685 | } else {
|
|---|
| 686 | /* fail */
|
|---|
| 687 | mask[i] = 0;
|
|---|
| 688 | }
|
|---|
| 689 | }
|
|---|
| 690 | }
|
|---|
| 691 | } else {
|
|---|
| 692 | /* Don't update Z buffer */
|
|---|
| 693 | for (i=0; i<n; i++) {
|
|---|
| 694 | if (mask[i]) {
|
|---|
| 695 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 696 | if (z[i] != zval) {
|
|---|
| 697 | /* pass */
|
|---|
| 698 | }
|
|---|
| 699 | else {
|
|---|
| 700 | /* fail */
|
|---|
| 701 | mask[i] = 0;
|
|---|
| 702 | }
|
|---|
| 703 | }
|
|---|
| 704 | }
|
|---|
| 705 | }
|
|---|
| 706 | break;
|
|---|
| 707 | case GL_EQUAL:
|
|---|
| 708 | if (ctx->Depth.Mask) {
|
|---|
| 709 | /* Update Z buffer */
|
|---|
| 710 | for (i=0; i<n; i++) {
|
|---|
| 711 | if (mask[i]) {
|
|---|
| 712 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 713 | if (z[i] == zval) {
|
|---|
| 714 | /* pass */
|
|---|
| 715 | grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,&z[i]);
|
|---|
| 716 | } else {
|
|---|
| 717 | /* fail */
|
|---|
| 718 | mask[i] = 0;
|
|---|
| 719 | }
|
|---|
| 720 | }
|
|---|
| 721 | }
|
|---|
| 722 | } else {
|
|---|
| 723 | /* Don't update Z buffer */
|
|---|
| 724 | for (i=0; i<n; i++) {
|
|---|
| 725 | if (mask[i]) {
|
|---|
| 726 | grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
|
|---|
| 727 | if (z[i] == zval) {
|
|---|
| 728 | /* pass */
|
|---|
| 729 | } else {
|
|---|
| 730 | /* fail */
|
|---|
| 731 | mask[i] = 0;
|
|---|
| 732 | }
|
|---|
| 733 | }
|
|---|
| 734 | }
|
|---|
| 735 | }
|
|---|
| 736 | break;
|
|---|
| 737 | case GL_ALWAYS:
|
|---|
| 738 | if (ctx->Depth.Mask) {
|
|---|
| 739 | /* Update Z buffer */
|
|---|
| 740 | for (i=0; i<n; i++) {
|
|---|
| 741 | if (mask[i]) {
|
|---|
| 742 | grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,&z[i]);
|
|---|
| 743 | }
|
|---|
| 744 | }
|
|---|
| 745 | } else {
|
|---|
| 746 | /* Don't update Z buffer or mask */
|
|---|
| 747 | }
|
|---|
| 748 | break;
|
|---|
| 749 | case GL_NEVER:
|
|---|
| 750 | /* depth test never passes */
|
|---|
| 751 | for (i=0;i<n;i++) {
|
|---|
| 752 | mask[i] = 0;
|
|---|
| 753 | }
|
|---|
| 754 | break;
|
|---|
| 755 | default:
|
|---|
| 756 | ;
|
|---|
| 757 | } /*switch*/
|
|---|
| 758 | }
|
|---|
| 759 |
|
|---|
| 760 | /************************************************************************/
|
|---|
| 761 |
|
|---|
| 762 | void fxUpdateDDSpanPointers(GLcontext *ctx)
|
|---|
| 763 | {
|
|---|
| 764 | ctx->Driver.DepthTestSpan=fxDDDepthTestSpanGeneric;
|
|---|
| 765 | ctx->Driver.DepthTestPixels=fxDDDepthTestPixelsGeneric;
|
|---|
| 766 |
|
|---|
| 767 | ctx->Driver.ReadDepthSpanFloat=fxDDReadDepthSpanFloat;
|
|---|
| 768 | ctx->Driver.ReadDepthSpanInt=fxDDReadDepthSpanInt;
|
|---|
| 769 | }
|
|---|
| 770 |
|
|---|
| 771 | void fxSetupDDSpanPointers(GLcontext *ctx)
|
|---|
| 772 | {
|
|---|
| 773 | ctx->Driver.WriteRGBASpan =fxDDWriteRGBASpan;
|
|---|
| 774 | ctx->Driver.WriteRGBSpan =fxDDWriteRGBSpan;
|
|---|
| 775 | ctx->Driver.WriteMonoRGBASpan =fxDDWriteMonoRGBASpan;
|
|---|
| 776 | ctx->Driver.WriteRGBAPixels =fxDDWriteRGBAPixels;
|
|---|
| 777 | ctx->Driver.WriteMonoRGBAPixels =fxDDWriteMonoRGBAPixels;
|
|---|
| 778 |
|
|---|
| 779 | ctx->Driver.WriteCI8Span =NULL;
|
|---|
| 780 | ctx->Driver.WriteCI32Span =NULL;
|
|---|
| 781 | ctx->Driver.WriteMonoCISpan =NULL;
|
|---|
| 782 | ctx->Driver.WriteCI32Pixels =NULL;
|
|---|
| 783 | ctx->Driver.WriteMonoCIPixels =NULL;
|
|---|
| 784 |
|
|---|
| 785 | ctx->Driver.ReadRGBASpan =fxDDReadRGBASpan;
|
|---|
| 786 | ctx->Driver.ReadRGBAPixels =fxDDReadRGBAPixels;
|
|---|
| 787 |
|
|---|
| 788 | ctx->Driver.ReadCI32Span =NULL;
|
|---|
| 789 | ctx->Driver.ReadCI32Pixels =NULL;
|
|---|
| 790 | }
|
|---|
| 791 |
|
|---|
| 792 |
|
|---|
| 793 | #else
|
|---|
| 794 |
|
|---|
| 795 |
|
|---|
| 796 | /*
|
|---|
| 797 | * Need this to provide at least one external definition.
|
|---|
| 798 | */
|
|---|
| 799 |
|
|---|
| 800 | int gl_fx_dummy_function_span(void)
|
|---|
| 801 | {
|
|---|
| 802 | return 0;
|
|---|
| 803 | }
|
|---|
| 804 |
|
|---|
| 805 | #endif /* FX */
|
|---|