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