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.
53 _swrast_update_rasterflags( GLcontext
*ctx
)
55 GLuint RasterMask
= 0;
57 if (ctx
->Color
.AlphaEnabled
) RasterMask
|= ALPHATEST_BIT
;
58 if (ctx
->Color
.BlendEnabled
) RasterMask
|= BLEND_BIT
;
59 if (ctx
->Depth
.Test
) RasterMask
|= DEPTH_BIT
;
60 if (ctx
->Fog
.Enabled
) RasterMask
|= FOG_BIT
;
61 if (ctx
->Scissor
.Enabled
) RasterMask
|= CLIP_BIT
;
62 if (ctx
->Stencil
.Enabled
) RasterMask
|= STENCIL_BIT
;
63 if (ctx
->Visual
.rgbMode
) {
64 const GLuint colorMask
= *((GLuint
*) &ctx
->Color
.ColorMask
);
65 if (colorMask
!= 0xffffffff) RasterMask
|= MASKING_BIT
;
66 if (ctx
->Color
._LogicOpEnabled
) RasterMask
|= LOGIC_OP_BIT
;
67 if (ctx
->Texture
._EnabledUnits
) RasterMask
|= TEXTURE_BIT
;
70 if (ctx
->Color
.IndexMask
!= 0xffffffff) RasterMask
|= MASKING_BIT
;
71 if (ctx
->Color
.IndexLogicOpEnabled
) RasterMask
|= LOGIC_OP_BIT
;
74 if (ctx
->DrawBuffer
->UseSoftwareAlphaBuffers
75 && ctx
->Color
.ColorMask
[ACOMP
]
76 && ctx
->Color
.DrawBuffer
!= GL_NONE
)
77 RasterMask
|= ALPHABUF_BIT
;
79 if ( ctx
->Viewport
.X
< 0
80 || ctx
->Viewport
.X
+ ctx
->Viewport
.Width
> (GLint
) ctx
->DrawBuffer
->Width
81 || ctx
->Viewport
.Y
< 0
82 || ctx
->Viewport
.Y
+ ctx
->Viewport
.Height
> (GLint
) ctx
->DrawBuffer
->Height
) {
83 RasterMask
|= CLIP_BIT
;
86 if (ctx
->Depth
.OcclusionTest
|| ctx
->Occlusion
.Active
)
87 RasterMask
|= OCCLUSION_BIT
;
90 /* If we're not drawing to exactly one color buffer set the
91 * MULTI_DRAW_BIT flag. Also set it if we're drawing to no
92 * buffers or the RGBA or CI mask disables all writes.
94 if (_mesa_bitcount(ctx
->Color
._DrawDestMask
) != 1) {
95 /* more than one color buffer designated for writing (or zero buffers) */
96 RasterMask
|= MULTI_DRAW_BIT
;
98 else if (ctx
->Visual
.rgbMode
&& *((GLuint
*) ctx
->Color
.ColorMask
) == 0) {
99 RasterMask
|= MULTI_DRAW_BIT
; /* all RGBA channels disabled */
101 else if (!ctx
->Visual
.rgbMode
&& ctx
->Color
.IndexMask
==0) {
102 RasterMask
|= MULTI_DRAW_BIT
; /* all color index bits disabled */
105 if (ctx
->FragmentProgram
._Enabled
) {
106 RasterMask
|= FRAGPROG_BIT
;
109 SWRAST_CONTEXT(ctx
)->_RasterMask
= RasterMask
;
114 _swrast_update_polygon( GLcontext
*ctx
)
116 GLfloat backface_sign
= 1;
118 if (ctx
->Polygon
.CullFlag
) {
120 switch(ctx
->Polygon
.CullFaceMode
) {
122 if(ctx
->Polygon
.FrontFace
==GL_CCW
)
126 if(ctx
->Polygon
.FrontFace
!=GL_CCW
)
130 case GL_FRONT_AND_BACK
:
139 SWRAST_CONTEXT(ctx
)->_BackfaceSign
= backface_sign
;
144 _swrast_update_fog_hint( GLcontext
*ctx
)
146 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
147 swrast
->_PreferPixelFog
= (!swrast
->AllowVertexFog
||
148 ctx
->FragmentProgram
._Enabled
||
149 (ctx
->Hint
.Fog
== GL_NICEST
&&
150 swrast
->AllowPixelFog
));
156 * Update the swrast->_AnyTextureCombine flag.
159 _swrast_update_texture_env( GLcontext
*ctx
)
161 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
163 swrast
->_AnyTextureCombine
= GL_FALSE
;
164 for (i
= 0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
165 if (ctx
->Texture
.Unit
[i
].EnvMode
== GL_COMBINE_EXT
||
166 ctx
->Texture
.Unit
[i
].EnvMode
== GL_COMBINE4_NV
) {
167 swrast
->_AnyTextureCombine
= GL_TRUE
;
175 * Update swrast->_FogColor and swrast->_FogEnable values.
178 _swrast_update_fog_state( GLcontext
*ctx
)
180 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
182 /* convert fog color to GLchan values */
183 CLAMPED_FLOAT_TO_CHAN(swrast
->_FogColor
[RCOMP
], ctx
->Fog
.Color
[RCOMP
]);
184 CLAMPED_FLOAT_TO_CHAN(swrast
->_FogColor
[GCOMP
], ctx
->Fog
.Color
[GCOMP
]);
185 CLAMPED_FLOAT_TO_CHAN(swrast
->_FogColor
[BCOMP
], ctx
->Fog
.Color
[BCOMP
]);
187 /* determine if fog is needed */
188 swrast
->_FogEnabled
= GL_FALSE
;
189 if (ctx
->Fog
.Enabled
) {
190 swrast
->_FogEnabled
= GL_TRUE
;
192 else if (ctx
->FragmentProgram
._Enabled
&&
193 ctx
->FragmentProgram
.Current
->Base
.Target
== GL_FRAGMENT_PROGRAM_ARB
) {
194 const struct fragment_program
*p
;
195 p
= (struct fragment_program
*) ctx
->FragmentProgram
.Current
;
196 if (p
->FogOption
!= GL_NONE
) {
197 swrast
->_FogEnabled
= GL_TRUE
;
204 _swrast_update_fragment_program( GLcontext
*ctx
)
206 if (ctx
->FragmentProgram
._Enabled
) {
207 struct fragment_program
*program
= ctx
->FragmentProgram
.Current
;
208 _mesa_load_state_parameters(ctx
, program
->Parameters
);
214 #define _SWRAST_NEW_DERIVED (_SWRAST_NEW_RASTERMASK | \
219 /* State referenced by _swrast_choose_triangle, _swrast_choose_line.
221 #define _SWRAST_NEW_TRIANGLE (_SWRAST_NEW_DERIVED | \
228 _SWRAST_NEW_RASTERMASK| \
231 _DD_NEW_SEPARATE_SPECULAR)
233 #define _SWRAST_NEW_LINE (_SWRAST_NEW_DERIVED | \
240 _DD_NEW_SEPARATE_SPECULAR)
242 #define _SWRAST_NEW_POINT (_SWRAST_NEW_DERIVED | \
248 _DD_NEW_SEPARATE_SPECULAR)
250 #define _SWRAST_NEW_TEXTURE_SAMPLE_FUNC _NEW_TEXTURE
252 #define _SWRAST_NEW_TEXTURE_ENV_MODE _NEW_TEXTURE
254 #define _SWRAST_NEW_BLEND_FUNC _NEW_COLOR
258 /* Stub for swrast->Triangle to select a true triangle function
259 * after a state change.
262 _swrast_validate_triangle( GLcontext
*ctx
,
267 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
269 _swrast_validate_derived( ctx
);
270 swrast
->choose_triangle( ctx
);
272 if (ctx
->Texture
._EnabledUnits
== 0
273 && NEED_SECONDARY_COLOR(ctx
)
274 && !ctx
->FragmentProgram
._Enabled
) {
275 /* separate specular color, but no texture */
276 swrast
->SpecTriangle
= swrast
->Triangle
;
277 swrast
->Triangle
= _swrast_add_spec_terms_triangle
;
280 swrast
->Triangle( ctx
, v0
, v1
, v2
);
284 _swrast_validate_line( GLcontext
*ctx
, const SWvertex
*v0
, const SWvertex
*v1
)
286 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
288 _swrast_validate_derived( ctx
);
289 swrast
->choose_line( ctx
);
291 if (ctx
->Texture
._EnabledUnits
== 0
292 && NEED_SECONDARY_COLOR(ctx
)
293 && !ctx
->FragmentProgram
._Enabled
) {
294 swrast
->SpecLine
= swrast
->Line
;
295 swrast
->Line
= _swrast_add_spec_terms_line
;
299 swrast
->Line( ctx
, v0
, v1
);
303 _swrast_validate_point( GLcontext
*ctx
, const SWvertex
*v0
)
305 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
307 _swrast_validate_derived( ctx
);
308 swrast
->choose_point( ctx
);
310 if (ctx
->Texture
._EnabledUnits
== 0
311 && NEED_SECONDARY_COLOR(ctx
)
312 && !ctx
->FragmentProgram
._Enabled
) {
313 swrast
->SpecPoint
= swrast
->Point
;
314 swrast
->Point
= _swrast_add_spec_terms_point
;
317 swrast
->Point( ctx
, v0
);
322 _swrast_validate_blend_func( GLcontext
*ctx
, GLuint n
,
323 const GLubyte mask
[],
325 CONST GLchan dst
[][4] )
327 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
329 _swrast_validate_derived( ctx
);
330 _swrast_choose_blend_func( ctx
);
332 swrast
->BlendFunc( ctx
, n
, mask
, src
, dst
);
337 * Called via the swrast->TextureSample[i] function pointer.
338 * Basically, given a texture object, an array of texture coords
339 * and an array of level-of-detail values, return an array of colors.
340 * In this case, determine the correct texture sampling routine
341 * (depending on filter mode, texture dimensions, etc) then call the
345 _swrast_validate_texture_sample( GLcontext
*ctx
, GLuint texUnit
,
346 const struct gl_texture_object
*tObj
,
347 GLuint n
, const GLfloat texcoords
[][4],
348 const GLfloat lambda
[], GLchan rgba
[][4] )
350 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
352 _swrast_validate_derived( ctx
);
354 /* Compute min/mag filter threshold */
355 if (tObj
&& tObj
->MinFilter
!= tObj
->MagFilter
) {
356 if (tObj
->MagFilter
== GL_LINEAR
357 && (tObj
->MinFilter
== GL_NEAREST_MIPMAP_NEAREST
||
358 tObj
->MinFilter
== GL_NEAREST_MIPMAP_LINEAR
)) {
359 swrast
->_MinMagThresh
[texUnit
] = 0.5F
;
362 swrast
->_MinMagThresh
[texUnit
] = 0.0F
;
366 swrast
->TextureSample
[texUnit
] =
367 _swrast_choose_texture_sample_func( ctx
, tObj
);
369 swrast
->TextureSample
[texUnit
]( ctx
, texUnit
, tObj
, n
, texcoords
,
375 _swrast_sleep( GLcontext
*ctx
, GLuint new_state
)
381 _swrast_invalidate_state( GLcontext
*ctx
, GLuint new_state
)
383 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
386 swrast
->NewState
|= new_state
;
388 /* After 10 statechanges without any swrast functions being called,
389 * put the module to sleep.
391 if (++swrast
->StateChanges
> 10) {
392 swrast
->InvalidateState
= _swrast_sleep
;
393 swrast
->NewState
= ~0;
397 if (new_state
& swrast
->invalidate_triangle
)
398 swrast
->Triangle
= _swrast_validate_triangle
;
400 if (new_state
& swrast
->invalidate_line
)
401 swrast
->Line
= _swrast_validate_line
;
403 if (new_state
& swrast
->invalidate_point
)
404 swrast
->Point
= _swrast_validate_point
;
406 if (new_state
& _SWRAST_NEW_BLEND_FUNC
)
407 swrast
->BlendFunc
= _swrast_validate_blend_func
;
409 if (new_state
& _SWRAST_NEW_TEXTURE_SAMPLE_FUNC
)
410 for (i
= 0 ; i
< ctx
->Const
.MaxTextureUnits
; i
++)
411 swrast
->TextureSample
[i
] = _swrast_validate_texture_sample
;
413 if (ctx
->Visual
.rgbMode
) {
414 ASSERT(swrast
->Driver
.WriteRGBASpan
);
415 ASSERT(swrast
->Driver
.WriteRGBSpan
);
416 ASSERT(swrast
->Driver
.WriteMonoRGBASpan
);
417 ASSERT(swrast
->Driver
.WriteRGBAPixels
);
418 ASSERT(swrast
->Driver
.WriteMonoRGBAPixels
);
419 ASSERT(swrast
->Driver
.ReadRGBASpan
);
420 ASSERT(swrast
->Driver
.ReadRGBAPixels
);
423 ASSERT(swrast
->Driver
.WriteCI32Span
);
424 ASSERT(swrast
->Driver
.WriteCI8Span
);
425 ASSERT(swrast
->Driver
.WriteMonoCISpan
);
426 ASSERT(swrast
->Driver
.WriteCI32Pixels
);
427 ASSERT(swrast
->Driver
.WriteMonoCIPixels
);
428 ASSERT(swrast
->Driver
.ReadCI32Span
);
429 ASSERT(swrast
->Driver
.ReadCI32Pixels
);
435 _swrast_validate_derived( GLcontext
*ctx
)
437 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
439 if (swrast
->NewState
) {
440 if (swrast
->NewState
& _SWRAST_NEW_RASTERMASK
)
441 _swrast_update_rasterflags( ctx
);
443 if (swrast
->NewState
& _NEW_POLYGON
)
444 _swrast_update_polygon( ctx
);
446 if (swrast
->NewState
& (_NEW_HINT
| _NEW_PROGRAM
))
447 _swrast_update_fog_hint( ctx
);
449 if (swrast
->NewState
& _SWRAST_NEW_TEXTURE_ENV_MODE
)
450 _swrast_update_texture_env( ctx
);
452 if (swrast
->NewState
& _NEW_FOG
)
453 _swrast_update_fog_state( ctx
);
455 if (swrast
->NewState
& _NEW_PROGRAM
)
456 _swrast_update_fragment_program( ctx
);
458 swrast
->NewState
= 0;
459 swrast
->StateChanges
= 0;
460 swrast
->InvalidateState
= _swrast_invalidate_state
;
464 #define SWRAST_DEBUG 0
466 /* Public entrypoints: See also s_accum.c, s_bitmap.c, etc.
469 _swrast_Quad( GLcontext
*ctx
,
470 const SWvertex
*v0
, const SWvertex
*v1
,
471 const SWvertex
*v2
, const SWvertex
*v3
)
474 _mesa_debug(ctx
, "_swrast_Quad\n");
475 _swrast_print_vertex( ctx
, v0
);
476 _swrast_print_vertex( ctx
, v1
);
477 _swrast_print_vertex( ctx
, v2
);
478 _swrast_print_vertex( ctx
, v3
);
480 SWRAST_CONTEXT(ctx
)->Triangle( ctx
, v0
, v1
, v3
);
481 SWRAST_CONTEXT(ctx
)->Triangle( ctx
, v1
, v2
, v3
);
485 _swrast_Triangle( GLcontext
*ctx
, const SWvertex
*v0
,
486 const SWvertex
*v1
, const SWvertex
*v2
)
489 _mesa_debug(ctx
, "_swrast_Triangle\n");
490 _swrast_print_vertex( ctx
, v0
);
491 _swrast_print_vertex( ctx
, v1
);
492 _swrast_print_vertex( ctx
, v2
);
494 SWRAST_CONTEXT(ctx
)->Triangle( ctx
, v0
, v1
, v2
);
498 _swrast_Line( GLcontext
*ctx
, const SWvertex
*v0
, const SWvertex
*v1
)
501 _mesa_debug(ctx
, "_swrast_Line\n");
502 _swrast_print_vertex( ctx
, v0
);
503 _swrast_print_vertex( ctx
, v1
);
505 SWRAST_CONTEXT(ctx
)->Line( ctx
, v0
, v1
);
509 _swrast_Point( GLcontext
*ctx
, const SWvertex
*v0
)
512 _mesa_debug(ctx
, "_swrast_Point\n");
513 _swrast_print_vertex( ctx
, v0
);
515 SWRAST_CONTEXT(ctx
)->Point( ctx
, v0
);
519 _swrast_InvalidateState( GLcontext
*ctx
, GLuint new_state
)
522 _mesa_debug(ctx
, "_swrast_InvalidateState\n");
524 SWRAST_CONTEXT(ctx
)->InvalidateState( ctx
, new_state
);
528 _swrast_ResetLineStipple( GLcontext
*ctx
)
531 _mesa_debug(ctx
, "_swrast_ResetLineStipple\n");
533 SWRAST_CONTEXT(ctx
)->StippleCounter
= 0;
537 _swrast_allow_vertex_fog( GLcontext
*ctx
, GLboolean value
)
540 _mesa_debug(ctx
, "_swrast_allow_vertex_fog %d\n", value
);
542 SWRAST_CONTEXT(ctx
)->InvalidateState( ctx
, _NEW_HINT
);
543 SWRAST_CONTEXT(ctx
)->AllowVertexFog
= value
;
547 _swrast_allow_pixel_fog( GLcontext
*ctx
, GLboolean value
)
550 _mesa_debug(ctx
, "_swrast_allow_pixel_fog %d\n", value
);
552 SWRAST_CONTEXT(ctx
)->InvalidateState( ctx
, _NEW_HINT
);
553 SWRAST_CONTEXT(ctx
)->AllowPixelFog
= value
;
558 _swrast_CreateContext( GLcontext
*ctx
)
561 SWcontext
*swrast
= (SWcontext
*)CALLOC(sizeof(SWcontext
));
564 _mesa_debug(ctx
, "_swrast_CreateContext\n");
570 swrast
->NewState
= ~0;
572 swrast
->choose_point
= _swrast_choose_point
;
573 swrast
->choose_line
= _swrast_choose_line
;
574 swrast
->choose_triangle
= _swrast_choose_triangle
;
576 swrast
->invalidate_point
= _SWRAST_NEW_POINT
;
577 swrast
->invalidate_line
= _SWRAST_NEW_LINE
;
578 swrast
->invalidate_triangle
= _SWRAST_NEW_TRIANGLE
;
580 swrast
->Point
= _swrast_validate_point
;
581 swrast
->Line
= _swrast_validate_line
;
582 swrast
->Triangle
= _swrast_validate_triangle
;
583 swrast
->InvalidateState
= _swrast_sleep
;
584 swrast
->BlendFunc
= _swrast_validate_blend_func
;
586 swrast
->AllowVertexFog
= GL_TRUE
;
587 swrast
->AllowPixelFog
= GL_TRUE
;
589 if (ctx
->Visual
.doubleBufferMode
)
590 swrast
->CurrentBufferBit
= DD_BACK_LEFT_BIT
;
592 swrast
->CurrentBufferBit
= DD_FRONT_LEFT_BIT
;
594 /* Optimized Accum buffer */
595 swrast
->_IntegerAccumMode
= GL_TRUE
;
596 swrast
->_IntegerAccumScaler
= 0.0;
598 for (i
= 0; i
< MAX_TEXTURE_IMAGE_UNITS
; i
++)
599 swrast
->TextureSample
[i
] = _swrast_validate_texture_sample
;
601 swrast
->SpanArrays
= MALLOC_STRUCT(span_arrays
);
602 if (!swrast
->SpanArrays
) {
607 /* init point span buffer */
608 swrast
->PointSpan
.primitive
= GL_POINT
;
609 swrast
->PointSpan
.start
= 0;
610 swrast
->PointSpan
.end
= 0;
611 swrast
->PointSpan
.facing
= 0;
612 swrast
->PointSpan
.array
= swrast
->SpanArrays
;
614 assert(ctx
->Const
.MaxTextureUnits
> 0);
615 assert(ctx
->Const
.MaxTextureUnits
<= MAX_TEXTURE_UNITS
);
617 swrast
->TexelBuffer
= (GLchan
*) MALLOC(ctx
->Const
.MaxTextureUnits
*
618 MAX_WIDTH
* 4 * sizeof(GLchan
));
619 if (!swrast
->TexelBuffer
) {
620 FREE(swrast
->SpanArrays
);
625 ctx
->swrast_context
= swrast
;
631 _swrast_DestroyContext( GLcontext
*ctx
)
633 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
636 _mesa_debug(ctx
, "_swrast_DestroyContext\n");
639 FREE( swrast
->SpanArrays
);
640 FREE( swrast
->TexelBuffer
);
643 ctx
->swrast_context
= 0;
647 struct swrast_device_driver
*
648 _swrast_GetDeviceDriverReference( GLcontext
*ctx
)
650 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
651 return &swrast
->Driver
;
655 _swrast_flush( GLcontext
*ctx
)
657 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
658 /* flush any pending fragments from rendering points */
659 if (swrast
->PointSpan
.end
> 0) {
660 if (ctx
->Visual
.rgbMode
) {
661 if (ctx
->Texture
._EnabledCoordUnits
)
662 _swrast_write_texture_span(ctx
, &(swrast
->PointSpan
));
664 _swrast_write_rgba_span(ctx
, &(swrast
->PointSpan
));
667 _swrast_write_index_span(ctx
, &(swrast
->PointSpan
));
669 swrast
->PointSpan
.end
= 0;
674 _swrast_render_primitive( GLcontext
*ctx
, GLenum prim
)
676 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
677 if (swrast
->Primitive
== GL_POINTS
&& prim
!= GL_POINTS
) {
680 swrast
->Primitive
= prim
;
685 _swrast_render_start( GLcontext
*ctx
)
687 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
688 if (swrast
->Driver
.SpanRenderStart
)
689 swrast
->Driver
.SpanRenderStart( ctx
);
690 swrast
->PointSpan
.end
= 0;
694 _swrast_render_finish( GLcontext
*ctx
)
696 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
697 if (swrast
->Driver
.SpanRenderFinish
)
698 swrast
->Driver
.SpanRenderFinish( ctx
);
704 #define SWRAST_DEBUG_VERTICES 0
707 _swrast_print_vertex( GLcontext
*ctx
, const SWvertex
*v
)
711 if (SWRAST_DEBUG_VERTICES
) {
712 _mesa_debug(ctx
, "win %f %f %f %f\n",
713 v
->win
[0], v
->win
[1], v
->win
[2], v
->win
[3]);
715 for (i
= 0 ; i
< ctx
->Const
.MaxTextureUnits
; i
++)
716 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
)
717 _mesa_debug(ctx
, "texcoord[%d] %f %f %f %f\n", i
,
718 v
->texcoord
[i
][0], v
->texcoord
[i
][1],
719 v
->texcoord
[i
][2], v
->texcoord
[i
][3]);
721 #if CHAN_TYPE == GL_FLOAT
722 _mesa_debug(ctx
, "color %f %f %f %f\n",
723 v
->color
[0], v
->color
[1], v
->color
[2], v
->color
[3]);
724 _mesa_debug(ctx
, "spec %f %f %f %f\n",
725 v
->specular
[0], v
->specular
[1],
726 v
->specular
[2], v
->specular
[3]);
728 _mesa_debug(ctx
, "color %d %d %d %d\n",
729 v
->color
[0], v
->color
[1], v
->color
[2], v
->color
[3]);
730 _mesa_debug(ctx
, "spec %d %d %d %d\n",
731 v
->specular
[0], v
->specular
[1],
732 v
->specular
[2], v
->specular
[3]);
734 _mesa_debug(ctx
, "fog %f\n", v
->fog
);
735 _mesa_debug(ctx
, "index %d\n", v
->index
);
736 _mesa_debug(ctx
, "pointsize %f\n", v
->pointSize
);
737 _mesa_debug(ctx
, "\n");
743 * Validate access to a PBO to be sure we're not going to read/write
744 * out of buffer bounds.
747 _swrast_validate_pbo_access(const struct gl_pixelstore_attrib
*pack
,
748 GLsizei width
, GLsizei height
, GLsizei depth
,
749 GLenum format
, GLenum type
, GLvoid
*ptr
)
751 if (pack
->BufferObj
->Name
== 0) {
755 else if (_mesa_validate_pbo_access(pack
, width
, height
, depth
, format
,
757 return ADD_POINTERS(pack
->BufferObj
->Data
, ptr
);