home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mesa5.zip / mesa5src.zip / swrast / s_context.cpp < prev    next >
C/C++ Source or Header  |  2002-12-11  |  18KB  |  634 lines

  1. /* $Id: s_context.c,v 1.42 2002/10/29 20:28:59 brianp Exp $ */
  2.  
  3.  
  4. #include "glheader.h"
  5. #include "context.h"
  6. #include "mtypes.h"
  7. #include "imports.h"
  8.  
  9. #include "swrast.h"
  10. #include "s_blend.h"
  11. #include "s_context.h"
  12. #include "s_lines.h"
  13. #include "s_points.h"
  14. #include "s_span.h"
  15. #include "s_triangle.h"
  16. #include "s_texture.h"
  17.  
  18.  
  19. /*
  20.  * Recompute the value of swrast->_RasterMask, etc. according to
  21.  * the current context.
  22.  */
  23. static void
  24. _swrast_update_rasterflags( GLcontext *ctx )
  25. {
  26.    GLuint RasterMask = 0;
  27.  
  28.    if (ctx->Color.AlphaEnabled)           RasterMask |= 0x001;
  29.    if (ctx->Color.BlendEnabled)           RasterMask |= 0x002;
  30.    if (ctx->Depth.Test)                   RasterMask |= 0x004;
  31.    if (ctx->Fog.Enabled)                  RasterMask |= 0x008;
  32.    if (ctx->Scissor.Enabled)              RasterMask |= 0x020;
  33.    if (ctx->Stencil.Enabled)              RasterMask |= 0x040;
  34.    if (ctx->Visual.rgbMode) {
  35.       const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
  36.       if (colorMask != 0xffffffff)        RasterMask |= 0x080;
  37.       if (ctx->Color.ColorLogicOpEnabled) RasterMask |= 0x010;
  38.       if (ctx->Texture._EnabledUnits)     RasterMask |= 0x1000;
  39.    }
  40.    else {
  41.       if (ctx->Color.IndexMask != 0xffffffff) RasterMask |= 0x080;
  42.       if (ctx->Color.IndexLogicOpEnabled)     RasterMask |= 0x010;
  43.    }
  44.  
  45.    if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
  46.        && ctx->Color.ColorMask[3]
  47.        && ctx->Color.DrawBuffer != 0x0)
  48.       RasterMask |= 0x100;
  49.  
  50.    if (   ctx->Viewport.X < 0
  51.        || ctx->Viewport.X + ctx->Viewport.Width > (GLint) ctx->DrawBuffer->Width
  52.        || ctx->Viewport.Y < 0
  53.        || ctx->Viewport.Y + ctx->Viewport.Height > (GLint) ctx->DrawBuffer->Height) {
  54.       RasterMask |= 0x020;
  55.    }
  56.  
  57.    if (ctx->Depth.OcclusionTest)
  58.       RasterMask |= 0x800;
  59.  
  60.  
  61.    /* If we're not drawing to exactly one color buffer set the
  62.     * MULTI_DRAW_BIT flag.  Also set it if we're drawing to no
  63.     * buffers or the RGBA or CI mask disables all writes.
  64.     */
  65.    if (ctx->Color._DrawDestMask != 0x1 &&
  66.        ctx->Color._DrawDestMask != 0x4 &&
  67.        ctx->Color._DrawDestMask != 0x2 &&
  68.        ctx->Color._DrawDestMask != 0x8) {
  69.       /* more than one color buffer designated for writing (or zero buffers) */
  70.       RasterMask |= 0x400;
  71.    }
  72.    else if (ctx->Visual.rgbMode && *((GLuint *) ctx->Color.ColorMask) == 0) {
  73.       RasterMask |= 0x400; /* all RGBA channels disabled */
  74.    }
  75.    else if (!ctx->Visual.rgbMode && ctx->Color.IndexMask==0) {
  76.       RasterMask |= 0x400; /* all color index bits disabled */
  77.    }
  78.  
  79.    ((SWcontext *)ctx->swrast_context)->_RasterMask = RasterMask;
  80. }
  81.  
  82.  
  83. static void
  84. _swrast_update_polygon( GLcontext *ctx )
  85. {
  86.    GLfloat backface_sign = 1;
  87.  
  88.    if (ctx->Polygon.CullFlag) {
  89.       backface_sign = 1;
  90.       switch(ctx->Polygon.CullFaceMode) {
  91.       case 0x0405:
  92.         if(ctx->Polygon.FrontFace==0x0901)
  93.            backface_sign = -1;
  94.         break;
  95.       case 0x0404:
  96.         if(ctx->Polygon.FrontFace!=0x0901)
  97.            backface_sign = -1;
  98.         break;
  99.       default:
  100.       case 0x0408:
  101.         backface_sign = 0;
  102.         break;
  103.       }
  104.    }
  105.    else {
  106.       backface_sign = 0;
  107.    }
  108.  
  109.    ((SWcontext *)ctx->swrast_context)->_backface_sign = backface_sign;
  110. }
  111.  
  112.  
  113. static void
  114. _swrast_update_hint( GLcontext *ctx )
  115. {
  116.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  117.    swrast->_PreferPixelFog = (!swrast->AllowVertexFog ||
  118.                              (ctx->Hint.Fog == 0x1102 &&
  119.                               swrast->AllowPixelFog));
  120. }
  121.  
  122.  
  123. /*
  124.  * Update the swrast->_AnyTextureCombine flag.
  125.  */
  126. static void
  127. _swrast_update_texture_env( GLcontext *ctx )
  128. {
  129.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  130.    GLuint i;
  131.    swrast->_AnyTextureCombine = 0x0;
  132.    for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
  133.       if (ctx->Texture.Unit[i].EnvMode == 0x8570 ||
  134.           ctx->Texture.Unit[i].EnvMode == 0x8503) {
  135.          swrast->_AnyTextureCombine = 0x1;
  136.          return;
  137.       }
  138.    }
  139. }
  140.  
  141.  
  142.  
  143. /* State referenced by _swrast_choose_triangle, _swrast_choose_line.
  144.  */
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153. /* Stub for swrast->Triangle to select a true triangle function
  154.  * after a state change.
  155.  */
  156. static void
  157. _swrast_validate_triangle( GLcontext *ctx,
  158.                           const SWvertex *v0,
  159.                            const SWvertex *v1,
  160.                            const SWvertex *v2 )
  161. {
  162.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  163.  
  164.    _swrast_validate_derived( ctx );
  165.    swrast->choose_triangle( ctx );
  166.  
  167.    if ((ctx->_TriangleCaps & 0x2) &&
  168.        ctx->Texture._EnabledUnits == 0) {
  169.       swrast->SpecTriangle = swrast->Triangle;
  170.       swrast->Triangle = _swrast_add_spec_terms_triangle;
  171.    }
  172. // _mesa_debug(ctx, "_swrast_validate_triangle Triangle call\n");
  173.  
  174.    swrast->Triangle( ctx, v0, v1, v2 );
  175. // _mesa_debug(ctx, "_swrast_validate_triangle  Triangle call return \n");
  176. }
  177.  
  178. static void
  179. _swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
  180. {
  181.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  182.  
  183.    _swrast_validate_derived( ctx );
  184.    swrast->choose_line( ctx );
  185.  
  186.    if ((ctx->_TriangleCaps & 0x2) &&
  187.        ctx->Texture._EnabledUnits == 0) {
  188.       swrast->SpecLine = swrast->Line;
  189.       swrast->Line = _swrast_add_spec_terms_line;
  190.    }
  191.  
  192.  
  193.    swrast->Line( ctx, v0, v1 );
  194. }
  195.  
  196. static void
  197. _swrast_validate_point( GLcontext *ctx, const SWvertex *v0 )
  198. {
  199.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  200.  
  201.    _swrast_validate_derived( ctx );
  202.    swrast->choose_point( ctx );
  203.  
  204.    if ((ctx->_TriangleCaps & 0x2) &&
  205.        ctx->Texture._EnabledUnits == 0) {
  206.       swrast->SpecPoint = swrast->Point;
  207.       swrast->Point = _swrast_add_spec_terms_point;
  208.    }
  209.  
  210.    swrast->Point( ctx, v0 );
  211. }
  212.  
  213. static void
  214. _swrast_validate_blend_func( GLcontext *ctx, GLuint n,
  215.                             const GLubyte mask[],
  216.                             GLchan src[][4],
  217.                             const GLchan dst[][4] )
  218. {
  219.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  220.  
  221.    _swrast_validate_derived( ctx );
  222.    _swrast_choose_blend_func( ctx );
  223.  
  224.    swrast->BlendFunc( ctx, n, mask, src, dst );
  225. }
  226.  
  227.  
  228. static void
  229. _swrast_validate_texture_sample( GLcontext *ctx, GLuint texUnit,
  230.                                 const struct gl_texture_object *tObj,
  231.                                 GLuint n, GLfloat texcoords[][4],
  232.                                 const GLfloat lambda[], GLchan rgba[][4] )
  233. {
  234.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  235.  
  236.    _swrast_validate_derived( ctx );
  237.    _swrast_choose_texture_sample_func( ctx, texUnit, tObj );
  238.  
  239.    swrast->TextureSample[texUnit]( ctx, texUnit, tObj, n, texcoords,
  240.                                   lambda, rgba );
  241. }
  242.  
  243.  
  244. static void
  245. _swrast_sleep( GLcontext *ctx, GLuint new_state )
  246. {
  247. }
  248.  
  249.  
  250. static void
  251. _swrast_invalidate_state( GLcontext *ctx, GLuint new_state )
  252. {
  253.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  254.    GLuint i;
  255.  
  256.    swrast->NewState |= new_state;
  257.  
  258.    /* After 10 statechanges without any swrast functions being called,
  259.     * put the module to sleep.
  260.     */
  261.    if (++swrast->StateChanges > 10) {
  262.       swrast->InvalidateState = _swrast_sleep;
  263.       swrast->NewState = ~0;
  264.       new_state = ~0;
  265.    }
  266.  
  267.    if (new_state & swrast->invalidate_triangle)
  268.       swrast->Triangle = _swrast_validate_triangle;
  269.  
  270.    if (new_state & swrast->invalidate_line)
  271.       swrast->Line = _swrast_validate_line;
  272.  
  273.    if (new_state & swrast->invalidate_point)
  274.       swrast->Point = _swrast_validate_point;
  275.  
  276.    if (new_state & 0x20)
  277.       swrast->BlendFunc = _swrast_validate_blend_func;
  278.  
  279.    if (new_state & 0x40000)
  280.       for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
  281.         swrast->TextureSample[i] = _swrast_validate_texture_sample;
  282.  
  283.    if (ctx->Visual.rgbMode) {
  284.       ;
  285.       ;
  286.       ;
  287.       ;
  288.       ;
  289.       ;
  290.       ;
  291.    }
  292.    else {
  293.       ;
  294.       ;
  295.       ;
  296.       ;
  297.       ;
  298.       ;
  299.       ;
  300.    }
  301. }
  302.  
  303.  
  304. void
  305. _swrast_validate_derived( GLcontext *ctx )
  306. {
  307.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  308.  
  309.    if (swrast->NewState) {
  310.       if (swrast->NewState & (0x1000000| 0x10000| 0x20| 0x40| 0x100| 0x20000| 0x40000| 0x100000| 0x40))
  311.         _swrast_update_rasterflags( ctx );
  312.  
  313.       if (swrast->NewState & 0x4000)
  314.         _swrast_update_polygon( ctx );
  315.  
  316.       if (swrast->NewState & 0x200)
  317.         _swrast_update_hint( ctx );
  318.  
  319.       if (swrast->NewState & 0x40000)
  320.         _swrast_update_texture_env( ctx );
  321.  
  322.       swrast->NewState = 0;
  323.       swrast->StateChanges = 0;
  324.       swrast->InvalidateState = _swrast_invalidate_state;
  325.    }
  326. }
  327.  
  328.  
  329. /* Public entrypoints:  See also s_accum.c, s_bitmap.c, etc.
  330.  */
  331. void
  332. _swrast_Quad( GLcontext *ctx,
  333.              const SWvertex *v0, const SWvertex *v1,
  334.               const SWvertex *v2, const SWvertex *v3 )
  335. {
  336.    if (0) {
  337.       _mesa_debug(ctx, "_swrast_Quad\n");
  338.       _swrast_print_vertex( ctx, v0 );
  339.       _swrast_print_vertex( ctx, v1 );
  340.       _swrast_print_vertex( ctx, v2 );
  341.       _swrast_print_vertex( ctx, v3 );
  342.    }
  343.  _mesa_debug(ctx, "_swrast_Quad Triangle call\n");
  344.  
  345.    ((SWcontext *)ctx->swrast_context)->Triangle( ctx, v0, v1, v3 );
  346.  _mesa_debug(ctx, "_swrast_Quad Triangle call2\n");
  347.    ((SWcontext *)ctx->swrast_context)->Triangle( ctx, v1, v2, v3 );
  348.  _mesa_debug(ctx, "_swrast_Quad Triangle call2 return\n");
  349.  
  350.    _mesa_debug(ctx, "_swrast_Quad: v0=%p,v1=%p,v2=%p\n",v0,v1,v2);
  351. }
  352.  
  353. //EK DEBUG
  354. int debug_write(int *buff, int n);
  355.  
  356.  
  357. void
  358. _swrast_Triangle( GLcontext *ctx, const SWvertex *v0,
  359.                   const SWvertex *v1, const SWvertex *v2 )
  360. {
  361. static int raz=0;
  362. //   printf("-%i-\n",raz);
  363. //EK   if (0) {
  364. //      _mesa_debug(ctx, "_swrast_Triangle\n");
  365. //      _swrast_print_vertex( ctx, v0 );
  366. //      _swrast_print_vertex( ctx, v1 );
  367. //      _swrast_print_vertex( ctx, v2 );
  368. ////   }
  369. //  { int tmp[4];
  370. //    tmp[0] = 0;
  371. //    if(ctx) tmp[0] = 1;
  372. //    tmp[1] = 0;
  373. //    if(v0) tmp[1] = 1;
  374. //    tmp[2] = 0;
  375. //    if(v1) tmp[2] = 1;
  376. //    tmp[3] = 0;
  377. //    if(v1) tmp[3] = 1;
  378. //
  379. //   debug_write(tmp, 4);
  380. //   debug_write(tmp, 1);
  381. //  }
  382.  
  383. // _mesa_debug(ctx, "_swrast_Triangle Triangle call\n");
  384.  
  385.    ((SWcontext *)ctx->swrast_context)->Triangle( ctx, v0, v1, v2 );
  386.  
  387. // _mesa_debug(ctx, "_swrast_Triangle Triangle call return\n");
  388.  
  389. //{
  390. //      _mesa_debug(ctx, "_swrast_Triangle: v0=%p,v1=%p,v2=%p\n",v0,v1,v2);
  391. //      _mesa_debug(ctx, "_swrast_Triangle: (%f,%f,%f),(%f,%f,%f),(%f,%f,%f)\n",
  392. //        v0->win[0],v0->win[1],v0->win[2],
  393. //        v1->win[0],v1->win[1],v1->win[2],
  394. //        v2->win[0],v2->win[1],v2->win[2] );
  395. //
  396. // }
  397. //   raz++;
  398. //   printf("%i,%i\n",raz,v0->index);
  399. }
  400.  
  401. void
  402. _swrast_Line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
  403. {
  404.    if (0) {
  405.       _mesa_debug(ctx, "_swrast_Line\n");
  406.       _swrast_print_vertex( ctx, v0 );
  407.       _swrast_print_vertex( ctx, v1 );
  408.    }
  409.    ((SWcontext *)ctx->swrast_context)->Line( ctx, v0, v1 );
  410. }
  411.  
  412. void
  413. _swrast_Point( GLcontext *ctx, const SWvertex *v0 )
  414. {
  415.    if (0) {
  416.       _mesa_debug(ctx, "_swrast_Point\n");
  417.       _swrast_print_vertex( ctx, v0 );
  418.    }
  419.    ((SWcontext *)ctx->swrast_context)->Point( ctx, v0 );
  420. }
  421.  
  422. void
  423. _swrast_InvalidateState( GLcontext *ctx, GLuint new_state )
  424. {
  425.    if (0) {
  426.       _mesa_debug(ctx, "_swrast_InvalidateState\n");
  427.    }
  428.    ((SWcontext *)ctx->swrast_context)->InvalidateState( ctx, new_state );
  429. }
  430.  
  431. void
  432. _swrast_ResetLineStipple( GLcontext *ctx )
  433. {
  434.    if (0) {
  435.       _mesa_debug(ctx, "_swrast_ResetLineStipple\n");
  436.    }
  437.    ((SWcontext *)ctx->swrast_context)->StippleCounter = 0;
  438. }
  439.  
  440. void
  441. _swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value )
  442. {
  443.    if (0) {
  444.       _mesa_debug(ctx, "_swrast_allow_vertex_fog %d\n", value);
  445.    }
  446.    ((SWcontext *)ctx->swrast_context)->InvalidateState( ctx, 0x200 );
  447.    ((SWcontext *)ctx->swrast_context)->AllowVertexFog = value;
  448. }
  449.  
  450. void
  451. _swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value )
  452. {
  453.    if (0) {
  454.       _mesa_debug(ctx, "_swrast_allow_pixel_fog %d\n", value);
  455.    }
  456.    ((SWcontext *)ctx->swrast_context)->InvalidateState( ctx, 0x200 );
  457.    ((SWcontext *)ctx->swrast_context)->AllowPixelFog = value;
  458. }
  459.  
  460.  
  461. GLboolean
  462. _swrast_CreateContext( GLcontext *ctx )
  463. {
  464.    GLuint i;
  465.    SWcontext *swrast = (SWcontext *)_mesa_calloc(sizeof(SWcontext));
  466.  
  467.    if (0) {
  468.       _mesa_debug(ctx, "_swrast_CreateContext\n");
  469.    }
  470.  
  471.    if (!swrast)
  472.       return 0x0;
  473.  
  474.    swrast->NewState = ~0;
  475.  
  476.    swrast->choose_point = _swrast_choose_point;
  477.    swrast->choose_line = _swrast_choose_line;
  478.    swrast->choose_triangle = _swrast_choose_triangle;
  479.  
  480.    swrast->invalidate_point = (((0x1000000| 0x10000| 0x20| 0x40| 0x100| 0x20000| 0x40000| 0x100000| 0x40) | 0x40000 | 0x200 | 0x4000 ) | 0x800000 | 0x2000 | 0x40000 | 0x400 | 0x100 | (0x400 | 0x100));
  481.    swrast->invalidate_line = (((0x1000000| 0x10000| 0x20| 0x40| 0x100| 0x20000| 0x40000| 0x100000| 0x40) | 0x40000 | 0x200 | 0x4000 ) | 0x800000| 0x800| 0x40000| 0x400| 0x100| 0x40 | (0x400 | 0x100));
  482.    swrast->invalidate_triangle = (((0x1000000| 0x10000| 0x20| 0x40| 0x100| 0x20000| 0x40000| 0x100000| 0x40) | 0x40000 | 0x200 | 0x4000 ) | 0x800000| 0x4000| 0x40| 0x20000| 0x20| 0x40000| (0x1000000| 0x10000| 0x20| 0x40| 0x100| 0x20000| 0x40000| 0x100000| 0x40)| 0x400| 0x100 | (0x400 | 0x100));
  483.  
  484.    swrast->Point = _swrast_validate_point;
  485.    swrast->Line = _swrast_validate_line;
  486.    swrast->Triangle = _swrast_validate_triangle;
  487.    swrast->InvalidateState = _swrast_sleep;
  488.    swrast->BlendFunc = _swrast_validate_blend_func;
  489.  
  490.    swrast->AllowVertexFog = 0x1;
  491.    swrast->AllowPixelFog = 0x1;
  492.  
  493.    if (ctx->Visual.doubleBufferMode)
  494.       swrast->CurrentBuffer = 0x4;
  495.    else
  496.       swrast->CurrentBuffer = 0x1;
  497.  
  498.    /* Optimized Accum buffer */
  499.    swrast->_IntegerAccumMode = 0x1;
  500.    swrast->_IntegerAccumScaler = 0.0;
  501.  
  502.    for (i = 0 ; i < 8 ; i++)
  503.       swrast->TextureSample[i] = _swrast_validate_texture_sample;
  504.  
  505.    swrast->SpanArrays = (struct span_arrays *) _mesa_malloc(sizeof(struct span_arrays));
  506.    if (!swrast->SpanArrays) {
  507.       _mesa_free(swrast);
  508.       return 0x0;
  509.    }
  510.  
  511.    /* init point span buffer */
  512.    swrast->PointSpan.primitive = 0x1B00;
  513.    swrast->PointSpan.start = 0;
  514.    swrast->PointSpan.end = 0;
  515.    swrast->PointSpan.facing = 0;
  516.    swrast->PointSpan.array = swrast->SpanArrays;
  517.  
  518.    ( ( ctx->Const.MaxTextureUnits > 0 ) ? ( void )0 : _assert( "ctx->Const.MaxTextureUnits > 0", "s_context.c", 535 ) );
  519.    ( ( ctx->Const.MaxTextureUnits <= 8 ) ? ( void )0 : _assert( "ctx->Const.MaxTextureUnits <= MAX_TEXTURE_UNITS", "s_context.c", 536 ) );
  520.  
  521.    swrast->TexelBuffer = (GLchan *) _mesa_malloc(ctx->Const.MaxTextureUnits * 2048 * 4 * sizeof(GLchan));
  522.    if (!swrast->TexelBuffer) {
  523.       _mesa_free(swrast->SpanArrays);
  524.       _mesa_free(swrast);
  525.       return 0x0;
  526.    }
  527.  
  528.    ctx->swrast_context = swrast;
  529.  
  530.    return 0x1;
  531. }
  532.  
  533. void
  534. _swrast_DestroyContext( GLcontext *ctx )
  535. {
  536.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  537.  
  538.    if (0) {
  539.       _mesa_debug(ctx, "_swrast_DestroyContext\n");
  540.    }
  541.  
  542.    _mesa_free(swrast->SpanArrays);
  543.    _mesa_free(swrast->TexelBuffer);
  544.    _mesa_free(swrast);
  545.  
  546.    ctx->swrast_context = 0;
  547. }
  548.  
  549.  
  550. struct swrast_device_driver *
  551. _swrast_GetDeviceDriverReference( GLcontext *ctx )
  552. {
  553.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  554.    return &swrast->Driver;
  555. }
  556.  
  557. void
  558. _swrast_flush( GLcontext *ctx )
  559. {
  560.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  561.    /* flush any pending fragments from rendering points */
  562.    if (swrast->PointSpan.end > 0) {
  563.       if (ctx->Visual.rgbMode) {
  564.          if (ctx->Texture._EnabledUnits)
  565.             _mesa_write_texture_span(ctx, &(swrast->PointSpan));
  566.          else
  567.             _mesa_write_rgba_span(ctx, &(swrast->PointSpan));
  568.       }
  569.       else {
  570.          _mesa_write_index_span(ctx, &(swrast->PointSpan));
  571.       }
  572.       swrast->PointSpan.end = 0;
  573.    }
  574. }
  575.  
  576. void
  577. _swrast_render_primitive( GLcontext *ctx, GLenum prim )
  578. {
  579.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  580.    if (swrast->Primitive == 0x0000 && prim != 0x0000) {
  581.       _swrast_flush(ctx);
  582.    }
  583.    swrast->Primitive = prim;
  584. }
  585.  
  586.  
  587. void
  588. _swrast_render_start( GLcontext *ctx )
  589. {
  590.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  591.    if (swrast->Driver.SpanRenderStart)
  592.       swrast->Driver.SpanRenderStart( ctx );
  593.    swrast->PointSpan.end = 0;
  594. }
  595.  
  596. void
  597. _swrast_render_finish( GLcontext *ctx )
  598. {
  599.    SWcontext *swrast = ((SWcontext *)ctx->swrast_context);
  600.    if (swrast->Driver.SpanRenderFinish)
  601.       swrast->Driver.SpanRenderFinish( ctx );
  602.  
  603.    _swrast_flush(ctx);
  604. }
  605.  
  606.  
  607.  
  608. void
  609. _swrast_print_vertex( GLcontext *ctx, const SWvertex *v )
  610. {
  611.    GLuint i;
  612.  
  613.    if (0) {
  614.       _mesa_debug(ctx, "win %f %f %f %f\n",
  615.                   v->win[0], v->win[1], v->win[2], v->win[3]);
  616.  
  617.       for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
  618.         if (ctx->Texture.Unit[i]._ReallyEnabled)
  619.            _mesa_debug(ctx, "texcoord[%d] %f %f %f %f\n", i,
  620.                         v->texcoord[i][0], v->texcoord[i][1],
  621.                         v->texcoord[i][2], v->texcoord[i][3]);
  622.  
  623.       _mesa_debug(ctx, "color %d %d %d %d\n",
  624.                   v->color[0], v->color[1], v->color[2], v->color[3]);
  625.       _mesa_debug(ctx, "spec %d %d %d %d\n",
  626.                   v->specular[0], v->specular[1],
  627.                   v->specular[2], v->specular[3]);
  628.       _mesa_debug(ctx, "fog %f\n", v->fog);
  629.       _mesa_debug(ctx, "index %d\n", v->index);
  630.       _mesa_debug(ctx, "pointsize %f\n", v->pointSize);
  631.       _mesa_debug(ctx, "\n");
  632.    }
  633. }
  634.