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 _swrast_validate_texture_sample( GLcontext
*ctx
, GLuint texUnit
,
338 const struct gl_texture_object
*tObj
,
339 GLuint n
, const GLfloat texcoords
[][4],
340 const GLfloat lambda
[], GLchan rgba
[][4] )
342 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
344 _swrast_validate_derived( ctx
);
346 /* Compute min/mag filter threshold */
347 if (tObj
->MinFilter
!= tObj
->MagFilter
) {
348 if (tObj
->MagFilter
== GL_LINEAR
349 && (tObj
->MinFilter
== GL_NEAREST_MIPMAP_NEAREST
||
350 tObj
->MinFilter
== GL_NEAREST_MIPMAP_LINEAR
)) {
351 swrast
->_MinMagThresh
[texUnit
] = 0.5F
;
354 swrast
->_MinMagThresh
[texUnit
] = 0.0F
;
358 swrast
->TextureSample
[texUnit
] =
359 _swrast_choose_texture_sample_func( ctx
, tObj
);
361 swrast
->TextureSample
[texUnit
]( ctx
, texUnit
, tObj
, n
, texcoords
,
367 _swrast_sleep( GLcontext
*ctx
, GLuint new_state
)
373 _swrast_invalidate_state( GLcontext
*ctx
, GLuint new_state
)
375 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
378 swrast
->NewState
|= new_state
;
380 /* After 10 statechanges without any swrast functions being called,
381 * put the module to sleep.
383 if (++swrast
->StateChanges
> 10) {
384 swrast
->InvalidateState
= _swrast_sleep
;
385 swrast
->NewState
= ~0;
389 if (new_state
& swrast
->invalidate_triangle
)
390 swrast
->Triangle
= _swrast_validate_triangle
;
392 if (new_state
& swrast
->invalidate_line
)
393 swrast
->Line
= _swrast_validate_line
;
395 if (new_state
& swrast
->invalidate_point
)
396 swrast
->Point
= _swrast_validate_point
;
398 if (new_state
& _SWRAST_NEW_BLEND_FUNC
)
399 swrast
->BlendFunc
= _swrast_validate_blend_func
;
401 if (new_state
& _SWRAST_NEW_TEXTURE_SAMPLE_FUNC
)
402 for (i
= 0 ; i
< ctx
->Const
.MaxTextureUnits
; i
++)
403 swrast
->TextureSample
[i
] = _swrast_validate_texture_sample
;
405 if (ctx
->Visual
.rgbMode
) {
406 ASSERT(swrast
->Driver
.WriteRGBASpan
);
407 ASSERT(swrast
->Driver
.WriteRGBSpan
);
408 ASSERT(swrast
->Driver
.WriteMonoRGBASpan
);
409 ASSERT(swrast
->Driver
.WriteRGBAPixels
);
410 ASSERT(swrast
->Driver
.WriteMonoRGBAPixels
);
411 ASSERT(swrast
->Driver
.ReadRGBASpan
);
412 ASSERT(swrast
->Driver
.ReadRGBAPixels
);
415 ASSERT(swrast
->Driver
.WriteCI32Span
);
416 ASSERT(swrast
->Driver
.WriteCI8Span
);
417 ASSERT(swrast
->Driver
.WriteMonoCISpan
);
418 ASSERT(swrast
->Driver
.WriteCI32Pixels
);
419 ASSERT(swrast
->Driver
.WriteMonoCIPixels
);
420 ASSERT(swrast
->Driver
.ReadCI32Span
);
421 ASSERT(swrast
->Driver
.ReadCI32Pixels
);
427 _swrast_validate_derived( GLcontext
*ctx
)
429 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
431 if (swrast
->NewState
) {
432 if (swrast
->NewState
& _SWRAST_NEW_RASTERMASK
)
433 _swrast_update_rasterflags( ctx
);
435 if (swrast
->NewState
& _NEW_POLYGON
)
436 _swrast_update_polygon( ctx
);
438 if (swrast
->NewState
& (_NEW_HINT
| _NEW_PROGRAM
))
439 _swrast_update_fog_hint( ctx
);
441 if (swrast
->NewState
& _SWRAST_NEW_TEXTURE_ENV_MODE
)
442 _swrast_update_texture_env( ctx
);
444 if (swrast
->NewState
& _NEW_FOG
)
445 _swrast_update_fog_state( ctx
);
447 if (swrast
->NewState
& _NEW_PROGRAM
)
448 _swrast_update_fragment_program( ctx
);
450 swrast
->NewState
= 0;
451 swrast
->StateChanges
= 0;
452 swrast
->InvalidateState
= _swrast_invalidate_state
;
456 #define SWRAST_DEBUG 0
458 /* Public entrypoints: See also s_accum.c, s_bitmap.c, etc.
461 _swrast_Quad( GLcontext
*ctx
,
462 const SWvertex
*v0
, const SWvertex
*v1
,
463 const SWvertex
*v2
, const SWvertex
*v3
)
466 _mesa_debug(ctx
, "_swrast_Quad\n");
467 _swrast_print_vertex( ctx
, v0
);
468 _swrast_print_vertex( ctx
, v1
);
469 _swrast_print_vertex( ctx
, v2
);
470 _swrast_print_vertex( ctx
, v3
);
472 SWRAST_CONTEXT(ctx
)->Triangle( ctx
, v0
, v1
, v3
);
473 SWRAST_CONTEXT(ctx
)->Triangle( ctx
, v1
, v2
, v3
);
477 _swrast_Triangle( GLcontext
*ctx
, const SWvertex
*v0
,
478 const SWvertex
*v1
, const SWvertex
*v2
)
481 _mesa_debug(ctx
, "_swrast_Triangle\n");
482 _swrast_print_vertex( ctx
, v0
);
483 _swrast_print_vertex( ctx
, v1
);
484 _swrast_print_vertex( ctx
, v2
);
486 SWRAST_CONTEXT(ctx
)->Triangle( ctx
, v0
, v1
, v2
);
490 _swrast_Line( GLcontext
*ctx
, const SWvertex
*v0
, const SWvertex
*v1
)
493 _mesa_debug(ctx
, "_swrast_Line\n");
494 _swrast_print_vertex( ctx
, v0
);
495 _swrast_print_vertex( ctx
, v1
);
497 SWRAST_CONTEXT(ctx
)->Line( ctx
, v0
, v1
);
501 _swrast_Point( GLcontext
*ctx
, const SWvertex
*v0
)
504 _mesa_debug(ctx
, "_swrast_Point\n");
505 _swrast_print_vertex( ctx
, v0
);
507 SWRAST_CONTEXT(ctx
)->Point( ctx
, v0
);
511 _swrast_InvalidateState( GLcontext
*ctx
, GLuint new_state
)
514 _mesa_debug(ctx
, "_swrast_InvalidateState\n");
516 SWRAST_CONTEXT(ctx
)->InvalidateState( ctx
, new_state
);
520 _swrast_ResetLineStipple( GLcontext
*ctx
)
523 _mesa_debug(ctx
, "_swrast_ResetLineStipple\n");
525 SWRAST_CONTEXT(ctx
)->StippleCounter
= 0;
529 _swrast_allow_vertex_fog( GLcontext
*ctx
, GLboolean value
)
532 _mesa_debug(ctx
, "_swrast_allow_vertex_fog %d\n", value
);
534 SWRAST_CONTEXT(ctx
)->InvalidateState( ctx
, _NEW_HINT
);
535 SWRAST_CONTEXT(ctx
)->AllowVertexFog
= value
;
539 _swrast_allow_pixel_fog( GLcontext
*ctx
, GLboolean value
)
542 _mesa_debug(ctx
, "_swrast_allow_pixel_fog %d\n", value
);
544 SWRAST_CONTEXT(ctx
)->InvalidateState( ctx
, _NEW_HINT
);
545 SWRAST_CONTEXT(ctx
)->AllowPixelFog
= value
;
550 _swrast_CreateContext( GLcontext
*ctx
)
553 SWcontext
*swrast
= (SWcontext
*)CALLOC(sizeof(SWcontext
));
556 _mesa_debug(ctx
, "_swrast_CreateContext\n");
562 swrast
->NewState
= ~0;
564 swrast
->choose_point
= _swrast_choose_point
;
565 swrast
->choose_line
= _swrast_choose_line
;
566 swrast
->choose_triangle
= _swrast_choose_triangle
;
568 swrast
->invalidate_point
= _SWRAST_NEW_POINT
;
569 swrast
->invalidate_line
= _SWRAST_NEW_LINE
;
570 swrast
->invalidate_triangle
= _SWRAST_NEW_TRIANGLE
;
572 swrast
->Point
= _swrast_validate_point
;
573 swrast
->Line
= _swrast_validate_line
;
574 swrast
->Triangle
= _swrast_validate_triangle
;
575 swrast
->InvalidateState
= _swrast_sleep
;
576 swrast
->BlendFunc
= _swrast_validate_blend_func
;
578 swrast
->AllowVertexFog
= GL_TRUE
;
579 swrast
->AllowPixelFog
= GL_TRUE
;
581 if (ctx
->Visual
.doubleBufferMode
)
582 swrast
->CurrentBufferBit
= DD_BACK_LEFT_BIT
;
584 swrast
->CurrentBufferBit
= DD_FRONT_LEFT_BIT
;
586 /* Optimized Accum buffer */
587 swrast
->_IntegerAccumMode
= GL_TRUE
;
588 swrast
->_IntegerAccumScaler
= 0.0;
590 for (i
= 0; i
< MAX_TEXTURE_IMAGE_UNITS
; i
++)
591 swrast
->TextureSample
[i
] = _swrast_validate_texture_sample
;
593 swrast
->SpanArrays
= MALLOC_STRUCT(span_arrays
);
594 if (!swrast
->SpanArrays
) {
599 /* init point span buffer */
600 swrast
->PointSpan
.primitive
= GL_POINT
;
601 swrast
->PointSpan
.start
= 0;
602 swrast
->PointSpan
.end
= 0;
603 swrast
->PointSpan
.facing
= 0;
604 swrast
->PointSpan
.array
= swrast
->SpanArrays
;
606 assert(ctx
->Const
.MaxTextureUnits
> 0);
607 assert(ctx
->Const
.MaxTextureUnits
<= MAX_TEXTURE_UNITS
);
609 swrast
->TexelBuffer
= (GLchan
*) MALLOC(ctx
->Const
.MaxTextureUnits
*
610 MAX_WIDTH
* 4 * sizeof(GLchan
));
611 if (!swrast
->TexelBuffer
) {
612 FREE(swrast
->SpanArrays
);
617 ctx
->swrast_context
= swrast
;
623 _swrast_DestroyContext( GLcontext
*ctx
)
625 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
628 _mesa_debug(ctx
, "_swrast_DestroyContext\n");
631 FREE( swrast
->SpanArrays
);
632 FREE( swrast
->TexelBuffer
);
635 ctx
->swrast_context
= 0;
639 struct swrast_device_driver
*
640 _swrast_GetDeviceDriverReference( GLcontext
*ctx
)
642 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
643 return &swrast
->Driver
;
647 _swrast_flush( GLcontext
*ctx
)
649 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
650 /* flush any pending fragments from rendering points */
651 if (swrast
->PointSpan
.end
> 0) {
652 if (ctx
->Visual
.rgbMode
) {
653 if (ctx
->Texture
._EnabledCoordUnits
)
654 _swrast_write_texture_span(ctx
, &(swrast
->PointSpan
));
656 _swrast_write_rgba_span(ctx
, &(swrast
->PointSpan
));
659 _swrast_write_index_span(ctx
, &(swrast
->PointSpan
));
661 swrast
->PointSpan
.end
= 0;
666 _swrast_render_primitive( GLcontext
*ctx
, GLenum prim
)
668 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
669 if (swrast
->Primitive
== GL_POINTS
&& prim
!= GL_POINTS
) {
672 swrast
->Primitive
= prim
;
677 _swrast_render_start( GLcontext
*ctx
)
679 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
680 if (swrast
->Driver
.SpanRenderStart
)
681 swrast
->Driver
.SpanRenderStart( ctx
);
682 swrast
->PointSpan
.end
= 0;
686 _swrast_render_finish( GLcontext
*ctx
)
688 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
689 if (swrast
->Driver
.SpanRenderFinish
)
690 swrast
->Driver
.SpanRenderFinish( ctx
);
696 #define SWRAST_DEBUG_VERTICES 0
699 _swrast_print_vertex( GLcontext
*ctx
, const SWvertex
*v
)
703 if (SWRAST_DEBUG_VERTICES
) {
704 _mesa_debug(ctx
, "win %f %f %f %f\n",
705 v
->win
[0], v
->win
[1], v
->win
[2], v
->win
[3]);
707 for (i
= 0 ; i
< ctx
->Const
.MaxTextureUnits
; i
++)
708 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
)
709 _mesa_debug(ctx
, "texcoord[%d] %f %f %f %f\n", i
,
710 v
->texcoord
[i
][0], v
->texcoord
[i
][1],
711 v
->texcoord
[i
][2], v
->texcoord
[i
][3]);
713 #if CHAN_TYPE == GL_FLOAT
714 _mesa_debug(ctx
, "color %f %f %f %f\n",
715 v
->color
[0], v
->color
[1], v
->color
[2], v
->color
[3]);
716 _mesa_debug(ctx
, "spec %f %f %f %f\n",
717 v
->specular
[0], v
->specular
[1],
718 v
->specular
[2], v
->specular
[3]);
720 _mesa_debug(ctx
, "color %d %d %d %d\n",
721 v
->color
[0], v
->color
[1], v
->color
[2], v
->color
[3]);
722 _mesa_debug(ctx
, "spec %d %d %d %d\n",
723 v
->specular
[0], v
->specular
[1],
724 v
->specular
[2], v
->specular
[3]);
726 _mesa_debug(ctx
, "fog %f\n", v
->fog
);
727 _mesa_debug(ctx
, "index %d\n", v
->index
);
728 _mesa_debug(ctx
, "pointsize %f\n", v
->pointSize
);
729 _mesa_debug(ctx
, "\n");
735 * Validate access to a PBO to be sure we're not going to read/write
736 * out of buffer bounds.
739 _swrast_validate_pbo_access(const struct gl_pixelstore_attrib
*pack
,
740 GLsizei width
, GLsizei height
, GLsizei depth
,
741 GLenum format
, GLenum type
, GLvoid
*ptr
)
743 if (pack
->BufferObj
->Name
== 0) {
747 else if (_mesa_validate_pbo_access(pack
, width
, height
, depth
, format
,
749 return ADD_POINTERS(pack
->BufferObj
->Data
, ptr
);