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