Use ctx->Const.MaxTextureImageUnits and MaxTextureCoordUnits in more places.
[mesa.git] / src / mesa / swrast / s_context.c
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
34 #include "swrast.h"
35 #include "s_blend.h"
36 #include "s_context.h"
37 #include "s_lines.h"
38 #include "s_points.h"
39 #include "s_span.h"
40 #include "s_triangle.h"
41 #include "s_texture.h"
42
43
44 /*
45 * Recompute the value of swrast->_RasterMask, etc. according to
46 * the current context.
47 */
48 static void
49 _swrast_update_rasterflags( GLcontext *ctx )
50 {
51 GLuint RasterMask = 0;
52
53 if (ctx->Color.AlphaEnabled) RasterMask |= ALPHATEST_BIT;
54 if (ctx->Color.BlendEnabled) RasterMask |= BLEND_BIT;
55 if (ctx->Depth.Test) RasterMask |= DEPTH_BIT;
56 if (ctx->Fog.Enabled) RasterMask |= FOG_BIT;
57 if (ctx->Scissor.Enabled) RasterMask |= CLIP_BIT;
58 if (ctx->Stencil.Enabled) RasterMask |= STENCIL_BIT;
59 if (ctx->Visual.rgbMode) {
60 const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
61 if (colorMask != 0xffffffff) RasterMask |= MASKING_BIT;
62 if (ctx->Color.ColorLogicOpEnabled) RasterMask |= LOGIC_OP_BIT;
63 if (ctx->Texture._EnabledUnits) RasterMask |= TEXTURE_BIT;
64 }
65 else {
66 if (ctx->Color.IndexMask != 0xffffffff) RasterMask |= MASKING_BIT;
67 if (ctx->Color.IndexLogicOpEnabled) RasterMask |= LOGIC_OP_BIT;
68 }
69
70 if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
71 && ctx->Color.ColorMask[ACOMP]
72 && ctx->Color.DrawBuffer != GL_NONE)
73 RasterMask |= ALPHABUF_BIT;
74
75 if ( ctx->Viewport.X < 0
76 || ctx->Viewport.X + ctx->Viewport.Width > (GLint) ctx->DrawBuffer->Width
77 || ctx->Viewport.Y < 0
78 || ctx->Viewport.Y + ctx->Viewport.Height > (GLint) ctx->DrawBuffer->Height) {
79 RasterMask |= CLIP_BIT;
80 }
81
82 if (ctx->Depth.OcclusionTest)
83 RasterMask |= OCCLUSION_BIT;
84
85
86 /* If we're not drawing to exactly one color buffer set the
87 * MULTI_DRAW_BIT flag. Also set it if we're drawing to no
88 * buffers or the RGBA or CI mask disables all writes.
89 */
90 if (ctx->Color._DrawDestMask != FRONT_LEFT_BIT &&
91 ctx->Color._DrawDestMask != BACK_LEFT_BIT &&
92 ctx->Color._DrawDestMask != FRONT_RIGHT_BIT &&
93 ctx->Color._DrawDestMask != BACK_RIGHT_BIT) {
94 /* more than one color buffer designated for writing (or zero buffers) */
95 RasterMask |= MULTI_DRAW_BIT;
96 }
97 else if (ctx->Visual.rgbMode && *((GLuint *) ctx->Color.ColorMask) == 0) {
98 RasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */
99 }
100 else if (!ctx->Visual.rgbMode && ctx->Color.IndexMask==0) {
101 RasterMask |= MULTI_DRAW_BIT; /* all color index bits disabled */
102 }
103
104 if (ctx->FragmentProgram.Enabled) {
105 RasterMask |= FRAGPROG_BIT;
106 }
107
108 SWRAST_CONTEXT(ctx)->_RasterMask = RasterMask;
109 }
110
111
112 static void
113 _swrast_update_polygon( GLcontext *ctx )
114 {
115 GLfloat backface_sign = 1;
116
117 if (ctx->Polygon.CullFlag) {
118 backface_sign = 1;
119 switch(ctx->Polygon.CullFaceMode) {
120 case GL_BACK:
121 if(ctx->Polygon.FrontFace==GL_CCW)
122 backface_sign = -1;
123 break;
124 case GL_FRONT:
125 if(ctx->Polygon.FrontFace!=GL_CCW)
126 backface_sign = -1;
127 break;
128 default:
129 case GL_FRONT_AND_BACK:
130 backface_sign = 0;
131 break;
132 }
133 }
134 else {
135 backface_sign = 0;
136 }
137
138 SWRAST_CONTEXT(ctx)->_backface_sign = backface_sign;
139 }
140
141
142 static void
143 _swrast_update_hint( GLcontext *ctx )
144 {
145 SWcontext *swrast = SWRAST_CONTEXT(ctx);
146 swrast->_PreferPixelFog = (!swrast->AllowVertexFog ||
147 (ctx->Hint.Fog == GL_NICEST &&
148 swrast->AllowPixelFog));
149 }
150
151
152 /*
153 * Update the swrast->_AnyTextureCombine flag.
154 */
155 static void
156 _swrast_update_texture_env( GLcontext *ctx )
157 {
158 SWcontext *swrast = SWRAST_CONTEXT(ctx);
159 GLuint i;
160 swrast->_AnyTextureCombine = GL_FALSE;
161 for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
162 if (ctx->Texture.Unit[i].EnvMode == GL_COMBINE_EXT ||
163 ctx->Texture.Unit[i].EnvMode == GL_COMBINE4_NV) {
164 swrast->_AnyTextureCombine = GL_TRUE;
165 return;
166 }
167 }
168 }
169
170
171 #define _SWRAST_NEW_DERIVED (_SWRAST_NEW_RASTERMASK | \
172 _NEW_TEXTURE | \
173 _NEW_HINT | \
174 _NEW_POLYGON )
175
176 /* State referenced by _swrast_choose_triangle, _swrast_choose_line.
177 */
178 #define _SWRAST_NEW_TRIANGLE (_SWRAST_NEW_DERIVED | \
179 _NEW_RENDERMODE| \
180 _NEW_POLYGON| \
181 _NEW_DEPTH| \
182 _NEW_STENCIL| \
183 _NEW_COLOR| \
184 _NEW_TEXTURE| \
185 _SWRAST_NEW_RASTERMASK| \
186 _NEW_LIGHT| \
187 _NEW_FOG | \
188 _DD_NEW_SEPARATE_SPECULAR)
189
190 #define _SWRAST_NEW_LINE (_SWRAST_NEW_DERIVED | \
191 _NEW_RENDERMODE| \
192 _NEW_LINE| \
193 _NEW_TEXTURE| \
194 _NEW_LIGHT| \
195 _NEW_FOG| \
196 _NEW_DEPTH | \
197 _DD_NEW_SEPARATE_SPECULAR)
198
199 #define _SWRAST_NEW_POINT (_SWRAST_NEW_DERIVED | \
200 _NEW_RENDERMODE | \
201 _NEW_POINT | \
202 _NEW_TEXTURE | \
203 _NEW_LIGHT | \
204 _NEW_FOG | \
205 _DD_NEW_SEPARATE_SPECULAR)
206
207 #define _SWRAST_NEW_TEXTURE_SAMPLE_FUNC _NEW_TEXTURE
208
209 #define _SWRAST_NEW_TEXTURE_ENV_MODE _NEW_TEXTURE
210
211 #define _SWRAST_NEW_BLEND_FUNC _NEW_COLOR
212
213
214
215 /* Stub for swrast->Triangle to select a true triangle function
216 * after a state change.
217 */
218 static void
219 _swrast_validate_triangle( GLcontext *ctx,
220 const SWvertex *v0,
221 const SWvertex *v1,
222 const SWvertex *v2 )
223 {
224 SWcontext *swrast = SWRAST_CONTEXT(ctx);
225
226 _swrast_validate_derived( ctx );
227 swrast->choose_triangle( ctx );
228
229 if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
230 ctx->Texture._EnabledUnits == 0) {
231 swrast->SpecTriangle = swrast->Triangle;
232 swrast->Triangle = _swrast_add_spec_terms_triangle;
233 }
234
235 swrast->Triangle( ctx, v0, v1, v2 );
236 }
237
238 static void
239 _swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
240 {
241 SWcontext *swrast = SWRAST_CONTEXT(ctx);
242
243 _swrast_validate_derived( ctx );
244 swrast->choose_line( ctx );
245
246 if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
247 ctx->Texture._EnabledUnits == 0) {
248 swrast->SpecLine = swrast->Line;
249 swrast->Line = _swrast_add_spec_terms_line;
250 }
251
252
253 swrast->Line( ctx, v0, v1 );
254 }
255
256 static void
257 _swrast_validate_point( GLcontext *ctx, const SWvertex *v0 )
258 {
259 SWcontext *swrast = SWRAST_CONTEXT(ctx);
260
261 _swrast_validate_derived( ctx );
262 swrast->choose_point( ctx );
263
264 if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
265 ctx->Texture._EnabledUnits == 0) {
266 swrast->SpecPoint = swrast->Point;
267 swrast->Point = _swrast_add_spec_terms_point;
268 }
269
270 swrast->Point( ctx, v0 );
271 }
272
273
274 static void
275 _swrast_validate_blend_func( GLcontext *ctx, GLuint n,
276 const GLubyte mask[],
277 GLchan src[][4],
278 CONST GLchan dst[][4] )
279 {
280 SWcontext *swrast = SWRAST_CONTEXT(ctx);
281
282 _swrast_validate_derived( ctx );
283 _swrast_choose_blend_func( ctx );
284
285 swrast->BlendFunc( ctx, n, mask, src, dst );
286 }
287
288
289 static void
290 _swrast_validate_texture_sample( GLcontext *ctx, GLuint texUnit,
291 const struct gl_texture_object *tObj,
292 GLuint n, const GLfloat texcoords[][4],
293 const GLfloat lambda[], GLchan rgba[][4] )
294 {
295 SWcontext *swrast = SWRAST_CONTEXT(ctx);
296
297 _swrast_validate_derived( ctx );
298
299 /* Compute min/mag filter threshold */
300 if (tObj->MinFilter != tObj->MagFilter) {
301 if (tObj->MagFilter == GL_LINEAR
302 && (tObj->MinFilter == GL_NEAREST_MIPMAP_NEAREST ||
303 tObj->MinFilter == GL_NEAREST_MIPMAP_LINEAR)) {
304 swrast->_MinMagThresh[texUnit] = 0.5F;
305 }
306 else {
307 swrast->_MinMagThresh[texUnit] = 0.0F;
308 }
309 }
310
311 swrast->TextureSample[texUnit] =
312 _swrast_choose_texture_sample_func( ctx, tObj );
313
314 swrast->TextureSample[texUnit]( ctx, texUnit, tObj, n, texcoords,
315 lambda, rgba );
316
317 /* GL_SGI_texture_color_table */
318 if (ctx->Texture.Unit[texUnit].ColorTableEnabled) {
319 _swrast_texture_table_lookup(&ctx->Texture.Unit[texUnit].ColorTable, n, rgba);
320 }
321 }
322
323
324 static void
325 _swrast_sleep( GLcontext *ctx, GLuint new_state )
326 {
327 }
328
329
330 static 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
384 void
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 */
412 void
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
428 void
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
441 void
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
452 void
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
462 void
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
471 void
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
480 void
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
490 void
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
501 GLboolean
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
574 void
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
591 struct swrast_device_driver *
592 _swrast_GetDeviceDriverReference( GLcontext *ctx )
593 {
594 SWcontext *swrast = SWRAST_CONTEXT(ctx);
595 return &swrast->Driver;
596 }
597
598 void
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
617 void
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
628 void
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
637 void
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
650 void
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 }