2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 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.
30 * This file manages recalculation of derived values in GLcontext.
39 #include "ffvertex_prog.h"
40 #include "framebuffer.h"
44 #include "shader/program.h"
45 #include "shader/prog_parameter.h"
48 #include "texenvprogram.h"
54 update_separate_specular(GLcontext
*ctx
)
56 if (NEED_SECONDARY_COLOR(ctx
))
57 ctx
->_TriangleCaps
|= DD_SEPARATE_SPECULAR
;
59 ctx
->_TriangleCaps
&= ~DD_SEPARATE_SPECULAR
;
64 * Compute the index of the last array element that can be safely accessed
65 * in a vertex array. We can really only do this when the array lives in
67 * The array->_MaxElement field will be updated.
68 * Later in glDrawArrays/Elements/etc we can do some bounds checking.
71 compute_max_element(struct gl_client_array
*array
)
73 assert(array
->Enabled
);
74 if (array
->BufferObj
->Name
) {
75 GLsizeiptrARB offset
= (GLsizeiptrARB
) array
->Ptr
;
76 GLsizeiptrARB obj_size
= (GLsizeiptrARB
) array
->BufferObj
->Size
;
78 if (offset
< obj_size
) {
79 array
->_MaxElement
= (obj_size
- offset
+
81 array
->_ElementSize
) / array
->StrideB
;
83 array
->_MaxElement
= 0;
87 /* user-space array, no idea how big it is */
88 array
->_MaxElement
= 2 * 1000 * 1000 * 1000; /* just a big number */
94 * Helper for update_arrays().
95 * \return min(current min, array->_MaxElement).
98 update_min(GLuint min
, struct gl_client_array
*array
)
100 compute_max_element(array
);
101 return MIN2(min
, array
->_MaxElement
);
106 * Update ctx->Array._MaxElement (the max legal index into all enabled arrays).
107 * Need to do this upon new array state or new buffer object state.
110 update_arrays( GLcontext
*ctx
)
112 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
115 /* find min of _MaxElement values for all enabled arrays */
118 if (ctx
->VertexProgram
._Current
119 && arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
) {
120 min
= update_min(min
, &arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
]);
122 else if (arrayObj
->Vertex
.Enabled
) {
123 min
= update_min(min
, &arrayObj
->Vertex
);
127 if (ctx
->VertexProgram
._Enabled
128 && arrayObj
->VertexAttrib
[VERT_ATTRIB_WEIGHT
].Enabled
) {
129 min
= update_min(min
, &arrayObj
->VertexAttrib
[VERT_ATTRIB_WEIGHT
]);
131 /* no conventional vertex weight array */
134 if (ctx
->VertexProgram
._Enabled
135 && arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
) {
136 min
= update_min(min
, &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
]);
138 else if (arrayObj
->Normal
.Enabled
) {
139 min
= update_min(min
, &arrayObj
->Normal
);
143 if (ctx
->VertexProgram
._Enabled
144 && arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
) {
145 min
= update_min(min
, &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
]);
147 else if (arrayObj
->Color
.Enabled
) {
148 min
= update_min(min
, &arrayObj
->Color
);
152 if (ctx
->VertexProgram
._Enabled
153 && arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
) {
154 min
= update_min(min
, &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
]);
156 else if (arrayObj
->SecondaryColor
.Enabled
) {
157 min
= update_min(min
, &arrayObj
->SecondaryColor
);
161 if (ctx
->VertexProgram
._Enabled
162 && arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
) {
163 min
= update_min(min
, &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
]);
165 else if (arrayObj
->FogCoord
.Enabled
) {
166 min
= update_min(min
, &arrayObj
->FogCoord
);
170 if (ctx
->VertexProgram
._Enabled
171 && arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
) {
172 min
= update_min(min
, &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
]);
174 else if (arrayObj
->Index
.Enabled
) {
175 min
= update_min(min
, &arrayObj
->Index
);
179 if (ctx
->VertexProgram
._Enabled
180 && arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
) {
181 min
= update_min(min
, &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
]);
185 for (i
= VERT_ATTRIB_TEX0
; i
<= VERT_ATTRIB_TEX7
; i
++) {
186 if (ctx
->VertexProgram
._Enabled
187 && arrayObj
->VertexAttrib
[i
].Enabled
) {
188 min
= update_min(min
, &arrayObj
->VertexAttrib
[i
]);
190 else if (i
- VERT_ATTRIB_TEX0
< ctx
->Const
.MaxTextureCoordUnits
191 && arrayObj
->TexCoord
[i
- VERT_ATTRIB_TEX0
].Enabled
) {
192 min
= update_min(min
, &arrayObj
->TexCoord
[i
- VERT_ATTRIB_TEX0
]);
197 if (ctx
->VertexProgram
._Current
) {
198 for (i
= 0; i
< Elements(arrayObj
->VertexAttrib
); i
++) {
199 if (arrayObj
->VertexAttrib
[i
].Enabled
) {
200 min
= update_min(min
, &arrayObj
->VertexAttrib
[i
]);
205 if (arrayObj
->EdgeFlag
.Enabled
) {
206 min
= update_min(min
, &arrayObj
->EdgeFlag
);
209 /* _MaxElement is one past the last legal array element */
210 arrayObj
->_MaxElement
= min
;
215 * Update the following fields:
216 * ctx->VertexProgram._Enabled
217 * ctx->FragmentProgram._Enabled
218 * ctx->ATIFragmentShader._Enabled
219 * This needs to be done before texture state validation.
222 update_program_enables(GLcontext
*ctx
)
224 /* These _Enabled flags indicate if the program is enabled AND valid. */
225 ctx
->VertexProgram
._Enabled
= ctx
->VertexProgram
.Enabled
226 && ctx
->VertexProgram
.Current
->Base
.Instructions
;
227 ctx
->FragmentProgram
._Enabled
= ctx
->FragmentProgram
.Enabled
228 && ctx
->FragmentProgram
.Current
->Base
.Instructions
;
229 ctx
->ATIFragmentShader
._Enabled
= ctx
->ATIFragmentShader
.Enabled
230 && ctx
->ATIFragmentShader
.Current
->Instructions
[0];
235 * Update vertex/fragment program state. In particular, update these fields:
236 * ctx->VertexProgram._Current
237 * ctx->VertexProgram._TnlProgram,
238 * These point to the highest priority enabled vertex/fragment program or are
239 * NULL if fixed-function processing is to be done.
241 * This function needs to be called after texture state validation in case
242 * we're generating a fragment program from fixed-function texture state.
244 * \return bitfield which will indicate _NEW_PROGRAM state if a new vertex
245 * or fragment program is being used.
248 update_program(GLcontext
*ctx
)
250 const struct gl_shader_program
*shProg
= ctx
->Shader
.CurrentProgram
;
251 const struct gl_vertex_program
*prevVP
= ctx
->VertexProgram
._Current
;
252 const struct gl_fragment_program
*prevFP
= ctx
->FragmentProgram
._Current
;
253 GLbitfield new_state
= 0x0;
256 * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current
257 * pointers to the programs that should be used for rendering. If either
258 * is NULL, use fixed-function code paths.
260 * These programs may come from several sources. The priority is as
262 * 1. OpenGL 2.0/ARB vertex/fragment shaders
263 * 2. ARB/NV vertex/fragment programs
264 * 3. Programs derived from fixed-function state.
266 * Note: it's possible for a vertex shader to get used with a fragment
267 * program (and vice versa) here, but in practice that shouldn't ever
268 * come up, or matter.
271 if (shProg
&& shProg
->LinkStatus
&& shProg
->FragmentProgram
) {
272 /* Use shader programs */
273 _mesa_reference_fragprog(ctx
, &ctx
->FragmentProgram
._Current
,
274 shProg
->FragmentProgram
);
276 else if (ctx
->FragmentProgram
._Enabled
) {
277 /* use user-defined vertex program */
278 _mesa_reference_fragprog(ctx
, &ctx
->FragmentProgram
._Current
,
279 ctx
->FragmentProgram
.Current
);
281 else if (ctx
->FragmentProgram
._MaintainTexEnvProgram
) {
282 /* Use fragment program generated from fixed-function state.
284 _mesa_reference_fragprog(ctx
, &ctx
->FragmentProgram
._Current
,
285 _mesa_get_fixed_func_fragment_program(ctx
));
286 _mesa_reference_fragprog(ctx
, &ctx
->FragmentProgram
._TexEnvProgram
,
287 ctx
->FragmentProgram
._Current
);
290 /* no fragment program */
291 _mesa_reference_fragprog(ctx
, &ctx
->FragmentProgram
._Current
, NULL
);
294 /* Examine vertex program after fragment program as
295 * _mesa_get_fixed_func_vertex_program() needs to know active
298 if (shProg
&& shProg
->LinkStatus
&& shProg
->VertexProgram
) {
299 /* Use shader programs */
300 _mesa_reference_vertprog(ctx
, &ctx
->VertexProgram
._Current
,
301 shProg
->VertexProgram
);
303 else if (ctx
->VertexProgram
._Enabled
) {
304 /* use user-defined vertex program */
305 _mesa_reference_vertprog(ctx
, &ctx
->VertexProgram
._Current
,
306 ctx
->VertexProgram
.Current
);
308 else if (ctx
->VertexProgram
._MaintainTnlProgram
) {
309 /* Use vertex program generated from fixed-function state.
311 _mesa_reference_vertprog(ctx
, &ctx
->VertexProgram
._Current
,
312 _mesa_get_fixed_func_vertex_program(ctx
));
313 _mesa_reference_vertprog(ctx
, &ctx
->VertexProgram
._TnlProgram
,
314 ctx
->VertexProgram
._Current
);
317 /* no vertex program */
318 _mesa_reference_vertprog(ctx
, &ctx
->VertexProgram
._Current
, NULL
);
321 /* Let the driver know what's happening:
323 if (ctx
->FragmentProgram
._Current
!= prevFP
) {
324 new_state
|= _NEW_PROGRAM
;
325 if (ctx
->Driver
.BindProgram
) {
326 ctx
->Driver
.BindProgram(ctx
, GL_FRAGMENT_PROGRAM_ARB
,
327 (struct gl_program
*) ctx
->FragmentProgram
._Current
);
331 if (ctx
->VertexProgram
._Current
!= prevVP
) {
332 new_state
|= _NEW_PROGRAM
;
333 if (ctx
->Driver
.BindProgram
) {
334 ctx
->Driver
.BindProgram(ctx
, GL_VERTEX_PROGRAM_ARB
,
335 (struct gl_program
*) ctx
->VertexProgram
._Current
);
344 * Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0.
347 update_program_constants(GLcontext
*ctx
)
349 GLbitfield new_state
= 0x0;
351 if (ctx
->FragmentProgram
._Current
) {
352 const struct gl_program_parameter_list
*params
=
353 ctx
->FragmentProgram
._Current
->Base
.Parameters
;
354 if (params
&& params
->StateFlags
& ctx
->NewState
) {
355 new_state
|= _NEW_PROGRAM_CONSTANTS
;
359 if (ctx
->VertexProgram
._Current
) {
360 const struct gl_program_parameter_list
*params
=
361 ctx
->VertexProgram
._Current
->Base
.Parameters
;
362 if (params
&& params
->StateFlags
& ctx
->NewState
) {
363 new_state
|= _NEW_PROGRAM_CONSTANTS
;
374 update_viewport_matrix(GLcontext
*ctx
)
376 const GLfloat depthMax
= ctx
->DrawBuffer
->_DepthMaxF
;
378 ASSERT(depthMax
> 0);
380 /* Compute scale and bias values. This is really driver-specific
381 * and should be maintained elsewhere if at all.
382 * NOTE: RasterPos uses this.
384 _math_matrix_viewport(&ctx
->Viewport
._WindowMap
,
385 ctx
->Viewport
.X
, ctx
->Viewport
.Y
,
386 ctx
->Viewport
.Width
, ctx
->Viewport
.Height
,
387 ctx
->Viewport
.Near
, ctx
->Viewport
.Far
,
393 * Update derived multisample state.
396 update_multisample(GLcontext
*ctx
)
398 ctx
->Multisample
._Enabled
= GL_FALSE
;
399 if (ctx
->Multisample
.Enabled
&&
401 ctx
->DrawBuffer
->Visual
.sampleBuffers
)
402 ctx
->Multisample
._Enabled
= GL_TRUE
;
407 * Update derived color/blend/logicop state.
410 update_color(GLcontext
*ctx
)
412 /* This is needed to support 1.1's RGB logic ops AND
413 * 1.0's blending logicops.
415 ctx
->Color
._LogicOpEnabled
= RGBA_LOGICOP_ENABLED(ctx
);
420 * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET
421 * in ctx->_TriangleCaps if needed.
424 update_polygon(GLcontext
*ctx
)
426 ctx
->_TriangleCaps
&= ~(DD_TRI_CULL_FRONT_BACK
| DD_TRI_OFFSET
);
428 if (ctx
->Polygon
.CullFlag
&& ctx
->Polygon
.CullFaceMode
== GL_FRONT_AND_BACK
)
429 ctx
->_TriangleCaps
|= DD_TRI_CULL_FRONT_BACK
;
431 if ( ctx
->Polygon
.OffsetPoint
432 || ctx
->Polygon
.OffsetLine
433 || ctx
->Polygon
.OffsetFill
)
434 ctx
->_TriangleCaps
|= DD_TRI_OFFSET
;
439 * Update the ctx->_TriangleCaps bitfield.
440 * XXX that bitfield should really go away someday!
441 * This function must be called after other update_*() functions since
442 * there are dependencies on some other derived values.
446 update_tricaps(GLcontext
*ctx
, GLbitfield new_state
)
448 ctx
->_TriangleCaps
= 0;
453 if (1/*new_state & _NEW_POINT*/) {
454 if (ctx
->Point
.SmoothFlag
)
455 ctx
->_TriangleCaps
|= DD_POINT_SMOOTH
;
456 if (ctx
->Point
.Size
!= 1.0F
)
457 ctx
->_TriangleCaps
|= DD_POINT_SIZE
;
458 if (ctx
->Point
._Attenuated
)
459 ctx
->_TriangleCaps
|= DD_POINT_ATTEN
;
465 if (1/*new_state & _NEW_LINE*/) {
466 if (ctx
->Line
.SmoothFlag
)
467 ctx
->_TriangleCaps
|= DD_LINE_SMOOTH
;
468 if (ctx
->Line
.StippleFlag
)
469 ctx
->_TriangleCaps
|= DD_LINE_STIPPLE
;
470 if (ctx
->Line
.Width
!= 1.0)
471 ctx
->_TriangleCaps
|= DD_LINE_WIDTH
;
477 if (1/*new_state & _NEW_POLYGON*/) {
478 if (ctx
->Polygon
.SmoothFlag
)
479 ctx
->_TriangleCaps
|= DD_TRI_SMOOTH
;
480 if (ctx
->Polygon
.StippleFlag
)
481 ctx
->_TriangleCaps
|= DD_TRI_STIPPLE
;
482 if (ctx
->Polygon
.FrontMode
!= GL_FILL
483 || ctx
->Polygon
.BackMode
!= GL_FILL
)
484 ctx
->_TriangleCaps
|= DD_TRI_UNFILLED
;
485 if (ctx
->Polygon
.CullFlag
486 && ctx
->Polygon
.CullFaceMode
== GL_FRONT_AND_BACK
)
487 ctx
->_TriangleCaps
|= DD_TRI_CULL_FRONT_BACK
;
488 if (ctx
->Polygon
.OffsetPoint
||
489 ctx
->Polygon
.OffsetLine
||
490 ctx
->Polygon
.OffsetFill
)
491 ctx
->_TriangleCaps
|= DD_TRI_OFFSET
;
495 * Lighting and shading
497 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
498 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
499 if (ctx
->Light
.ShadeModel
== GL_FLAT
)
500 ctx
->_TriangleCaps
|= DD_FLATSHADE
;
501 if (NEED_SECONDARY_COLOR(ctx
))
502 ctx
->_TriangleCaps
|= DD_SEPARATE_SPECULAR
;
507 if (ctx
->Stencil
._TestTwoSide
)
508 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
514 * Compute derived GL state.
515 * If __GLcontextRec::NewState is non-zero then this function \b must
516 * be called before rendering anything.
518 * Calls dd_function_table::UpdateState to perform any internal state
519 * management necessary.
521 * \sa _mesa_update_modelview_project(), _mesa_update_texture(),
522 * _mesa_update_buffer_bounds(),
523 * _mesa_update_lighting() and _mesa_update_tnl_spaces().
526 _mesa_update_state_locked( GLcontext
*ctx
)
528 GLbitfield new_state
= ctx
->NewState
;
529 GLbitfield prog_flags
= _NEW_PROGRAM
;
530 GLbitfield new_prog_state
= 0x0;
532 if (new_state
== _NEW_CURRENT_ATTRIB
)
535 if (MESA_VERBOSE
& VERBOSE_STATE
)
536 _mesa_print_state("_mesa_update_state", new_state
);
538 /* Determine which state flags effect vertex/fragment program state */
539 if (ctx
->FragmentProgram
._MaintainTexEnvProgram
) {
540 prog_flags
|= (_NEW_TEXTURE
| _NEW_FOG
|
541 _NEW_ARRAY
| _NEW_LIGHT
| _NEW_POINT
| _NEW_RENDERMODE
|
544 if (ctx
->VertexProgram
._MaintainTnlProgram
) {
545 prog_flags
|= (_NEW_ARRAY
| _NEW_TEXTURE
| _NEW_TEXTURE_MATRIX
|
546 _NEW_TRANSFORM
| _NEW_POINT
|
547 _NEW_FOG
| _NEW_LIGHT
|
548 _MESA_NEW_NEED_EYE_COORDS
);
552 * Now update derived state info
555 if (new_state
& prog_flags
)
556 update_program_enables( ctx
);
558 if (new_state
& (_NEW_MODELVIEW
|_NEW_PROJECTION
))
559 _mesa_update_modelview_project( ctx
, new_state
);
561 if (new_state
& (_NEW_PROGRAM
|_NEW_TEXTURE
|_NEW_TEXTURE_MATRIX
))
562 _mesa_update_texture( ctx
, new_state
);
564 if (new_state
& _NEW_BUFFERS
)
565 _mesa_update_framebuffer(ctx
);
567 if (new_state
& (_NEW_SCISSOR
| _NEW_BUFFERS
| _NEW_VIEWPORT
))
568 _mesa_update_draw_buffer_bounds( ctx
);
570 if (new_state
& _NEW_POLYGON
)
571 update_polygon( ctx
);
573 if (new_state
& _NEW_LIGHT
)
574 _mesa_update_lighting( ctx
);
576 if (new_state
& (_NEW_STENCIL
| _NEW_BUFFERS
))
577 _mesa_update_stencil( ctx
);
579 if (new_state
& _MESA_NEW_TRANSFER_STATE
)
580 _mesa_update_pixel( ctx
, new_state
);
582 if (new_state
& _DD_NEW_SEPARATE_SPECULAR
)
583 update_separate_specular( ctx
);
585 if (new_state
& (_NEW_ARRAY
| _NEW_PROGRAM
| _NEW_BUFFER_OBJECT
))
586 update_arrays( ctx
);
588 if (new_state
& (_NEW_BUFFERS
| _NEW_VIEWPORT
))
589 update_viewport_matrix(ctx
);
591 if (new_state
& _NEW_MULTISAMPLE
)
592 update_multisample( ctx
);
594 if (new_state
& _NEW_COLOR
)
598 if (new_state
& (_NEW_POINT
| _NEW_LINE
| _NEW_POLYGON
| _NEW_LIGHT
599 | _NEW_STENCIL
| _DD_NEW_SEPARATE_SPECULAR
))
600 update_tricaps( ctx
, new_state
);
603 /* ctx->_NeedEyeCoords is now up to date.
605 * If the truth value of this variable has changed, update for the
606 * new lighting space and recompute the positions of lights and the
609 * If the lighting space hasn't changed, may still need to recompute
610 * light positions & normal transforms for other reasons.
612 if (new_state
& _MESA_NEW_NEED_EYE_COORDS
)
613 _mesa_update_tnl_spaces( ctx
, new_state
);
615 if (new_state
& prog_flags
) {
616 /* When we generate programs from fixed-function vertex/fragment state
617 * this call may generate/bind a new program. If so, we need to
618 * propogate the _NEW_PROGRAM flag to the driver.
620 new_prog_state
|= update_program( ctx
);
625 new_prog_state
|= update_program_constants(ctx
);
628 * Give the driver a chance to act upon the new_state flags.
629 * The driver might plug in different span functions, for example.
630 * Also, this is where the driver can invalidate the state of any
631 * active modules (such as swrast_setup, swrast, tnl, etc).
633 * Set ctx->NewState to zero to avoid recursion if
634 * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?)
636 new_state
= ctx
->NewState
| new_prog_state
;
638 ctx
->Driver
.UpdateState(ctx
, new_state
);
639 ctx
->Array
.NewState
= 0;
643 /* This is the usual entrypoint for state updates:
646 _mesa_update_state( GLcontext
*ctx
)
648 _mesa_lock_context_textures(ctx
);
649 _mesa_update_state_locked(ctx
);
650 _mesa_unlock_context_textures(ctx
);
657 * Want to figure out which fragment program inputs are actually
658 * constant/current values from ctx->Current. These should be
659 * referenced as a tracked state variable rather than a fragment
660 * program input, to save the overhead of putting a constant value in
661 * every submitted vertex, transferring it to hardware, interpolating
662 * it across the triangle, etc...
664 * When there is a VP bound, just use vp->outputs. But when we're
665 * generating vp from fixed function state, basically want to
668 * vp_out_2_fp_in( vp_in_2_vp_out( varying_inputs ) |
669 * potential_vp_outputs )
671 * Where potential_vp_outputs is calculated by looking at enabled
674 * The generated fragment program should then only declare inputs that
675 * may vary or otherwise differ from the ctx->Current values.
676 * Otherwise, the fp should track them as state values instead.
679 _mesa_set_varying_vp_inputs( GLcontext
*ctx
,
680 GLbitfield varying_inputs
)
682 if (ctx
->varying_vp_inputs
!= varying_inputs
) {
683 ctx
->varying_vp_inputs
= varying_inputs
;
684 ctx
->NewState
|= _NEW_ARRAY
;
685 /*printf("%s %x\n", __FUNCTION__, varying_inputs);*/
691 * Used by drivers to tell core Mesa that the driver is going to
692 * install/ use its own vertex program. In particular, this will
693 * prevent generated fragment programs from using state vars instead
694 * of ordinary varyings/inputs.
697 _mesa_set_vp_override(GLcontext
*ctx
, GLboolean flag
)
699 if (ctx
->VertexProgram
._Overriden
!= flag
) {
700 ctx
->VertexProgram
._Overriden
= flag
;
702 /* Set one of the bits which will trigger fragment program
705 ctx
->NewState
|= _NEW_PROGRAM
;