2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
25 * Keith Whitwell <keith@tungstengraphics.com>
30 #include "bufferobj.h"
36 #include "nvfragprog.h"
40 #include "s_context.h"
44 #include "s_triangle.h"
45 #include "s_texture.h"
49 * Recompute the value of swrast->_RasterMask, etc. according to
50 * the current context. The _RasterMask field can be easily tested by
51 * drivers to determine certain basic GL state (does the primitive need
52 * stenciling, logic-op, fog, etc?).
55 _swrast_update_rasterflags( GLcontext
*ctx
)
57 GLuint rasterMask
= 0;
59 if (ctx
->Color
.AlphaEnabled
) rasterMask
|= ALPHATEST_BIT
;
60 if (ctx
->Color
.BlendEnabled
) rasterMask
|= BLEND_BIT
;
61 if (ctx
->Depth
.Test
) rasterMask
|= DEPTH_BIT
;
62 if (ctx
->Fog
.Enabled
) rasterMask
|= FOG_BIT
;
63 if (ctx
->Scissor
.Enabled
) rasterMask
|= CLIP_BIT
;
64 if (ctx
->Stencil
.Enabled
) rasterMask
|= STENCIL_BIT
;
65 if (ctx
->Visual
.rgbMode
) {
66 const GLuint colorMask
= *((GLuint
*) &ctx
->Color
.ColorMask
);
67 if (colorMask
!= 0xffffffff) rasterMask
|= MASKING_BIT
;
68 if (ctx
->Color
._LogicOpEnabled
) rasterMask
|= LOGIC_OP_BIT
;
69 if (ctx
->Texture
._EnabledUnits
) rasterMask
|= TEXTURE_BIT
;
72 if (ctx
->Color
.IndexMask
!= 0xffffffff) rasterMask
|= MASKING_BIT
;
73 if (ctx
->Color
.IndexLogicOpEnabled
) rasterMask
|= LOGIC_OP_BIT
;
76 if (ctx
->DrawBuffer
->UseSoftwareAlphaBuffers
77 && ctx
->Color
.ColorMask
[ACOMP
]
78 && ctx
->Color
.DrawBuffer
!= GL_NONE
)
79 rasterMask
|= ALPHABUF_BIT
;
81 if ( ctx
->Viewport
.X
< 0
82 || ctx
->Viewport
.X
+ ctx
->Viewport
.Width
> (GLint
) ctx
->DrawBuffer
->Width
83 || ctx
->Viewport
.Y
< 0
84 || ctx
->Viewport
.Y
+ ctx
->Viewport
.Height
> (GLint
) ctx
->DrawBuffer
->Height
) {
85 rasterMask
|= CLIP_BIT
;
88 if (ctx
->Depth
.OcclusionTest
|| ctx
->Occlusion
.Active
)
89 rasterMask
|= OCCLUSION_BIT
;
92 /* If we're not drawing to exactly one color buffer set the
93 * MULTI_DRAW_BIT flag. Also set it if we're drawing to no
94 * buffers or the RGBA or CI mask disables all writes.
96 if (_mesa_bitcount(ctx
->Color
._DrawDestMask
[0]) != 1) {
97 /* more than one color buffer designated for writing (or zero buffers) */
98 rasterMask
|= MULTI_DRAW_BIT
;
100 else if (ctx
->Visual
.rgbMode
&& *((GLuint
*) ctx
->Color
.ColorMask
) == 0) {
101 rasterMask
|= MULTI_DRAW_BIT
; /* all RGBA channels disabled */
103 else if (!ctx
->Visual
.rgbMode
&& ctx
->Color
.IndexMask
==0) {
104 rasterMask
|= MULTI_DRAW_BIT
; /* all color index bits disabled */
107 if (ctx
->FragmentProgram
._Enabled
) {
108 rasterMask
|= FRAGPROG_BIT
;
111 SWRAST_CONTEXT(ctx
)->_RasterMask
= rasterMask
;
116 * Examine polycon culls tate to compute the _BackfaceSign field.
117 * _BackfaceSign will be 0 if no culling, -1 if culling back-faces,
118 * and 1 if culling front-faces. The Polygon FrontFace state also
122 _swrast_update_polygon( GLcontext
*ctx
)
124 GLfloat backface_sign
= 1;
126 if (ctx
->Polygon
.CullFlag
) {
128 switch(ctx
->Polygon
.CullFaceMode
) {
130 if(ctx
->Polygon
.FrontFace
==GL_CCW
)
134 if(ctx
->Polygon
.FrontFace
!=GL_CCW
)
138 case GL_FRONT_AND_BACK
:
147 SWRAST_CONTEXT(ctx
)->_BackfaceSign
= backface_sign
;
152 * Update the _PreferPixelFog field to indicate if we need to compute
153 * fog factors per-fragment.
156 _swrast_update_fog_hint( GLcontext
*ctx
)
158 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
159 swrast
->_PreferPixelFog
= (!swrast
->AllowVertexFog
||
160 ctx
->FragmentProgram
._Enabled
||
161 (ctx
->Hint
.Fog
== GL_NICEST
&&
162 swrast
->AllowPixelFog
));
168 * Update the swrast->_AnyTextureCombine flag.
171 _swrast_update_texture_env( GLcontext
*ctx
)
173 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
175 swrast
->_AnyTextureCombine
= GL_FALSE
;
176 for (i
= 0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
177 if (ctx
->Texture
.Unit
[i
].EnvMode
== GL_COMBINE_EXT
||
178 ctx
->Texture
.Unit
[i
].EnvMode
== GL_COMBINE4_NV
) {
179 swrast
->_AnyTextureCombine
= GL_TRUE
;
187 * Update swrast->_FogColor and swrast->_FogEnable values.
190 _swrast_update_fog_state( GLcontext
*ctx
)
192 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
194 /* convert fog color to GLchan values */
195 CLAMPED_FLOAT_TO_CHAN(swrast
->_FogColor
[RCOMP
], ctx
->Fog
.Color
[RCOMP
]);
196 CLAMPED_FLOAT_TO_CHAN(swrast
->_FogColor
[GCOMP
], ctx
->Fog
.Color
[GCOMP
]);
197 CLAMPED_FLOAT_TO_CHAN(swrast
->_FogColor
[BCOMP
], ctx
->Fog
.Color
[BCOMP
]);
199 /* determine if fog is needed, and if so, which fog mode */
200 swrast
->_FogEnabled
= GL_FALSE
;
201 if (ctx
->FragmentProgram
._Enabled
) {
202 if (ctx
->FragmentProgram
.Current
->Base
.Target
==GL_FRAGMENT_PROGRAM_ARB
) {
203 const struct fragment_program
*p
204 = (struct fragment_program
*) ctx
->FragmentProgram
.Current
;
205 if (p
->FogOption
!= GL_NONE
) {
206 swrast
->_FogEnabled
= GL_TRUE
;
207 swrast
->_FogMode
= p
->FogOption
;
211 else if (ctx
->Fog
.Enabled
) {
212 swrast
->_FogEnabled
= GL_TRUE
;
213 swrast
->_FogMode
= ctx
->Fog
.Mode
;
219 * Update state for running fragment programs. Basically, load the
220 * program parameters with current state values.
223 _swrast_update_fragment_program( GLcontext
*ctx
)
225 if (ctx
->FragmentProgram
._Enabled
) {
226 struct fragment_program
*program
= ctx
->FragmentProgram
.Current
;
227 _mesa_load_state_parameters(ctx
, program
->Parameters
);
233 #define _SWRAST_NEW_DERIVED (_SWRAST_NEW_RASTERMASK | \
238 /* State referenced by _swrast_choose_triangle, _swrast_choose_line.
240 #define _SWRAST_NEW_TRIANGLE (_SWRAST_NEW_DERIVED | \
247 _SWRAST_NEW_RASTERMASK| \
250 _DD_NEW_SEPARATE_SPECULAR)
252 #define _SWRAST_NEW_LINE (_SWRAST_NEW_DERIVED | \
259 _DD_NEW_SEPARATE_SPECULAR)
261 #define _SWRAST_NEW_POINT (_SWRAST_NEW_DERIVED | \
267 _DD_NEW_SEPARATE_SPECULAR)
269 #define _SWRAST_NEW_TEXTURE_SAMPLE_FUNC _NEW_TEXTURE
271 #define _SWRAST_NEW_TEXTURE_ENV_MODE _NEW_TEXTURE
273 #define _SWRAST_NEW_BLEND_FUNC _NEW_COLOR
278 * Stub for swrast->Triangle to select a true triangle function
279 * after a state change.
282 _swrast_validate_triangle( GLcontext
*ctx
,
287 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
289 _swrast_validate_derived( ctx
);
290 swrast
->choose_triangle( ctx
);
292 if (ctx
->Texture
._EnabledUnits
== 0
293 && NEED_SECONDARY_COLOR(ctx
)
294 && !ctx
->FragmentProgram
._Enabled
) {
295 /* separate specular color, but no texture */
296 swrast
->SpecTriangle
= swrast
->Triangle
;
297 swrast
->Triangle
= _swrast_add_spec_terms_triangle
;
300 swrast
->Triangle( ctx
, v0
, v1
, v2
);
304 * Called via swrast->Line. Examine current GL state and choose a software
305 * line routine. Then call it.
308 _swrast_validate_line( GLcontext
*ctx
, const SWvertex
*v0
, const SWvertex
*v1
)
310 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
312 _swrast_validate_derived( ctx
);
313 swrast
->choose_line( ctx
);
315 if (ctx
->Texture
._EnabledUnits
== 0
316 && NEED_SECONDARY_COLOR(ctx
)
317 && !ctx
->FragmentProgram
._Enabled
) {
318 swrast
->SpecLine
= swrast
->Line
;
319 swrast
->Line
= _swrast_add_spec_terms_line
;
323 swrast
->Line( ctx
, v0
, v1
);
327 * Called via swrast->Point. Examine current GL state and choose a software
328 * point routine. Then call it.
331 _swrast_validate_point( GLcontext
*ctx
, const SWvertex
*v0
)
333 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
335 _swrast_validate_derived( ctx
);
336 swrast
->choose_point( ctx
);
338 if (ctx
->Texture
._EnabledUnits
== 0
339 && NEED_SECONDARY_COLOR(ctx
)
340 && !ctx
->FragmentProgram
._Enabled
) {
341 swrast
->SpecPoint
= swrast
->Point
;
342 swrast
->Point
= _swrast_add_spec_terms_point
;
345 swrast
->Point( ctx
, v0
);
350 * Called via swrast->BlendFunc. Examine GL state to choose a blending
351 * function, then call it.
354 _swrast_validate_blend_func( GLcontext
*ctx
, GLuint n
,
355 const GLubyte mask
[],
357 CONST GLchan dst
[][4] )
359 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
361 _swrast_validate_derived( ctx
);
362 _swrast_choose_blend_func( ctx
);
364 swrast
->BlendFunc( ctx
, n
, mask
, src
, dst
);
369 * Called via the swrast->TextureSample[i] function pointer.
370 * Basically, given a texture object, an array of texture coords
371 * and an array of level-of-detail values, return an array of colors.
372 * In this case, determine the correct texture sampling routine
373 * (depending on filter mode, texture dimensions, etc) then call the
377 _swrast_validate_texture_sample( GLcontext
*ctx
, GLuint texUnit
,
378 const struct gl_texture_object
*tObj
,
379 GLuint n
, const GLfloat texcoords
[][4],
380 const GLfloat lambda
[], GLchan rgba
[][4] )
382 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
384 _swrast_validate_derived( ctx
);
386 /* Compute min/mag filter threshold */
387 if (tObj
&& tObj
->MinFilter
!= tObj
->MagFilter
) {
388 if (tObj
->MagFilter
== GL_LINEAR
389 && (tObj
->MinFilter
== GL_NEAREST_MIPMAP_NEAREST
||
390 tObj
->MinFilter
== GL_NEAREST_MIPMAP_LINEAR
)) {
391 swrast
->_MinMagThresh
[texUnit
] = 0.5F
;
394 swrast
->_MinMagThresh
[texUnit
] = 0.0F
;
398 swrast
->TextureSample
[texUnit
] =
399 _swrast_choose_texture_sample_func( ctx
, tObj
);
401 swrast
->TextureSample
[texUnit
]( ctx
, texUnit
, tObj
, n
, texcoords
,
407 _swrast_sleep( GLcontext
*ctx
, GLuint new_state
)
409 (void) ctx
; (void) new_state
;
414 _swrast_invalidate_state( GLcontext
*ctx
, GLuint new_state
)
416 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
419 swrast
->NewState
|= new_state
;
421 /* After 10 statechanges without any swrast functions being called,
422 * put the module to sleep.
424 if (++swrast
->StateChanges
> 10) {
425 swrast
->InvalidateState
= _swrast_sleep
;
426 swrast
->NewState
= ~0;
430 if (new_state
& swrast
->invalidate_triangle
)
431 swrast
->Triangle
= _swrast_validate_triangle
;
433 if (new_state
& swrast
->invalidate_line
)
434 swrast
->Line
= _swrast_validate_line
;
436 if (new_state
& swrast
->invalidate_point
)
437 swrast
->Point
= _swrast_validate_point
;
439 if (new_state
& _SWRAST_NEW_BLEND_FUNC
)
440 swrast
->BlendFunc
= _swrast_validate_blend_func
;
442 if (new_state
& _SWRAST_NEW_TEXTURE_SAMPLE_FUNC
)
443 for (i
= 0 ; i
< ctx
->Const
.MaxTextureUnits
; i
++)
444 swrast
->TextureSample
[i
] = _swrast_validate_texture_sample
;
447 if (ctx
->Visual
.rgbMode
) {
448 ASSERT(swrast
->Driver
.WriteRGBASpan
);
449 ASSERT(swrast
->Driver
.WriteRGBSpan
);
450 ASSERT(swrast
->Driver
.WriteMonoRGBASpan
);
451 ASSERT(swrast
->Driver
.WriteRGBAPixels
);
452 ASSERT(swrast
->Driver
.WriteMonoRGBAPixels
);
453 ASSERT(swrast
->Driver
.ReadRGBASpan
);
454 ASSERT(swrast
->Driver
.ReadRGBAPixels
);
457 ASSERT(swrast
->Driver
.WriteCI32Span
);
458 ASSERT(swrast
->Driver
.WriteCI8Span
);
459 ASSERT(swrast
->Driver
.WriteMonoCISpan
);
460 ASSERT(swrast
->Driver
.WriteCI32Pixels
);
461 ASSERT(swrast
->Driver
.WriteMonoCIPixels
);
462 ASSERT(swrast
->Driver
.ReadCI32Span
);
463 ASSERT(swrast
->Driver
.ReadCI32Pixels
);
469 _swrast_validate_derived( GLcontext
*ctx
)
471 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
473 if (swrast
->NewState
) {
474 if (swrast
->NewState
& _SWRAST_NEW_RASTERMASK
)
475 _swrast_update_rasterflags( ctx
);
477 if (swrast
->NewState
& _NEW_POLYGON
)
478 _swrast_update_polygon( ctx
);
480 if (swrast
->NewState
& (_NEW_HINT
| _NEW_PROGRAM
))
481 _swrast_update_fog_hint( ctx
);
483 if (swrast
->NewState
& _SWRAST_NEW_TEXTURE_ENV_MODE
)
484 _swrast_update_texture_env( ctx
);
486 if (swrast
->NewState
& (_NEW_FOG
| _NEW_PROGRAM
))
487 _swrast_update_fog_state( ctx
);
489 if (swrast
->NewState
& _NEW_PROGRAM
)
490 _swrast_update_fragment_program( ctx
);
492 swrast
->NewState
= 0;
493 swrast
->StateChanges
= 0;
494 swrast
->InvalidateState
= _swrast_invalidate_state
;
498 #define SWRAST_DEBUG 0
500 /* Public entrypoints: See also s_accum.c, s_bitmap.c, etc.
503 _swrast_Quad( GLcontext
*ctx
,
504 const SWvertex
*v0
, const SWvertex
*v1
,
505 const SWvertex
*v2
, const SWvertex
*v3
)
508 _mesa_debug(ctx
, "_swrast_Quad\n");
509 _swrast_print_vertex( ctx
, v0
);
510 _swrast_print_vertex( ctx
, v1
);
511 _swrast_print_vertex( ctx
, v2
);
512 _swrast_print_vertex( ctx
, v3
);
514 SWRAST_CONTEXT(ctx
)->Triangle( ctx
, v0
, v1
, v3
);
515 SWRAST_CONTEXT(ctx
)->Triangle( ctx
, v1
, v2
, v3
);
519 _swrast_Triangle( GLcontext
*ctx
, const SWvertex
*v0
,
520 const SWvertex
*v1
, const SWvertex
*v2
)
523 _mesa_debug(ctx
, "_swrast_Triangle\n");
524 _swrast_print_vertex( ctx
, v0
);
525 _swrast_print_vertex( ctx
, v1
);
526 _swrast_print_vertex( ctx
, v2
);
528 SWRAST_CONTEXT(ctx
)->Triangle( ctx
, v0
, v1
, v2
);
532 _swrast_Line( GLcontext
*ctx
, const SWvertex
*v0
, const SWvertex
*v1
)
535 _mesa_debug(ctx
, "_swrast_Line\n");
536 _swrast_print_vertex( ctx
, v0
);
537 _swrast_print_vertex( ctx
, v1
);
539 SWRAST_CONTEXT(ctx
)->Line( ctx
, v0
, v1
);
543 _swrast_Point( GLcontext
*ctx
, const SWvertex
*v0
)
546 _mesa_debug(ctx
, "_swrast_Point\n");
547 _swrast_print_vertex( ctx
, v0
);
549 SWRAST_CONTEXT(ctx
)->Point( ctx
, v0
);
553 _swrast_InvalidateState( GLcontext
*ctx
, GLuint new_state
)
556 _mesa_debug(ctx
, "_swrast_InvalidateState\n");
558 SWRAST_CONTEXT(ctx
)->InvalidateState( ctx
, new_state
);
562 _swrast_ResetLineStipple( GLcontext
*ctx
)
565 _mesa_debug(ctx
, "_swrast_ResetLineStipple\n");
567 SWRAST_CONTEXT(ctx
)->StippleCounter
= 0;
571 _swrast_allow_vertex_fog( GLcontext
*ctx
, GLboolean value
)
574 _mesa_debug(ctx
, "_swrast_allow_vertex_fog %d\n", value
);
576 SWRAST_CONTEXT(ctx
)->InvalidateState( ctx
, _NEW_HINT
);
577 SWRAST_CONTEXT(ctx
)->AllowVertexFog
= value
;
581 _swrast_allow_pixel_fog( GLcontext
*ctx
, GLboolean value
)
584 _mesa_debug(ctx
, "_swrast_allow_pixel_fog %d\n", value
);
586 SWRAST_CONTEXT(ctx
)->InvalidateState( ctx
, _NEW_HINT
);
587 SWRAST_CONTEXT(ctx
)->AllowPixelFog
= value
;
592 _swrast_CreateContext( GLcontext
*ctx
)
595 SWcontext
*swrast
= (SWcontext
*)CALLOC(sizeof(SWcontext
));
598 _mesa_debug(ctx
, "_swrast_CreateContext\n");
604 swrast
->NewState
= ~0;
606 swrast
->choose_point
= _swrast_choose_point
;
607 swrast
->choose_line
= _swrast_choose_line
;
608 swrast
->choose_triangle
= _swrast_choose_triangle
;
610 swrast
->invalidate_point
= _SWRAST_NEW_POINT
;
611 swrast
->invalidate_line
= _SWRAST_NEW_LINE
;
612 swrast
->invalidate_triangle
= _SWRAST_NEW_TRIANGLE
;
614 swrast
->Point
= _swrast_validate_point
;
615 swrast
->Line
= _swrast_validate_line
;
616 swrast
->Triangle
= _swrast_validate_triangle
;
617 swrast
->InvalidateState
= _swrast_sleep
;
618 swrast
->BlendFunc
= _swrast_validate_blend_func
;
620 swrast
->AllowVertexFog
= GL_TRUE
;
621 swrast
->AllowPixelFog
= GL_TRUE
;
623 if (ctx
->Visual
.doubleBufferMode
)
624 swrast
->CurrentBufferBit
= DD_BACK_LEFT_BIT
;
626 swrast
->CurrentBufferBit
= DD_FRONT_LEFT_BIT
;
628 /* Optimized Accum buffer */
629 swrast
->_IntegerAccumMode
= GL_TRUE
;
630 swrast
->_IntegerAccumScaler
= 0.0;
632 for (i
= 0; i
< MAX_TEXTURE_IMAGE_UNITS
; i
++)
633 swrast
->TextureSample
[i
] = _swrast_validate_texture_sample
;
635 swrast
->SpanArrays
= MALLOC_STRUCT(span_arrays
);
636 if (!swrast
->SpanArrays
) {
641 /* init point span buffer */
642 swrast
->PointSpan
.primitive
= GL_POINT
;
643 swrast
->PointSpan
.start
= 0;
644 swrast
->PointSpan
.end
= 0;
645 swrast
->PointSpan
.facing
= 0;
646 swrast
->PointSpan
.array
= swrast
->SpanArrays
;
648 assert(ctx
->Const
.MaxTextureUnits
> 0);
649 assert(ctx
->Const
.MaxTextureUnits
<= MAX_TEXTURE_UNITS
);
651 swrast
->TexelBuffer
= (GLchan
*) MALLOC(ctx
->Const
.MaxTextureUnits
*
652 MAX_WIDTH
* 4 * sizeof(GLchan
));
653 if (!swrast
->TexelBuffer
) {
654 FREE(swrast
->SpanArrays
);
659 ctx
->swrast_context
= swrast
;
665 _swrast_DestroyContext( GLcontext
*ctx
)
667 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
670 _mesa_debug(ctx
, "_swrast_DestroyContext\n");
673 FREE( swrast
->SpanArrays
);
674 FREE( swrast
->TexelBuffer
);
677 ctx
->swrast_context
= 0;
681 struct swrast_device_driver
*
682 _swrast_GetDeviceDriverReference( GLcontext
*ctx
)
684 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
685 return &swrast
->Driver
;
689 _swrast_flush( GLcontext
*ctx
)
691 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
692 /* flush any pending fragments from rendering points */
693 if (swrast
->PointSpan
.end
> 0) {
694 if (ctx
->Visual
.rgbMode
) {
695 if (ctx
->Texture
._EnabledCoordUnits
)
696 _swrast_write_texture_span(ctx
, &(swrast
->PointSpan
));
698 _swrast_write_rgba_span(ctx
, &(swrast
->PointSpan
));
701 _swrast_write_index_span(ctx
, &(swrast
->PointSpan
));
703 swrast
->PointSpan
.end
= 0;
708 _swrast_render_primitive( GLcontext
*ctx
, GLenum prim
)
710 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
711 if (swrast
->Primitive
== GL_POINTS
&& prim
!= GL_POINTS
) {
714 swrast
->Primitive
= prim
;
719 _swrast_render_start( GLcontext
*ctx
)
721 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
722 if (swrast
->Driver
.SpanRenderStart
)
723 swrast
->Driver
.SpanRenderStart( ctx
);
724 swrast
->PointSpan
.end
= 0;
728 _swrast_render_finish( GLcontext
*ctx
)
730 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
731 if (swrast
->Driver
.SpanRenderFinish
)
732 swrast
->Driver
.SpanRenderFinish( ctx
);
738 #define SWRAST_DEBUG_VERTICES 0
741 _swrast_print_vertex( GLcontext
*ctx
, const SWvertex
*v
)
745 if (SWRAST_DEBUG_VERTICES
) {
746 _mesa_debug(ctx
, "win %f %f %f %f\n",
747 v
->win
[0], v
->win
[1], v
->win
[2], v
->win
[3]);
749 for (i
= 0 ; i
< ctx
->Const
.MaxTextureUnits
; i
++)
750 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
)
751 _mesa_debug(ctx
, "texcoord[%d] %f %f %f %f\n", i
,
752 v
->texcoord
[i
][0], v
->texcoord
[i
][1],
753 v
->texcoord
[i
][2], v
->texcoord
[i
][3]);
755 #if CHAN_TYPE == GL_FLOAT
756 _mesa_debug(ctx
, "color %f %f %f %f\n",
757 v
->color
[0], v
->color
[1], v
->color
[2], v
->color
[3]);
758 _mesa_debug(ctx
, "spec %f %f %f %f\n",
759 v
->specular
[0], v
->specular
[1],
760 v
->specular
[2], v
->specular
[3]);
762 _mesa_debug(ctx
, "color %d %d %d %d\n",
763 v
->color
[0], v
->color
[1], v
->color
[2], v
->color
[3]);
764 _mesa_debug(ctx
, "spec %d %d %d %d\n",
765 v
->specular
[0], v
->specular
[1],
766 v
->specular
[2], v
->specular
[3]);
768 _mesa_debug(ctx
, "fog %f\n", v
->fog
);
769 _mesa_debug(ctx
, "index %d\n", v
->index
);
770 _mesa_debug(ctx
, "pointsize %f\n", v
->pointSize
);
771 _mesa_debug(ctx
, "\n");