1 /* $Id: state.c,v 1.66 2001/05/29 15:23:49 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 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 * This file manages recalculation of derived values in the
40 #include "api_loopback.h"
59 #include "histogram.h"
82 #include "math/m_matrix.h"
83 #include "math/m_xform.h"
91 _mesa_problem(NULL
, "undefined function dispatch");
98 * Set all pointers in the given dispatch table to point to a
99 * generic no-op function.
102 _mesa_init_no_op_table(struct _glapi_table
*table
, GLuint tableSize
)
105 void **dispatch
= (void **) table
;
106 for (i
= 0; i
< tableSize
; i
++) {
107 dispatch
[i
] = (void *) generic_noop
;
114 * Initialize the given dispatch table with pointers to Mesa's
115 * immediate-mode commands.
117 * Pointers to begin/end object commands and a few others
118 * are provided via the vtxfmt interface elsewhere.
121 _mesa_init_exec_table(struct _glapi_table
*exec
, GLuint tableSize
)
123 /* first initialize all dispatch slots to no-op */
124 _mesa_init_no_op_table(exec
, tableSize
);
126 _mesa_loopback_init_api_table( exec
, GL_TRUE
);
128 /* load the dispatch slots we understand */
129 exec
->Accum
= _mesa_Accum
;
130 exec
->AlphaFunc
= _mesa_AlphaFunc
;
131 exec
->Bitmap
= _mesa_Bitmap
;
132 exec
->BlendFunc
= _mesa_BlendFunc
;
133 exec
->CallList
= _mesa_CallList
;
134 exec
->CallLists
= _mesa_CallLists
;
135 exec
->Clear
= _mesa_Clear
;
136 exec
->ClearAccum
= _mesa_ClearAccum
;
137 exec
->ClearColor
= _mesa_ClearColor
;
138 exec
->ClearDepth
= _mesa_ClearDepth
;
139 exec
->ClearIndex
= _mesa_ClearIndex
;
140 exec
->ClearStencil
= _mesa_ClearStencil
;
141 exec
->ClipPlane
= _mesa_ClipPlane
;
142 exec
->ColorMask
= _mesa_ColorMask
;
143 exec
->ColorMaterial
= _mesa_ColorMaterial
;
144 exec
->CopyPixels
= _mesa_CopyPixels
;
145 exec
->CullFace
= _mesa_CullFace
;
146 exec
->DeleteLists
= _mesa_DeleteLists
;
147 exec
->DepthFunc
= _mesa_DepthFunc
;
148 exec
->DepthMask
= _mesa_DepthMask
;
149 exec
->DepthRange
= _mesa_DepthRange
;
150 exec
->Disable
= _mesa_Disable
;
151 exec
->DrawBuffer
= _mesa_DrawBuffer
;
152 exec
->DrawPixels
= _mesa_DrawPixels
;
153 exec
->Enable
= _mesa_Enable
;
154 exec
->EndList
= _mesa_EndList
;
155 exec
->FeedbackBuffer
= _mesa_FeedbackBuffer
;
156 exec
->Finish
= _mesa_Finish
;
157 exec
->Flush
= _mesa_Flush
;
158 exec
->FogCoordPointerEXT
= _mesa_FogCoordPointerEXT
;
159 exec
->Fogf
= _mesa_Fogf
;
160 exec
->Fogfv
= _mesa_Fogfv
;
161 exec
->Fogi
= _mesa_Fogi
;
162 exec
->Fogiv
= _mesa_Fogiv
;
163 exec
->FrontFace
= _mesa_FrontFace
;
164 exec
->Frustum
= _mesa_Frustum
;
165 exec
->GenLists
= _mesa_GenLists
;
166 exec
->GetBooleanv
= _mesa_GetBooleanv
;
167 exec
->GetClipPlane
= _mesa_GetClipPlane
;
168 exec
->GetDoublev
= _mesa_GetDoublev
;
169 exec
->GetError
= _mesa_GetError
;
170 exec
->GetFloatv
= _mesa_GetFloatv
;
171 exec
->GetIntegerv
= _mesa_GetIntegerv
;
172 exec
->GetLightfv
= _mesa_GetLightfv
;
173 exec
->GetLightiv
= _mesa_GetLightiv
;
174 exec
->GetMapdv
= _mesa_GetMapdv
;
175 exec
->GetMapfv
= _mesa_GetMapfv
;
176 exec
->GetMapiv
= _mesa_GetMapiv
;
177 exec
->GetMaterialfv
= _mesa_GetMaterialfv
;
178 exec
->GetMaterialiv
= _mesa_GetMaterialiv
;
179 exec
->GetPixelMapfv
= _mesa_GetPixelMapfv
;
180 exec
->GetPixelMapuiv
= _mesa_GetPixelMapuiv
;
181 exec
->GetPixelMapusv
= _mesa_GetPixelMapusv
;
182 exec
->GetPolygonStipple
= _mesa_GetPolygonStipple
;
183 exec
->GetString
= _mesa_GetString
;
184 exec
->GetTexEnvfv
= _mesa_GetTexEnvfv
;
185 exec
->GetTexEnviv
= _mesa_GetTexEnviv
;
186 exec
->GetTexGendv
= _mesa_GetTexGendv
;
187 exec
->GetTexGenfv
= _mesa_GetTexGenfv
;
188 exec
->GetTexGeniv
= _mesa_GetTexGeniv
;
189 exec
->GetTexImage
= _mesa_GetTexImage
;
190 exec
->GetTexLevelParameterfv
= _mesa_GetTexLevelParameterfv
;
191 exec
->GetTexLevelParameteriv
= _mesa_GetTexLevelParameteriv
;
192 exec
->GetTexParameterfv
= _mesa_GetTexParameterfv
;
193 exec
->GetTexParameteriv
= _mesa_GetTexParameteriv
;
194 exec
->Hint
= _mesa_Hint
;
195 exec
->IndexMask
= _mesa_IndexMask
;
196 exec
->InitNames
= _mesa_InitNames
;
197 exec
->IsEnabled
= _mesa_IsEnabled
;
198 exec
->IsList
= _mesa_IsList
;
199 exec
->LightModelf
= _mesa_LightModelf
;
200 exec
->LightModelfv
= _mesa_LightModelfv
;
201 exec
->LightModeli
= _mesa_LightModeli
;
202 exec
->LightModeliv
= _mesa_LightModeliv
;
203 exec
->Lightf
= _mesa_Lightf
;
204 exec
->Lightfv
= _mesa_Lightfv
;
205 exec
->Lighti
= _mesa_Lighti
;
206 exec
->Lightiv
= _mesa_Lightiv
;
207 exec
->LineStipple
= _mesa_LineStipple
;
208 exec
->LineWidth
= _mesa_LineWidth
;
209 exec
->ListBase
= _mesa_ListBase
;
210 exec
->LoadIdentity
= _mesa_LoadIdentity
;
211 exec
->LoadMatrixd
= _mesa_LoadMatrixd
;
212 exec
->LoadMatrixf
= _mesa_LoadMatrixf
;
213 exec
->LoadName
= _mesa_LoadName
;
214 exec
->LogicOp
= _mesa_LogicOp
;
215 exec
->Map1d
= _mesa_Map1d
;
216 exec
->Map1f
= _mesa_Map1f
;
217 exec
->Map2d
= _mesa_Map2d
;
218 exec
->Map2f
= _mesa_Map2f
;
219 exec
->MapGrid1d
= _mesa_MapGrid1d
;
220 exec
->MapGrid1f
= _mesa_MapGrid1f
;
221 exec
->MapGrid2d
= _mesa_MapGrid2d
;
222 exec
->MapGrid2f
= _mesa_MapGrid2f
;
223 exec
->MatrixMode
= _mesa_MatrixMode
;
224 exec
->MultMatrixd
= _mesa_MultMatrixd
;
225 exec
->MultMatrixf
= _mesa_MultMatrixf
;
226 exec
->NewList
= _mesa_NewList
;
227 exec
->Ortho
= _mesa_Ortho
;
228 exec
->PassThrough
= _mesa_PassThrough
;
229 exec
->PixelMapfv
= _mesa_PixelMapfv
;
230 exec
->PixelMapuiv
= _mesa_PixelMapuiv
;
231 exec
->PixelMapusv
= _mesa_PixelMapusv
;
232 exec
->PixelStoref
= _mesa_PixelStoref
;
233 exec
->PixelStorei
= _mesa_PixelStorei
;
234 exec
->PixelTransferf
= _mesa_PixelTransferf
;
235 exec
->PixelTransferi
= _mesa_PixelTransferi
;
236 exec
->PixelZoom
= _mesa_PixelZoom
;
237 exec
->PointSize
= _mesa_PointSize
;
238 exec
->PolygonMode
= _mesa_PolygonMode
;
239 exec
->PolygonOffset
= _mesa_PolygonOffset
;
240 exec
->PolygonStipple
= _mesa_PolygonStipple
;
241 exec
->PopAttrib
= _mesa_PopAttrib
;
242 exec
->PopMatrix
= _mesa_PopMatrix
;
243 exec
->PopName
= _mesa_PopName
;
244 exec
->PushAttrib
= _mesa_PushAttrib
;
245 exec
->PushMatrix
= _mesa_PushMatrix
;
246 exec
->PushName
= _mesa_PushName
;
247 exec
->RasterPos2d
= _mesa_RasterPos2d
;
248 exec
->RasterPos2dv
= _mesa_RasterPos2dv
;
249 exec
->RasterPos2f
= _mesa_RasterPos2f
;
250 exec
->RasterPos2fv
= _mesa_RasterPos2fv
;
251 exec
->RasterPos2i
= _mesa_RasterPos2i
;
252 exec
->RasterPos2iv
= _mesa_RasterPos2iv
;
253 exec
->RasterPos2s
= _mesa_RasterPos2s
;
254 exec
->RasterPos2sv
= _mesa_RasterPos2sv
;
255 exec
->RasterPos3d
= _mesa_RasterPos3d
;
256 exec
->RasterPos3dv
= _mesa_RasterPos3dv
;
257 exec
->RasterPos3f
= _mesa_RasterPos3f
;
258 exec
->RasterPos3fv
= _mesa_RasterPos3fv
;
259 exec
->RasterPos3i
= _mesa_RasterPos3i
;
260 exec
->RasterPos3iv
= _mesa_RasterPos3iv
;
261 exec
->RasterPos3s
= _mesa_RasterPos3s
;
262 exec
->RasterPos3sv
= _mesa_RasterPos3sv
;
263 exec
->RasterPos4d
= _mesa_RasterPos4d
;
264 exec
->RasterPos4dv
= _mesa_RasterPos4dv
;
265 exec
->RasterPos4f
= _mesa_RasterPos4f
;
266 exec
->RasterPos4fv
= _mesa_RasterPos4fv
;
267 exec
->RasterPos4i
= _mesa_RasterPos4i
;
268 exec
->RasterPos4iv
= _mesa_RasterPos4iv
;
269 exec
->RasterPos4s
= _mesa_RasterPos4s
;
270 exec
->RasterPos4sv
= _mesa_RasterPos4sv
;
271 exec
->ReadBuffer
= _mesa_ReadBuffer
;
272 exec
->ReadPixels
= _mesa_ReadPixels
;
273 exec
->RenderMode
= _mesa_RenderMode
;
274 exec
->Rotated
= _mesa_Rotated
;
275 exec
->Rotatef
= _mesa_Rotatef
;
276 exec
->Scaled
= _mesa_Scaled
;
277 exec
->Scalef
= _mesa_Scalef
;
278 exec
->Scissor
= _mesa_Scissor
;
279 exec
->SecondaryColorPointerEXT
= _mesa_SecondaryColorPointerEXT
;
280 exec
->SelectBuffer
= _mesa_SelectBuffer
;
281 exec
->ShadeModel
= _mesa_ShadeModel
;
282 exec
->StencilFunc
= _mesa_StencilFunc
;
283 exec
->StencilMask
= _mesa_StencilMask
;
284 exec
->StencilOp
= _mesa_StencilOp
;
285 exec
->TexEnvf
= _mesa_TexEnvf
;
286 exec
->TexEnvfv
= _mesa_TexEnvfv
;
287 exec
->TexEnvi
= _mesa_TexEnvi
;
288 exec
->TexEnviv
= _mesa_TexEnviv
;
289 exec
->TexGend
= _mesa_TexGend
;
290 exec
->TexGendv
= _mesa_TexGendv
;
291 exec
->TexGenf
= _mesa_TexGenf
;
292 exec
->TexGenfv
= _mesa_TexGenfv
;
293 exec
->TexGeni
= _mesa_TexGeni
;
294 exec
->TexGeniv
= _mesa_TexGeniv
;
295 exec
->TexImage1D
= _mesa_TexImage1D
;
296 exec
->TexImage2D
= _mesa_TexImage2D
;
297 exec
->TexParameterf
= _mesa_TexParameterf
;
298 exec
->TexParameterfv
= _mesa_TexParameterfv
;
299 exec
->TexParameteri
= _mesa_TexParameteri
;
300 exec
->TexParameteriv
= _mesa_TexParameteriv
;
301 exec
->Translated
= _mesa_Translated
;
302 exec
->Translatef
= _mesa_Translatef
;
303 exec
->Viewport
= _mesa_Viewport
;
306 exec
->AreTexturesResident
= _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
->GetPointerv
= _mesa_GetPointerv
;
319 exec
->IndexPointer
= _mesa_IndexPointer
;
320 exec
->InterleavedArrays
= _mesa_InterleavedArrays
;
321 exec
->IsTexture
= _mesa_IsTexture
;
322 exec
->NormalPointer
= _mesa_NormalPointer
;
323 exec
->PopClientAttrib
= _mesa_PopClientAttrib
;
324 exec
->PrioritizeTextures
= _mesa_PrioritizeTextures
;
325 exec
->PushClientAttrib
= _mesa_PushClientAttrib
;
326 exec
->TexCoordPointer
= _mesa_TexCoordPointer
;
327 exec
->TexSubImage1D
= _mesa_TexSubImage1D
;
328 exec
->TexSubImage2D
= _mesa_TexSubImage2D
;
329 exec
->VertexPointer
= _mesa_VertexPointer
;
332 exec
->CopyTexSubImage3D
= _mesa_CopyTexSubImage3D
;
333 exec
->TexImage3D
= _mesa_TexImage3D
;
334 exec
->TexSubImage3D
= _mesa_TexSubImage3D
;
336 /* OpenGL 1.2 GL_ARB_imaging */
337 exec
->BlendColor
= _mesa_BlendColor
;
338 exec
->BlendEquation
= _mesa_BlendEquation
;
339 exec
->ColorSubTable
= _mesa_ColorSubTable
;
340 exec
->ColorTable
= _mesa_ColorTable
;
341 exec
->ColorTableParameterfv
= _mesa_ColorTableParameterfv
;
342 exec
->ColorTableParameteriv
= _mesa_ColorTableParameteriv
;
343 exec
->ConvolutionFilter1D
= _mesa_ConvolutionFilter1D
;
344 exec
->ConvolutionFilter2D
= _mesa_ConvolutionFilter2D
;
345 exec
->ConvolutionParameterf
= _mesa_ConvolutionParameterf
;
346 exec
->ConvolutionParameterfv
= _mesa_ConvolutionParameterfv
;
347 exec
->ConvolutionParameteri
= _mesa_ConvolutionParameteri
;
348 exec
->ConvolutionParameteriv
= _mesa_ConvolutionParameteriv
;
349 exec
->CopyColorSubTable
= _mesa_CopyColorSubTable
;
350 exec
->CopyColorTable
= _mesa_CopyColorTable
;
351 exec
->CopyConvolutionFilter1D
= _mesa_CopyConvolutionFilter1D
;
352 exec
->CopyConvolutionFilter2D
= _mesa_CopyConvolutionFilter2D
;
353 exec
->GetColorTable
= _mesa_GetColorTable
;
354 exec
->GetColorTableParameterfv
= _mesa_GetColorTableParameterfv
;
355 exec
->GetColorTableParameteriv
= _mesa_GetColorTableParameteriv
;
356 exec
->GetConvolutionFilter
= _mesa_GetConvolutionFilter
;
357 exec
->GetConvolutionParameterfv
= _mesa_GetConvolutionParameterfv
;
358 exec
->GetConvolutionParameteriv
= _mesa_GetConvolutionParameteriv
;
359 exec
->GetHistogram
= _mesa_GetHistogram
;
360 exec
->GetHistogramParameterfv
= _mesa_GetHistogramParameterfv
;
361 exec
->GetHistogramParameteriv
= _mesa_GetHistogramParameteriv
;
362 exec
->GetMinmax
= _mesa_GetMinmax
;
363 exec
->GetMinmaxParameterfv
= _mesa_GetMinmaxParameterfv
;
364 exec
->GetMinmaxParameteriv
= _mesa_GetMinmaxParameteriv
;
365 exec
->GetSeparableFilter
= _mesa_GetSeparableFilter
;
366 exec
->Histogram
= _mesa_Histogram
;
367 exec
->Minmax
= _mesa_Minmax
;
368 exec
->ResetHistogram
= _mesa_ResetHistogram
;
369 exec
->ResetMinmax
= _mesa_ResetMinmax
;
370 exec
->SeparableFilter2D
= _mesa_SeparableFilter2D
;
372 /* 2. GL_EXT_blend_color */
374 exec
->BlendColorEXT
= _mesa_BlendColorEXT
;
377 /* 3. GL_EXT_polygon_offset */
378 exec
->PolygonOffsetEXT
= _mesa_PolygonOffsetEXT
;
380 /* 6. GL_EXT_texture3d */
382 exec
->CopyTexSubImage3DEXT
= _mesa_CopyTexSubImage3D
;
383 exec
->TexImage3DEXT
= _mesa_TexImage3DEXT
;
384 exec
->TexSubImage3DEXT
= _mesa_TexSubImage3D
;
387 /* 11. GL_EXT_histogram */
388 exec
->GetHistogramEXT
= _mesa_GetHistogram
;
389 exec
->GetHistogramParameterfvEXT
= _mesa_GetHistogramParameterfv
;
390 exec
->GetHistogramParameterivEXT
= _mesa_GetHistogramParameteriv
;
391 exec
->GetMinmaxEXT
= _mesa_GetMinmax
;
392 exec
->GetMinmaxParameterfvEXT
= _mesa_GetMinmaxParameterfv
;
393 exec
->GetMinmaxParameterivEXT
= _mesa_GetMinmaxParameteriv
;
395 /* ?. GL_SGIX_pixel_texture */
396 exec
->PixelTexGenSGIX
= _mesa_PixelTexGenSGIX
;
398 /* 15. GL_SGIS_pixel_texture */
399 exec
->PixelTexGenParameteriSGIS
= _mesa_PixelTexGenParameteriSGIS
;
400 exec
->PixelTexGenParameterivSGIS
= _mesa_PixelTexGenParameterivSGIS
;
401 exec
->PixelTexGenParameterfSGIS
= _mesa_PixelTexGenParameterfSGIS
;
402 exec
->PixelTexGenParameterfvSGIS
= _mesa_PixelTexGenParameterfvSGIS
;
403 exec
->GetPixelTexGenParameterivSGIS
= _mesa_GetPixelTexGenParameterivSGIS
;
404 exec
->GetPixelTexGenParameterfvSGIS
= _mesa_GetPixelTexGenParameterfvSGIS
;
406 /* 30. GL_EXT_vertex_array */
407 exec
->ColorPointerEXT
= _mesa_ColorPointerEXT
;
408 exec
->EdgeFlagPointerEXT
= _mesa_EdgeFlagPointerEXT
;
409 exec
->IndexPointerEXT
= _mesa_IndexPointerEXT
;
410 exec
->NormalPointerEXT
= _mesa_NormalPointerEXT
;
411 exec
->TexCoordPointerEXT
= _mesa_TexCoordPointerEXT
;
412 exec
->VertexPointerEXT
= _mesa_VertexPointerEXT
;
414 /* 37. GL_EXT_blend_minmax */
416 exec
->BlendEquationEXT
= _mesa_BlendEquationEXT
;
419 /* 54. GL_EXT_point_parameters */
420 exec
->PointParameterfEXT
= _mesa_PointParameterfEXT
;
421 exec
->PointParameterfvEXT
= _mesa_PointParameterfvEXT
;
423 /* 78. GL_EXT_paletted_texture */
425 exec
->ColorTableEXT
= _mesa_ColorTableEXT
;
426 exec
->ColorSubTableEXT
= _mesa_ColorSubTableEXT
;
428 exec
->GetColorTableEXT
= _mesa_GetColorTable
;
429 exec
->GetColorTableParameterfvEXT
= _mesa_GetColorTableParameterfv
;
430 exec
->GetColorTableParameterivEXT
= _mesa_GetColorTableParameteriv
;
432 /* 97. GL_EXT_compiled_vertex_array */
433 exec
->LockArraysEXT
= _mesa_LockArraysEXT
;
434 exec
->UnlockArraysEXT
= _mesa_UnlockArraysEXT
;
436 /* 173. GL_INGR_blend_func_separate */
437 exec
->BlendFuncSeparateEXT
= _mesa_BlendFuncSeparateEXT
;
439 /* 196. GL_MESA_resize_buffers */
440 exec
->ResizeBuffersMESA
= _mesa_ResizeBuffersMESA
;
442 /* 197. GL_MESA_window_pos */
443 exec
->WindowPos2dMESA
= _mesa_WindowPos2dMESA
;
444 exec
->WindowPos2dvMESA
= _mesa_WindowPos2dvMESA
;
445 exec
->WindowPos2fMESA
= _mesa_WindowPos2fMESA
;
446 exec
->WindowPos2fvMESA
= _mesa_WindowPos2fvMESA
;
447 exec
->WindowPos2iMESA
= _mesa_WindowPos2iMESA
;
448 exec
->WindowPos2ivMESA
= _mesa_WindowPos2ivMESA
;
449 exec
->WindowPos2sMESA
= _mesa_WindowPos2sMESA
;
450 exec
->WindowPos2svMESA
= _mesa_WindowPos2svMESA
;
451 exec
->WindowPos3dMESA
= _mesa_WindowPos3dMESA
;
452 exec
->WindowPos3dvMESA
= _mesa_WindowPos3dvMESA
;
453 exec
->WindowPos3fMESA
= _mesa_WindowPos3fMESA
;
454 exec
->WindowPos3fvMESA
= _mesa_WindowPos3fvMESA
;
455 exec
->WindowPos3iMESA
= _mesa_WindowPos3iMESA
;
456 exec
->WindowPos3ivMESA
= _mesa_WindowPos3ivMESA
;
457 exec
->WindowPos3sMESA
= _mesa_WindowPos3sMESA
;
458 exec
->WindowPos3svMESA
= _mesa_WindowPos3svMESA
;
459 exec
->WindowPos4dMESA
= _mesa_WindowPos4dMESA
;
460 exec
->WindowPos4dvMESA
= _mesa_WindowPos4dvMESA
;
461 exec
->WindowPos4fMESA
= _mesa_WindowPos4fMESA
;
462 exec
->WindowPos4fvMESA
= _mesa_WindowPos4fvMESA
;
463 exec
->WindowPos4iMESA
= _mesa_WindowPos4iMESA
;
464 exec
->WindowPos4ivMESA
= _mesa_WindowPos4ivMESA
;
465 exec
->WindowPos4sMESA
= _mesa_WindowPos4sMESA
;
466 exec
->WindowPos4svMESA
= _mesa_WindowPos4svMESA
;
468 /* ARB 1. GL_ARB_multitexture */
469 exec
->ActiveTextureARB
= _mesa_ActiveTextureARB
;
470 exec
->ClientActiveTextureARB
= _mesa_ClientActiveTextureARB
;
472 /* ARB 3. GL_ARB_transpose_matrix */
473 exec
->LoadTransposeMatrixdARB
= _mesa_LoadTransposeMatrixdARB
;
474 exec
->LoadTransposeMatrixfARB
= _mesa_LoadTransposeMatrixfARB
;
475 exec
->MultTransposeMatrixdARB
= _mesa_MultTransposeMatrixdARB
;
476 exec
->MultTransposeMatrixfARB
= _mesa_MultTransposeMatrixfARB
;
478 /* ARB 5. GL_ARB_multisample */
479 exec
->SampleCoverageARB
= _mesa_SampleCoverageARB
;
481 /* ARB 12. GL_ARB_texture_compression */
482 exec
->CompressedTexImage3DARB
= _mesa_CompressedTexImage3DARB
;
483 exec
->CompressedTexImage2DARB
= _mesa_CompressedTexImage2DARB
;
484 exec
->CompressedTexImage1DARB
= _mesa_CompressedTexImage1DARB
;
485 exec
->CompressedTexSubImage3DARB
= _mesa_CompressedTexSubImage3DARB
;
486 exec
->CompressedTexSubImage2DARB
= _mesa_CompressedTexSubImage2DARB
;
487 exec
->CompressedTexSubImage1DARB
= _mesa_CompressedTexSubImage1DARB
;
488 exec
->GetCompressedTexImageARB
= _mesa_GetCompressedTexImageARB
;
494 /**********************************************************************/
495 /***** State update logic *****/
496 /**********************************************************************/
500 update_polygon( GLcontext
*ctx
)
502 ctx
->_TriangleCaps
&= ~(DD_TRI_CULL_FRONT_BACK
| DD_TRI_OFFSET
);
504 if (ctx
->Polygon
.CullFlag
&& ctx
->Polygon
.CullFaceMode
== GL_FRONT_AND_BACK
)
505 ctx
->_TriangleCaps
|= DD_TRI_CULL_FRONT_BACK
;
507 /* Any Polygon offsets enabled? */
508 ctx
->Polygon
._OffsetAny
= GL_FALSE
;
509 ctx
->_TriangleCaps
&= ~DD_TRI_OFFSET
;
511 if (ctx
->Polygon
.OffsetPoint
||
512 ctx
->Polygon
.OffsetLine
||
513 ctx
->Polygon
.OffsetFill
) {
514 ctx
->_TriangleCaps
|= DD_TRI_OFFSET
;
515 ctx
->Polygon
._OffsetAny
= GL_TRUE
;
520 calculate_model_project_matrix( GLcontext
*ctx
)
522 if (!ctx
->_NeedEyeCoords
) {
523 _math_matrix_mul_matrix( &ctx
->_ModelProjectMatrix
,
524 &ctx
->ProjectionMatrix
,
527 _math_matrix_analyse( &ctx
->_ModelProjectMatrix
);
532 update_modelview_scale( GLcontext
*ctx
)
534 ctx
->_ModelViewInvScale
= 1.0F
;
535 if (ctx
->ModelView
.flags
& (MAT_FLAG_UNIFORM_SCALE
|
536 MAT_FLAG_GENERAL_SCALE
|
537 MAT_FLAG_GENERAL_3D
|
538 MAT_FLAG_GENERAL
) ) {
539 const GLfloat
*m
= ctx
->ModelView
.inv
;
540 GLfloat f
= m
[2] * m
[2] + m
[6] * m
[6] + m
[10] * m
[10];
541 if (f
< 1e-12) f
= 1.0;
542 if (ctx
->_NeedEyeCoords
)
543 ctx
->_ModelViewInvScale
= 1.0/GL_SQRT(f
);
545 ctx
->_ModelViewInvScale
= GL_SQRT(f
);
550 /* Bring uptodate any state that relies on _NeedEyeCoords.
553 update_tnl_spaces( GLcontext
*ctx
, GLuint oldneedeyecoords
)
555 /* Check if the truth-value interpretations of the bitfields have
558 if ((oldneedeyecoords
== 0) != (ctx
->_NeedEyeCoords
== 0)) {
559 /* Recalculate all state that depends on _NeedEyeCoords.
561 update_modelview_scale(ctx
);
562 calculate_model_project_matrix(ctx
);
563 _mesa_compute_light_positions( ctx
);
565 if (ctx
->Driver
.LightingSpaceChange
)
566 ctx
->Driver
.LightingSpaceChange( ctx
);
569 GLuint new_state
= ctx
->NewState
;
571 /* Recalculate that same state only if it has been invalidated
572 * by other statechanges.
574 if (new_state
& _NEW_MODELVIEW
)
575 update_modelview_scale(ctx
);
577 if (new_state
& (_NEW_MODELVIEW
|_NEW_PROJECTION
))
578 calculate_model_project_matrix(ctx
);
580 if (new_state
& (_NEW_LIGHT
|_NEW_MODELVIEW
))
581 _mesa_compute_light_positions( ctx
);
587 update_drawbuffer( GLcontext
*ctx
)
589 ctx
->DrawBuffer
->_Xmin
= 0;
590 ctx
->DrawBuffer
->_Ymin
= 0;
591 ctx
->DrawBuffer
->_Xmax
= ctx
->DrawBuffer
->Width
;
592 ctx
->DrawBuffer
->_Ymax
= ctx
->DrawBuffer
->Height
;
593 if (ctx
->Scissor
.Enabled
) {
594 if (ctx
->Scissor
.X
> ctx
->DrawBuffer
->_Xmin
) {
595 ctx
->DrawBuffer
->_Xmin
= ctx
->Scissor
.X
;
597 if (ctx
->Scissor
.Y
> ctx
->DrawBuffer
->_Ymin
) {
598 ctx
->DrawBuffer
->_Ymin
= ctx
->Scissor
.Y
;
600 if (ctx
->Scissor
.X
+ ctx
->Scissor
.Width
< ctx
->DrawBuffer
->_Xmax
) {
601 ctx
->DrawBuffer
->_Xmax
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
;
603 if (ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
< ctx
->DrawBuffer
->_Ymax
) {
604 ctx
->DrawBuffer
->_Ymax
= ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
;
610 /* NOTE: This routine references Tranform attribute values to compute
611 * userclip positions in clip space, but is only called on
612 * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values
613 * uptodate across changes to the Transform attributes.
616 update_projection( GLcontext
*ctx
)
618 _math_matrix_analyse( &ctx
->ProjectionMatrix
);
620 /* Recompute clip plane positions in clipspace. This is also done
621 * in _mesa_ClipPlane().
623 if (ctx
->Transform
._AnyClip
) {
625 for (p
= 0; p
< ctx
->Const
.MaxClipPlanes
; p
++) {
626 if (ctx
->Transform
.ClipEnabled
[p
]) {
627 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
628 ctx
->Transform
.EyeUserPlane
[p
],
629 ctx
->ProjectionMatrix
.inv
);
637 * Return a bitmask of IMAGE_*_BIT flags which to indicate which
638 * pixel transfer operations are enabled.
641 update_image_transfer_state(GLcontext
*ctx
)
645 if (ctx
->Pixel
.RedScale
!= 1.0F
|| ctx
->Pixel
.RedBias
!= 0.0F
||
646 ctx
->Pixel
.GreenScale
!= 1.0F
|| ctx
->Pixel
.GreenBias
!= 0.0F
||
647 ctx
->Pixel
.BlueScale
!= 1.0F
|| ctx
->Pixel
.BlueBias
!= 0.0F
||
648 ctx
->Pixel
.AlphaScale
!= 1.0F
|| ctx
->Pixel
.AlphaBias
!= 0.0F
)
649 mask
|= IMAGE_SCALE_BIAS_BIT
;
651 if (ctx
->Pixel
.IndexShift
|| ctx
->Pixel
.IndexOffset
)
652 mask
|= IMAGE_SHIFT_OFFSET_BIT
;
654 if (ctx
->Pixel
.MapColorFlag
)
655 mask
|= IMAGE_MAP_COLOR_BIT
;
657 if (ctx
->Pixel
.ColorTableEnabled
)
658 mask
|= IMAGE_COLOR_TABLE_BIT
;
660 if (ctx
->Pixel
.Convolution1DEnabled
||
661 ctx
->Pixel
.Convolution2DEnabled
||
662 ctx
->Pixel
.Separable2DEnabled
) {
663 mask
|= IMAGE_CONVOLUTION_BIT
;
664 if (ctx
->Pixel
.PostConvolutionScale
[0] != 1.0F
||
665 ctx
->Pixel
.PostConvolutionScale
[1] != 1.0F
||
666 ctx
->Pixel
.PostConvolutionScale
[2] != 1.0F
||
667 ctx
->Pixel
.PostConvolutionScale
[3] != 1.0F
||
668 ctx
->Pixel
.PostConvolutionBias
[0] != 0.0F
||
669 ctx
->Pixel
.PostConvolutionBias
[1] != 0.0F
||
670 ctx
->Pixel
.PostConvolutionBias
[2] != 0.0F
||
671 ctx
->Pixel
.PostConvolutionBias
[3] != 0.0F
) {
672 mask
|= IMAGE_POST_CONVOLUTION_SCALE_BIAS
;
676 if (ctx
->Pixel
.PostConvolutionColorTableEnabled
)
677 mask
|= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT
;
679 if (ctx
->ColorMatrix
.type
!= MATRIX_IDENTITY
||
680 ctx
->Pixel
.PostColorMatrixScale
[0] != 1.0F
||
681 ctx
->Pixel
.PostColorMatrixBias
[0] != 0.0F
||
682 ctx
->Pixel
.PostColorMatrixScale
[1] != 1.0F
||
683 ctx
->Pixel
.PostColorMatrixBias
[1] != 0.0F
||
684 ctx
->Pixel
.PostColorMatrixScale
[2] != 1.0F
||
685 ctx
->Pixel
.PostColorMatrixBias
[2] != 0.0F
||
686 ctx
->Pixel
.PostColorMatrixScale
[3] != 1.0F
||
687 ctx
->Pixel
.PostColorMatrixBias
[3] != 0.0F
)
688 mask
|= IMAGE_COLOR_MATRIX_BIT
;
690 if (ctx
->Pixel
.PostColorMatrixColorTableEnabled
)
691 mask
|= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT
;
693 if (ctx
->Pixel
.HistogramEnabled
)
694 mask
|= IMAGE_HISTOGRAM_BIT
;
696 if (ctx
->Pixel
.MinMaxEnabled
)
697 mask
|= IMAGE_MIN_MAX_BIT
;
699 ctx
->_ImageTransferState
= mask
;
705 /* Note: This routine refers to derived texture attribute values to
706 * compute the ENABLE_TEXMAT flags, but is only called on
707 * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT
708 * flags are updated by _mesa_update_textures(), below.
710 * If both TEXTURE and TEXTURE_MATRIX change at once, these values
711 * will be computed twice.
714 update_texture_matrices( GLcontext
*ctx
)
718 ctx
->Texture
._TexMatEnabled
= 0;
720 for (i
=0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
721 if (ctx
->TextureMatrix
[i
].flags
& MAT_DIRTY
) {
722 _math_matrix_analyse( &ctx
->TextureMatrix
[i
] );
724 if (ctx
->Driver
.TextureMatrix
)
725 ctx
->Driver
.TextureMatrix( ctx
, i
, &ctx
->TextureMatrix
[i
] );
727 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
&&
728 ctx
->TextureMatrix
[i
].type
!= MATRIX_IDENTITY
)
729 ctx
->Texture
._TexMatEnabled
|= ENABLE_TEXMAT(i
);
735 /* Note: This routine refers to derived texture matrix values to
736 * compute the ENABLE_TEXMAT flags, but is only called on
737 * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT
738 * flags are updated by _mesa_update_texture_matrices, above.
740 * If both TEXTURE and TEXTURE_MATRIX change at once, these values
741 * will be computed twice.
744 update_texture_state( GLcontext
*ctx
)
748 ctx
->Texture
._ReallyEnabled
= 0;
749 ctx
->Texture
._GenFlags
= 0;
750 ctx
->_NeedNormals
&= ~NEED_NORMALS_TEXGEN
;
751 ctx
->_NeedEyeCoords
&= ~NEED_EYE_TEXGEN
;
752 ctx
->Texture
._TexMatEnabled
= 0;
753 ctx
->Texture
._TexGenEnabled
= 0;
755 /* Update texture unit state.
757 for (i
=0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
758 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[i
];
760 texUnit
->_ReallyEnabled
= 0;
761 texUnit
->_GenFlags
= 0;
763 if (!texUnit
->Enabled
)
766 /* Find the texture of highest dimensionality that is enabled
767 * and complete. We'll use it for texturing.
769 if (texUnit
->Enabled
& TEXTURE0_CUBE
) {
770 struct gl_texture_object
*texObj
= texUnit
->CurrentCubeMap
;
771 if (!texObj
->Complete
) {
772 _mesa_test_texobj_completeness(ctx
, texObj
);
774 if (texObj
->Complete
) {
775 texUnit
->_ReallyEnabled
= TEXTURE0_CUBE
;
776 texUnit
->_Current
= texObj
;
780 if (!texUnit
->_ReallyEnabled
&& (texUnit
->Enabled
& TEXTURE0_3D
)) {
781 struct gl_texture_object
*texObj
= texUnit
->Current3D
;
782 if (!texObj
->Complete
) {
783 _mesa_test_texobj_completeness(ctx
, texObj
);
785 if (texObj
->Complete
) {
786 texUnit
->_ReallyEnabled
= TEXTURE0_3D
;
787 texUnit
->_Current
= texObj
;
791 if (!texUnit
->_ReallyEnabled
&& (texUnit
->Enabled
& TEXTURE0_2D
)) {
792 struct gl_texture_object
*texObj
= texUnit
->Current2D
;
793 if (!texObj
->Complete
) {
794 _mesa_test_texobj_completeness(ctx
, texObj
);
796 if (texObj
->Complete
) {
797 texUnit
->_ReallyEnabled
= TEXTURE0_2D
;
798 texUnit
->_Current
= texObj
;
802 if (!texUnit
->_ReallyEnabled
&& (texUnit
->Enabled
& TEXTURE0_1D
)) {
803 struct gl_texture_object
*texObj
= texUnit
->Current1D
;
804 if (!texObj
->Complete
) {
805 _mesa_test_texobj_completeness(ctx
, texObj
);
807 if (texObj
->Complete
) {
808 texUnit
->_ReallyEnabled
= TEXTURE0_1D
;
809 texUnit
->_Current
= texObj
;
813 if (!texUnit
->_ReallyEnabled
) {
814 texUnit
->_Current
= NULL
;
819 GLuint flag
= texUnit
->_ReallyEnabled
<< (i
* 4);
820 ctx
->Texture
._ReallyEnabled
|= flag
;
823 if (texUnit
->TexGenEnabled
) {
824 if (texUnit
->TexGenEnabled
& S_BIT
) {
825 texUnit
->_GenFlags
|= texUnit
->_GenBitS
;
827 if (texUnit
->TexGenEnabled
& T_BIT
) {
828 texUnit
->_GenFlags
|= texUnit
->_GenBitT
;
830 if (texUnit
->TexGenEnabled
& Q_BIT
) {
831 texUnit
->_GenFlags
|= texUnit
->_GenBitQ
;
833 if (texUnit
->TexGenEnabled
& R_BIT
) {
834 texUnit
->_GenFlags
|= texUnit
->_GenBitR
;
837 ctx
->Texture
._TexGenEnabled
|= ENABLE_TEXGEN(i
);
838 ctx
->Texture
._GenFlags
|= texUnit
->_GenFlags
;
841 if (ctx
->TextureMatrix
[i
].type
!= MATRIX_IDENTITY
)
842 ctx
->Texture
._TexMatEnabled
|= ENABLE_TEXMAT(i
);
845 if (ctx
->Texture
._GenFlags
& TEXGEN_NEED_NORMALS
) {
846 ctx
->_NeedNormals
|= NEED_NORMALS_TEXGEN
;
847 ctx
->_NeedEyeCoords
|= NEED_EYE_TEXGEN
;
850 if (ctx
->Texture
._GenFlags
& TEXGEN_NEED_EYE_COORD
) {
851 ctx
->_NeedEyeCoords
|= NEED_EYE_TEXGEN
;
857 * If ctx->NewState is non-zero then this function MUST be called before
858 * rendering any primitive. Basically, function pointers and miscellaneous
859 * flags are updated to reflect the current state of the state machine.
861 * The above constraint is now maintained largely by the two Exec
862 * dispatch tables, which trigger the appropriate flush on transition
863 * between State and Geometry modes.
865 * Special care is taken with the derived value _NeedEyeCoords. This
866 * is a bitflag which is updated with information from a number of
867 * attribute groups (MODELVIEW, LIGHT, TEXTURE). A lot of derived
868 * state references this value, and must be treated with care to
869 * ensure that updates are done correctly. All state dependent on
870 * _NeedEyeCoords is calculated from within _mesa_update_tnl_spaces(),
871 * and from nowhere else.
873 void _mesa_update_state( GLcontext
*ctx
)
875 const GLuint new_state
= ctx
->NewState
;
876 const GLuint oldneedeyecoords
= ctx
->_NeedEyeCoords
;
878 if (MESA_VERBOSE
& VERBOSE_STATE
)
879 _mesa_print_state("", new_state
);
881 if (new_state
& _NEW_MODELVIEW
)
882 _math_matrix_analyse( &ctx
->ModelView
);
884 if (new_state
& _NEW_PROJECTION
)
885 update_projection( ctx
);
887 if (new_state
& _NEW_TEXTURE_MATRIX
)
888 update_texture_matrices( ctx
);
890 if (new_state
& _NEW_COLOR_MATRIX
)
891 _math_matrix_analyse( &ctx
->ColorMatrix
);
893 /* References ColorMatrix.type (derived above).
895 if (new_state
& _IMAGE_NEW_TRANSFER_STATE
)
896 update_image_transfer_state(ctx
);
898 /* Contributes to NeedEyeCoords, NeedNormals.
900 if (new_state
& _NEW_TEXTURE
)
901 update_texture_state( ctx
);
903 if (new_state
& (_NEW_BUFFERS
|_NEW_SCISSOR
))
904 update_drawbuffer( ctx
);
906 if (new_state
& _NEW_POLYGON
)
907 update_polygon( ctx
);
909 /* Contributes to NeedEyeCoords, NeedNormals.
911 if (new_state
& _NEW_LIGHT
)
912 _mesa_update_lighting( ctx
);
914 /* We can light in object space if the modelview matrix preserves
915 * lengths and relative angles.
917 if (new_state
& (_NEW_MODELVIEW
|_NEW_LIGHT
)) {
918 ctx
->_NeedEyeCoords
&= ~NEED_EYE_LIGHT_MODELVIEW
;
919 if (ctx
->Light
.Enabled
&&
920 !TEST_MAT_FLAGS( &ctx
->ModelView
, MAT_FLAGS_LENGTH_PRESERVING
))
921 ctx
->_NeedEyeCoords
|= NEED_EYE_LIGHT_MODELVIEW
;
925 /* ctx->_NeedEyeCoords is now uptodate.
927 * If the truth value of this variable has changed, update for the
928 * new lighting space and recompute the positions of lights and the
931 * If the lighting space hasn't changed, may still need to recompute
932 * light positions & normal transforms for other reasons.
934 if (new_state
& (_NEW_MODELVIEW
|
937 _MESA_NEW_NEED_EYE_COORDS
))
938 update_tnl_spaces( ctx
, oldneedeyecoords
);
941 * Here the driver sets up all the ctx->Driver function pointers
942 * to it's specific, private functions, and performs any
943 * internal state management necessary, including invalidating
944 * state of active modules.
946 * Set ctx->NewState to zero to avoid recursion if
947 * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?)
950 ctx
->Driver
.UpdateState(ctx
, new_state
);
951 ctx
->Array
.NewState
= 0;
953 /* At this point we can do some assertions to be sure the required
954 * device driver function pointers are all initialized.
956 ASSERT(ctx
->Driver
.GetString
);
957 ASSERT(ctx
->Driver
.UpdateState
);
958 ASSERT(ctx
->Driver
.Clear
);
959 ASSERT(ctx
->Driver
.SetDrawBuffer
);
960 ASSERT(ctx
->Driver
.GetBufferSize
);
961 if (ctx
->Visual
.accumRedBits
> 0) {
962 ASSERT(ctx
->Driver
.Accum
);
964 ASSERT(ctx
->Driver
.DrawPixels
);
965 ASSERT(ctx
->Driver
.ReadPixels
);
966 ASSERT(ctx
->Driver
.CopyPixels
);
967 ASSERT(ctx
->Driver
.Bitmap
);
968 ASSERT(ctx
->Driver
.ResizeBuffersMESA
);
969 ASSERT(ctx
->Driver
.TexImage1D
);
970 ASSERT(ctx
->Driver
.TexImage2D
);
971 ASSERT(ctx
->Driver
.TexImage3D
);
972 ASSERT(ctx
->Driver
.TexSubImage1D
);
973 ASSERT(ctx
->Driver
.TexSubImage2D
);
974 ASSERT(ctx
->Driver
.TexSubImage3D
);
975 ASSERT(ctx
->Driver
.CopyTexImage1D
);
976 ASSERT(ctx
->Driver
.CopyTexImage2D
);
977 ASSERT(ctx
->Driver
.CopyTexSubImage1D
);
978 ASSERT(ctx
->Driver
.CopyTexSubImage2D
);
979 ASSERT(ctx
->Driver
.CopyTexSubImage3D
);
980 if (ctx
->Extensions
.ARB_texture_compression
) {
981 ASSERT(ctx
->Driver
.CompressedTexImage1D
);
982 ASSERT(ctx
->Driver
.CompressedTexImage2D
);
983 ASSERT(ctx
->Driver
.CompressedTexImage3D
);
984 ASSERT(ctx
->Driver
.CompressedTexSubImage1D
);
985 ASSERT(ctx
->Driver
.CompressedTexSubImage2D
);
986 ASSERT(ctx
->Driver
.CompressedTexSubImage3D
);
987 ASSERT(ctx
->Driver
.IsCompressedFormat
);
988 ASSERT(ctx
->Driver
.GetCompressedTexImage
);
989 ASSERT(ctx
->Driver
.BaseCompressedTexFormat
);