1 /* $Id: state.c,v 1.104 2003/04/17 02:33:09 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
;
539 /* ARB 1. GL_ARB_multitexture */
540 exec
->ActiveTextureARB
= _mesa_ActiveTextureARB
;
541 exec
->ClientActiveTextureARB
= _mesa_ClientActiveTextureARB
;
543 /* ARB 3. GL_ARB_transpose_matrix */
544 exec
->LoadTransposeMatrixdARB
= _mesa_LoadTransposeMatrixdARB
;
545 exec
->LoadTransposeMatrixfARB
= _mesa_LoadTransposeMatrixfARB
;
546 exec
->MultTransposeMatrixdARB
= _mesa_MultTransposeMatrixdARB
;
547 exec
->MultTransposeMatrixfARB
= _mesa_MultTransposeMatrixfARB
;
549 /* ARB 5. GL_ARB_multisample */
550 exec
->SampleCoverageARB
= _mesa_SampleCoverageARB
;
552 /* ARB 12. GL_ARB_texture_compression */
553 exec
->CompressedTexImage3DARB
= _mesa_CompressedTexImage3DARB
;
554 exec
->CompressedTexImage2DARB
= _mesa_CompressedTexImage2DARB
;
555 exec
->CompressedTexImage1DARB
= _mesa_CompressedTexImage1DARB
;
556 exec
->CompressedTexSubImage3DARB
= _mesa_CompressedTexSubImage3DARB
;
557 exec
->CompressedTexSubImage2DARB
= _mesa_CompressedTexSubImage2DARB
;
558 exec
->CompressedTexSubImage1DARB
= _mesa_CompressedTexSubImage1DARB
;
559 exec
->GetCompressedTexImageARB
= _mesa_GetCompressedTexImageARB
;
561 /* ARB 14. GL_ARB_point_parameters */
562 /* reuse EXT_point_parameters functions */
564 /* ARB 26. GL_ARB_vertex_program */
565 /* ARB 27. GL_ARB_fragment_program */
566 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
567 exec
->VertexAttrib1sARB
= _mesa_VertexAttrib1sARB
;
568 exec
->VertexAttrib1fARB
= _mesa_VertexAttrib1fARB
;
569 exec
->VertexAttrib1dARB
= _mesa_VertexAttrib1dARB
;
570 exec
->VertexAttrib2sARB
= _mesa_VertexAttrib2sARB
;
571 exec
->VertexAttrib2fARB
= _mesa_VertexAttrib2fARB
;
572 exec
->VertexAttrib2dARB
= _mesa_VertexAttrib2dARB
;
573 exec
->VertexAttrib3sARB
= _mesa_VertexAttrib3sARB
;
574 exec
->VertexAttrib3fARB
= _mesa_VertexAttrib3fARB
;
575 exec
->VertexAttrib3dARB
= _mesa_VertexAttrib3dARB
;
576 exec
->VertexAttrib4sARB
= _mesa_VertexAttrib4sARB
;
577 exec
->VertexAttrib4fARB
= _mesa_VertexAttrib4fARB
;
578 exec
->VertexAttrib4dARB
= _mesa_VertexAttrib4dARB
;
579 exec
->VertexAttrib4NubARB
= _mesa_VertexAttrib4NubARB
;
580 exec
->VertexAttrib1svARB
= _mesa_VertexAttrib1svARB
;
581 exec
->VertexAttrib1fvARB
= _mesa_VertexAttrib1fvARB
;
582 exec
->VertexAttrib1dvARB
= _mesa_VertexAttrib1dvARB
;
583 exec
->VertexAttrib2svARB
= _mesa_VertexAttrib2svARB
;
584 exec
->VertexAttrib2fvARB
= _mesa_VertexAttrib2fvARB
;
585 exec
->VertexAttrib2dvARB
= _mesa_VertexAttrib2dvARB
;
586 exec
->VertexAttrib3svARB
= _mesa_VertexAttrib3svARB
;
587 exec
->VertexAttrib3fvARB
= _mesa_VertexAttrib3fvARB
;
588 exec
->VertexAttrib3dvARB
= _mesa_VertexAttrib3dvARB
;
589 exec
->VertexAttrib4bvARB
= _mesa_VertexAttrib4bvARB
;
590 exec
->VertexAttrib4svARB
= _mesa_VertexAttrib4svARB
;
591 exec
->VertexAttrib4ivARB
= _mesa_VertexAttrib4ivARB
;
592 exec
->VertexAttrib4ubvARB
= _mesa_VertexAttrib4ubvARB
;
593 exec
->VertexAttrib4usvARB
= _mesa_VertexAttrib4usvARB
;
594 exec
->VertexAttrib4uivARB
= _mesa_VertexAttrib4uivARB
;
595 exec
->VertexAttrib4fvARB
= _mesa_VertexAttrib4fvARB
;
596 exec
->VertexAttrib4dvARB
= _mesa_VertexAttrib4dvARB
;
597 exec
->VertexAttrib4NbvARB
= _mesa_VertexAttrib4NbvARB
;
598 exec
->VertexAttrib4NsvARB
= _mesa_VertexAttrib4NsvARB
;
599 exec
->VertexAttrib4NivARB
= _mesa_VertexAttrib4NivARB
;
600 exec
->VertexAttrib4NubvARB
= _mesa_VertexAttrib4NubvARB
;
601 exec
->VertexAttrib4NusvARB
= _mesa_VertexAttrib4NusvARB
;
602 exec
->VertexAttrib4NuivARB
= _mesa_VertexAttrib4NuivARB
;
603 exec
->VertexAttribPointerARB
= _mesa_VertexAttribPointerARB
;
604 exec
->EnableVertexAttribArrayARB
= _mesa_EnableVertexAttribArrayARB
;
605 exec
->DisableVertexAttribArrayARB
= _mesa_DisableVertexAttribArrayARB
;
606 exec
->ProgramStringARB
= _mesa_ProgramStringARB
;
607 exec
->BindProgramARB
= _mesa_BindProgramARB
;
608 exec
->DeleteProgramsARB
= _mesa_DeleteProgramsARB
;
609 exec
->GenProgramsARB
= _mesa_GenProgramsARB
;
610 exec
->ProgramEnvParameter4dARB
= _mesa_ProgramEnvParameter4dARB
;
611 exec
->ProgramEnvParameter4dvARB
= _mesa_ProgramEnvParameter4dvARB
;
612 exec
->ProgramEnvParameter4fARB
= _mesa_ProgramEnvParameter4fARB
;
613 exec
->ProgramEnvParameter4fvARB
= _mesa_ProgramEnvParameter4fvARB
;
614 exec
->ProgramLocalParameter4dARB
= _mesa_ProgramLocalParameter4dARB
;
615 exec
->ProgramLocalParameter4dvARB
= _mesa_ProgramLocalParameter4dvARB
;
616 exec
->ProgramLocalParameter4fARB
= _mesa_ProgramLocalParameter4fARB
;
617 exec
->ProgramLocalParameter4fvARB
= _mesa_ProgramLocalParameter4fvARB
;
618 exec
->GetProgramEnvParameterdvARB
= _mesa_GetProgramEnvParameterdvARB
;
619 exec
->GetProgramEnvParameterfvARB
= _mesa_GetProgramEnvParameterfvARB
;
620 exec
->GetProgramLocalParameterdvARB
= _mesa_GetProgramLocalParameterdvARB
;
621 exec
->GetProgramLocalParameterfvARB
= _mesa_GetProgramLocalParameterfvARB
;
622 exec
->GetProgramivARB
= _mesa_GetProgramivARB
;
623 exec
->GetProgramStringARB
= _mesa_GetProgramStringARB
;
624 exec
->GetVertexAttribdvARB
= _mesa_GetVertexAttribdvARB
;
625 exec
->GetVertexAttribfvARB
= _mesa_GetVertexAttribfvARB
;
626 exec
->GetVertexAttribivARB
= _mesa_GetVertexAttribivARB
;
627 exec
->GetVertexAttribPointervARB
= _mesa_GetVertexAttribPointervARB
;
628 exec
->IsProgramARB
= _mesa_IsProgramARB
;
631 /* ARB 28. GL_ARB_vertex_buffer_object */
632 #if FEATURE_ARB_vertex_buffer_object
633 exec
->BindBufferARB
= _mesa_BindBufferARB
;
634 exec
->DeleteBuffersARB
= _mesa_DeleteBuffersARB
;
635 exec
->GenBuffersARB
= _mesa_GenBuffersARB
;
636 exec
->IsBufferARB
= _mesa_IsBufferARB
;
637 exec
->BufferDataARB
= _mesa_BufferDataARB
;
638 exec
->BufferSubDataARB
= _mesa_BufferSubDataARB
;
639 exec
->GetBufferSubDataARB
= _mesa_GetBufferSubDataARB
;
640 exec
->MapBufferARB
= _mesa_MapBufferARB
;
641 exec
->UnmapBufferARB
= _mesa_UnmapBufferARB
;
642 exec
->GetBufferParameterivARB
= _mesa_GetBufferParameterivARB
;
643 exec
->GetBufferPointervARB
= _mesa_GetBufferPointervARB
;
649 /**********************************************************************/
650 /***** State update logic *****/
651 /**********************************************************************/
655 * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET
656 * in ctx->_TriangleCaps if needed.
659 update_polygon( GLcontext
*ctx
)
661 ctx
->_TriangleCaps
&= ~(DD_TRI_CULL_FRONT_BACK
| DD_TRI_OFFSET
);
663 if (ctx
->Polygon
.CullFlag
&& ctx
->Polygon
.CullFaceMode
== GL_FRONT_AND_BACK
)
664 ctx
->_TriangleCaps
|= DD_TRI_CULL_FRONT_BACK
;
666 /* Any Polygon offsets enabled? */
667 if (ctx
->Polygon
.OffsetPoint
||
668 ctx
->Polygon
.OffsetLine
||
669 ctx
->Polygon
.OffsetFill
) {
670 ctx
->_TriangleCaps
|= DD_TRI_OFFSET
;
675 calculate_model_project_matrix( GLcontext
*ctx
)
677 _math_matrix_mul_matrix( &ctx
->_ModelProjectMatrix
,
678 ctx
->ProjectionMatrixStack
.Top
,
679 ctx
->ModelviewMatrixStack
.Top
);
681 _math_matrix_analyse( &ctx
->_ModelProjectMatrix
);
685 update_modelview_scale( GLcontext
*ctx
)
687 ctx
->_ModelViewInvScale
= 1.0F
;
688 if (ctx
->ModelviewMatrixStack
.Top
->flags
& (MAT_FLAG_UNIFORM_SCALE
|
689 MAT_FLAG_GENERAL_SCALE
|
690 MAT_FLAG_GENERAL_3D
|
691 MAT_FLAG_GENERAL
) ) {
692 const GLfloat
*m
= ctx
->ModelviewMatrixStack
.Top
->inv
;
693 GLfloat f
= m
[2] * m
[2] + m
[6] * m
[6] + m
[10] * m
[10];
694 if (f
< 1e-12) f
= 1.0;
695 if (ctx
->_NeedEyeCoords
)
696 ctx
->_ModelViewInvScale
= 1.0F
/ SQRTF(f
);
698 ctx
->_ModelViewInvScale
= SQRTF(f
);
703 /* Bring uptodate any state that relies on _NeedEyeCoords.
706 update_tnl_spaces( GLcontext
*ctx
, GLuint oldneedeyecoords
)
708 /* Check if the truth-value interpretations of the bitfields have
711 if ((oldneedeyecoords
== 0) != (ctx
->_NeedEyeCoords
== 0)) {
712 /* Recalculate all state that depends on _NeedEyeCoords.
714 update_modelview_scale(ctx
);
715 _mesa_compute_light_positions( ctx
);
717 if (ctx
->Driver
.LightingSpaceChange
)
718 ctx
->Driver
.LightingSpaceChange( ctx
);
721 GLuint new_state
= ctx
->NewState
;
723 /* Recalculate that same state only if it has been invalidated
724 * by other statechanges.
726 if (new_state
& _NEW_MODELVIEW
)
727 update_modelview_scale(ctx
);
729 if (new_state
& (_NEW_LIGHT
|_NEW_MODELVIEW
))
730 _mesa_compute_light_positions( ctx
);
736 update_drawbuffer( GLcontext
*ctx
)
738 ctx
->DrawBuffer
->_Xmin
= 0;
739 ctx
->DrawBuffer
->_Ymin
= 0;
740 ctx
->DrawBuffer
->_Xmax
= ctx
->DrawBuffer
->Width
;
741 ctx
->DrawBuffer
->_Ymax
= ctx
->DrawBuffer
->Height
;
742 if (ctx
->Scissor
.Enabled
) {
743 if (ctx
->Scissor
.X
> ctx
->DrawBuffer
->_Xmin
) {
744 ctx
->DrawBuffer
->_Xmin
= ctx
->Scissor
.X
;
746 if (ctx
->Scissor
.Y
> ctx
->DrawBuffer
->_Ymin
) {
747 ctx
->DrawBuffer
->_Ymin
= ctx
->Scissor
.Y
;
749 if (ctx
->Scissor
.X
+ ctx
->Scissor
.Width
< ctx
->DrawBuffer
->_Xmax
) {
750 ctx
->DrawBuffer
->_Xmax
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
;
752 if (ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
< ctx
->DrawBuffer
->_Ymax
) {
753 ctx
->DrawBuffer
->_Ymax
= ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
;
759 /* NOTE: This routine references Tranform attribute values to compute
760 * userclip positions in clip space, but is only called on
761 * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values
762 * up to date across changes to the Transform attributes.
765 update_projection( GLcontext
*ctx
)
767 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
769 /* Recompute clip plane positions in clipspace. This is also done
770 * in _mesa_ClipPlane().
772 if (ctx
->Transform
.ClipPlanesEnabled
) {
774 for (p
= 0; p
< ctx
->Const
.MaxClipPlanes
; p
++) {
775 if (ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) {
776 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
777 ctx
->Transform
.EyeUserPlane
[p
],
778 ctx
->ProjectionMatrixStack
.Top
->inv
);
786 * Return a bitmask of IMAGE_*_BIT flags which to indicate which
787 * pixel transfer operations are enabled.
790 update_image_transfer_state(GLcontext
*ctx
)
794 if (ctx
->Pixel
.RedScale
!= 1.0F
|| ctx
->Pixel
.RedBias
!= 0.0F
||
795 ctx
->Pixel
.GreenScale
!= 1.0F
|| ctx
->Pixel
.GreenBias
!= 0.0F
||
796 ctx
->Pixel
.BlueScale
!= 1.0F
|| ctx
->Pixel
.BlueBias
!= 0.0F
||
797 ctx
->Pixel
.AlphaScale
!= 1.0F
|| ctx
->Pixel
.AlphaBias
!= 0.0F
)
798 mask
|= IMAGE_SCALE_BIAS_BIT
;
800 if (ctx
->Pixel
.IndexShift
|| ctx
->Pixel
.IndexOffset
)
801 mask
|= IMAGE_SHIFT_OFFSET_BIT
;
803 if (ctx
->Pixel
.MapColorFlag
)
804 mask
|= IMAGE_MAP_COLOR_BIT
;
806 if (ctx
->Pixel
.ColorTableEnabled
)
807 mask
|= IMAGE_COLOR_TABLE_BIT
;
809 if (ctx
->Pixel
.Convolution1DEnabled
||
810 ctx
->Pixel
.Convolution2DEnabled
||
811 ctx
->Pixel
.Separable2DEnabled
) {
812 mask
|= IMAGE_CONVOLUTION_BIT
;
813 if (ctx
->Pixel
.PostConvolutionScale
[0] != 1.0F
||
814 ctx
->Pixel
.PostConvolutionScale
[1] != 1.0F
||
815 ctx
->Pixel
.PostConvolutionScale
[2] != 1.0F
||
816 ctx
->Pixel
.PostConvolutionScale
[3] != 1.0F
||
817 ctx
->Pixel
.PostConvolutionBias
[0] != 0.0F
||
818 ctx
->Pixel
.PostConvolutionBias
[1] != 0.0F
||
819 ctx
->Pixel
.PostConvolutionBias
[2] != 0.0F
||
820 ctx
->Pixel
.PostConvolutionBias
[3] != 0.0F
) {
821 mask
|= IMAGE_POST_CONVOLUTION_SCALE_BIAS
;
825 if (ctx
->Pixel
.PostConvolutionColorTableEnabled
)
826 mask
|= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT
;
828 if (ctx
->ColorMatrixStack
.Top
->type
!= MATRIX_IDENTITY
||
829 ctx
->Pixel
.PostColorMatrixScale
[0] != 1.0F
||
830 ctx
->Pixel
.PostColorMatrixBias
[0] != 0.0F
||
831 ctx
->Pixel
.PostColorMatrixScale
[1] != 1.0F
||
832 ctx
->Pixel
.PostColorMatrixBias
[1] != 0.0F
||
833 ctx
->Pixel
.PostColorMatrixScale
[2] != 1.0F
||
834 ctx
->Pixel
.PostColorMatrixBias
[2] != 0.0F
||
835 ctx
->Pixel
.PostColorMatrixScale
[3] != 1.0F
||
836 ctx
->Pixel
.PostColorMatrixBias
[3] != 0.0F
)
837 mask
|= IMAGE_COLOR_MATRIX_BIT
;
839 if (ctx
->Pixel
.PostColorMatrixColorTableEnabled
)
840 mask
|= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT
;
842 if (ctx
->Pixel
.HistogramEnabled
)
843 mask
|= IMAGE_HISTOGRAM_BIT
;
845 if (ctx
->Pixel
.MinMaxEnabled
)
846 mask
|= IMAGE_MIN_MAX_BIT
;
848 ctx
->_ImageTransferState
= mask
;
854 /* Note: This routine refers to derived texture attribute values to
855 * compute the ENABLE_TEXMAT flags, but is only called on
856 * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT
857 * flags are updated by _mesa_update_textures(), below.
859 * If both TEXTURE and TEXTURE_MATRIX change at once, these values
860 * will be computed twice.
863 update_texture_matrices( GLcontext
*ctx
)
867 ctx
->Texture
._TexMatEnabled
= 0;
869 for (i
=0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
870 if (ctx
->TextureMatrixStack
[i
].Top
->flags
& MAT_DIRTY
) {
871 _math_matrix_analyse( ctx
->TextureMatrixStack
[i
].Top
);
873 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
&&
874 ctx
->TextureMatrixStack
[i
].Top
->type
!= MATRIX_IDENTITY
)
875 ctx
->Texture
._TexMatEnabled
|= ENABLE_TEXMAT(i
);
877 if (ctx
->Driver
.TextureMatrix
)
878 ctx
->Driver
.TextureMatrix( ctx
, i
, ctx
->TextureMatrixStack
[i
].Top
);
884 /* Note: This routine refers to derived texture matrix values to
885 * compute the ENABLE_TEXMAT flags, but is only called on
886 * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT
887 * flags are updated by _mesa_update_texture_matrices, above.
889 * If both TEXTURE and TEXTURE_MATRIX change at once, these values
890 * will be computed twice.
893 update_texture_state( GLcontext
*ctx
)
897 ctx
->Texture
._EnabledUnits
= 0;
898 ctx
->Texture
._GenFlags
= 0;
899 ctx
->_NeedNormals
&= ~NEED_NORMALS_TEXGEN
;
900 ctx
->_NeedEyeCoords
&= ~NEED_EYE_TEXGEN
;
901 ctx
->Texture
._TexMatEnabled
= 0;
902 ctx
->Texture
._TexGenEnabled
= 0;
904 /* Update texture unit state.
906 for (unit
= 0; unit
< ctx
->Const
.MaxTextureUnits
; unit
++) {
907 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
910 texUnit
->_ReallyEnabled
= 0;
911 texUnit
->_GenFlags
= 0;
913 /* Get the bitmask of texture enables */
914 if (ctx
->FragmentProgram
.Enabled
&& ctx
->FragmentProgram
.Current
) {
915 enableBits
= ctx
->FragmentProgram
.Current
->TexturesUsed
[unit
];
918 if (!texUnit
->Enabled
)
920 enableBits
= texUnit
->Enabled
;
923 /* Look for the highest-priority texture target that's enabled and
924 * complete. That's the one we'll use for texturing. If we're using
925 * a fragment program we're guaranteed that bitcount(enabledBits) <= 1.
927 if (enableBits
& TEXTURE_CUBE_BIT
) {
928 struct gl_texture_object
*texObj
= texUnit
->CurrentCubeMap
;
929 if (!texObj
->Complete
) {
930 _mesa_test_texobj_completeness(ctx
, texObj
);
932 if (texObj
->Complete
) {
933 texUnit
->_ReallyEnabled
= TEXTURE_CUBE_BIT
;
934 texUnit
->_Current
= texObj
;
938 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_3D_BIT
)) {
939 struct gl_texture_object
*texObj
= texUnit
->Current3D
;
940 if (!texObj
->Complete
) {
941 _mesa_test_texobj_completeness(ctx
, texObj
);
943 if (texObj
->Complete
) {
944 texUnit
->_ReallyEnabled
= TEXTURE_3D_BIT
;
945 texUnit
->_Current
= texObj
;
949 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_RECT_BIT
)) {
950 struct gl_texture_object
*texObj
= texUnit
->CurrentRect
;
951 if (!texObj
->Complete
) {
952 _mesa_test_texobj_completeness(ctx
, texObj
);
954 if (texObj
->Complete
) {
955 texUnit
->_ReallyEnabled
= TEXTURE_RECT_BIT
;
956 texUnit
->_Current
= texObj
;
960 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_2D_BIT
)) {
961 struct gl_texture_object
*texObj
= texUnit
->Current2D
;
962 if (!texObj
->Complete
) {
963 _mesa_test_texobj_completeness(ctx
, texObj
);
965 if (texObj
->Complete
) {
966 texUnit
->_ReallyEnabled
= TEXTURE_2D_BIT
;
967 texUnit
->_Current
= texObj
;
971 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_1D_BIT
)) {
972 struct gl_texture_object
*texObj
= texUnit
->Current1D
;
973 if (!texObj
->Complete
) {
974 _mesa_test_texobj_completeness(ctx
, texObj
);
976 if (texObj
->Complete
) {
977 texUnit
->_ReallyEnabled
= TEXTURE_1D_BIT
;
978 texUnit
->_Current
= texObj
;
982 if (!texUnit
->_ReallyEnabled
) {
983 texUnit
->_Current
= NULL
;
987 if (texUnit
->_ReallyEnabled
)
988 ctx
->Texture
._EnabledUnits
|= (1 << unit
);
990 if (texUnit
->TexGenEnabled
) {
991 if (texUnit
->TexGenEnabled
& S_BIT
) {
992 texUnit
->_GenFlags
|= texUnit
->_GenBitS
;
994 if (texUnit
->TexGenEnabled
& T_BIT
) {
995 texUnit
->_GenFlags
|= texUnit
->_GenBitT
;
997 if (texUnit
->TexGenEnabled
& Q_BIT
) {
998 texUnit
->_GenFlags
|= texUnit
->_GenBitQ
;
1000 if (texUnit
->TexGenEnabled
& R_BIT
) {
1001 texUnit
->_GenFlags
|= texUnit
->_GenBitR
;
1004 ctx
->Texture
._TexGenEnabled
|= ENABLE_TEXGEN(unit
);
1005 ctx
->Texture
._GenFlags
|= texUnit
->_GenFlags
;
1008 if (ctx
->TextureMatrixStack
[unit
].Top
->type
!= MATRIX_IDENTITY
)
1009 ctx
->Texture
._TexMatEnabled
|= ENABLE_TEXMAT(unit
);
1012 if (ctx
->Texture
._GenFlags
& TEXGEN_NEED_NORMALS
) {
1013 ctx
->_NeedNormals
|= NEED_NORMALS_TEXGEN
;
1014 ctx
->_NeedEyeCoords
|= NEED_EYE_TEXGEN
;
1017 if (ctx
->Texture
._GenFlags
& TEXGEN_NEED_EYE_COORD
) {
1018 ctx
->_NeedEyeCoords
|= NEED_EYE_TEXGEN
;
1021 ctx
->Texture
._EnabledCoordUnits
= ctx
->Texture
._EnabledUnits
;
1022 /* Fragment programs may need texture coordinates but not the
1023 * corresponding texture images.
1025 if (ctx
->FragmentProgram
.Enabled
&& ctx
->FragmentProgram
.Current
) {
1026 ctx
->Texture
._EnabledCoordUnits
|=
1027 (ctx
->FragmentProgram
.Current
->InputsRead
>> FRAG_ATTRIB_TEX0
);
1033 * Update items which depend on vertex/fragment programs.
1036 update_program( GLcontext
*ctx
)
1038 if (ctx
->FragmentProgram
.Enabled
&& ctx
->FragmentProgram
.Current
) {
1039 if (ctx
->FragmentProgram
.Current
->InputsRead
& (1 << FRAG_ATTRIB_COL1
))
1040 ctx
->_TriangleCaps
|= DD_SEPARATE_SPECULAR
;
1046 * If ctx->NewState is non-zero then this function MUST be called before
1047 * rendering any primitive. Basically, function pointers and miscellaneous
1048 * flags are updated to reflect the current state of the state machine.
1050 * The above constraint is now maintained largely by the two Exec
1051 * dispatch tables, which trigger the appropriate flush on transition
1052 * between State and Geometry modes.
1054 * Special care is taken with the derived value _NeedEyeCoords. This
1055 * is a bitflag which is updated with information from a number of
1056 * attribute groups (MODELVIEW, LIGHT, TEXTURE). A lot of derived
1057 * state references this value, and must be treated with care to
1058 * ensure that updates are done correctly. All state dependent on
1059 * _NeedEyeCoords is calculated from within _mesa_update_tnl_spaces(),
1060 * and from nowhere else.
1062 void _mesa_update_state( GLcontext
*ctx
)
1064 const GLuint new_state
= ctx
->NewState
;
1065 const GLuint oldneedeyecoords
= ctx
->_NeedEyeCoords
;
1067 if (MESA_VERBOSE
& VERBOSE_STATE
)
1068 _mesa_print_state("_mesa_update_state", new_state
);
1070 if (new_state
& _NEW_MODELVIEW
)
1071 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1073 if (new_state
& _NEW_PROJECTION
)
1074 update_projection( ctx
);
1076 if (new_state
& _NEW_TEXTURE_MATRIX
)
1077 update_texture_matrices( ctx
);
1079 if (new_state
& _NEW_COLOR_MATRIX
)
1080 _math_matrix_analyse( ctx
->ColorMatrixStack
.Top
);
1082 /* References ColorMatrix.type (derived above).
1084 if (new_state
& _IMAGE_NEW_TRANSFER_STATE
)
1085 update_image_transfer_state(ctx
);
1087 /* Contributes to NeedEyeCoords, NeedNormals.
1089 if (new_state
& _NEW_TEXTURE
)
1090 update_texture_state( ctx
);
1092 if (new_state
& (_NEW_BUFFERS
|_NEW_SCISSOR
))
1093 update_drawbuffer( ctx
);
1095 if (new_state
& _NEW_POLYGON
)
1096 update_polygon( ctx
);
1098 /* Contributes to NeedEyeCoords, NeedNormals.
1100 if (new_state
& _NEW_LIGHT
)
1101 _mesa_update_lighting( ctx
);
1103 /* We can light in object space if the modelview matrix preserves
1104 * lengths and relative angles.
1106 if (new_state
& (_NEW_MODELVIEW
|_NEW_LIGHT
)) {
1107 ctx
->_NeedEyeCoords
&= ~NEED_EYE_LIGHT_MODELVIEW
;
1108 if (ctx
->Light
.Enabled
&&
1109 !TEST_MAT_FLAGS( ctx
->ModelviewMatrixStack
.Top
, MAT_FLAGS_LENGTH_PRESERVING
))
1110 ctx
->_NeedEyeCoords
|= NEED_EYE_LIGHT_MODELVIEW
;
1113 if (new_state
& _NEW_PROGRAM
)
1114 update_program( ctx
);
1117 /* XXX this is a bit of a hack. We should be checking elsewhere if
1118 * vertex program mode is enabled. We set _NeedEyeCoords to zero to
1119 * ensure that the combined modelview/projection matrix is computed
1120 * in calculate_model_project_matrix().
1122 if (ctx
->VertexProgram
.Enabled
)
1123 ctx
->_NeedEyeCoords
= 0;
1124 /* KW: it's now always computed.
1128 /* Keep ModelviewProject uptodate always to allow tnl
1129 * implementations that go model->clip even when eye is required.
1131 if (new_state
& (_NEW_MODELVIEW
|_NEW_PROJECTION
))
1132 calculate_model_project_matrix(ctx
);
1134 /* ctx->_NeedEyeCoords is now uptodate.
1136 * If the truth value of this variable has changed, update for the
1137 * new lighting space and recompute the positions of lights and the
1140 * If the lighting space hasn't changed, may still need to recompute
1141 * light positions & normal transforms for other reasons.
1143 if (new_state
& (_NEW_MODELVIEW
|
1145 _MESA_NEW_NEED_EYE_COORDS
))
1146 update_tnl_spaces( ctx
, oldneedeyecoords
);
1149 * Here the driver sets up all the ctx->Driver function pointers
1150 * to it's specific, private functions, and performs any
1151 * internal state management necessary, including invalidating
1152 * state of active modules.
1154 * Set ctx->NewState to zero to avoid recursion if
1155 * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?)
1158 ctx
->Driver
.UpdateState(ctx
, new_state
);
1159 ctx
->Array
.NewState
= 0;
1161 /* At this point we can do some assertions to be sure the required
1162 * device driver function pointers are all initialized.
1164 ASSERT(ctx
->Driver
.GetString
);
1165 ASSERT(ctx
->Driver
.UpdateState
);
1166 ASSERT(ctx
->Driver
.Clear
);
1167 ASSERT(ctx
->Driver
.GetBufferSize
);
1168 if (ctx
->Visual
.accumRedBits
> 0) {
1169 ASSERT(ctx
->Driver
.Accum
);
1171 ASSERT(ctx
->Driver
.DrawPixels
);
1172 ASSERT(ctx
->Driver
.ReadPixels
);
1173 ASSERT(ctx
->Driver
.CopyPixels
);
1174 ASSERT(ctx
->Driver
.Bitmap
);
1175 ASSERT(ctx
->Driver
.ResizeBuffers
);
1176 ASSERT(ctx
->Driver
.TexImage1D
);
1177 ASSERT(ctx
->Driver
.TexImage2D
);
1178 ASSERT(ctx
->Driver
.TexImage3D
);
1179 ASSERT(ctx
->Driver
.TexSubImage1D
);
1180 ASSERT(ctx
->Driver
.TexSubImage2D
);
1181 ASSERT(ctx
->Driver
.TexSubImage3D
);
1182 ASSERT(ctx
->Driver
.CopyTexImage1D
);
1183 ASSERT(ctx
->Driver
.CopyTexImage2D
);
1184 ASSERT(ctx
->Driver
.CopyTexSubImage1D
);
1185 ASSERT(ctx
->Driver
.CopyTexSubImage2D
);
1186 ASSERT(ctx
->Driver
.CopyTexSubImage3D
);
1187 if (ctx
->Extensions
.ARB_texture_compression
) {
1188 #if 0 /* HW drivers need these, but not SW rasterizers */
1189 ASSERT(ctx
->Driver
.CompressedTexImage1D
);
1190 ASSERT(ctx
->Driver
.CompressedTexImage2D
);
1191 ASSERT(ctx
->Driver
.CompressedTexImage3D
);
1192 ASSERT(ctx
->Driver
.CompressedTexSubImage1D
);
1193 ASSERT(ctx
->Driver
.CompressedTexSubImage2D
);
1194 ASSERT(ctx
->Driver
.CompressedTexSubImage3D
);
1202 _mesa_allow_light_in_model( GLcontext
*ctx
, GLboolean flag
)
1205 ctx
->_NeedEyeCoords
&= ~NEED_EYE_DRIVER
;
1207 ctx
->_NeedEyeCoords
|= NEED_EYE_DRIVER
;
1209 ctx
->NewState
|= _NEW_POINT
; /* one of the bits from
1210 * _MESA_NEW_NEED_EYE_COORDS.