73c5a1c263fce203433d947a18884a0c8073bdf3
[mesa.git] / src / mesa / main / state.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.3
4 *
5 * Copyright (C) 1999-2008 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
25
26 /**
27 * \file state.c
28 * State management.
29 *
30 * This file manages recalculation of derived values in struct gl_context.
31 */
32
33
34 #include "glheader.h"
35 #include "mtypes.h"
36 #include "arrayobj.h"
37 #include "context.h"
38 #include "debug.h"
39 #include "macros.h"
40 #include "ffvertex_prog.h"
41 #include "framebuffer.h"
42 #include "light.h"
43 #include "matrix.h"
44 #include "pixel.h"
45 #include "program/program.h"
46 #include "program/prog_parameter.h"
47 #include "shaderobj.h"
48 #include "state.h"
49 #include "stencil.h"
50 #include "texenvprogram.h"
51 #include "texobj.h"
52 #include "texstate.h"
53 #include "varray.h"
54 #include "blend.h"
55
56
57 static void
58 update_separate_specular(struct gl_context *ctx)
59 {
60 if (_mesa_need_secondary_color(ctx))
61 ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
62 else
63 ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
64 }
65
66
67 /**
68 * Update the following fields:
69 * ctx->VertexProgram._Enabled
70 * ctx->FragmentProgram._Enabled
71 * ctx->ATIFragmentShader._Enabled
72 * This needs to be done before texture state validation.
73 */
74 static void
75 update_program_enables(struct gl_context *ctx)
76 {
77 /* These _Enabled flags indicate if the user-defined ARB/NV vertex/fragment
78 * program is enabled AND valid. Similarly for ATI fragment shaders.
79 * GLSL shaders not relevant here.
80 */
81 ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
82 && ctx->VertexProgram.Current->Base.Instructions;
83 ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
84 && ctx->FragmentProgram.Current->Base.Instructions;
85 ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
86 && ctx->ATIFragmentShader.Current->Instructions[0];
87 }
88
89
90 /**
91 * Update the ctx->Vertex/Geometry/FragmentProgram._Current pointers to point
92 * to the current/active programs. Then call ctx->Driver.BindProgram() to
93 * tell the driver which programs to use.
94 *
95 * Programs may come from 3 sources: GLSL shaders, ARB/NV_vertex/fragment
96 * programs or programs derived from fixed-function state.
97 *
98 * This function needs to be called after texture state validation in case
99 * we're generating a fragment program from fixed-function texture state.
100 *
101 * \return bitfield which will indicate _NEW_PROGRAM state if a new vertex
102 * or fragment program is being used.
103 */
104 static GLbitfield
105 update_program(struct gl_context *ctx)
106 {
107 const struct gl_shader_program *vsProg = ctx->Shader.CurrentVertexProgram;
108 const struct gl_shader_program *gsProg = ctx->Shader.CurrentGeometryProgram;
109 struct gl_shader_program *fsProg = ctx->Shader.CurrentFragmentProgram;
110 const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
111 const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
112 const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current;
113 GLbitfield new_state = 0x0;
114
115 /*
116 * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current
117 * pointers to the programs that should be used for rendering. If either
118 * is NULL, use fixed-function code paths.
119 *
120 * These programs may come from several sources. The priority is as
121 * follows:
122 * 1. OpenGL 2.0/ARB vertex/fragment shaders
123 * 2. ARB/NV vertex/fragment programs
124 * 3. Programs derived from fixed-function state.
125 *
126 * Note: it's possible for a vertex shader to get used with a fragment
127 * program (and vice versa) here, but in practice that shouldn't ever
128 * come up, or matter.
129 */
130
131 if (fsProg && fsProg->LinkStatus
132 && fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
133 /* Use GLSL fragment shader */
134 _mesa_reference_shader_program(ctx,
135 &ctx->Shader._CurrentFragmentProgram,
136 fsProg);
137 _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
138 gl_fragment_program(fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program));
139 _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
140 NULL);
141 }
142 else if (ctx->FragmentProgram._Enabled) {
143 /* Use user-defined fragment program */
144 _mesa_reference_shader_program(ctx,
145 &ctx->Shader._CurrentFragmentProgram,
146 NULL);
147 _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
148 ctx->FragmentProgram.Current);
149 _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
150 NULL);
151 }
152 else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
153 /* Use fragment program generated from fixed-function state */
154 struct gl_shader_program *f = _mesa_get_fixed_func_fragment_program(ctx);
155
156 _mesa_reference_shader_program(ctx,
157 &ctx->Shader._CurrentFragmentProgram,
158 f);
159 _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
160 gl_fragment_program(f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program));
161 _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
162 gl_fragment_program(f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program));
163 }
164 else {
165 /* No fragment program */
166 _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
167 _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
168 NULL);
169 }
170
171 if (gsProg && gsProg->LinkStatus
172 && gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]) {
173 /* Use GLSL geometry shader */
174 _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current,
175 gl_geometry_program(gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program));
176 } else {
177 /* No geometry program */
178 _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL);
179 }
180
181 /* Examine vertex program after fragment program as
182 * _mesa_get_fixed_func_vertex_program() needs to know active
183 * fragprog inputs.
184 */
185 if (vsProg && vsProg->LinkStatus
186 && vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
187 /* Use GLSL vertex shader */
188 _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
189 gl_vertex_program(vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program));
190 }
191 else if (ctx->VertexProgram._Enabled) {
192 /* Use user-defined vertex program */
193 _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
194 ctx->VertexProgram.Current);
195 }
196 else if (ctx->VertexProgram._MaintainTnlProgram) {
197 /* Use vertex program generated from fixed-function state */
198 _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
199 _mesa_get_fixed_func_vertex_program(ctx));
200 _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram,
201 ctx->VertexProgram._Current);
202 }
203 else {
204 /* no vertex program */
205 _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
206 }
207
208 /* Let the driver know what's happening:
209 */
210 if (ctx->FragmentProgram._Current != prevFP) {
211 new_state |= _NEW_PROGRAM;
212 if (ctx->Driver.BindProgram) {
213 ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB,
214 (struct gl_program *) ctx->FragmentProgram._Current);
215 }
216 }
217
218 if (ctx->GeometryProgram._Current != prevGP) {
219 new_state |= _NEW_PROGRAM;
220 if (ctx->Driver.BindProgram) {
221 ctx->Driver.BindProgram(ctx, MESA_GEOMETRY_PROGRAM,
222 (struct gl_program *) ctx->GeometryProgram._Current);
223 }
224 }
225
226 if (ctx->VertexProgram._Current != prevVP) {
227 new_state |= _NEW_PROGRAM;
228 if (ctx->Driver.BindProgram) {
229 ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB,
230 (struct gl_program *) ctx->VertexProgram._Current);
231 }
232 }
233
234 return new_state;
235 }
236
237
238 /**
239 * Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0.
240 */
241 static GLbitfield
242 update_program_constants(struct gl_context *ctx)
243 {
244 GLbitfield new_state = 0x0;
245
246 if (ctx->FragmentProgram._Current) {
247 const struct gl_program_parameter_list *params =
248 ctx->FragmentProgram._Current->Base.Parameters;
249 if (params && params->StateFlags & ctx->NewState) {
250 new_state |= _NEW_PROGRAM_CONSTANTS;
251 }
252 }
253
254 if (ctx->GeometryProgram._Current) {
255 const struct gl_program_parameter_list *params =
256 ctx->GeometryProgram._Current->Base.Parameters;
257 /*FIXME: StateFlags is always 0 because we have unnamed constant
258 * not state changes */
259 if (params /*&& params->StateFlags & ctx->NewState*/) {
260 new_state |= _NEW_PROGRAM_CONSTANTS;
261 }
262 }
263
264 if (ctx->VertexProgram._Current) {
265 const struct gl_program_parameter_list *params =
266 ctx->VertexProgram._Current->Base.Parameters;
267 if (params && params->StateFlags & ctx->NewState) {
268 new_state |= _NEW_PROGRAM_CONSTANTS;
269 }
270 }
271
272 return new_state;
273 }
274
275
276
277
278 static void
279 update_viewport_matrix(struct gl_context *ctx)
280 {
281 const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
282
283 ASSERT(depthMax > 0);
284
285 /* Compute scale and bias values. This is really driver-specific
286 * and should be maintained elsewhere if at all.
287 * NOTE: RasterPos uses this.
288 */
289 _math_matrix_viewport(&ctx->Viewport._WindowMap,
290 ctx->Viewport.X, ctx->Viewport.Y,
291 ctx->Viewport.Width, ctx->Viewport.Height,
292 ctx->Viewport.Near, ctx->Viewport.Far,
293 depthMax);
294 }
295
296
297 /**
298 * Update derived multisample state.
299 */
300 static void
301 update_multisample(struct gl_context *ctx)
302 {
303 ctx->Multisample._Enabled = GL_FALSE;
304 if (ctx->Multisample.Enabled &&
305 ctx->DrawBuffer &&
306 ctx->DrawBuffer->Visual.sampleBuffers)
307 ctx->Multisample._Enabled = GL_TRUE;
308 }
309
310
311 /**
312 * Update the ctx->Color._ClampFragmentColor field
313 */
314 static void
315 update_clamp_fragment_color(struct gl_context *ctx)
316 {
317 struct gl_framebuffer *fb = ctx->DrawBuffer;
318
319 /* Don't clamp if:
320 * - there is no colorbuffer
321 * - all colorbuffers are unsigned normalized, so clamping has no effect
322 * - there is an integer colorbuffer
323 */
324 if (!fb || !fb->_HasSNormOrFloatColorBuffer || fb->_IntegerColor)
325 ctx->Color._ClampFragmentColor = GL_FALSE;
326 else
327 ctx->Color._ClampFragmentColor = _mesa_get_clamp_fragment_color(ctx);
328 }
329
330
331 /**
332 * Update the ctx->Color._ClampVertexColor field
333 */
334 static void
335 update_clamp_vertex_color(struct gl_context *ctx)
336 {
337 ctx->Light._ClampVertexColor = _mesa_get_clamp_vertex_color(ctx);
338 }
339
340
341 /**
342 * Update the ctx->VertexProgram._TwoSideEnabled flag.
343 */
344 static void
345 update_twoside(struct gl_context *ctx)
346 {
347 if (ctx->Shader.CurrentVertexProgram ||
348 ctx->VertexProgram._Enabled) {
349 ctx->VertexProgram._TwoSideEnabled = ctx->VertexProgram.TwoSideEnabled;
350 } else {
351 ctx->VertexProgram._TwoSideEnabled = (ctx->Light.Enabled &&
352 ctx->Light.Model.TwoSide);
353 }
354 }
355
356
357 /*
358 * Check polygon state and set DD_TRI_OFFSET
359 * in ctx->_TriangleCaps if needed.
360 */
361 static void
362 update_polygon(struct gl_context *ctx)
363 {
364 ctx->_TriangleCaps &= ~DD_TRI_OFFSET;
365
366 if ( ctx->Polygon.OffsetPoint
367 || ctx->Polygon.OffsetLine
368 || ctx->Polygon.OffsetFill)
369 ctx->_TriangleCaps |= DD_TRI_OFFSET;
370 }
371
372
373 /**
374 * Update the ctx->_TriangleCaps bitfield.
375 * XXX that bitfield should really go away someday!
376 * This function must be called after other update_*() functions since
377 * there are dependencies on some other derived values.
378 */
379 #if 0
380 static void
381 update_tricaps(struct gl_context *ctx, GLbitfield new_state)
382 {
383 ctx->_TriangleCaps = 0;
384
385 /*
386 * Points
387 */
388 if (1/*new_state & _NEW_POINT*/) {
389 if (ctx->Point.SmoothFlag)
390 ctx->_TriangleCaps |= DD_POINT_SMOOTH;
391 if (ctx->Point._Attenuated)
392 ctx->_TriangleCaps |= DD_POINT_ATTEN;
393 }
394
395 /*
396 * Lines
397 */
398 if (1/*new_state & _NEW_LINE*/) {
399 if (ctx->Line.SmoothFlag)
400 ctx->_TriangleCaps |= DD_LINE_SMOOTH;
401 if (ctx->Line.StippleFlag)
402 ctx->_TriangleCaps |= DD_LINE_STIPPLE;
403 }
404
405 /*
406 * Polygons
407 */
408 if (1/*new_state & _NEW_POLYGON*/) {
409 if (ctx->Polygon.SmoothFlag)
410 ctx->_TriangleCaps |= DD_TRI_SMOOTH;
411 if (ctx->Polygon.StippleFlag)
412 ctx->_TriangleCaps |= DD_TRI_STIPPLE;
413 if (ctx->Polygon.FrontMode != GL_FILL
414 || ctx->Polygon.BackMode != GL_FILL)
415 ctx->_TriangleCaps |= DD_TRI_UNFILLED;
416 if (ctx->Polygon.OffsetPoint ||
417 ctx->Polygon.OffsetLine ||
418 ctx->Polygon.OffsetFill)
419 ctx->_TriangleCaps |= DD_TRI_OFFSET;
420 }
421
422 /*
423 * Lighting and shading
424 */
425 if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
426 ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
427 if (_mesa_need_secondary_color(ctx))
428 ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
429 }
430 #endif
431
432
433 /**
434 * Compute derived GL state.
435 * If __struct gl_contextRec::NewState is non-zero then this function \b must
436 * be called before rendering anything.
437 *
438 * Calls dd_function_table::UpdateState to perform any internal state
439 * management necessary.
440 *
441 * \sa _mesa_update_modelview_project(), _mesa_update_texture(),
442 * _mesa_update_buffer_bounds(),
443 * _mesa_update_lighting() and _mesa_update_tnl_spaces().
444 */
445 void
446 _mesa_update_state_locked( struct gl_context *ctx )
447 {
448 GLbitfield new_state = ctx->NewState;
449 GLbitfield prog_flags = _NEW_PROGRAM;
450 GLbitfield new_prog_state = 0x0;
451
452 if (new_state == _NEW_CURRENT_ATTRIB)
453 goto out;
454
455 if (MESA_VERBOSE & VERBOSE_STATE)
456 _mesa_print_state("_mesa_update_state", new_state);
457
458 /* Determine which state flags effect vertex/fragment program state */
459 if (ctx->FragmentProgram._MaintainTexEnvProgram) {
460 prog_flags |= (_NEW_BUFFERS | _NEW_TEXTURE | _NEW_FOG |
461 _NEW_VARYING_VP_INPUTS | _NEW_LIGHT | _NEW_POINT |
462 _NEW_RENDERMODE | _NEW_PROGRAM | _NEW_FRAG_CLAMP |
463 _NEW_COLOR);
464 }
465 if (ctx->VertexProgram._MaintainTnlProgram) {
466 prog_flags |= (_NEW_VARYING_VP_INPUTS | _NEW_TEXTURE |
467 _NEW_TEXTURE_MATRIX | _NEW_TRANSFORM | _NEW_POINT |
468 _NEW_FOG | _NEW_LIGHT |
469 _MESA_NEW_NEED_EYE_COORDS);
470 }
471
472 /*
473 * Now update derived state info
474 */
475
476 if (new_state & prog_flags)
477 update_program_enables( ctx );
478
479 if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
480 _mesa_update_modelview_project( ctx, new_state );
481
482 if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX))
483 _mesa_update_texture( ctx, new_state );
484
485 if (new_state & _NEW_BUFFERS)
486 _mesa_update_framebuffer(ctx);
487
488 if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
489 _mesa_update_draw_buffer_bounds( ctx );
490
491 if (new_state & _NEW_POLYGON)
492 update_polygon( ctx );
493
494 if (new_state & _NEW_LIGHT)
495 _mesa_update_lighting( ctx );
496
497 if (new_state & (_NEW_LIGHT | _NEW_PROGRAM))
498 update_twoside( ctx );
499
500 if (new_state & (_NEW_LIGHT | _NEW_BUFFERS))
501 update_clamp_vertex_color(ctx);
502
503 if (new_state & (_NEW_STENCIL | _NEW_BUFFERS))
504 _mesa_update_stencil( ctx );
505
506 if (new_state & _NEW_PIXEL)
507 _mesa_update_pixel( ctx, new_state );
508
509 if (new_state & _MESA_NEW_SEPARATE_SPECULAR)
510 update_separate_specular( ctx );
511
512 if (new_state & (_NEW_BUFFERS | _NEW_VIEWPORT))
513 update_viewport_matrix(ctx);
514
515 if (new_state & (_NEW_MULTISAMPLE | _NEW_BUFFERS))
516 update_multisample( ctx );
517
518 if(new_state & (_NEW_FRAG_CLAMP | _NEW_BUFFERS))
519 update_clamp_fragment_color(ctx);
520
521 #if 0
522 if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT
523 | _NEW_STENCIL | _MESA_NEW_SEPARATE_SPECULAR))
524 update_tricaps( ctx, new_state );
525 #endif
526
527 /* ctx->_NeedEyeCoords is now up to date.
528 *
529 * If the truth value of this variable has changed, update for the
530 * new lighting space and recompute the positions of lights and the
531 * normal transform.
532 *
533 * If the lighting space hasn't changed, may still need to recompute
534 * light positions & normal transforms for other reasons.
535 */
536 if (new_state & _MESA_NEW_NEED_EYE_COORDS)
537 _mesa_update_tnl_spaces( ctx, new_state );
538
539 if (new_state & prog_flags) {
540 /* When we generate programs from fixed-function vertex/fragment state
541 * this call may generate/bind a new program. If so, we need to
542 * propogate the _NEW_PROGRAM flag to the driver.
543 */
544 new_prog_state |= update_program( ctx );
545 }
546
547 if (new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT))
548 _mesa_update_array_object_max_element(ctx, ctx->Array.ArrayObj);
549
550 out:
551 new_prog_state |= update_program_constants(ctx);
552
553 /*
554 * Give the driver a chance to act upon the new_state flags.
555 * The driver might plug in different span functions, for example.
556 * Also, this is where the driver can invalidate the state of any
557 * active modules (such as swrast_setup, swrast, tnl, etc).
558 *
559 * Set ctx->NewState to zero to avoid recursion if
560 * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?)
561 */
562 new_state = ctx->NewState | new_prog_state;
563 ctx->NewState = 0;
564 ctx->Driver.UpdateState(ctx, new_state);
565 ctx->Array.ArrayObj->NewArrays = 0x0;
566 }
567
568
569 /* This is the usual entrypoint for state updates:
570 */
571 void
572 _mesa_update_state( struct gl_context *ctx )
573 {
574 _mesa_lock_context_textures(ctx);
575 _mesa_update_state_locked(ctx);
576 _mesa_unlock_context_textures(ctx);
577 }
578
579
580
581
582 /**
583 * Want to figure out which fragment program inputs are actually
584 * constant/current values from ctx->Current. These should be
585 * referenced as a tracked state variable rather than a fragment
586 * program input, to save the overhead of putting a constant value in
587 * every submitted vertex, transferring it to hardware, interpolating
588 * it across the triangle, etc...
589 *
590 * When there is a VP bound, just use vp->outputs. But when we're
591 * generating vp from fixed function state, basically want to
592 * calculate:
593 *
594 * vp_out_2_fp_in( vp_in_2_vp_out( varying_inputs ) |
595 * potential_vp_outputs )
596 *
597 * Where potential_vp_outputs is calculated by looking at enabled
598 * texgen, etc.
599 *
600 * The generated fragment program should then only declare inputs that
601 * may vary or otherwise differ from the ctx->Current values.
602 * Otherwise, the fp should track them as state values instead.
603 */
604 void
605 _mesa_set_varying_vp_inputs( struct gl_context *ctx,
606 GLbitfield64 varying_inputs )
607 {
608 if (ctx->varying_vp_inputs != varying_inputs) {
609 ctx->varying_vp_inputs = varying_inputs;
610
611 /* Only the fixed-func generated programs need to use the flag
612 * and the fixed-func fragment program uses it only if there is also
613 * a fixed-func vertex program, so this only depends on the latter.
614 *
615 * It's okay to check the VP pointer here, because this is called after
616 * _mesa_update_state in the vbo module. */
617 if (ctx->VertexProgram._TnlProgram ||
618 ctx->FragmentProgram._TexEnvProgram) {
619 ctx->NewState |= _NEW_VARYING_VP_INPUTS;
620 }
621 /*printf("%s %x\n", __FUNCTION__, varying_inputs);*/
622 }
623 }
624
625
626 /**
627 * Used by drivers to tell core Mesa that the driver is going to
628 * install/ use its own vertex program. In particular, this will
629 * prevent generated fragment programs from using state vars instead
630 * of ordinary varyings/inputs.
631 */
632 void
633 _mesa_set_vp_override(struct gl_context *ctx, GLboolean flag)
634 {
635 if (ctx->VertexProgram._Overriden != flag) {
636 ctx->VertexProgram._Overriden = flag;
637
638 /* Set one of the bits which will trigger fragment program
639 * regeneration:
640 */
641 ctx->NewState |= _NEW_PROGRAM;
642 }
643 }