s_context.c revision 853bda3e7c4dfa7d8cc462729f6a3dce89e44963
1/* 2 * Mesa 3-D graphics library 3 * Version: 5.1 4 * 5 * Copyright (C) 1999-2003 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 * Authors: 25 * Keith Whitwell <keith@tungstengraphics.com> 26 * Brian Paul 27 */ 28 29#include "imports.h" 30#include "context.h" 31#include "mtypes.h" 32#include "texobj.h" 33#include "nvfragprog.h" 34 35#include "swrast.h" 36#include "s_blend.h" 37#include "s_context.h" 38#include "s_lines.h" 39#include "s_points.h" 40#include "s_span.h" 41#include "s_triangle.h" 42#include "s_texture.h" 43 44 45/* 46 * Recompute the value of swrast->_RasterMask, etc. according to 47 * the current context. 48 */ 49static void 50_swrast_update_rasterflags( GLcontext *ctx ) 51{ 52 GLuint RasterMask = 0; 53 54 if (ctx->Color.AlphaEnabled) RasterMask |= ALPHATEST_BIT; 55 if (ctx->Color.BlendEnabled) RasterMask |= BLEND_BIT; 56 if (ctx->Depth.Test) RasterMask |= DEPTH_BIT; 57 if (ctx->Fog.Enabled) RasterMask |= FOG_BIT; 58 if (ctx->Scissor.Enabled) RasterMask |= CLIP_BIT; 59 if (ctx->Stencil.Enabled) RasterMask |= STENCIL_BIT; 60 if (ctx->Visual.rgbMode) { 61 const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask); 62 if (colorMask != 0xffffffff) RasterMask |= MASKING_BIT; 63 if (ctx->Color._LogicOpEnabled) RasterMask |= LOGIC_OP_BIT; 64 if (ctx->Texture._EnabledUnits) RasterMask |= TEXTURE_BIT; 65 } 66 else { 67 if (ctx->Color.IndexMask != 0xffffffff) RasterMask |= MASKING_BIT; 68 if (ctx->Color.IndexLogicOpEnabled) RasterMask |= LOGIC_OP_BIT; 69 } 70 71 if (ctx->DrawBuffer->UseSoftwareAlphaBuffers 72 && ctx->Color.ColorMask[ACOMP] 73 && ctx->Color.DrawBuffer != GL_NONE) 74 RasterMask |= ALPHABUF_BIT; 75 76 if ( ctx->Viewport.X < 0 77 || ctx->Viewport.X + ctx->Viewport.Width > (GLint) ctx->DrawBuffer->Width 78 || ctx->Viewport.Y < 0 79 || ctx->Viewport.Y + ctx->Viewport.Height > (GLint) ctx->DrawBuffer->Height) { 80 RasterMask |= CLIP_BIT; 81 } 82 83 if (ctx->Depth.OcclusionTest || ctx->Occlusion.Active) 84 RasterMask |= OCCLUSION_BIT; 85 86 87 /* If we're not drawing to exactly one color buffer set the 88 * MULTI_DRAW_BIT flag. Also set it if we're drawing to no 89 * buffers or the RGBA or CI mask disables all writes. 90 */ 91 if (ctx->Color._DrawDestMask != FRONT_LEFT_BIT && 92 ctx->Color._DrawDestMask != BACK_LEFT_BIT && 93 ctx->Color._DrawDestMask != FRONT_RIGHT_BIT && 94 ctx->Color._DrawDestMask != BACK_RIGHT_BIT) { 95 /* more than one color buffer designated for writing (or zero buffers) */ 96 RasterMask |= MULTI_DRAW_BIT; 97 } 98 else if (ctx->Visual.rgbMode && *((GLuint *) ctx->Color.ColorMask) == 0) { 99 RasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */ 100 } 101 else if (!ctx->Visual.rgbMode && ctx->Color.IndexMask==0) { 102 RasterMask |= MULTI_DRAW_BIT; /* all color index bits disabled */ 103 } 104 105 if (ctx->FragmentProgram.Enabled) { 106 RasterMask |= FRAGPROG_BIT; 107 } 108 109 SWRAST_CONTEXT(ctx)->_RasterMask = RasterMask; 110} 111 112 113static void 114_swrast_update_polygon( GLcontext *ctx ) 115{ 116 GLfloat backface_sign = 1; 117 118 if (ctx->Polygon.CullFlag) { 119 backface_sign = 1; 120 switch(ctx->Polygon.CullFaceMode) { 121 case GL_BACK: 122 if(ctx->Polygon.FrontFace==GL_CCW) 123 backface_sign = -1; 124 break; 125 case GL_FRONT: 126 if(ctx->Polygon.FrontFace!=GL_CCW) 127 backface_sign = -1; 128 break; 129 default: 130 case GL_FRONT_AND_BACK: 131 backface_sign = 0; 132 break; 133 } 134 } 135 else { 136 backface_sign = 0; 137 } 138 139 SWRAST_CONTEXT(ctx)->_BackfaceSign = backface_sign; 140} 141 142 143static void 144_swrast_update_hint( GLcontext *ctx ) 145{ 146 SWcontext *swrast = SWRAST_CONTEXT(ctx); 147 swrast->_PreferPixelFog = (!swrast->AllowVertexFog || 148 (ctx->Hint.Fog == GL_NICEST && 149 swrast->AllowPixelFog)); 150} 151 152 153/* 154 * Update the swrast->_AnyTextureCombine flag. 155 */ 156static void 157_swrast_update_texture_env( GLcontext *ctx ) 158{ 159 SWcontext *swrast = SWRAST_CONTEXT(ctx); 160 GLuint i; 161 swrast->_AnyTextureCombine = GL_FALSE; 162 for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { 163 if (ctx->Texture.Unit[i].EnvMode == GL_COMBINE_EXT || 164 ctx->Texture.Unit[i].EnvMode == GL_COMBINE4_NV) { 165 swrast->_AnyTextureCombine = GL_TRUE; 166 return; 167 } 168 } 169} 170 171 172#define _SWRAST_NEW_DERIVED (_SWRAST_NEW_RASTERMASK | \ 173 _NEW_TEXTURE | \ 174 _NEW_HINT | \ 175 _NEW_POLYGON ) 176 177/* State referenced by _swrast_choose_triangle, _swrast_choose_line. 178 */ 179#define _SWRAST_NEW_TRIANGLE (_SWRAST_NEW_DERIVED | \ 180 _NEW_RENDERMODE| \ 181 _NEW_POLYGON| \ 182 _NEW_DEPTH| \ 183 _NEW_STENCIL| \ 184 _NEW_COLOR| \ 185 _NEW_TEXTURE| \ 186 _SWRAST_NEW_RASTERMASK| \ 187 _NEW_LIGHT| \ 188 _NEW_FOG | \ 189 _DD_NEW_SEPARATE_SPECULAR) 190 191#define _SWRAST_NEW_LINE (_SWRAST_NEW_DERIVED | \ 192 _NEW_RENDERMODE| \ 193 _NEW_LINE| \ 194 _NEW_TEXTURE| \ 195 _NEW_LIGHT| \ 196 _NEW_FOG| \ 197 _NEW_DEPTH | \ 198 _DD_NEW_SEPARATE_SPECULAR) 199 200#define _SWRAST_NEW_POINT (_SWRAST_NEW_DERIVED | \ 201 _NEW_RENDERMODE | \ 202 _NEW_POINT | \ 203 _NEW_TEXTURE | \ 204 _NEW_LIGHT | \ 205 _NEW_FOG | \ 206 _DD_NEW_SEPARATE_SPECULAR) 207 208#define _SWRAST_NEW_TEXTURE_SAMPLE_FUNC _NEW_TEXTURE 209 210#define _SWRAST_NEW_TEXTURE_ENV_MODE _NEW_TEXTURE 211 212#define _SWRAST_NEW_BLEND_FUNC _NEW_COLOR 213 214 215 216/* Stub for swrast->Triangle to select a true triangle function 217 * after a state change. 218 */ 219static void 220_swrast_validate_triangle( GLcontext *ctx, 221 const SWvertex *v0, 222 const SWvertex *v1, 223 const SWvertex *v2 ) 224{ 225 SWcontext *swrast = SWRAST_CONTEXT(ctx); 226 227 _swrast_validate_derived( ctx ); 228 swrast->choose_triangle( ctx ); 229 230 if (ctx->Texture._EnabledUnits == 0 231 && NEED_SECONDARY_COLOR(ctx) 232 && !ctx->FragmentProgram.Enabled) { 233 /* separate specular color, but no texture */ 234 swrast->SpecTriangle = swrast->Triangle; 235 swrast->Triangle = _swrast_add_spec_terms_triangle; 236 } 237 238 swrast->Triangle( ctx, v0, v1, v2 ); 239} 240 241static void 242_swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 ) 243{ 244 SWcontext *swrast = SWRAST_CONTEXT(ctx); 245 246 _swrast_validate_derived( ctx ); 247 swrast->choose_line( ctx ); 248 249 if (ctx->Texture._EnabledUnits == 0 250 && NEED_SECONDARY_COLOR(ctx) 251 && !ctx->FragmentProgram.Enabled) { 252 swrast->SpecLine = swrast->Line; 253 swrast->Line = _swrast_add_spec_terms_line; 254 } 255 256 257 swrast->Line( ctx, v0, v1 ); 258} 259 260static void 261_swrast_validate_point( GLcontext *ctx, const SWvertex *v0 ) 262{ 263 SWcontext *swrast = SWRAST_CONTEXT(ctx); 264 265 _swrast_validate_derived( ctx ); 266 swrast->choose_point( ctx ); 267 268 if (ctx->Texture._EnabledUnits == 0 269 && NEED_SECONDARY_COLOR(ctx) 270 && !ctx->FragmentProgram.Enabled) { 271 swrast->SpecPoint = swrast->Point; 272 swrast->Point = _swrast_add_spec_terms_point; 273 } 274 275 swrast->Point( ctx, v0 ); 276} 277 278 279static void _ASMAPI 280_swrast_validate_blend_func( GLcontext *ctx, GLuint n, 281 const GLubyte mask[], 282 GLchan src[][4], 283 CONST GLchan dst[][4] ) 284{ 285 SWcontext *swrast = SWRAST_CONTEXT(ctx); 286 287 _swrast_validate_derived( ctx ); 288 _swrast_choose_blend_func( ctx ); 289 290 swrast->BlendFunc( ctx, n, mask, src, dst ); 291} 292 293 294static void 295_swrast_validate_texture_sample( GLcontext *ctx, GLuint texUnit, 296 const struct gl_texture_object *tObj, 297 GLuint n, const GLfloat texcoords[][4], 298 const GLfloat lambda[], GLchan rgba[][4] ) 299{ 300 SWcontext *swrast = SWRAST_CONTEXT(ctx); 301 302 _swrast_validate_derived( ctx ); 303 304 /* Compute min/mag filter threshold */ 305 if (tObj->MinFilter != tObj->MagFilter) { 306 if (tObj->MagFilter == GL_LINEAR 307 && (tObj->MinFilter == GL_NEAREST_MIPMAP_NEAREST || 308 tObj->MinFilter == GL_NEAREST_MIPMAP_LINEAR)) { 309 swrast->_MinMagThresh[texUnit] = 0.5F; 310 } 311 else { 312 swrast->_MinMagThresh[texUnit] = 0.0F; 313 } 314 } 315 316 swrast->TextureSample[texUnit] = 317 _swrast_choose_texture_sample_func( ctx, tObj ); 318 319 swrast->TextureSample[texUnit]( ctx, texUnit, tObj, n, texcoords, 320 lambda, rgba ); 321} 322 323 324static void 325_swrast_sleep( GLcontext *ctx, GLuint new_state ) 326{ 327} 328 329 330static void 331_swrast_invalidate_state( GLcontext *ctx, GLuint new_state ) 332{ 333 SWcontext *swrast = SWRAST_CONTEXT(ctx); 334 GLuint i; 335 336 swrast->NewState |= new_state; 337 338 /* After 10 statechanges without any swrast functions being called, 339 * put the module to sleep. 340 */ 341 if (++swrast->StateChanges > 10) { 342 swrast->InvalidateState = _swrast_sleep; 343 swrast->NewState = ~0; 344 new_state = ~0; 345 } 346 347 if (new_state & swrast->invalidate_triangle) 348 swrast->Triangle = _swrast_validate_triangle; 349 350 if (new_state & swrast->invalidate_line) 351 swrast->Line = _swrast_validate_line; 352 353 if (new_state & swrast->invalidate_point) 354 swrast->Point = _swrast_validate_point; 355 356 if (new_state & _SWRAST_NEW_BLEND_FUNC) 357 swrast->BlendFunc = _swrast_validate_blend_func; 358 359 if (new_state & _SWRAST_NEW_TEXTURE_SAMPLE_FUNC) 360 for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) 361 swrast->TextureSample[i] = _swrast_validate_texture_sample; 362 363 if (ctx->Visual.rgbMode) { 364 ASSERT(swrast->Driver.WriteRGBASpan); 365 ASSERT(swrast->Driver.WriteRGBSpan); 366 ASSERT(swrast->Driver.WriteMonoRGBASpan); 367 ASSERT(swrast->Driver.WriteRGBAPixels); 368 ASSERT(swrast->Driver.WriteMonoRGBAPixels); 369 ASSERT(swrast->Driver.ReadRGBASpan); 370 ASSERT(swrast->Driver.ReadRGBAPixels); 371 } 372 else { 373 ASSERT(swrast->Driver.WriteCI32Span); 374 ASSERT(swrast->Driver.WriteCI8Span); 375 ASSERT(swrast->Driver.WriteMonoCISpan); 376 ASSERT(swrast->Driver.WriteCI32Pixels); 377 ASSERT(swrast->Driver.WriteMonoCIPixels); 378 ASSERT(swrast->Driver.ReadCI32Span); 379 ASSERT(swrast->Driver.ReadCI32Pixels); 380 } 381} 382 383 384void 385_swrast_validate_derived( GLcontext *ctx ) 386{ 387 SWcontext *swrast = SWRAST_CONTEXT(ctx); 388 389 if (swrast->NewState) { 390 if (swrast->NewState & _SWRAST_NEW_RASTERMASK) 391 _swrast_update_rasterflags( ctx ); 392 393 if (swrast->NewState & _NEW_POLYGON) 394 _swrast_update_polygon( ctx ); 395 396 if (swrast->NewState & _NEW_HINT) 397 _swrast_update_hint( ctx ); 398 399 if (swrast->NewState & _SWRAST_NEW_TEXTURE_ENV_MODE) 400 _swrast_update_texture_env( ctx ); 401 402 swrast->NewState = 0; 403 swrast->StateChanges = 0; 404 swrast->InvalidateState = _swrast_invalidate_state; 405 } 406} 407 408#define SWRAST_DEBUG 0 409 410/* Public entrypoints: See also s_accum.c, s_bitmap.c, etc. 411 */ 412void 413_swrast_Quad( GLcontext *ctx, 414 const SWvertex *v0, const SWvertex *v1, 415 const SWvertex *v2, const SWvertex *v3 ) 416{ 417 if (SWRAST_DEBUG) { 418 _mesa_debug(ctx, "_swrast_Quad\n"); 419 _swrast_print_vertex( ctx, v0 ); 420 _swrast_print_vertex( ctx, v1 ); 421 _swrast_print_vertex( ctx, v2 ); 422 _swrast_print_vertex( ctx, v3 ); 423 } 424 SWRAST_CONTEXT(ctx)->Triangle( ctx, v0, v1, v3 ); 425 SWRAST_CONTEXT(ctx)->Triangle( ctx, v1, v2, v3 ); 426} 427 428void 429_swrast_Triangle( GLcontext *ctx, const SWvertex *v0, 430 const SWvertex *v1, const SWvertex *v2 ) 431{ 432 if (SWRAST_DEBUG) { 433 _mesa_debug(ctx, "_swrast_Triangle\n"); 434 _swrast_print_vertex( ctx, v0 ); 435 _swrast_print_vertex( ctx, v1 ); 436 _swrast_print_vertex( ctx, v2 ); 437 } 438 SWRAST_CONTEXT(ctx)->Triangle( ctx, v0, v1, v2 ); 439} 440 441void 442_swrast_Line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 ) 443{ 444 if (SWRAST_DEBUG) { 445 _mesa_debug(ctx, "_swrast_Line\n"); 446 _swrast_print_vertex( ctx, v0 ); 447 _swrast_print_vertex( ctx, v1 ); 448 } 449 SWRAST_CONTEXT(ctx)->Line( ctx, v0, v1 ); 450} 451 452void 453_swrast_Point( GLcontext *ctx, const SWvertex *v0 ) 454{ 455 if (SWRAST_DEBUG) { 456 _mesa_debug(ctx, "_swrast_Point\n"); 457 _swrast_print_vertex( ctx, v0 ); 458 } 459 SWRAST_CONTEXT(ctx)->Point( ctx, v0 ); 460} 461 462void 463_swrast_InvalidateState( GLcontext *ctx, GLuint new_state ) 464{ 465 if (SWRAST_DEBUG) { 466 _mesa_debug(ctx, "_swrast_InvalidateState\n"); 467 } 468 SWRAST_CONTEXT(ctx)->InvalidateState( ctx, new_state ); 469} 470 471void 472_swrast_ResetLineStipple( GLcontext *ctx ) 473{ 474 if (SWRAST_DEBUG) { 475 _mesa_debug(ctx, "_swrast_ResetLineStipple\n"); 476 } 477 SWRAST_CONTEXT(ctx)->StippleCounter = 0; 478} 479 480void 481_swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value ) 482{ 483 if (SWRAST_DEBUG) { 484 _mesa_debug(ctx, "_swrast_allow_vertex_fog %d\n", value); 485 } 486 SWRAST_CONTEXT(ctx)->InvalidateState( ctx, _NEW_HINT ); 487 SWRAST_CONTEXT(ctx)->AllowVertexFog = value; 488} 489 490void 491_swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value ) 492{ 493 if (SWRAST_DEBUG) { 494 _mesa_debug(ctx, "_swrast_allow_pixel_fog %d\n", value); 495 } 496 SWRAST_CONTEXT(ctx)->InvalidateState( ctx, _NEW_HINT ); 497 SWRAST_CONTEXT(ctx)->AllowPixelFog = value; 498} 499 500 501GLboolean 502_swrast_CreateContext( GLcontext *ctx ) 503{ 504 GLuint i; 505 SWcontext *swrast = (SWcontext *)CALLOC(sizeof(SWcontext)); 506 507 if (SWRAST_DEBUG) { 508 _mesa_debug(ctx, "_swrast_CreateContext\n"); 509 } 510 511 if (!swrast) 512 return GL_FALSE; 513 514 swrast->NewState = ~0; 515 516 swrast->choose_point = _swrast_choose_point; 517 swrast->choose_line = _swrast_choose_line; 518 swrast->choose_triangle = _swrast_choose_triangle; 519 520 swrast->invalidate_point = _SWRAST_NEW_POINT; 521 swrast->invalidate_line = _SWRAST_NEW_LINE; 522 swrast->invalidate_triangle = _SWRAST_NEW_TRIANGLE; 523 524 swrast->Point = _swrast_validate_point; 525 swrast->Line = _swrast_validate_line; 526 swrast->Triangle = _swrast_validate_triangle; 527 swrast->InvalidateState = _swrast_sleep; 528 swrast->BlendFunc = _swrast_validate_blend_func; 529 530 swrast->AllowVertexFog = GL_TRUE; 531 swrast->AllowPixelFog = GL_TRUE; 532 533 if (ctx->Visual.doubleBufferMode) 534 swrast->CurrentBuffer = BACK_LEFT_BIT; 535 else 536 swrast->CurrentBuffer = FRONT_LEFT_BIT; 537 538 /* Optimized Accum buffer */ 539 swrast->_IntegerAccumMode = GL_TRUE; 540 swrast->_IntegerAccumScaler = 0.0; 541 542 for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) 543 swrast->TextureSample[i] = _swrast_validate_texture_sample; 544 545 swrast->SpanArrays = MALLOC_STRUCT(span_arrays); 546 if (!swrast->SpanArrays) { 547 FREE(swrast); 548 return GL_FALSE; 549 } 550 551 /* init point span buffer */ 552 swrast->PointSpan.primitive = GL_POINT; 553 swrast->PointSpan.start = 0; 554 swrast->PointSpan.end = 0; 555 swrast->PointSpan.facing = 0; 556 swrast->PointSpan.array = swrast->SpanArrays; 557 558 assert(ctx->Const.MaxTextureUnits > 0); 559 assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_UNITS); 560 561 swrast->TexelBuffer = (GLchan *) MALLOC(ctx->Const.MaxTextureUnits * 562 MAX_WIDTH * 4 * sizeof(GLchan)); 563 if (!swrast->TexelBuffer) { 564 FREE(swrast->SpanArrays); 565 FREE(swrast); 566 return GL_FALSE; 567 } 568 569 ctx->swrast_context = swrast; 570 571 return GL_TRUE; 572} 573 574void 575_swrast_DestroyContext( GLcontext *ctx ) 576{ 577 SWcontext *swrast = SWRAST_CONTEXT(ctx); 578 579 if (SWRAST_DEBUG) { 580 _mesa_debug(ctx, "_swrast_DestroyContext\n"); 581 } 582 583 FREE( swrast->SpanArrays ); 584 FREE( swrast->TexelBuffer ); 585 FREE( swrast ); 586 587 ctx->swrast_context = 0; 588} 589 590 591struct swrast_device_driver * 592_swrast_GetDeviceDriverReference( GLcontext *ctx ) 593{ 594 SWcontext *swrast = SWRAST_CONTEXT(ctx); 595 return &swrast->Driver; 596} 597 598void 599_swrast_flush( GLcontext *ctx ) 600{ 601 SWcontext *swrast = SWRAST_CONTEXT(ctx); 602 /* flush any pending fragments from rendering points */ 603 if (swrast->PointSpan.end > 0) { 604 if (ctx->Visual.rgbMode) { 605 if (ctx->Texture._EnabledCoordUnits) 606 _swrast_write_texture_span(ctx, &(swrast->PointSpan)); 607 else 608 _swrast_write_rgba_span(ctx, &(swrast->PointSpan)); 609 } 610 else { 611 _swrast_write_index_span(ctx, &(swrast->PointSpan)); 612 } 613 swrast->PointSpan.end = 0; 614 } 615} 616 617void 618_swrast_render_primitive( GLcontext *ctx, GLenum prim ) 619{ 620 SWcontext *swrast = SWRAST_CONTEXT(ctx); 621 if (swrast->Primitive == GL_POINTS && prim != GL_POINTS) { 622 _swrast_flush(ctx); 623 } 624 swrast->Primitive = prim; 625} 626 627 628void 629_swrast_render_start( GLcontext *ctx ) 630{ 631 SWcontext *swrast = SWRAST_CONTEXT(ctx); 632 if (swrast->Driver.SpanRenderStart) 633 swrast->Driver.SpanRenderStart( ctx ); 634 swrast->PointSpan.end = 0; 635} 636 637void 638_swrast_render_finish( GLcontext *ctx ) 639{ 640 SWcontext *swrast = SWRAST_CONTEXT(ctx); 641 if (swrast->Driver.SpanRenderFinish) 642 swrast->Driver.SpanRenderFinish( ctx ); 643 644 _swrast_flush(ctx); 645} 646 647 648#define SWRAST_DEBUG_VERTICES 0 649 650void 651_swrast_print_vertex( GLcontext *ctx, const SWvertex *v ) 652{ 653 GLuint i; 654 655 if (SWRAST_DEBUG_VERTICES) { 656 _mesa_debug(ctx, "win %f %f %f %f\n", 657 v->win[0], v->win[1], v->win[2], v->win[3]); 658 659 for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) 660 if (ctx->Texture.Unit[i]._ReallyEnabled) 661 _mesa_debug(ctx, "texcoord[%d] %f %f %f %f\n", i, 662 v->texcoord[i][0], v->texcoord[i][1], 663 v->texcoord[i][2], v->texcoord[i][3]); 664 665#if CHAN_TYPE == GL_FLOAT 666 _mesa_debug(ctx, "color %f %f %f %f\n", 667 v->color[0], v->color[1], v->color[2], v->color[3]); 668 _mesa_debug(ctx, "spec %f %f %f %f\n", 669 v->specular[0], v->specular[1], 670 v->specular[2], v->specular[3]); 671#else 672 _mesa_debug(ctx, "color %d %d %d %d\n", 673 v->color[0], v->color[1], v->color[2], v->color[3]); 674 _mesa_debug(ctx, "spec %d %d %d %d\n", 675 v->specular[0], v->specular[1], 676 v->specular[2], v->specular[3]); 677#endif 678 _mesa_debug(ctx, "fog %f\n", v->fog); 679 _mesa_debug(ctx, "index %d\n", v->index); 680 _mesa_debug(ctx, "pointsize %f\n", v->pointSize); 681 _mesa_debug(ctx, "\n"); 682 } 683} 684