1 /* $Id: state.c,v 1.105 2003/04/21 14:55:17 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * /brief This file manages recalculation of derived values in the
30 * __GLcontext. Also, this is where we initialize the API dispatch table.
36 #include "api_loopback.h"
37 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
38 #include "arbprogram.h"
42 #if FEATURE_ARB_vertex_buffer_object
43 #include "bufferobj.h"
59 #include "histogram.h"
75 #if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
76 #include "nvprogram.h"
78 #if FEATURE_NV_fragment_program
79 #include "nvfragprog.h"
82 #include "math/m_matrix.h"
83 #include "math/m_xform.h"
90 _mesa_problem(NULL
, "User called no-op dispatch function");
97 * Set all pointers in the given dispatch table to point to a
98 * generic no-op function.
101 _mesa_init_no_op_table(struct _glapi_table
*table
, GLuint tableSize
)
104 void **dispatch
= (void **) table
;
105 for (i
= 0; i
< tableSize
; i
++) {
106 dispatch
[i
] = (void *) generic_noop
;
113 * Initialize the given dispatch table with pointers to Mesa's
114 * immediate-mode commands.
116 * Pointers to begin/end object commands and a few others
117 * are provided via the vtxfmt interface elsewhere.
120 _mesa_init_exec_table(struct _glapi_table
*exec
, GLuint tableSize
)
122 /* first initialize all dispatch slots to no-op */
123 _mesa_init_no_op_table(exec
, tableSize
);
125 _mesa_loopback_init_api_table( exec
, GL_TRUE
);
127 /* load the dispatch slots we understand */
128 exec
->Accum
= _mesa_Accum
;
129 exec
->AlphaFunc
= _mesa_AlphaFunc
;
130 exec
->Bitmap
= _mesa_Bitmap
;
131 exec
->BlendFunc
= _mesa_BlendFunc
;
132 exec
->CallList
= _mesa_CallList
;
133 exec
->CallLists
= _mesa_CallLists
;
134 exec
->Clear
= _mesa_Clear
;
135 exec
->ClearAccum
= _mesa_ClearAccum
;
136 exec
->ClearColor
= _mesa_ClearColor
;
137 exec
->ClearDepth
= _mesa_ClearDepth
;
138 exec
->ClearIndex
= _mesa_ClearIndex
;
139 exec
->ClearStencil
= _mesa_ClearStencil
;
140 exec
->ClipPlane
= _mesa_ClipPlane
;
141 exec
->ColorMask
= _mesa_ColorMask
;
142 exec
->ColorMaterial
= _mesa_ColorMaterial
;
143 exec
->CopyPixels
= _mesa_CopyPixels
;
144 exec
->CullFace
= _mesa_CullFace
;
145 exec
->DeleteLists
= _mesa_DeleteLists
;
146 exec
->DepthFunc
= _mesa_DepthFunc
;
147 exec
->DepthMask
= _mesa_DepthMask
;
148 exec
->DepthRange
= _mesa_DepthRange
;
149 exec
->Disable
= _mesa_Disable
;
150 exec
->DrawBuffer
= _mesa_DrawBuffer
;
151 exec
->DrawPixels
= _mesa_DrawPixels
;
152 exec
->Enable
= _mesa_Enable
;
153 exec
->EndList
= _mesa_EndList
;
154 exec
->FeedbackBuffer
= _mesa_FeedbackBuffer
;
155 exec
->Finish
= _mesa_Finish
;
156 exec
->Flush
= _mesa_Flush
;
157 exec
->FogCoordPointerEXT
= _mesa_FogCoordPointerEXT
;
158 exec
->Fogf
= _mesa_Fogf
;
159 exec
->Fogfv
= _mesa_Fogfv
;
160 exec
->Fogi
= _mesa_Fogi
;
161 exec
->Fogiv
= _mesa_Fogiv
;
162 exec
->FrontFace
= _mesa_FrontFace
;
163 exec
->Frustum
= _mesa_Frustum
;
164 exec
->GenLists
= _mesa_GenLists
;
165 exec
->GetBooleanv
= _mesa_GetBooleanv
;
166 exec
->GetClipPlane
= _mesa_GetClipPlane
;
167 exec
->GetDoublev
= _mesa_GetDoublev
;
168 exec
->GetError
= _mesa_GetError
;
169 exec
->GetFloatv
= _mesa_GetFloatv
;
170 exec
->GetIntegerv
= _mesa_GetIntegerv
;
171 exec
->GetLightfv
= _mesa_GetLightfv
;
172 exec
->GetLightiv
= _mesa_GetLightiv
;
173 exec
->GetMapdv
= _mesa_GetMapdv
;
174 exec
->GetMapfv
= _mesa_GetMapfv
;
175 exec
->GetMapiv
= _mesa_GetMapiv
;
176 exec
->GetMaterialfv
= _mesa_GetMaterialfv
;
177 exec
->GetMaterialiv
= _mesa_GetMaterialiv
;
178 exec
->GetPixelMapfv
= _mesa_GetPixelMapfv
;
179 exec
->GetPixelMapuiv
= _mesa_GetPixelMapuiv
;
180 exec
->GetPixelMapusv
= _mesa_GetPixelMapusv
;
181 exec
->GetPolygonStipple
= _mesa_GetPolygonStipple
;
182 exec
->GetString
= _mesa_GetString
;
183 exec
->GetTexEnvfv
= _mesa_GetTexEnvfv
;
184 exec
->GetTexEnviv
= _mesa_GetTexEnviv
;
185 exec
->GetTexGendv
= _mesa_GetTexGendv
;
186 exec
->GetTexGenfv
= _mesa_GetTexGenfv
;
187 exec
->GetTexGeniv
= _mesa_GetTexGeniv
;
188 exec
->GetTexImage
= _mesa_GetTexImage
;
189 exec
->GetTexLevelParameterfv
= _mesa_GetTexLevelParameterfv
;
190 exec
->GetTexLevelParameteriv
= _mesa_GetTexLevelParameteriv
;
191 exec
->GetTexParameterfv
= _mesa_GetTexParameterfv
;
192 exec
->GetTexParameteriv
= _mesa_GetTexParameteriv
;
193 exec
->Hint
= _mesa_Hint
;
194 exec
->IndexMask
= _mesa_IndexMask
;
195 exec
->InitNames
= _mesa_InitNames
;
196 exec
->IsEnabled
= _mesa_IsEnabled
;
197 exec
->IsList
= _mesa_IsList
;
198 exec
->LightModelf
= _mesa_LightModelf
;
199 exec
->LightModelfv
= _mesa_LightModelfv
;
200 exec
->LightModeli
= _mesa_LightModeli
;
201 exec
->LightModeliv
= _mesa_LightModeliv
;
202 exec
->Lightf
= _mesa_Lightf
;
203 exec
->Lightfv
= _mesa_Lightfv
;
204 exec
->Lighti
= _mesa_Lighti
;
205 exec
->Lightiv
= _mesa_Lightiv
;
206 exec
->LineStipple
= _mesa_LineStipple
;
207 exec
->LineWidth
= _mesa_LineWidth
;
208 exec
->ListBase
= _mesa_ListBase
;
209 exec
->LoadIdentity
= _mesa_LoadIdentity
;
210 exec
->LoadMatrixd
= _mesa_LoadMatrixd
;
211 exec
->LoadMatrixf
= _mesa_LoadMatrixf
;
212 exec
->LoadName
= _mesa_LoadName
;
213 exec
->LogicOp
= _mesa_LogicOp
;
214 exec
->Map1d
= _mesa_Map1d
;
215 exec
->Map1f
= _mesa_Map1f
;
216 exec
->Map2d
= _mesa_Map2d
;
217 exec
->Map2f
= _mesa_Map2f
;
218 exec
->MapGrid1d
= _mesa_MapGrid1d
;
219 exec
->MapGrid1f
= _mesa_MapGrid1f
;
220 exec
->MapGrid2d
= _mesa_MapGrid2d
;
221 exec
->MapGrid2f
= _mesa_MapGrid2f
;
222 exec
->MatrixMode
= _mesa_MatrixMode
;
223 exec
->MultMatrixd
= _mesa_MultMatrixd
;
224 exec
->MultMatrixf
= _mesa_MultMatrixf
;
225 exec
->NewList
= _mesa_NewList
;
226 exec
->Ortho
= _mesa_Ortho
;
227 exec
->PassThrough
= _mesa_PassThrough
;
228 exec
->PixelMapfv
= _mesa_PixelMapfv
;
229 exec
->PixelMapuiv
= _mesa_PixelMapuiv
;
230 exec
->PixelMapusv
= _mesa_PixelMapusv
;
231 exec
->PixelStoref
= _mesa_PixelStoref
;
232 exec
->PixelStorei
= _mesa_PixelStorei
;
233 exec
->PixelTransferf
= _mesa_PixelTransferf
;
234 exec
->PixelTransferi
= _mesa_PixelTransferi
;
235 exec
->PixelZoom
= _mesa_PixelZoom
;
236 exec
->PointSize
= _mesa_PointSize
;
237 exec
->PolygonMode
= _mesa_PolygonMode
;
238 exec
->PolygonOffset
= _mesa_PolygonOffset
;
239 exec
->PolygonStipple
= _mesa_PolygonStipple
;
240 exec
->PopAttrib
= _mesa_PopAttrib
;
241 exec
->PopMatrix
= _mesa_PopMatrix
;
242 exec
->PopName
= _mesa_PopName
;
243 exec
->PushAttrib
= _mesa_PushAttrib
;
244 exec
->PushMatrix
= _mesa_PushMatrix
;
245 exec
->PushName
= _mesa_PushName
;
246 exec
->RasterPos2d
= _mesa_RasterPos2d
;
247 exec
->RasterPos2dv
= _mesa_RasterPos2dv
;
248 exec
->RasterPos2f
= _mesa_RasterPos2f
;
249 exec
->RasterPos2fv
= _mesa_RasterPos2fv
;
250 exec
->RasterPos2i
= _mesa_RasterPos2i
;
251 exec
->RasterPos2iv
= _mesa_RasterPos2iv
;
252 exec
->RasterPos2s
= _mesa_RasterPos2s
;
253 exec
->RasterPos2sv
= _mesa_RasterPos2sv
;
254 exec
->RasterPos3d
= _mesa_RasterPos3d
;
255 exec
->RasterPos3dv
= _mesa_RasterPos3dv
;
256 exec
->RasterPos3f
= _mesa_RasterPos3f
;
257 exec
->RasterPos3fv
= _mesa_RasterPos3fv
;
258 exec
->RasterPos3i
= _mesa_RasterPos3i
;
259 exec
->RasterPos3iv
= _mesa_RasterPos3iv
;
260 exec
->RasterPos3s
= _mesa_RasterPos3s
;
261 exec
->RasterPos3sv
= _mesa_RasterPos3sv
;
262 exec
->RasterPos4d
= _mesa_RasterPos4d
;
263 exec
->RasterPos4dv
= _mesa_RasterPos4dv
;
264 exec
->RasterPos4f
= _mesa_RasterPos4f
;
265 exec
->RasterPos4fv
= _mesa_RasterPos4fv
;
266 exec
->RasterPos4i
= _mesa_RasterPos4i
;
267 exec
->RasterPos4iv
= _mesa_RasterPos4iv
;
268 exec
->RasterPos4s
= _mesa_RasterPos4s
;
269 exec
->RasterPos4sv
= _mesa_RasterPos4sv
;
270 exec
->ReadBuffer
= _mesa_ReadBuffer
;
271 exec
->ReadPixels
= _mesa_ReadPixels
;
272 exec
->RenderMode
= _mesa_RenderMode
;
273 exec
->Rotated
= _mesa_Rotated
;
274 exec
->Rotatef
= _mesa_Rotatef
;
275 exec
->Scaled
= _mesa_Scaled
;
276 exec
->Scalef
= _mesa_Scalef
;
277 exec
->Scissor
= _mesa_Scissor
;
278 exec
->SecondaryColorPointerEXT
= _mesa_SecondaryColorPointerEXT
;
279 exec
->SelectBuffer
= _mesa_SelectBuffer
;
280 exec
->ShadeModel
= _mesa_ShadeModel
;
281 exec
->StencilFunc
= _mesa_StencilFunc
;
282 exec
->StencilMask
= _mesa_StencilMask
;
283 exec
->StencilOp
= _mesa_StencilOp
;
284 exec
->TexEnvf
= _mesa_TexEnvf
;
285 exec
->TexEnvfv
= _mesa_TexEnvfv
;
286 exec
->TexEnvi
= _mesa_TexEnvi
;
287 exec
->TexEnviv
= _mesa_TexEnviv
;
288 exec
->TexGend
= _mesa_TexGend
;
289 exec
->TexGendv
= _mesa_TexGendv
;
290 exec
->TexGenf
= _mesa_TexGenf
;
291 exec
->TexGenfv
= _mesa_TexGenfv
;
292 exec
->TexGeni
= _mesa_TexGeni
;
293 exec
->TexGeniv
= _mesa_TexGeniv
;
294 exec
->TexImage1D
= _mesa_TexImage1D
;
295 exec
->TexImage2D
= _mesa_TexImage2D
;
296 exec
->TexParameterf
= _mesa_TexParameterf
;
297 exec
->TexParameterfv
= _mesa_TexParameterfv
;
298 exec
->TexParameteri
= _mesa_TexParameteri
;
299 exec
->TexParameteriv
= _mesa_TexParameteriv
;
300 exec
->Translated
= _mesa_Translated
;
301 exec
->Translatef
= _mesa_Translatef
;
302 exec
->Viewport
= _mesa_Viewport
;
305 exec
->AreTexturesResident
= _mesa_AreTexturesResident
;
306 exec
->AreTexturesResidentEXT
= _mesa_AreTexturesResident
;
307 exec
->BindTexture
= _mesa_BindTexture
;
308 exec
->ColorPointer
= _mesa_ColorPointer
;
309 exec
->CopyTexImage1D
= _mesa_CopyTexImage1D
;
310 exec
->CopyTexImage2D
= _mesa_CopyTexImage2D
;
311 exec
->CopyTexSubImage1D
= _mesa_CopyTexSubImage1D
;
312 exec
->CopyTexSubImage2D
= _mesa_CopyTexSubImage2D
;
313 exec
->DeleteTextures
= _mesa_DeleteTextures
;
314 exec
->DisableClientState
= _mesa_DisableClientState
;
315 exec
->EdgeFlagPointer
= _mesa_EdgeFlagPointer
;
316 exec
->EnableClientState
= _mesa_EnableClientState
;
317 exec
->GenTextures
= _mesa_GenTextures
;
318 exec
->GenTexturesEXT
= _mesa_GenTextures
;
319 exec
->GetPointerv
= _mesa_GetPointerv
;
320 exec
->IndexPointer
= _mesa_IndexPointer
;
321 exec
->InterleavedArrays
= _mesa_InterleavedArrays
;
322 exec
->IsTexture
= _mesa_IsTexture
;
323 exec
->IsTextureEXT
= _mesa_IsTexture
;
324 exec
->NormalPointer
= _mesa_NormalPointer
;
325 exec
->PopClientAttrib
= _mesa_PopClientAttrib
;
326 exec
->PrioritizeTextures
= _mesa_PrioritizeTextures
;
327 exec
->PushClientAttrib
= _mesa_PushClientAttrib
;
328 exec
->TexCoordPointer
= _mesa_TexCoordPointer
;
329 exec
->TexSubImage1D
= _mesa_TexSubImage1D
;
330 exec
->TexSubImage2D
= _mesa_TexSubImage2D
;
331 exec
->VertexPointer
= _mesa_VertexPointer
;
334 exec
->CopyTexSubImage3D
= _mesa_CopyTexSubImage3D
;
335 exec
->TexImage3D
= _mesa_TexImage3D
;
336 exec
->TexSubImage3D
= _mesa_TexSubImage3D
;
338 /* OpenGL 1.2 GL_ARB_imaging */
339 exec
->BlendColor
= _mesa_BlendColor
;
340 exec
->BlendEquation
= _mesa_BlendEquation
;
341 exec
->ColorSubTable
= _mesa_ColorSubTable
;
342 exec
->ColorTable
= _mesa_ColorTable
;
343 exec
->ColorTableParameterfv
= _mesa_ColorTableParameterfv
;
344 exec
->ColorTableParameteriv
= _mesa_ColorTableParameteriv
;
345 exec
->ConvolutionFilter1D
= _mesa_ConvolutionFilter1D
;
346 exec
->ConvolutionFilter2D
= _mesa_ConvolutionFilter2D
;
347 exec
->ConvolutionParameterf
= _mesa_ConvolutionParameterf
;
348 exec
->ConvolutionParameterfv
= _mesa_ConvolutionParameterfv
;
349 exec
->ConvolutionParameteri
= _mesa_ConvolutionParameteri
;
350 exec
->ConvolutionParameteriv
= _mesa_ConvolutionParameteriv
;
351 exec
->CopyColorSubTable
= _mesa_CopyColorSubTable
;
352 exec
->CopyColorTable
= _mesa_CopyColorTable
;
353 exec
->CopyConvolutionFilter1D
= _mesa_CopyConvolutionFilter1D
;
354 exec
->CopyConvolutionFilter2D
= _mesa_CopyConvolutionFilter2D
;
355 exec
->GetColorTable
= _mesa_GetColorTable
;
356 exec
->GetColorTableEXT
= _mesa_GetColorTable
;
357 exec
->GetColorTableParameterfv
= _mesa_GetColorTableParameterfv
;
358 exec
->GetColorTableParameterfvEXT
= _mesa_GetColorTableParameterfv
;
359 exec
->GetColorTableParameteriv
= _mesa_GetColorTableParameteriv
;
360 exec
->GetColorTableParameterivEXT
= _mesa_GetColorTableParameteriv
;
361 exec
->GetConvolutionFilter
= _mesa_GetConvolutionFilter
;
362 exec
->GetConvolutionFilterEXT
= _mesa_GetConvolutionFilter
;
363 exec
->GetConvolutionParameterfv
= _mesa_GetConvolutionParameterfv
;
364 exec
->GetConvolutionParameterfvEXT
= _mesa_GetConvolutionParameterfv
;
365 exec
->GetConvolutionParameteriv
= _mesa_GetConvolutionParameteriv
;
366 exec
->GetConvolutionParameterivEXT
= _mesa_GetConvolutionParameteriv
;
367 exec
->GetHistogram
= _mesa_GetHistogram
;
368 exec
->GetHistogramEXT
= _mesa_GetHistogram
;
369 exec
->GetHistogramParameterfv
= _mesa_GetHistogramParameterfv
;
370 exec
->GetHistogramParameterfvEXT
= _mesa_GetHistogramParameterfv
;
371 exec
->GetHistogramParameteriv
= _mesa_GetHistogramParameteriv
;
372 exec
->GetHistogramParameterivEXT
= _mesa_GetHistogramParameteriv
;
373 exec
->GetMinmax
= _mesa_GetMinmax
;
374 exec
->GetMinmaxEXT
= _mesa_GetMinmax
;
375 exec
->GetMinmaxParameterfv
= _mesa_GetMinmaxParameterfv
;
376 exec
->GetMinmaxParameterfvEXT
= _mesa_GetMinmaxParameterfv
;
377 exec
->GetMinmaxParameteriv
= _mesa_GetMinmaxParameteriv
;
378 exec
->GetMinmaxParameterivEXT
= _mesa_GetMinmaxParameteriv
;
379 exec
->GetSeparableFilter
= _mesa_GetSeparableFilter
;
380 exec
->GetSeparableFilterEXT
= _mesa_GetSeparableFilter
;
381 exec
->Histogram
= _mesa_Histogram
;
382 exec
->Minmax
= _mesa_Minmax
;
383 exec
->ResetHistogram
= _mesa_ResetHistogram
;
384 exec
->ResetMinmax
= _mesa_ResetMinmax
;
385 exec
->SeparableFilter2D
= _mesa_SeparableFilter2D
;
387 /* 2. GL_EXT_blend_color */
389 exec
->BlendColorEXT
= _mesa_BlendColorEXT
;
392 /* 3. GL_EXT_polygon_offset */
393 exec
->PolygonOffsetEXT
= _mesa_PolygonOffsetEXT
;
395 /* 6. GL_EXT_texture3d */
397 exec
->CopyTexSubImage3DEXT
= _mesa_CopyTexSubImage3D
;
398 exec
->TexImage3DEXT
= _mesa_TexImage3DEXT
;
399 exec
->TexSubImage3DEXT
= _mesa_TexSubImage3D
;
402 /* 11. GL_EXT_histogram */
403 exec
->GetHistogramEXT
= _mesa_GetHistogram
;
404 exec
->GetHistogramParameterfvEXT
= _mesa_GetHistogramParameterfv
;
405 exec
->GetHistogramParameterivEXT
= _mesa_GetHistogramParameteriv
;
406 exec
->GetMinmaxEXT
= _mesa_GetMinmax
;
407 exec
->GetMinmaxParameterfvEXT
= _mesa_GetMinmaxParameterfv
;
408 exec
->GetMinmaxParameterivEXT
= _mesa_GetMinmaxParameteriv
;
410 /* ?. GL_SGIX_pixel_texture */
411 exec
->PixelTexGenSGIX
= _mesa_PixelTexGenSGIX
;
413 /* 15. GL_SGIS_pixel_texture */
414 exec
->PixelTexGenParameteriSGIS
= _mesa_PixelTexGenParameteriSGIS
;
415 exec
->PixelTexGenParameterivSGIS
= _mesa_PixelTexGenParameterivSGIS
;
416 exec
->PixelTexGenParameterfSGIS
= _mesa_PixelTexGenParameterfSGIS
;
417 exec
->PixelTexGenParameterfvSGIS
= _mesa_PixelTexGenParameterfvSGIS
;
418 exec
->GetPixelTexGenParameterivSGIS
= _mesa_GetPixelTexGenParameterivSGIS
;
419 exec
->GetPixelTexGenParameterfvSGIS
= _mesa_GetPixelTexGenParameterfvSGIS
;
421 /* 30. GL_EXT_vertex_array */
422 exec
->ColorPointerEXT
= _mesa_ColorPointerEXT
;
423 exec
->EdgeFlagPointerEXT
= _mesa_EdgeFlagPointerEXT
;
424 exec
->IndexPointerEXT
= _mesa_IndexPointerEXT
;
425 exec
->NormalPointerEXT
= _mesa_NormalPointerEXT
;
426 exec
->TexCoordPointerEXT
= _mesa_TexCoordPointerEXT
;
427 exec
->VertexPointerEXT
= _mesa_VertexPointerEXT
;
429 /* 37. GL_EXT_blend_minmax */
431 exec
->BlendEquationEXT
= _mesa_BlendEquationEXT
;
434 /* 54. GL_EXT_point_parameters */
435 exec
->PointParameterfEXT
= _mesa_PointParameterfEXT
;
436 exec
->PointParameterfvEXT
= _mesa_PointParameterfvEXT
;
438 /* 78. GL_EXT_paletted_texture */
440 exec
->ColorTableEXT
= _mesa_ColorTableEXT
;
441 exec
->ColorSubTableEXT
= _mesa_ColorSubTableEXT
;
443 exec
->GetColorTableEXT
= _mesa_GetColorTable
;
444 exec
->GetColorTableParameterfvEXT
= _mesa_GetColorTableParameterfv
;
445 exec
->GetColorTableParameterivEXT
= _mesa_GetColorTableParameteriv
;
447 /* 97. GL_EXT_compiled_vertex_array */
448 exec
->LockArraysEXT
= _mesa_LockArraysEXT
;
449 exec
->UnlockArraysEXT
= _mesa_UnlockArraysEXT
;
451 /* 148. GL_EXT_multi_draw_arrays */
452 exec
->MultiDrawArraysEXT
= _mesa_MultiDrawArraysEXT
;
453 exec
->MultiDrawElementsEXT
= _mesa_MultiDrawElementsEXT
;
455 /* 173. GL_INGR_blend_func_separate */
456 exec
->BlendFuncSeparateEXT
= _mesa_BlendFuncSeparateEXT
;
458 /* 196. GL_MESA_resize_buffers */
459 exec
->ResizeBuffersMESA
= _mesa_ResizeBuffersMESA
;
461 /* 197. GL_MESA_window_pos */
462 exec
->WindowPos2dMESA
= _mesa_WindowPos2dMESA
;
463 exec
->WindowPos2dvMESA
= _mesa_WindowPos2dvMESA
;
464 exec
->WindowPos2fMESA
= _mesa_WindowPos2fMESA
;
465 exec
->WindowPos2fvMESA
= _mesa_WindowPos2fvMESA
;
466 exec
->WindowPos2iMESA
= _mesa_WindowPos2iMESA
;
467 exec
->WindowPos2ivMESA
= _mesa_WindowPos2ivMESA
;
468 exec
->WindowPos2sMESA
= _mesa_WindowPos2sMESA
;
469 exec
->WindowPos2svMESA
= _mesa_WindowPos2svMESA
;
470 exec
->WindowPos3dMESA
= _mesa_WindowPos3dMESA
;
471 exec
->WindowPos3dvMESA
= _mesa_WindowPos3dvMESA
;
472 exec
->WindowPos3fMESA
= _mesa_WindowPos3fMESA
;
473 exec
->WindowPos3fvMESA
= _mesa_WindowPos3fvMESA
;
474 exec
->WindowPos3iMESA
= _mesa_WindowPos3iMESA
;
475 exec
->WindowPos3ivMESA
= _mesa_WindowPos3ivMESA
;
476 exec
->WindowPos3sMESA
= _mesa_WindowPos3sMESA
;
477 exec
->WindowPos3svMESA
= _mesa_WindowPos3svMESA
;
478 exec
->WindowPos4dMESA
= _mesa_WindowPos4dMESA
;
479 exec
->WindowPos4dvMESA
= _mesa_WindowPos4dvMESA
;
480 exec
->WindowPos4fMESA
= _mesa_WindowPos4fMESA
;
481 exec
->WindowPos4fvMESA
= _mesa_WindowPos4fvMESA
;
482 exec
->WindowPos4iMESA
= _mesa_WindowPos4iMESA
;
483 exec
->WindowPos4ivMESA
= _mesa_WindowPos4ivMESA
;
484 exec
->WindowPos4sMESA
= _mesa_WindowPos4sMESA
;
485 exec
->WindowPos4svMESA
= _mesa_WindowPos4svMESA
;
487 /* 233. GL_NV_vertex_program */
488 #if FEATURE_NV_vertex_program
489 exec
->BindProgramNV
= _mesa_BindProgramNV
;
490 exec
->DeleteProgramsNV
= _mesa_DeleteProgramsNV
;
491 exec
->ExecuteProgramNV
= _mesa_ExecuteProgramNV
;
492 exec
->GenProgramsNV
= _mesa_GenProgramsNV
;
493 exec
->AreProgramsResidentNV
= _mesa_AreProgramsResidentNV
;
494 exec
->RequestResidentProgramsNV
= _mesa_RequestResidentProgramsNV
;
495 exec
->GetProgramParameterfvNV
= _mesa_GetProgramParameterfvNV
;
496 exec
->GetProgramParameterdvNV
= _mesa_GetProgramParameterdvNV
;
497 exec
->GetProgramivNV
= _mesa_GetProgramivNV
;
498 exec
->GetProgramStringNV
= _mesa_GetProgramStringNV
;
499 exec
->GetTrackMatrixivNV
= _mesa_GetTrackMatrixivNV
;
500 exec
->GetVertexAttribdvNV
= _mesa_GetVertexAttribdvNV
;
501 exec
->GetVertexAttribfvNV
= _mesa_GetVertexAttribfvNV
;
502 exec
->GetVertexAttribivNV
= _mesa_GetVertexAttribivNV
;
503 exec
->GetVertexAttribPointervNV
= _mesa_GetVertexAttribPointervNV
;
504 exec
->IsProgramNV
= _mesa_IsProgramNV
;
505 exec
->LoadProgramNV
= _mesa_LoadProgramNV
;
506 exec
->ProgramParameter4dNV
= _mesa_ProgramParameter4dNV
;
507 exec
->ProgramParameter4dvNV
= _mesa_ProgramParameter4dvNV
;
508 exec
->ProgramParameter4fNV
= _mesa_ProgramParameter4fNV
;
509 exec
->ProgramParameter4fvNV
= _mesa_ProgramParameter4fvNV
;
510 exec
->ProgramParameters4dvNV
= _mesa_ProgramParameters4dvNV
;
511 exec
->ProgramParameters4fvNV
= _mesa_ProgramParameters4fvNV
;
512 exec
->TrackMatrixNV
= _mesa_TrackMatrixNV
;
513 exec
->VertexAttribPointerNV
= _mesa_VertexAttribPointerNV
;
516 /* 282. GL_NV_fragment_program */
517 #if FEATURE_NV_fragment_program
518 exec
->ProgramNamedParameter4fNV
= _mesa_ProgramNamedParameter4fNV
;
519 exec
->ProgramNamedParameter4dNV
= _mesa_ProgramNamedParameter4dNV
;
520 exec
->ProgramNamedParameter4fvNV
= _mesa_ProgramNamedParameter4fvNV
;
521 exec
->ProgramNamedParameter4dvNV
= _mesa_ProgramNamedParameter4dvNV
;
522 exec
->GetProgramNamedParameterfvNV
= _mesa_GetProgramNamedParameterfvNV
;
523 exec
->GetProgramNamedParameterdvNV
= _mesa_GetProgramNamedParameterdvNV
;
524 exec
->ProgramLocalParameter4dARB
= _mesa_ProgramLocalParameter4dARB
;
525 exec
->ProgramLocalParameter4dvARB
= _mesa_ProgramLocalParameter4dvARB
;
526 exec
->ProgramLocalParameter4fARB
= _mesa_ProgramLocalParameter4fARB
;
527 exec
->ProgramLocalParameter4fvARB
= _mesa_ProgramLocalParameter4fvARB
;
528 exec
->GetProgramLocalParameterdvARB
= _mesa_GetProgramLocalParameterdvARB
;
529 exec
->GetProgramLocalParameterfvARB
= _mesa_GetProgramLocalParameterfvARB
;
532 /* 262. GL_NV_point_sprite */
533 exec
->PointParameteriNV
= _mesa_PointParameteriNV
;
534 exec
->PointParameterivNV
= _mesa_PointParameterivNV
;
536 /* 268. GL_EXT_stencil_two_side */
537 exec
->ActiveStencilFaceEXT
= _mesa_ActiveStencilFaceEXT
;
540 /* ???. GL_EXT_depth_bounds_test */
541 exec
->DepthBoundsEXT
= _mesa_DepthBoundsEXT
;
544 /* ARB 1. GL_ARB_multitexture */
545 exec
->ActiveTextureARB
= _mesa_ActiveTextureARB
;
546 exec
->ClientActiveTextureARB
= _mesa_ClientActiveTextureARB
;
548 /* ARB 3. GL_ARB_transpose_matrix */
549 exec
->LoadTransposeMatrixdARB
= _mesa_LoadTransposeMatrixdARB
;
550 exec
->LoadTransposeMatrixfARB
= _mesa_LoadTransposeMatrixfARB
;
551 exec
->MultTransposeMatrixdARB
= _mesa_MultTransposeMatrixdARB
;
552 exec
->MultTransposeMatrixfARB
= _mesa_MultTransposeMatrixfARB
;
554 /* ARB 5. GL_ARB_multisample */
555 exec
->SampleCoverageARB
= _mesa_SampleCoverageARB
;
557 /* ARB 12. GL_ARB_texture_compression */
558 exec
->CompressedTexImage3DARB
= _mesa_CompressedTexImage3DARB
;
559 exec
->CompressedTexImage2DARB
= _mesa_CompressedTexImage2DARB
;
560 exec
->CompressedTexImage1DARB
= _mesa_CompressedTexImage1DARB
;
561 exec
->CompressedTexSubImage3DARB
= _mesa_CompressedTexSubImage3DARB
;
562 exec
->CompressedTexSubImage2DARB
= _mesa_CompressedTexSubImage2DARB
;
563 exec
->CompressedTexSubImage1DARB
= _mesa_CompressedTexSubImage1DARB
;
564 exec
->GetCompressedTexImageARB
= _mesa_GetCompressedTexImageARB
;
566 /* ARB 14. GL_ARB_point_parameters */
567 /* reuse EXT_point_parameters functions */
569 /* ARB 26. GL_ARB_vertex_program */
570 /* ARB 27. GL_ARB_fragment_program */
571 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
572 /* glVertexAttrib1sARB aliases glVertexAttrib1sNV */
573 /* glVertexAttrib1fARB aliases glVertexAttrib1fNV */
574 /* glVertexAttrib1dARB aliases glVertexAttrib1dNV */
575 /* glVertexAttrib2sARB aliases glVertexAttrib2sNV */
576 /* glVertexAttrib2fARB aliases glVertexAttrib2fNV */
577 /* glVertexAttrib2dARB aliases glVertexAttrib2dNV */
578 /* glVertexAttrib3sARB aliases glVertexAttrib3sNV */
579 /* glVertexAttrib3fARB aliases glVertexAttrib3fNV */
580 /* glVertexAttrib3dARB aliases glVertexAttrib3dNV */
581 /* glVertexAttrib4sARB aliases glVertexAttrib4sNV */
582 /* glVertexAttrib4fARB aliases glVertexAttrib4fNV */
583 /* glVertexAttrib4dARB aliases glVertexAttrib4dNV */
584 /* glVertexAttrib4NubARB aliases glVertexAttrib4NubNV */
585 /* glVertexAttrib1svARB aliases glVertexAttrib1svNV */
586 /* glVertexAttrib1fvARB aliases glVertexAttrib1fvNV */
587 /* glVertexAttrib1dvARB aliases glVertexAttrib1dvNV */
588 /* glVertexAttrib2svARB aliases glVertexAttrib2svNV */
589 /* glVertexAttrib2fvARB aliases glVertexAttrib2fvNV */
590 /* glVertexAttrib2dvARB aliases glVertexAttrib2dvNV */
591 /* glVertexAttrib3svARB aliases glVertexAttrib3svNV */
592 /* glVertexAttrib3fvARB aliases glVertexAttrib3fvNV */
593 /* glVertexAttrib3dvARB aliases glVertexAttrib3dvNV */
594 /* glVertexAttrib4svARB aliases glVertexAttrib4svNV */
595 /* glVertexAttrib4fvARB aliases glVertexAttrib4fvNV */
596 /* glVertexAttrib4dvARB aliases glVertexAttrib4dvNV */
597 /* glVertexAttrib4NubvARB aliases glVertexAttrib4NubvNV */
598 exec
->VertexAttrib4bvARB
= _mesa_VertexAttrib4bvARB
;
599 exec
->VertexAttrib4ivARB
= _mesa_VertexAttrib4ivARB
;
600 exec
->VertexAttrib4ubvARB
= _mesa_VertexAttrib4ubvARB
;
601 exec
->VertexAttrib4usvARB
= _mesa_VertexAttrib4usvARB
;
602 exec
->VertexAttrib4uivARB
= _mesa_VertexAttrib4uivARB
;
603 exec
->VertexAttrib4NbvARB
= _mesa_VertexAttrib4NbvARB
;
604 exec
->VertexAttrib4NsvARB
= _mesa_VertexAttrib4NsvARB
;
605 exec
->VertexAttrib4NivARB
= _mesa_VertexAttrib4NivARB
;
606 exec
->VertexAttrib4NusvARB
= _mesa_VertexAttrib4NusvARB
;
607 exec
->VertexAttrib4NuivARB
= _mesa_VertexAttrib4NuivARB
;
608 exec
->VertexAttribPointerARB
= _mesa_VertexAttribPointerARB
;
609 exec
->EnableVertexAttribArrayARB
= _mesa_EnableVertexAttribArrayARB
;
610 exec
->DisableVertexAttribArrayARB
= _mesa_DisableVertexAttribArrayARB
;
611 exec
->ProgramStringARB
= _mesa_ProgramStringARB
;
612 /* glBindProgramARB aliases glBindProgramNV */
613 /* glDeleteProgramsARB aliases glDeleteProgramsNV */
614 /* glGenProgramsARB aliases glGenProgramsNV */
615 /* glIsProgramARB aliases glIsProgramNV */
616 /* glGetVertexAttribdvARB aliases glGetVertexAttribdvNV */
617 /* glGetVertexAttribfvARB aliases glGetVertexAttribfvNV */
618 /* glGetVertexAttribivARB aliases glGetVertexAttribivNV */
619 /* glGetVertexAttribPointervARB aliases glGetVertexAttribPointervNV */
620 exec
->ProgramEnvParameter4dARB
= _mesa_ProgramEnvParameter4dARB
;
621 exec
->ProgramEnvParameter4dvARB
= _mesa_ProgramEnvParameter4dvARB
;
622 exec
->ProgramEnvParameter4fARB
= _mesa_ProgramEnvParameter4fARB
;
623 exec
->ProgramEnvParameter4fvARB
= _mesa_ProgramEnvParameter4fvARB
;
624 exec
->ProgramLocalParameter4dARB
= _mesa_ProgramLocalParameter4dARB
;
625 exec
->ProgramLocalParameter4dvARB
= _mesa_ProgramLocalParameter4dvARB
;
626 exec
->ProgramLocalParameter4fARB
= _mesa_ProgramLocalParameter4fARB
;
627 exec
->ProgramLocalParameter4fvARB
= _mesa_ProgramLocalParameter4fvARB
;
628 exec
->GetProgramEnvParameterdvARB
= _mesa_GetProgramEnvParameterdvARB
;
629 exec
->GetProgramEnvParameterfvARB
= _mesa_GetProgramEnvParameterfvARB
;
630 exec
->GetProgramLocalParameterdvARB
= _mesa_GetProgramLocalParameterdvARB
;
631 exec
->GetProgramLocalParameterfvARB
= _mesa_GetProgramLocalParameterfvARB
;
632 exec
->GetProgramivARB
= _mesa_GetProgramivARB
;
633 exec
->GetProgramStringARB
= _mesa_GetProgramStringARB
;
636 /* ARB 28. GL_ARB_vertex_buffer_object */
637 #if FEATURE_ARB_vertex_buffer_object
638 exec
->BindBufferARB
= _mesa_BindBufferARB
;
639 exec
->BufferDataARB
= _mesa_BufferDataARB
;
640 exec
->BufferSubDataARB
= _mesa_BufferSubDataARB
;
641 exec
->DeleteBuffersARB
= _mesa_DeleteBuffersARB
;
642 exec
->GenBuffersARB
= _mesa_GenBuffersARB
;
643 exec
->GetBufferParameterivARB
= _mesa_GetBufferParameterivARB
;
644 exec
->GetBufferPointervARB
= _mesa_GetBufferPointervARB
;
645 exec
->GetBufferSubDataARB
= _mesa_GetBufferSubDataARB
;
646 exec
->IsBufferARB
= _mesa_IsBufferARB
;
647 exec
->MapBufferARB
= _mesa_MapBufferARB
;
648 exec
->UnmapBufferARB
= _mesa_UnmapBufferARB
;
654 /**********************************************************************/
655 /***** State update logic *****/
656 /**********************************************************************/
660 * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET
661 * in ctx->_TriangleCaps if needed.
664 update_polygon( GLcontext
*ctx
)
666 ctx
->_TriangleCaps
&= ~(DD_TRI_CULL_FRONT_BACK
| DD_TRI_OFFSET
);
668 if (ctx
->Polygon
.CullFlag
&& ctx
->Polygon
.CullFaceMode
== GL_FRONT_AND_BACK
)
669 ctx
->_TriangleCaps
|= DD_TRI_CULL_FRONT_BACK
;
671 /* Any Polygon offsets enabled? */
672 if (ctx
->Polygon
.OffsetPoint
||
673 ctx
->Polygon
.OffsetLine
||
674 ctx
->Polygon
.OffsetFill
) {
675 ctx
->_TriangleCaps
|= DD_TRI_OFFSET
;
680 calculate_model_project_matrix( GLcontext
*ctx
)
682 _math_matrix_mul_matrix( &ctx
->_ModelProjectMatrix
,
683 ctx
->ProjectionMatrixStack
.Top
,
684 ctx
->ModelviewMatrixStack
.Top
);
686 _math_matrix_analyse( &ctx
->_ModelProjectMatrix
);
690 update_modelview_scale( GLcontext
*ctx
)
692 ctx
->_ModelViewInvScale
= 1.0F
;
693 if (ctx
->ModelviewMatrixStack
.Top
->flags
& (MAT_FLAG_UNIFORM_SCALE
|
694 MAT_FLAG_GENERAL_SCALE
|
695 MAT_FLAG_GENERAL_3D
|
696 MAT_FLAG_GENERAL
) ) {
697 const GLfloat
*m
= ctx
->ModelviewMatrixStack
.Top
->inv
;
698 GLfloat f
= m
[2] * m
[2] + m
[6] * m
[6] + m
[10] * m
[10];
699 if (f
< 1e-12) f
= 1.0;
700 if (ctx
->_NeedEyeCoords
)
701 ctx
->_ModelViewInvScale
= 1.0F
/ SQRTF(f
);
703 ctx
->_ModelViewInvScale
= SQRTF(f
);
708 /* Bring uptodate any state that relies on _NeedEyeCoords.
711 update_tnl_spaces( GLcontext
*ctx
, GLuint oldneedeyecoords
)
713 /* Check if the truth-value interpretations of the bitfields have
716 if ((oldneedeyecoords
== 0) != (ctx
->_NeedEyeCoords
== 0)) {
717 /* Recalculate all state that depends on _NeedEyeCoords.
719 update_modelview_scale(ctx
);
720 _mesa_compute_light_positions( ctx
);
722 if (ctx
->Driver
.LightingSpaceChange
)
723 ctx
->Driver
.LightingSpaceChange( ctx
);
726 GLuint new_state
= ctx
->NewState
;
728 /* Recalculate that same state only if it has been invalidated
729 * by other statechanges.
731 if (new_state
& _NEW_MODELVIEW
)
732 update_modelview_scale(ctx
);
734 if (new_state
& (_NEW_LIGHT
|_NEW_MODELVIEW
))
735 _mesa_compute_light_positions( ctx
);
741 update_drawbuffer( GLcontext
*ctx
)
743 ctx
->DrawBuffer
->_Xmin
= 0;
744 ctx
->DrawBuffer
->_Ymin
= 0;
745 ctx
->DrawBuffer
->_Xmax
= ctx
->DrawBuffer
->Width
;
746 ctx
->DrawBuffer
->_Ymax
= ctx
->DrawBuffer
->Height
;
747 if (ctx
->Scissor
.Enabled
) {
748 if (ctx
->Scissor
.X
> ctx
->DrawBuffer
->_Xmin
) {
749 ctx
->DrawBuffer
->_Xmin
= ctx
->Scissor
.X
;
751 if (ctx
->Scissor
.Y
> ctx
->DrawBuffer
->_Ymin
) {
752 ctx
->DrawBuffer
->_Ymin
= ctx
->Scissor
.Y
;
754 if (ctx
->Scissor
.X
+ ctx
->Scissor
.Width
< ctx
->DrawBuffer
->_Xmax
) {
755 ctx
->DrawBuffer
->_Xmax
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
;
757 if (ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
< ctx
->DrawBuffer
->_Ymax
) {
758 ctx
->DrawBuffer
->_Ymax
= ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
;
764 /* NOTE: This routine references Tranform attribute values to compute
765 * userclip positions in clip space, but is only called on
766 * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values
767 * up to date across changes to the Transform attributes.
770 update_projection( GLcontext
*ctx
)
772 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
774 /* Recompute clip plane positions in clipspace. This is also done
775 * in _mesa_ClipPlane().
777 if (ctx
->Transform
.ClipPlanesEnabled
) {
779 for (p
= 0; p
< ctx
->Const
.MaxClipPlanes
; p
++) {
780 if (ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) {
781 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
782 ctx
->Transform
.EyeUserPlane
[p
],
783 ctx
->ProjectionMatrixStack
.Top
->inv
);
791 * Return a bitmask of IMAGE_*_BIT flags which to indicate which
792 * pixel transfer operations are enabled.
795 update_image_transfer_state(GLcontext
*ctx
)
799 if (ctx
->Pixel
.RedScale
!= 1.0F
|| ctx
->Pixel
.RedBias
!= 0.0F
||
800 ctx
->Pixel
.GreenScale
!= 1.0F
|| ctx
->Pixel
.GreenBias
!= 0.0F
||
801 ctx
->Pixel
.BlueScale
!= 1.0F
|| ctx
->Pixel
.BlueBias
!= 0.0F
||
802 ctx
->Pixel
.AlphaScale
!= 1.0F
|| ctx
->Pixel
.AlphaBias
!= 0.0F
)
803 mask
|= IMAGE_SCALE_BIAS_BIT
;
805 if (ctx
->Pixel
.IndexShift
|| ctx
->Pixel
.IndexOffset
)
806 mask
|= IMAGE_SHIFT_OFFSET_BIT
;
808 if (ctx
->Pixel
.MapColorFlag
)
809 mask
|= IMAGE_MAP_COLOR_BIT
;
811 if (ctx
->Pixel
.ColorTableEnabled
)
812 mask
|= IMAGE_COLOR_TABLE_BIT
;
814 if (ctx
->Pixel
.Convolution1DEnabled
||
815 ctx
->Pixel
.Convolution2DEnabled
||
816 ctx
->Pixel
.Separable2DEnabled
) {
817 mask
|= IMAGE_CONVOLUTION_BIT
;
818 if (ctx
->Pixel
.PostConvolutionScale
[0] != 1.0F
||
819 ctx
->Pixel
.PostConvolutionScale
[1] != 1.0F
||
820 ctx
->Pixel
.PostConvolutionScale
[2] != 1.0F
||
821 ctx
->Pixel
.PostConvolutionScale
[3] != 1.0F
||
822 ctx
->Pixel
.PostConvolutionBias
[0] != 0.0F
||
823 ctx
->Pixel
.PostConvolutionBias
[1] != 0.0F
||
824 ctx
->Pixel
.PostConvolutionBias
[2] != 0.0F
||
825 ctx
->Pixel
.PostConvolutionBias
[3] != 0.0F
) {
826 mask
|= IMAGE_POST_CONVOLUTION_SCALE_BIAS
;
830 if (ctx
->Pixel
.PostConvolutionColorTableEnabled
)
831 mask
|= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT
;
833 if (ctx
->ColorMatrixStack
.Top
->type
!= MATRIX_IDENTITY
||
834 ctx
->Pixel
.PostColorMatrixScale
[0] != 1.0F
||
835 ctx
->Pixel
.PostColorMatrixBias
[0] != 0.0F
||
836 ctx
->Pixel
.PostColorMatrixScale
[1] != 1.0F
||
837 ctx
->Pixel
.PostColorMatrixBias
[1] != 0.0F
||
838 ctx
->Pixel
.PostColorMatrixScale
[2] != 1.0F
||
839 ctx
->Pixel
.PostColorMatrixBias
[2] != 0.0F
||
840 ctx
->Pixel
.PostColorMatrixScale
[3] != 1.0F
||
841 ctx
->Pixel
.PostColorMatrixBias
[3] != 0.0F
)
842 mask
|= IMAGE_COLOR_MATRIX_BIT
;
844 if (ctx
->Pixel
.PostColorMatrixColorTableEnabled
)
845 mask
|= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT
;
847 if (ctx
->Pixel
.HistogramEnabled
)
848 mask
|= IMAGE_HISTOGRAM_BIT
;
850 if (ctx
->Pixel
.MinMaxEnabled
)
851 mask
|= IMAGE_MIN_MAX_BIT
;
853 ctx
->_ImageTransferState
= mask
;
859 /* Note: This routine refers to derived texture attribute values to
860 * compute the ENABLE_TEXMAT flags, but is only called on
861 * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT
862 * flags are updated by _mesa_update_textures(), below.
864 * If both TEXTURE and TEXTURE_MATRIX change at once, these values
865 * will be computed twice.
868 update_texture_matrices( GLcontext
*ctx
)
872 ctx
->Texture
._TexMatEnabled
= 0;
874 for (i
=0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
875 if (ctx
->TextureMatrixStack
[i
].Top
->flags
& MAT_DIRTY
) {
876 _math_matrix_analyse( ctx
->TextureMatrixStack
[i
].Top
);
878 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
&&
879 ctx
->TextureMatrixStack
[i
].Top
->type
!= MATRIX_IDENTITY
)
880 ctx
->Texture
._TexMatEnabled
|= ENABLE_TEXMAT(i
);
882 if (ctx
->Driver
.TextureMatrix
)
883 ctx
->Driver
.TextureMatrix( ctx
, i
, ctx
->TextureMatrixStack
[i
].Top
);
889 /* Note: This routine refers to derived texture matrix values to
890 * compute the ENABLE_TEXMAT flags, but is only called on
891 * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT
892 * flags are updated by _mesa_update_texture_matrices, above.
894 * If both TEXTURE and TEXTURE_MATRIX change at once, these values
895 * will be computed twice.
898 update_texture_state( GLcontext
*ctx
)
902 ctx
->Texture
._EnabledUnits
= 0;
903 ctx
->Texture
._GenFlags
= 0;
904 ctx
->_NeedNormals
&= ~NEED_NORMALS_TEXGEN
;
905 ctx
->_NeedEyeCoords
&= ~NEED_EYE_TEXGEN
;
906 ctx
->Texture
._TexMatEnabled
= 0;
907 ctx
->Texture
._TexGenEnabled
= 0;
909 /* Update texture unit state.
911 for (unit
= 0; unit
< ctx
->Const
.MaxTextureUnits
; unit
++) {
912 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
915 texUnit
->_ReallyEnabled
= 0;
916 texUnit
->_GenFlags
= 0;
918 /* Get the bitmask of texture enables */
919 if (ctx
->FragmentProgram
.Enabled
&& ctx
->FragmentProgram
.Current
) {
920 enableBits
= ctx
->FragmentProgram
.Current
->TexturesUsed
[unit
];
923 if (!texUnit
->Enabled
)
925 enableBits
= texUnit
->Enabled
;
928 /* Look for the highest-priority texture target that's enabled and
929 * complete. That's the one we'll use for texturing. If we're using
930 * a fragment program we're guaranteed that bitcount(enabledBits) <= 1.
932 if (enableBits
& TEXTURE_CUBE_BIT
) {
933 struct gl_texture_object
*texObj
= texUnit
->CurrentCubeMap
;
934 if (!texObj
->Complete
) {
935 _mesa_test_texobj_completeness(ctx
, texObj
);
937 if (texObj
->Complete
) {
938 texUnit
->_ReallyEnabled
= TEXTURE_CUBE_BIT
;
939 texUnit
->_Current
= texObj
;
943 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_3D_BIT
)) {
944 struct gl_texture_object
*texObj
= texUnit
->Current3D
;
945 if (!texObj
->Complete
) {
946 _mesa_test_texobj_completeness(ctx
, texObj
);
948 if (texObj
->Complete
) {
949 texUnit
->_ReallyEnabled
= TEXTURE_3D_BIT
;
950 texUnit
->_Current
= texObj
;
954 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_RECT_BIT
)) {
955 struct gl_texture_object
*texObj
= texUnit
->CurrentRect
;
956 if (!texObj
->Complete
) {
957 _mesa_test_texobj_completeness(ctx
, texObj
);
959 if (texObj
->Complete
) {
960 texUnit
->_ReallyEnabled
= TEXTURE_RECT_BIT
;
961 texUnit
->_Current
= texObj
;
965 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_2D_BIT
)) {
966 struct gl_texture_object
*texObj
= texUnit
->Current2D
;
967 if (!texObj
->Complete
) {
968 _mesa_test_texobj_completeness(ctx
, texObj
);
970 if (texObj
->Complete
) {
971 texUnit
->_ReallyEnabled
= TEXTURE_2D_BIT
;
972 texUnit
->_Current
= texObj
;
976 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_1D_BIT
)) {
977 struct gl_texture_object
*texObj
= texUnit
->Current1D
;
978 if (!texObj
->Complete
) {
979 _mesa_test_texobj_completeness(ctx
, texObj
);
981 if (texObj
->Complete
) {
982 texUnit
->_ReallyEnabled
= TEXTURE_1D_BIT
;
983 texUnit
->_Current
= texObj
;
987 if (!texUnit
->_ReallyEnabled
) {
988 texUnit
->_Current
= NULL
;
992 if (texUnit
->_ReallyEnabled
)
993 ctx
->Texture
._EnabledUnits
|= (1 << unit
);
995 if (texUnit
->TexGenEnabled
) {
996 if (texUnit
->TexGenEnabled
& S_BIT
) {
997 texUnit
->_GenFlags
|= texUnit
->_GenBitS
;
999 if (texUnit
->TexGenEnabled
& T_BIT
) {
1000 texUnit
->_GenFlags
|= texUnit
->_GenBitT
;
1002 if (texUnit
->TexGenEnabled
& Q_BIT
) {
1003 texUnit
->_GenFlags
|= texUnit
->_GenBitQ
;
1005 if (texUnit
->TexGenEnabled
& R_BIT
) {
1006 texUnit
->_GenFlags
|= texUnit
->_GenBitR
;
1009 ctx
->Texture
._TexGenEnabled
|= ENABLE_TEXGEN(unit
);
1010 ctx
->Texture
._GenFlags
|= texUnit
->_GenFlags
;
1013 if (ctx
->TextureMatrixStack
[unit
].Top
->type
!= MATRIX_IDENTITY
)
1014 ctx
->Texture
._TexMatEnabled
|= ENABLE_TEXMAT(unit
);
1017 if (ctx
->Texture
._GenFlags
& TEXGEN_NEED_NORMALS
) {
1018 ctx
->_NeedNormals
|= NEED_NORMALS_TEXGEN
;
1019 ctx
->_NeedEyeCoords
|= NEED_EYE_TEXGEN
;
1022 if (ctx
->Texture
._GenFlags
& TEXGEN_NEED_EYE_COORD
) {
1023 ctx
->_NeedEyeCoords
|= NEED_EYE_TEXGEN
;
1026 ctx
->Texture
._EnabledCoordUnits
= ctx
->Texture
._EnabledUnits
;
1027 /* Fragment programs may need texture coordinates but not the
1028 * corresponding texture images.
1030 if (ctx
->FragmentProgram
.Enabled
&& ctx
->FragmentProgram
.Current
) {
1031 ctx
->Texture
._EnabledCoordUnits
|=
1032 (ctx
->FragmentProgram
.Current
->InputsRead
>> FRAG_ATTRIB_TEX0
);
1038 * Update items which depend on vertex/fragment programs.
1041 update_program( GLcontext
*ctx
)
1043 if (ctx
->FragmentProgram
.Enabled
&& ctx
->FragmentProgram
.Current
) {
1044 if (ctx
->FragmentProgram
.Current
->InputsRead
& (1 << FRAG_ATTRIB_COL1
))
1045 ctx
->_TriangleCaps
|= DD_SEPARATE_SPECULAR
;
1051 * If ctx->NewState is non-zero then this function MUST be called before
1052 * rendering any primitive. Basically, function pointers and miscellaneous
1053 * flags are updated to reflect the current state of the state machine.
1055 * The above constraint is now maintained largely by the two Exec
1056 * dispatch tables, which trigger the appropriate flush on transition
1057 * between State and Geometry modes.
1059 * Special care is taken with the derived value _NeedEyeCoords. This
1060 * is a bitflag which is updated with information from a number of
1061 * attribute groups (MODELVIEW, LIGHT, TEXTURE). A lot of derived
1062 * state references this value, and must be treated with care to
1063 * ensure that updates are done correctly. All state dependent on
1064 * _NeedEyeCoords is calculated from within _mesa_update_tnl_spaces(),
1065 * and from nowhere else.
1067 void _mesa_update_state( GLcontext
*ctx
)
1069 const GLuint new_state
= ctx
->NewState
;
1070 const GLuint oldneedeyecoords
= ctx
->_NeedEyeCoords
;
1072 if (MESA_VERBOSE
& VERBOSE_STATE
)
1073 _mesa_print_state("_mesa_update_state", new_state
);
1075 if (new_state
& _NEW_MODELVIEW
)
1076 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1078 if (new_state
& _NEW_PROJECTION
)
1079 update_projection( ctx
);
1081 if (new_state
& _NEW_TEXTURE_MATRIX
)
1082 update_texture_matrices( ctx
);
1084 if (new_state
& _NEW_COLOR_MATRIX
)
1085 _math_matrix_analyse( ctx
->ColorMatrixStack
.Top
);
1087 /* References ColorMatrix.type (derived above).
1089 if (new_state
& _IMAGE_NEW_TRANSFER_STATE
)
1090 update_image_transfer_state(ctx
);
1092 /* Contributes to NeedEyeCoords, NeedNormals.
1094 if (new_state
& _NEW_TEXTURE
)
1095 update_texture_state( ctx
);
1097 if (new_state
& (_NEW_BUFFERS
|_NEW_SCISSOR
))
1098 update_drawbuffer( ctx
);
1100 if (new_state
& _NEW_POLYGON
)
1101 update_polygon( ctx
);
1103 /* Contributes to NeedEyeCoords, NeedNormals.
1105 if (new_state
& _NEW_LIGHT
)
1106 _mesa_update_lighting( ctx
);
1108 /* We can light in object space if the modelview matrix preserves
1109 * lengths and relative angles.
1111 if (new_state
& (_NEW_MODELVIEW
|_NEW_LIGHT
)) {
1112 ctx
->_NeedEyeCoords
&= ~NEED_EYE_LIGHT_MODELVIEW
;
1113 if (ctx
->Light
.Enabled
&&
1114 !TEST_MAT_FLAGS( ctx
->ModelviewMatrixStack
.Top
, MAT_FLAGS_LENGTH_PRESERVING
))
1115 ctx
->_NeedEyeCoords
|= NEED_EYE_LIGHT_MODELVIEW
;
1118 if (new_state
& _NEW_PROGRAM
)
1119 update_program( ctx
);
1122 /* XXX this is a bit of a hack. We should be checking elsewhere if
1123 * vertex program mode is enabled. We set _NeedEyeCoords to zero to
1124 * ensure that the combined modelview/projection matrix is computed
1125 * in calculate_model_project_matrix().
1127 if (ctx
->VertexProgram
.Enabled
)
1128 ctx
->_NeedEyeCoords
= 0;
1129 /* KW: it's now always computed.
1133 /* Keep ModelviewProject uptodate always to allow tnl
1134 * implementations that go model->clip even when eye is required.
1136 if (new_state
& (_NEW_MODELVIEW
|_NEW_PROJECTION
))
1137 calculate_model_project_matrix(ctx
);
1139 /* ctx->_NeedEyeCoords is now uptodate.
1141 * If the truth value of this variable has changed, update for the
1142 * new lighting space and recompute the positions of lights and the
1145 * If the lighting space hasn't changed, may still need to recompute
1146 * light positions & normal transforms for other reasons.
1148 if (new_state
& (_NEW_MODELVIEW
|
1150 _MESA_NEW_NEED_EYE_COORDS
))
1151 update_tnl_spaces( ctx
, oldneedeyecoords
);
1154 * Here the driver sets up all the ctx->Driver function pointers
1155 * to it's specific, private functions, and performs any
1156 * internal state management necessary, including invalidating
1157 * state of active modules.
1159 * Set ctx->NewState to zero to avoid recursion if
1160 * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?)
1163 ctx
->Driver
.UpdateState(ctx
, new_state
);
1164 ctx
->Array
.NewState
= 0;
1166 /* At this point we can do some assertions to be sure the required
1167 * device driver function pointers are all initialized.
1169 ASSERT(ctx
->Driver
.GetString
);
1170 ASSERT(ctx
->Driver
.UpdateState
);
1171 ASSERT(ctx
->Driver
.Clear
);
1172 ASSERT(ctx
->Driver
.GetBufferSize
);
1173 if (ctx
->Visual
.accumRedBits
> 0) {
1174 ASSERT(ctx
->Driver
.Accum
);
1176 ASSERT(ctx
->Driver
.DrawPixels
);
1177 ASSERT(ctx
->Driver
.ReadPixels
);
1178 ASSERT(ctx
->Driver
.CopyPixels
);
1179 ASSERT(ctx
->Driver
.Bitmap
);
1180 ASSERT(ctx
->Driver
.ResizeBuffers
);
1181 ASSERT(ctx
->Driver
.TexImage1D
);
1182 ASSERT(ctx
->Driver
.TexImage2D
);
1183 ASSERT(ctx
->Driver
.TexImage3D
);
1184 ASSERT(ctx
->Driver
.TexSubImage1D
);
1185 ASSERT(ctx
->Driver
.TexSubImage2D
);
1186 ASSERT(ctx
->Driver
.TexSubImage3D
);
1187 ASSERT(ctx
->Driver
.CopyTexImage1D
);
1188 ASSERT(ctx
->Driver
.CopyTexImage2D
);
1189 ASSERT(ctx
->Driver
.CopyTexSubImage1D
);
1190 ASSERT(ctx
->Driver
.CopyTexSubImage2D
);
1191 ASSERT(ctx
->Driver
.CopyTexSubImage3D
);
1192 if (ctx
->Extensions
.ARB_texture_compression
) {
1193 #if 0 /* HW drivers need these, but not SW rasterizers */
1194 ASSERT(ctx
->Driver
.CompressedTexImage1D
);
1195 ASSERT(ctx
->Driver
.CompressedTexImage2D
);
1196 ASSERT(ctx
->Driver
.CompressedTexImage3D
);
1197 ASSERT(ctx
->Driver
.CompressedTexSubImage1D
);
1198 ASSERT(ctx
->Driver
.CompressedTexSubImage2D
);
1199 ASSERT(ctx
->Driver
.CompressedTexSubImage3D
);
1207 _mesa_allow_light_in_model( GLcontext
*ctx
, GLboolean flag
)
1210 ctx
->_NeedEyeCoords
&= ~NEED_EYE_DRIVER
;
1212 ctx
->_NeedEyeCoords
|= NEED_EYE_DRIVER
;
1214 ctx
->NewState
|= _NEW_POINT
; /* one of the bits from
1215 * _MESA_NEW_NEED_EYE_COORDS.