s_triangle.c revision c1f859d4
1/* 2 * Mesa 3-D graphics library 3 * Version: 7.3 4 * 5 * Copyright (C) 1999-2007 Brian Paul 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 shall be included 15 * in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 25 26/* 27 * When the device driver doesn't implement triangle rasterization it 28 * can hook in _swrast_Triangle, which eventually calls one of these 29 * functions to draw triangles. 30 */ 31 32#include "main/glheader.h" 33#include "main/context.h" 34#include "main/colormac.h" 35#include "main/imports.h" 36#include "main/macros.h" 37#include "main/texformat.h" 38 39#include "s_aatriangle.h" 40#include "s_context.h" 41#include "s_feedback.h" 42#include "s_span.h" 43#include "s_triangle.h" 44 45 46/* 47 * Just used for feedback mode. 48 */ 49GLboolean 50_swrast_culltriangle( GLcontext *ctx, 51 const SWvertex *v0, 52 const SWvertex *v1, 53 const SWvertex *v2 ) 54{ 55 GLfloat ex = v1->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0]; 56 GLfloat ey = v1->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1]; 57 GLfloat fx = v2->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0]; 58 GLfloat fy = v2->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1]; 59 GLfloat c = ex*fy-ey*fx; 60 61 if (c * SWRAST_CONTEXT(ctx)->_BackfaceCullSign > 0) 62 return 0; 63 64 return 1; 65} 66 67 68 69/* 70 * Render a smooth or flat-shaded color index triangle. 71 */ 72#define NAME ci_triangle 73#define INTERP_Z 1 74#define INTERP_ATTRIBS 1 /* just for fog */ 75#define INTERP_INDEX 1 76#define RENDER_SPAN( span ) _swrast_write_index_span(ctx, &span); 77#include "s_tritemp.h" 78 79 80 81/* 82 * Render a flat-shaded RGBA triangle. 83 */ 84#define NAME flat_rgba_triangle 85#define INTERP_Z 1 86#define SETUP_CODE \ 87 ASSERT(ctx->Texture._EnabledCoordUnits == 0);\ 88 ASSERT(ctx->Light.ShadeModel==GL_FLAT); \ 89 span.interpMask |= SPAN_RGBA; \ 90 span.red = ChanToFixed(v2->color[0]); \ 91 span.green = ChanToFixed(v2->color[1]); \ 92 span.blue = ChanToFixed(v2->color[2]); \ 93 span.alpha = ChanToFixed(v2->color[3]); \ 94 span.redStep = 0; \ 95 span.greenStep = 0; \ 96 span.blueStep = 0; \ 97 span.alphaStep = 0; 98#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span); 99#include "s_tritemp.h" 100 101 102 103/* 104 * Render a smooth-shaded RGBA triangle. 105 */ 106#define NAME smooth_rgba_triangle 107#define INTERP_Z 1 108#define INTERP_RGB 1 109#define INTERP_ALPHA 1 110#define SETUP_CODE \ 111 { \ 112 /* texturing must be off */ \ 113 ASSERT(ctx->Texture._EnabledCoordUnits == 0); \ 114 ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \ 115 } 116#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span); 117#include "s_tritemp.h" 118 119 120 121/* 122 * Render an RGB, GL_DECAL, textured triangle. 123 * Interpolate S,T only w/out mipmapping or perspective correction. 124 * 125 * No fog. No depth testing. 126 */ 127#define NAME simple_textured_triangle 128#define INTERP_INT_TEX 1 129#define S_SCALE twidth 130#define T_SCALE theight 131 132#define SETUP_CODE \ 133 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \ 134 struct gl_texture_object *obj = \ 135 ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ 136 const GLint b = obj->BaseLevel; \ 137 const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \ 138 const GLfloat theight = (GLfloat) obj->Image[0][b]->Height; \ 139 const GLint twidth_log2 = obj->Image[0][b]->WidthLog2; \ 140 const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data; \ 141 const GLint smask = obj->Image[0][b]->Width - 1; \ 142 const GLint tmask = obj->Image[0][b]->Height - 1; \ 143 if (!rb || !texture) { \ 144 return; \ 145 } 146 147#define RENDER_SPAN( span ) \ 148 GLuint i; \ 149 GLchan rgb[MAX_WIDTH][3]; \ 150 span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \ 151 span.intTex[1] -= FIXED_HALF; \ 152 for (i = 0; i < span.end; i++) { \ 153 GLint s = FixedToInt(span.intTex[0]) & smask; \ 154 GLint t = FixedToInt(span.intTex[1]) & tmask; \ 155 GLint pos = (t << twidth_log2) + s; \ 156 pos = pos + pos + pos; /* multiply by 3 */ \ 157 rgb[i][RCOMP] = texture[pos]; \ 158 rgb[i][GCOMP] = texture[pos+1]; \ 159 rgb[i][BCOMP] = texture[pos+2]; \ 160 span.intTex[0] += span.intTexStep[0]; \ 161 span.intTex[1] += span.intTexStep[1]; \ 162 } \ 163 rb->PutRowRGB(ctx, rb, span.end, span.x, span.y, rgb, NULL); 164 165#include "s_tritemp.h" 166 167 168 169/* 170 * Render an RGB, GL_DECAL, textured triangle. 171 * Interpolate S,T, GL_LESS depth test, w/out mipmapping or 172 * perspective correction. 173 * Depth buffer bits must be <= sizeof(DEFAULT_SOFTWARE_DEPTH_TYPE) 174 * 175 * No fog. 176 */ 177#define NAME simple_z_textured_triangle 178#define INTERP_Z 1 179#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE 180#define INTERP_INT_TEX 1 181#define S_SCALE twidth 182#define T_SCALE theight 183 184#define SETUP_CODE \ 185 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \ 186 struct gl_texture_object *obj = \ 187 ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ 188 const GLint b = obj->BaseLevel; \ 189 const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \ 190 const GLfloat theight = (GLfloat) obj->Image[0][b]->Height; \ 191 const GLint twidth_log2 = obj->Image[0][b]->WidthLog2; \ 192 const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data; \ 193 const GLint smask = obj->Image[0][b]->Width - 1; \ 194 const GLint tmask = obj->Image[0][b]->Height - 1; \ 195 if (!rb || !texture) { \ 196 return; \ 197 } 198 199#define RENDER_SPAN( span ) \ 200 GLuint i; \ 201 GLchan rgb[MAX_WIDTH][3]; \ 202 span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \ 203 span.intTex[1] -= FIXED_HALF; \ 204 for (i = 0; i < span.end; i++) { \ 205 const GLuint z = FixedToDepth(span.z); \ 206 if (z < zRow[i]) { \ 207 GLint s = FixedToInt(span.intTex[0]) & smask; \ 208 GLint t = FixedToInt(span.intTex[1]) & tmask; \ 209 GLint pos = (t << twidth_log2) + s; \ 210 pos = pos + pos + pos; /* multiply by 3 */ \ 211 rgb[i][RCOMP] = texture[pos]; \ 212 rgb[i][GCOMP] = texture[pos+1]; \ 213 rgb[i][BCOMP] = texture[pos+2]; \ 214 zRow[i] = z; \ 215 span.array->mask[i] = 1; \ 216 } \ 217 else { \ 218 span.array->mask[i] = 0; \ 219 } \ 220 span.intTex[0] += span.intTexStep[0]; \ 221 span.intTex[1] += span.intTexStep[1]; \ 222 span.z += span.zStep; \ 223 } \ 224 rb->PutRowRGB(ctx, rb, span.end, span.x, span.y, rgb, span.array->mask); 225 226#include "s_tritemp.h" 227 228 229#if CHAN_TYPE != GL_FLOAT 230 231struct affine_info 232{ 233 GLenum filter; 234 GLenum format; 235 GLenum envmode; 236 GLint smask, tmask; 237 GLint twidth_log2; 238 const GLchan *texture; 239 GLfixed er, eg, eb, ea; 240 GLint tbytesline, tsize; 241}; 242 243 244static INLINE GLint 245ilerp(GLint t, GLint a, GLint b) 246{ 247 return a + ((t * (b - a)) >> FIXED_SHIFT); 248} 249 250static INLINE GLint 251ilerp_2d(GLint ia, GLint ib, GLint v00, GLint v10, GLint v01, GLint v11) 252{ 253 const GLint temp0 = ilerp(ia, v00, v10); 254 const GLint temp1 = ilerp(ia, v01, v11); 255 return ilerp(ib, temp0, temp1); 256} 257 258 259/* This function can handle GL_NEAREST or GL_LINEAR sampling of 2D RGB or RGBA 260 * textures with GL_REPLACE, GL_MODULATE, GL_BLEND, GL_DECAL or GL_ADD 261 * texture env modes. 262 */ 263static INLINE void 264affine_span(GLcontext *ctx, SWspan *span, 265 struct affine_info *info) 266{ 267 GLchan sample[4]; /* the filtered texture sample */ 268 const GLuint texEnableSave = ctx->Texture._EnabledUnits; 269 270 /* Instead of defining a function for each mode, a test is done 271 * between the outer and inner loops. This is to reduce code size 272 * and complexity. Observe that an optimizing compiler kills 273 * unused variables (for instance tf,sf,ti,si in case of GL_NEAREST). 274 */ 275 276#define NEAREST_RGB \ 277 sample[RCOMP] = tex00[RCOMP]; \ 278 sample[GCOMP] = tex00[GCOMP]; \ 279 sample[BCOMP] = tex00[BCOMP]; \ 280 sample[ACOMP] = CHAN_MAX 281 282#define LINEAR_RGB \ 283 sample[RCOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]);\ 284 sample[GCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\ 285 sample[BCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\ 286 sample[ACOMP] = CHAN_MAX; 287 288#define NEAREST_RGBA COPY_CHAN4(sample, tex00) 289 290#define LINEAR_RGBA \ 291 sample[RCOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]);\ 292 sample[GCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\ 293 sample[BCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\ 294 sample[ACOMP] = ilerp_2d(sf, tf, tex00[3], tex01[3], tex10[3], tex11[3]) 295 296#define MODULATE \ 297 dest[RCOMP] = span->red * (sample[RCOMP] + 1u) >> (FIXED_SHIFT + 8); \ 298 dest[GCOMP] = span->green * (sample[GCOMP] + 1u) >> (FIXED_SHIFT + 8); \ 299 dest[BCOMP] = span->blue * (sample[BCOMP] + 1u) >> (FIXED_SHIFT + 8); \ 300 dest[ACOMP] = span->alpha * (sample[ACOMP] + 1u) >> (FIXED_SHIFT + 8) 301 302#define DECAL \ 303 dest[RCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->red + \ 304 ((sample[ACOMP] + 1) * sample[RCOMP] << FIXED_SHIFT)) \ 305 >> (FIXED_SHIFT + 8); \ 306 dest[GCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->green + \ 307 ((sample[ACOMP] + 1) * sample[GCOMP] << FIXED_SHIFT)) \ 308 >> (FIXED_SHIFT + 8); \ 309 dest[BCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->blue + \ 310 ((sample[ACOMP] + 1) * sample[BCOMP] << FIXED_SHIFT)) \ 311 >> (FIXED_SHIFT + 8); \ 312 dest[ACOMP] = FixedToInt(span->alpha) 313 314#define BLEND \ 315 dest[RCOMP] = ((CHAN_MAX - sample[RCOMP]) * span->red \ 316 + (sample[RCOMP] + 1) * info->er) >> (FIXED_SHIFT + 8); \ 317 dest[GCOMP] = ((CHAN_MAX - sample[GCOMP]) * span->green \ 318 + (sample[GCOMP] + 1) * info->eg) >> (FIXED_SHIFT + 8); \ 319 dest[BCOMP] = ((CHAN_MAX - sample[BCOMP]) * span->blue \ 320 + (sample[BCOMP] + 1) * info->eb) >> (FIXED_SHIFT + 8); \ 321 dest[ACOMP] = span->alpha * (sample[ACOMP] + 1) >> (FIXED_SHIFT + 8) 322 323#define REPLACE COPY_CHAN4(dest, sample) 324 325#define ADD \ 326 { \ 327 GLint rSum = FixedToInt(span->red) + (GLint) sample[RCOMP]; \ 328 GLint gSum = FixedToInt(span->green) + (GLint) sample[GCOMP]; \ 329 GLint bSum = FixedToInt(span->blue) + (GLint) sample[BCOMP]; \ 330 dest[RCOMP] = MIN2(rSum, CHAN_MAX); \ 331 dest[GCOMP] = MIN2(gSum, CHAN_MAX); \ 332 dest[BCOMP] = MIN2(bSum, CHAN_MAX); \ 333 dest[ACOMP] = span->alpha * (sample[ACOMP] + 1) >> (FIXED_SHIFT + 8); \ 334 } 335 336/* shortcuts */ 337 338#define NEAREST_RGB_REPLACE \ 339 NEAREST_RGB; \ 340 dest[0] = sample[0]; \ 341 dest[1] = sample[1]; \ 342 dest[2] = sample[2]; \ 343 dest[3] = FixedToInt(span->alpha); 344 345#define NEAREST_RGBA_REPLACE COPY_CHAN4(dest, tex00) 346 347#define SPAN_NEAREST(DO_TEX, COMPS) \ 348 for (i = 0; i < span->end; i++) { \ 349 /* Isn't it necessary to use FixedFloor below?? */ \ 350 GLint s = FixedToInt(span->intTex[0]) & info->smask; \ 351 GLint t = FixedToInt(span->intTex[1]) & info->tmask; \ 352 GLint pos = (t << info->twidth_log2) + s; \ 353 const GLchan *tex00 = info->texture + COMPS * pos; \ 354 DO_TEX; \ 355 span->red += span->redStep; \ 356 span->green += span->greenStep; \ 357 span->blue += span->blueStep; \ 358 span->alpha += span->alphaStep; \ 359 span->intTex[0] += span->intTexStep[0]; \ 360 span->intTex[1] += span->intTexStep[1]; \ 361 dest += 4; \ 362 } 363 364#define SPAN_LINEAR(DO_TEX, COMPS) \ 365 for (i = 0; i < span->end; i++) { \ 366 /* Isn't it necessary to use FixedFloor below?? */ \ 367 const GLint s = FixedToInt(span->intTex[0]) & info->smask; \ 368 const GLint t = FixedToInt(span->intTex[1]) & info->tmask; \ 369 const GLfixed sf = span->intTex[0] & FIXED_FRAC_MASK; \ 370 const GLfixed tf = span->intTex[1] & FIXED_FRAC_MASK; \ 371 const GLint pos = (t << info->twidth_log2) + s; \ 372 const GLchan *tex00 = info->texture + COMPS * pos; \ 373 const GLchan *tex10 = tex00 + info->tbytesline; \ 374 const GLchan *tex01 = tex00 + COMPS; \ 375 const GLchan *tex11 = tex10 + COMPS; \ 376 if (t == info->tmask) { \ 377 tex10 -= info->tsize; \ 378 tex11 -= info->tsize; \ 379 } \ 380 if (s == info->smask) { \ 381 tex01 -= info->tbytesline; \ 382 tex11 -= info->tbytesline; \ 383 } \ 384 DO_TEX; \ 385 span->red += span->redStep; \ 386 span->green += span->greenStep; \ 387 span->blue += span->blueStep; \ 388 span->alpha += span->alphaStep; \ 389 span->intTex[0] += span->intTexStep[0]; \ 390 span->intTex[1] += span->intTexStep[1]; \ 391 dest += 4; \ 392 } 393 394 395 GLuint i; 396 GLchan *dest = span->array->rgba[0]; 397 398 /* Disable tex units so they're not re-applied in swrast_write_rgba_span */ 399 ctx->Texture._EnabledUnits = 0x0; 400 401 span->intTex[0] -= FIXED_HALF; 402 span->intTex[1] -= FIXED_HALF; 403 switch (info->filter) { 404 case GL_NEAREST: 405 switch (info->format) { 406 case GL_RGB: 407 switch (info->envmode) { 408 case GL_MODULATE: 409 SPAN_NEAREST(NEAREST_RGB;MODULATE,3); 410 break; 411 case GL_DECAL: 412 case GL_REPLACE: 413 SPAN_NEAREST(NEAREST_RGB_REPLACE,3); 414 break; 415 case GL_BLEND: 416 SPAN_NEAREST(NEAREST_RGB;BLEND,3); 417 break; 418 case GL_ADD: 419 SPAN_NEAREST(NEAREST_RGB;ADD,3); 420 break; 421 default: 422 _mesa_problem(ctx, "bad tex env mode in SPAN_LINEAR"); 423 return; 424 } 425 break; 426 case GL_RGBA: 427 switch(info->envmode) { 428 case GL_MODULATE: 429 SPAN_NEAREST(NEAREST_RGBA;MODULATE,4); 430 break; 431 case GL_DECAL: 432 SPAN_NEAREST(NEAREST_RGBA;DECAL,4); 433 break; 434 case GL_BLEND: 435 SPAN_NEAREST(NEAREST_RGBA;BLEND,4); 436 break; 437 case GL_ADD: 438 SPAN_NEAREST(NEAREST_RGBA;ADD,4); 439 break; 440 case GL_REPLACE: 441 SPAN_NEAREST(NEAREST_RGBA_REPLACE,4); 442 break; 443 default: 444 _mesa_problem(ctx, "bad tex env mode (2) in SPAN_LINEAR"); 445 return; 446 } 447 break; 448 } 449 break; 450 451 case GL_LINEAR: 452 span->intTex[0] -= FIXED_HALF; 453 span->intTex[1] -= FIXED_HALF; 454 switch (info->format) { 455 case GL_RGB: 456 switch (info->envmode) { 457 case GL_MODULATE: 458 SPAN_LINEAR(LINEAR_RGB;MODULATE,3); 459 break; 460 case GL_DECAL: 461 case GL_REPLACE: 462 SPAN_LINEAR(LINEAR_RGB;REPLACE,3); 463 break; 464 case GL_BLEND: 465 SPAN_LINEAR(LINEAR_RGB;BLEND,3); 466 break; 467 case GL_ADD: 468 SPAN_LINEAR(LINEAR_RGB;ADD,3); 469 break; 470 default: 471 _mesa_problem(ctx, "bad tex env mode (3) in SPAN_LINEAR"); 472 return; 473 } 474 break; 475 case GL_RGBA: 476 switch (info->envmode) { 477 case GL_MODULATE: 478 SPAN_LINEAR(LINEAR_RGBA;MODULATE,4); 479 break; 480 case GL_DECAL: 481 SPAN_LINEAR(LINEAR_RGBA;DECAL,4); 482 break; 483 case GL_BLEND: 484 SPAN_LINEAR(LINEAR_RGBA;BLEND,4); 485 break; 486 case GL_ADD: 487 SPAN_LINEAR(LINEAR_RGBA;ADD,4); 488 break; 489 case GL_REPLACE: 490 SPAN_LINEAR(LINEAR_RGBA;REPLACE,4); 491 break; 492 default: 493 _mesa_problem(ctx, "bad tex env mode (4) in SPAN_LINEAR"); 494 return; 495 } 496 break; 497 } 498 break; 499 } 500 span->interpMask &= ~SPAN_RGBA; 501 ASSERT(span->arrayMask & SPAN_RGBA); 502 503 _swrast_write_rgba_span(ctx, span); 504 505 /* re-enable texture units */ 506 ctx->Texture._EnabledUnits = texEnableSave; 507 508#undef SPAN_NEAREST 509#undef SPAN_LINEAR 510} 511 512 513 514/* 515 * Render an RGB/RGBA textured triangle without perspective correction. 516 */ 517#define NAME affine_textured_triangle 518#define INTERP_Z 1 519#define INTERP_RGB 1 520#define INTERP_ALPHA 1 521#define INTERP_INT_TEX 1 522#define S_SCALE twidth 523#define T_SCALE theight 524 525#define SETUP_CODE \ 526 struct affine_info info; \ 527 struct gl_texture_unit *unit = ctx->Texture.Unit+0; \ 528 struct gl_texture_object *obj = \ 529 ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ 530 const GLint b = obj->BaseLevel; \ 531 const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \ 532 const GLfloat theight = (GLfloat) obj->Image[0][b]->Height; \ 533 info.texture = (const GLchan *) obj->Image[0][b]->Data; \ 534 info.twidth_log2 = obj->Image[0][b]->WidthLog2; \ 535 info.smask = obj->Image[0][b]->Width - 1; \ 536 info.tmask = obj->Image[0][b]->Height - 1; \ 537 info.format = obj->Image[0][b]->_BaseFormat; \ 538 info.filter = obj->MinFilter; \ 539 info.envmode = unit->EnvMode; \ 540 span.arrayMask |= SPAN_RGBA; \ 541 \ 542 if (info.envmode == GL_BLEND) { \ 543 /* potential off-by-one error here? (1.0f -> 2048 -> 0) */ \ 544 info.er = FloatToFixed(unit->EnvColor[RCOMP] * CHAN_MAXF); \ 545 info.eg = FloatToFixed(unit->EnvColor[GCOMP] * CHAN_MAXF); \ 546 info.eb = FloatToFixed(unit->EnvColor[BCOMP] * CHAN_MAXF); \ 547 info.ea = FloatToFixed(unit->EnvColor[ACOMP] * CHAN_MAXF); \ 548 } \ 549 if (!info.texture) { \ 550 /* this shouldn't happen */ \ 551 return; \ 552 } \ 553 \ 554 switch (info.format) { \ 555 case GL_ALPHA: \ 556 case GL_LUMINANCE: \ 557 case GL_INTENSITY: \ 558 info.tbytesline = obj->Image[0][b]->Width; \ 559 break; \ 560 case GL_LUMINANCE_ALPHA: \ 561 info.tbytesline = obj->Image[0][b]->Width * 2; \ 562 break; \ 563 case GL_RGB: \ 564 info.tbytesline = obj->Image[0][b]->Width * 3; \ 565 break; \ 566 case GL_RGBA: \ 567 info.tbytesline = obj->Image[0][b]->Width * 4; \ 568 break; \ 569 default: \ 570 _mesa_problem(NULL, "Bad texture format in affine_texture_triangle");\ 571 return; \ 572 } \ 573 info.tsize = obj->Image[0][b]->Height * info.tbytesline; 574 575#define RENDER_SPAN( span ) affine_span(ctx, &span, &info); 576 577#include "s_tritemp.h" 578 579 580 581struct persp_info 582{ 583 GLenum filter; 584 GLenum format; 585 GLenum envmode; 586 GLint smask, tmask; 587 GLint twidth_log2; 588 const GLchan *texture; 589 GLfixed er, eg, eb, ea; /* texture env color */ 590 GLint tbytesline, tsize; 591}; 592 593 594static INLINE void 595fast_persp_span(GLcontext *ctx, SWspan *span, 596 struct persp_info *info) 597{ 598 GLchan sample[4]; /* the filtered texture sample */ 599 600 /* Instead of defining a function for each mode, a test is done 601 * between the outer and inner loops. This is to reduce code size 602 * and complexity. Observe that an optimizing compiler kills 603 * unused variables (for instance tf,sf,ti,si in case of GL_NEAREST). 604 */ 605#define SPAN_NEAREST(DO_TEX,COMP) \ 606 for (i = 0; i < span->end; i++) { \ 607 GLdouble invQ = tex_coord[2] ? \ 608 (1.0 / tex_coord[2]) : 1.0; \ 609 GLfloat s_tmp = (GLfloat) (tex_coord[0] * invQ); \ 610 GLfloat t_tmp = (GLfloat) (tex_coord[1] * invQ); \ 611 GLint s = IFLOOR(s_tmp) & info->smask; \ 612 GLint t = IFLOOR(t_tmp) & info->tmask; \ 613 GLint pos = (t << info->twidth_log2) + s; \ 614 const GLchan *tex00 = info->texture + COMP * pos; \ 615 DO_TEX; \ 616 span->red += span->redStep; \ 617 span->green += span->greenStep; \ 618 span->blue += span->blueStep; \ 619 span->alpha += span->alphaStep; \ 620 tex_coord[0] += tex_step[0]; \ 621 tex_coord[1] += tex_step[1]; \ 622 tex_coord[2] += tex_step[2]; \ 623 dest += 4; \ 624 } 625 626#define SPAN_LINEAR(DO_TEX,COMP) \ 627 for (i = 0; i < span->end; i++) { \ 628 GLdouble invQ = tex_coord[2] ? \ 629 (1.0 / tex_coord[2]) : 1.0; \ 630 const GLfloat s_tmp = (GLfloat) (tex_coord[0] * invQ); \ 631 const GLfloat t_tmp = (GLfloat) (tex_coord[1] * invQ); \ 632 const GLfixed s_fix = FloatToFixed(s_tmp) - FIXED_HALF; \ 633 const GLfixed t_fix = FloatToFixed(t_tmp) - FIXED_HALF; \ 634 const GLint s = FixedToInt(FixedFloor(s_fix)) & info->smask; \ 635 const GLint t = FixedToInt(FixedFloor(t_fix)) & info->tmask; \ 636 const GLfixed sf = s_fix & FIXED_FRAC_MASK; \ 637 const GLfixed tf = t_fix & FIXED_FRAC_MASK; \ 638 const GLint pos = (t << info->twidth_log2) + s; \ 639 const GLchan *tex00 = info->texture + COMP * pos; \ 640 const GLchan *tex10 = tex00 + info->tbytesline; \ 641 const GLchan *tex01 = tex00 + COMP; \ 642 const GLchan *tex11 = tex10 + COMP; \ 643 if (t == info->tmask) { \ 644 tex10 -= info->tsize; \ 645 tex11 -= info->tsize; \ 646 } \ 647 if (s == info->smask) { \ 648 tex01 -= info->tbytesline; \ 649 tex11 -= info->tbytesline; \ 650 } \ 651 DO_TEX; \ 652 span->red += span->redStep; \ 653 span->green += span->greenStep; \ 654 span->blue += span->blueStep; \ 655 span->alpha += span->alphaStep; \ 656 tex_coord[0] += tex_step[0]; \ 657 tex_coord[1] += tex_step[1]; \ 658 tex_coord[2] += tex_step[2]; \ 659 dest += 4; \ 660 } 661 662 GLuint i; 663 GLfloat tex_coord[3], tex_step[3]; 664 GLchan *dest = span->array->rgba[0]; 665 666 const GLuint savedTexEnable = ctx->Texture._EnabledUnits; 667 ctx->Texture._EnabledUnits = 0; 668 669 tex_coord[0] = span->attrStart[FRAG_ATTRIB_TEX0][0] * (info->smask + 1); 670 tex_step[0] = span->attrStepX[FRAG_ATTRIB_TEX0][0] * (info->smask + 1); 671 tex_coord[1] = span->attrStart[FRAG_ATTRIB_TEX0][1] * (info->tmask + 1); 672 tex_step[1] = span->attrStepX[FRAG_ATTRIB_TEX0][1] * (info->tmask + 1); 673 /* span->attrStart[FRAG_ATTRIB_TEX0][2] only if 3D-texturing, here only 2D */ 674 tex_coord[2] = span->attrStart[FRAG_ATTRIB_TEX0][3]; 675 tex_step[2] = span->attrStepX[FRAG_ATTRIB_TEX0][3]; 676 677 switch (info->filter) { 678 case GL_NEAREST: 679 switch (info->format) { 680 case GL_RGB: 681 switch (info->envmode) { 682 case GL_MODULATE: 683 SPAN_NEAREST(NEAREST_RGB;MODULATE,3); 684 break; 685 case GL_DECAL: 686 case GL_REPLACE: 687 SPAN_NEAREST(NEAREST_RGB_REPLACE,3); 688 break; 689 case GL_BLEND: 690 SPAN_NEAREST(NEAREST_RGB;BLEND,3); 691 break; 692 case GL_ADD: 693 SPAN_NEAREST(NEAREST_RGB;ADD,3); 694 break; 695 default: 696 _mesa_problem(ctx, "bad tex env mode (5) in SPAN_LINEAR"); 697 return; 698 } 699 break; 700 case GL_RGBA: 701 switch(info->envmode) { 702 case GL_MODULATE: 703 SPAN_NEAREST(NEAREST_RGBA;MODULATE,4); 704 break; 705 case GL_DECAL: 706 SPAN_NEAREST(NEAREST_RGBA;DECAL,4); 707 break; 708 case GL_BLEND: 709 SPAN_NEAREST(NEAREST_RGBA;BLEND,4); 710 break; 711 case GL_ADD: 712 SPAN_NEAREST(NEAREST_RGBA;ADD,4); 713 break; 714 case GL_REPLACE: 715 SPAN_NEAREST(NEAREST_RGBA_REPLACE,4); 716 break; 717 default: 718 _mesa_problem(ctx, "bad tex env mode (6) in SPAN_LINEAR"); 719 return; 720 } 721 break; 722 } 723 break; 724 725 case GL_LINEAR: 726 switch (info->format) { 727 case GL_RGB: 728 switch (info->envmode) { 729 case GL_MODULATE: 730 SPAN_LINEAR(LINEAR_RGB;MODULATE,3); 731 break; 732 case GL_DECAL: 733 case GL_REPLACE: 734 SPAN_LINEAR(LINEAR_RGB;REPLACE,3); 735 break; 736 case GL_BLEND: 737 SPAN_LINEAR(LINEAR_RGB;BLEND,3); 738 break; 739 case GL_ADD: 740 SPAN_LINEAR(LINEAR_RGB;ADD,3); 741 break; 742 default: 743 _mesa_problem(ctx, "bad tex env mode (7) in SPAN_LINEAR"); 744 return; 745 } 746 break; 747 case GL_RGBA: 748 switch (info->envmode) { 749 case GL_MODULATE: 750 SPAN_LINEAR(LINEAR_RGBA;MODULATE,4); 751 break; 752 case GL_DECAL: 753 SPAN_LINEAR(LINEAR_RGBA;DECAL,4); 754 break; 755 case GL_BLEND: 756 SPAN_LINEAR(LINEAR_RGBA;BLEND,4); 757 break; 758 case GL_ADD: 759 SPAN_LINEAR(LINEAR_RGBA;ADD,4); 760 break; 761 case GL_REPLACE: 762 SPAN_LINEAR(LINEAR_RGBA;REPLACE,4); 763 break; 764 default: 765 _mesa_problem(ctx, "bad tex env mode (8) in SPAN_LINEAR"); 766 return; 767 } 768 break; 769 } 770 break; 771 } 772 773 ASSERT(span->arrayMask & SPAN_RGBA); 774 _swrast_write_rgba_span(ctx, span); 775 776#undef SPAN_NEAREST 777#undef SPAN_LINEAR 778 779 /* restore state */ 780 ctx->Texture._EnabledUnits = savedTexEnable; 781} 782 783 784/* 785 * Render an perspective corrected RGB/RGBA textured triangle. 786 * The Q (aka V in Mesa) coordinate must be zero such that the divide 787 * by interpolated Q/W comes out right. 788 * 789 */ 790#define NAME persp_textured_triangle 791#define INTERP_Z 1 792#define INTERP_RGB 1 793#define INTERP_ALPHA 1 794#define INTERP_ATTRIBS 1 795 796#define SETUP_CODE \ 797 struct persp_info info; \ 798 const struct gl_texture_unit *unit = ctx->Texture.Unit+0; \ 799 struct gl_texture_object *obj = \ 800 ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ 801 const GLint b = obj->BaseLevel; \ 802 info.texture = (const GLchan *) obj->Image[0][b]->Data; \ 803 info.twidth_log2 = obj->Image[0][b]->WidthLog2; \ 804 info.smask = obj->Image[0][b]->Width - 1; \ 805 info.tmask = obj->Image[0][b]->Height - 1; \ 806 info.format = obj->Image[0][b]->_BaseFormat; \ 807 info.filter = obj->MinFilter; \ 808 info.envmode = unit->EnvMode; \ 809 \ 810 if (info.envmode == GL_BLEND) { \ 811 /* potential off-by-one error here? (1.0f -> 2048 -> 0) */ \ 812 info.er = FloatToFixed(unit->EnvColor[RCOMP] * CHAN_MAXF); \ 813 info.eg = FloatToFixed(unit->EnvColor[GCOMP] * CHAN_MAXF); \ 814 info.eb = FloatToFixed(unit->EnvColor[BCOMP] * CHAN_MAXF); \ 815 info.ea = FloatToFixed(unit->EnvColor[ACOMP] * CHAN_MAXF); \ 816 } \ 817 if (!info.texture) { \ 818 /* this shouldn't happen */ \ 819 return; \ 820 } \ 821 \ 822 switch (info.format) { \ 823 case GL_ALPHA: \ 824 case GL_LUMINANCE: \ 825 case GL_INTENSITY: \ 826 info.tbytesline = obj->Image[0][b]->Width; \ 827 break; \ 828 case GL_LUMINANCE_ALPHA: \ 829 info.tbytesline = obj->Image[0][b]->Width * 2; \ 830 break; \ 831 case GL_RGB: \ 832 info.tbytesline = obj->Image[0][b]->Width * 3; \ 833 break; \ 834 case GL_RGBA: \ 835 info.tbytesline = obj->Image[0][b]->Width * 4; \ 836 break; \ 837 default: \ 838 _mesa_problem(NULL, "Bad texture format in persp_textured_triangle");\ 839 return; \ 840 } \ 841 info.tsize = obj->Image[0][b]->Height * info.tbytesline; 842 843#define RENDER_SPAN( span ) \ 844 span.interpMask &= ~SPAN_RGBA; \ 845 span.arrayMask |= SPAN_RGBA; \ 846 fast_persp_span(ctx, &span, &info); 847 848#include "s_tritemp.h" 849 850#endif /*CHAN_TYPE != GL_FLOAT*/ 851 852 853 854/* 855 * Render an RGBA triangle with arbitrary attributes. 856 */ 857#define NAME general_triangle 858#define INTERP_Z 1 859#define INTERP_RGB 1 860#define INTERP_ALPHA 1 861#define INTERP_ATTRIBS 1 862#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span); 863#include "s_tritemp.h" 864 865 866 867 868/* 869 * Special tri function for occlusion testing 870 */ 871#define NAME occlusion_zless_triangle 872#define INTERP_Z 1 873#define SETUP_CODE \ 874 struct gl_renderbuffer *rb = ctx->DrawBuffer->_DepthBuffer; \ 875 struct gl_query_object *q = ctx->Query.CurrentOcclusionObject; \ 876 ASSERT(ctx->Depth.Test); \ 877 ASSERT(!ctx->Depth.Mask); \ 878 ASSERT(ctx->Depth.Func == GL_LESS); \ 879 if (!q) { \ 880 return; \ 881 } 882#define RENDER_SPAN( span ) \ 883 if (rb->DepthBits <= 16) { \ 884 GLuint i; \ 885 const GLushort *zRow = (const GLushort *) \ 886 rb->GetPointer(ctx, rb, span.x, span.y); \ 887 for (i = 0; i < span.end; i++) { \ 888 GLuint z = FixedToDepth(span.z); \ 889 if (z < zRow[i]) { \ 890 q->Result++; \ 891 } \ 892 span.z += span.zStep; \ 893 } \ 894 } \ 895 else { \ 896 GLuint i; \ 897 const GLuint *zRow = (const GLuint *) \ 898 rb->GetPointer(ctx, rb, span.x, span.y); \ 899 for (i = 0; i < span.end; i++) { \ 900 if ((GLuint)span.z < zRow[i]) { \ 901 q->Result++; \ 902 } \ 903 span.z += span.zStep; \ 904 } \ 905 } 906#include "s_tritemp.h" 907 908 909 910static void 911nodraw_triangle( GLcontext *ctx, 912 const SWvertex *v0, 913 const SWvertex *v1, 914 const SWvertex *v2 ) 915{ 916 (void) (ctx && v0 && v1 && v2); 917} 918 919 920/* 921 * This is used when separate specular color is enabled, but not 922 * texturing. We add the specular color to the primary color, 923 * draw the triangle, then restore the original primary color. 924 * Inefficient, but seldom needed. 925 */ 926void 927_swrast_add_spec_terms_triangle(GLcontext *ctx, const SWvertex *v0, 928 const SWvertex *v1, const SWvertex *v2) 929{ 930 SWvertex *ncv0 = (SWvertex *)v0; /* drop const qualifier */ 931 SWvertex *ncv1 = (SWvertex *)v1; 932 SWvertex *ncv2 = (SWvertex *)v2; 933 GLfloat rSum, gSum, bSum; 934 GLchan cSave[3][4]; 935 936 /* save original colors */ 937 COPY_CHAN4( cSave[0], ncv0->color ); 938 COPY_CHAN4( cSave[1], ncv1->color ); 939 COPY_CHAN4( cSave[2], ncv2->color ); 940 /* sum v0 */ 941 rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[FRAG_ATTRIB_COL1][0]; 942 gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[FRAG_ATTRIB_COL1][1]; 943 bSum = CHAN_TO_FLOAT(ncv0->color[2]) + ncv0->attrib[FRAG_ATTRIB_COL1][2]; 944 UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[0], rSum); 945 UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[1], gSum); 946 UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[2], bSum); 947 /* sum v1 */ 948 rSum = CHAN_TO_FLOAT(ncv1->color[0]) + ncv1->attrib[FRAG_ATTRIB_COL1][0]; 949 gSum = CHAN_TO_FLOAT(ncv1->color[1]) + ncv1->attrib[FRAG_ATTRIB_COL1][1]; 950 bSum = CHAN_TO_FLOAT(ncv1->color[2]) + ncv1->attrib[FRAG_ATTRIB_COL1][2]; 951 UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[0], rSum); 952 UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[1], gSum); 953 UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[2], bSum); 954 /* sum v2 */ 955 rSum = CHAN_TO_FLOAT(ncv2->color[0]) + ncv2->attrib[FRAG_ATTRIB_COL1][0]; 956 gSum = CHAN_TO_FLOAT(ncv2->color[1]) + ncv2->attrib[FRAG_ATTRIB_COL1][1]; 957 bSum = CHAN_TO_FLOAT(ncv2->color[2]) + ncv2->attrib[FRAG_ATTRIB_COL1][2]; 958 UNCLAMPED_FLOAT_TO_CHAN(ncv2->color[0], rSum); 959 UNCLAMPED_FLOAT_TO_CHAN(ncv2->color[1], gSum); 960 UNCLAMPED_FLOAT_TO_CHAN(ncv2->color[2], bSum); 961 /* draw */ 962 SWRAST_CONTEXT(ctx)->SpecTriangle( ctx, ncv0, ncv1, ncv2 ); 963 /* restore original colors */ 964 COPY_CHAN4( ncv0->color, cSave[0] ); 965 COPY_CHAN4( ncv1->color, cSave[1] ); 966 COPY_CHAN4( ncv2->color, cSave[2] ); 967} 968 969 970 971#ifdef DEBUG 972 973/* record the current triangle function name */ 974const char *_mesa_triFuncName = NULL; 975 976#define USE(triFunc) \ 977do { \ 978 _mesa_triFuncName = #triFunc; \ 979 /*printf("%s\n", _mesa_triFuncName);*/ \ 980 swrast->Triangle = triFunc; \ 981} while (0) 982 983#else 984 985#define USE(triFunc) swrast->Triangle = triFunc; 986 987#endif 988 989 990 991 992/* 993 * Determine which triangle rendering function to use given the current 994 * rendering context. 995 * 996 * Please update the summary flag _SWRAST_NEW_TRIANGLE if you add or 997 * remove tests to this code. 998 */ 999void 1000_swrast_choose_triangle( GLcontext *ctx ) 1001{ 1002 SWcontext *swrast = SWRAST_CONTEXT(ctx); 1003 const GLboolean rgbmode = ctx->Visual.rgbMode; 1004 1005 if (ctx->Polygon.CullFlag && 1006 ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { 1007 USE(nodraw_triangle); 1008 return; 1009 } 1010 1011 if (ctx->RenderMode==GL_RENDER) { 1012 1013 if (ctx->Polygon.SmoothFlag) { 1014 _swrast_set_aa_triangle_function(ctx); 1015 ASSERT(swrast->Triangle); 1016 return; 1017 } 1018 1019 /* special case for occlusion testing */ 1020 if (ctx->Query.CurrentOcclusionObject && 1021 ctx->Depth.Test && 1022 ctx->Depth.Mask == GL_FALSE && 1023 ctx->Depth.Func == GL_LESS && 1024 !ctx->Stencil.Enabled) { 1025 if ((rgbmode && 1026 ctx->Color.ColorMask[0] == 0 && 1027 ctx->Color.ColorMask[1] == 0 && 1028 ctx->Color.ColorMask[2] == 0 && 1029 ctx->Color.ColorMask[3] == 0) 1030 || 1031 (!rgbmode && ctx->Color.IndexMask == 0)) { 1032 USE(occlusion_zless_triangle); 1033 return; 1034 } 1035 } 1036 1037 if (!rgbmode) { 1038 USE(ci_triangle); 1039 return; 1040 } 1041 1042 /* 1043 * XXX should examine swrast->_ActiveAttribMask to determine what 1044 * needs to be interpolated. 1045 */ 1046 if (ctx->Texture._EnabledCoordUnits || 1047 ctx->FragmentProgram._Current || 1048 ctx->ATIFragmentShader._Enabled || 1049 NEED_SECONDARY_COLOR(ctx) || 1050 swrast->_FogEnabled) { 1051 /* Ugh, we do a _lot_ of tests to pick the best textured tri func */ 1052 const struct gl_texture_object *texObj2D; 1053 const struct gl_texture_image *texImg; 1054 GLenum minFilter, magFilter, envMode; 1055 GLint format; 1056 texObj2D = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; 1057 1058 texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL; 1059 format = texImg ? texImg->TexFormat->MesaFormat : -1; 1060 minFilter = texObj2D ? texObj2D->MinFilter : (GLenum) 0; 1061 magFilter = texObj2D ? texObj2D->MagFilter : (GLenum) 0; 1062 envMode = ctx->Texture.Unit[0].EnvMode; 1063 1064 /* First see if we can use an optimized 2-D texture function */ 1065 if (ctx->Texture._EnabledCoordUnits == 0x1 1066 && !ctx->FragmentProgram._Current 1067 && !ctx->ATIFragmentShader._Enabled 1068 && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT 1069 && texObj2D->WrapS == GL_REPEAT 1070 && texObj2D->WrapT == GL_REPEAT 1071 && texImg->_IsPowerOfTwo 1072 && texImg->Border == 0 1073 && texImg->Width == texImg->RowStride 1074 && (format == MESA_FORMAT_RGB || format == MESA_FORMAT_RGBA) 1075 && minFilter == magFilter 1076 && ctx->Light.Model.ColorControl == GL_SINGLE_COLOR 1077 && !swrast->_FogEnabled 1078 && ctx->Texture.Unit[0].EnvMode != GL_COMBINE_EXT) { 1079 if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) { 1080 if (minFilter == GL_NEAREST 1081 && format == MESA_FORMAT_RGB 1082 && (envMode == GL_REPLACE || envMode == GL_DECAL) 1083 && ((swrast->_RasterMask == (DEPTH_BIT | TEXTURE_BIT) 1084 && ctx->Depth.Func == GL_LESS 1085 && ctx->Depth.Mask == GL_TRUE) 1086 || swrast->_RasterMask == TEXTURE_BIT) 1087 && ctx->Polygon.StippleFlag == GL_FALSE 1088 && ctx->DrawBuffer->Visual.depthBits <= 16) { 1089 if (swrast->_RasterMask == (DEPTH_BIT | TEXTURE_BIT)) { 1090 USE(simple_z_textured_triangle); 1091 } 1092 else { 1093 USE(simple_textured_triangle); 1094 } 1095 } 1096 else { 1097#if CHAN_BITS != 8 1098 USE(general_triangle); 1099#else 1100 USE(affine_textured_triangle); 1101#endif 1102 } 1103 } 1104 else { 1105#if CHAN_BITS != 8 1106 USE(general_triangle); 1107#else 1108 USE(persp_textured_triangle); 1109#endif 1110 } 1111 } 1112 else { 1113 /* general case textured triangles */ 1114 USE(general_triangle); 1115 } 1116 } 1117 else { 1118 ASSERT(!swrast->_FogEnabled); 1119 ASSERT(!NEED_SECONDARY_COLOR(ctx)); 1120 if (ctx->Light.ShadeModel==GL_SMOOTH) { 1121 /* smooth shaded, no texturing, stippled or some raster ops */ 1122#if CHAN_BITS != 8 1123 USE(general_triangle); 1124#else 1125 USE(smooth_rgba_triangle); 1126#endif 1127 } 1128 else { 1129 /* flat shaded, no texturing, stippled or some raster ops */ 1130#if CHAN_BITS != 8 1131 USE(general_triangle); 1132#else 1133 USE(flat_rgba_triangle); 1134#endif 1135 } 1136 } 1137 } 1138 else if (ctx->RenderMode==GL_FEEDBACK) { 1139 USE(_swrast_feedback_triangle); 1140 } 1141 else { 1142 /* GL_SELECT mode */ 1143 USE(_swrast_select_triangle); 1144 } 1145} 1146