1 /* $Id: state.c,v 1.30 2000/10/02 15:45:12 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 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 initializes the immediate-mode dispatch table (which may
30 * be state-dependant) and manages internal Mesa state update.
97 gl_problem(NULL
, "undefined function dispatch");
104 * Set all pointers in the given dispatch table to point to a
105 * generic no-op function.
108 _mesa_init_no_op_table(struct _glapi_table
*table
, GLuint tableSize
)
111 void **dispatch
= (void **) table
;
112 for (i
= 0; i
< tableSize
; i
++) {
113 dispatch
[i
] = (void *) generic_noop
;
119 * Initialize the given dispatch table with pointers to Mesa's
120 * immediate-mode commands.
123 _mesa_init_exec_table(struct _glapi_table
*exec
, GLuint tableSize
)
125 /* first initialize all dispatch slots to no-op */
126 _mesa_init_no_op_table(exec
, tableSize
);
128 /* load the dispatch slots we understand */
129 exec
->Accum
= _mesa_Accum
;
130 exec
->AlphaFunc
= _mesa_AlphaFunc
;
131 exec
->Begin
= _mesa_Begin
;
132 exec
->Bitmap
= _mesa_Bitmap
;
133 exec
->BlendFunc
= _mesa_BlendFunc
;
134 exec
->CallList
= _mesa_CallList
;
135 exec
->CallLists
= _mesa_CallLists
;
136 exec
->Clear
= _mesa_Clear
;
137 exec
->ClearAccum
= _mesa_ClearAccum
;
138 exec
->ClearColor
= _mesa_ClearColor
;
139 exec
->ClearDepth
= _mesa_ClearDepth
;
140 exec
->ClearIndex
= _mesa_ClearIndex
;
141 exec
->ClearStencil
= _mesa_ClearStencil
;
142 exec
->ClipPlane
= _mesa_ClipPlane
;
143 exec
->Color3b
= _mesa_Color3b
;
144 exec
->Color3bv
= _mesa_Color3bv
;
145 exec
->Color3d
= _mesa_Color3d
;
146 exec
->Color3dv
= _mesa_Color3dv
;
147 exec
->Color3f
= _mesa_Color3f
;
148 exec
->Color3fv
= _mesa_Color3fv
;
149 exec
->Color3i
= _mesa_Color3i
;
150 exec
->Color3iv
= _mesa_Color3iv
;
151 exec
->Color3s
= _mesa_Color3s
;
152 exec
->Color3sv
= _mesa_Color3sv
;
153 exec
->Color3ub
= _mesa_Color3ub
;
154 exec
->Color3ubv
= _mesa_Color3ubv
;
155 exec
->Color3ui
= _mesa_Color3ui
;
156 exec
->Color3uiv
= _mesa_Color3uiv
;
157 exec
->Color3us
= _mesa_Color3us
;
158 exec
->Color3usv
= _mesa_Color3usv
;
159 exec
->Color4b
= _mesa_Color4b
;
160 exec
->Color4bv
= _mesa_Color4bv
;
161 exec
->Color4d
= _mesa_Color4d
;
162 exec
->Color4dv
= _mesa_Color4dv
;
163 exec
->Color4f
= _mesa_Color4f
;
164 exec
->Color4fv
= _mesa_Color4fv
;
165 exec
->Color4i
= _mesa_Color4i
;
166 exec
->Color4iv
= _mesa_Color4iv
;
167 exec
->Color4s
= _mesa_Color4s
;
168 exec
->Color4sv
= _mesa_Color4sv
;
169 exec
->Color4ub
= _mesa_Color4ub
;
170 exec
->Color4ubv
= _mesa_Color4ubv
;
171 exec
->Color4ui
= _mesa_Color4ui
;
172 exec
->Color4uiv
= _mesa_Color4uiv
;
173 exec
->Color4us
= _mesa_Color4us
;
174 exec
->Color4usv
= _mesa_Color4usv
;
175 exec
->ColorMask
= _mesa_ColorMask
;
176 exec
->ColorMaterial
= _mesa_ColorMaterial
;
177 exec
->CopyPixels
= _mesa_CopyPixels
;
178 exec
->CullFace
= _mesa_CullFace
;
179 exec
->DeleteLists
= _mesa_DeleteLists
;
180 exec
->DepthFunc
= _mesa_DepthFunc
;
181 exec
->DepthMask
= _mesa_DepthMask
;
182 exec
->DepthRange
= _mesa_DepthRange
;
183 exec
->Disable
= _mesa_Disable
;
184 exec
->DrawBuffer
= _mesa_DrawBuffer
;
185 exec
->DrawPixels
= _mesa_DrawPixels
;
186 exec
->EdgeFlag
= _mesa_EdgeFlag
;
187 exec
->EdgeFlagv
= _mesa_EdgeFlagv
;
188 exec
->Enable
= _mesa_Enable
;
189 exec
->End
= _mesa_End
;
190 exec
->EndList
= _mesa_EndList
;
191 exec
->EvalCoord1d
= _mesa_EvalCoord1d
;
192 exec
->EvalCoord1dv
= _mesa_EvalCoord1dv
;
193 exec
->EvalCoord1f
= _mesa_EvalCoord1f
;
194 exec
->EvalCoord1fv
= _mesa_EvalCoord1fv
;
195 exec
->EvalCoord2d
= _mesa_EvalCoord2d
;
196 exec
->EvalCoord2dv
= _mesa_EvalCoord2dv
;
197 exec
->EvalCoord2f
= _mesa_EvalCoord2f
;
198 exec
->EvalCoord2fv
= _mesa_EvalCoord2fv
;
199 exec
->EvalMesh1
= _mesa_EvalMesh1
;
200 exec
->EvalMesh2
= _mesa_EvalMesh2
;
201 exec
->EvalPoint1
= _mesa_EvalPoint1
;
202 exec
->EvalPoint2
= _mesa_EvalPoint2
;
203 exec
->FeedbackBuffer
= _mesa_FeedbackBuffer
;
204 exec
->Finish
= _mesa_Finish
;
205 exec
->Flush
= _mesa_Flush
;
206 exec
->Fogf
= _mesa_Fogf
;
207 exec
->Fogfv
= _mesa_Fogfv
;
208 exec
->Fogi
= _mesa_Fogi
;
209 exec
->Fogiv
= _mesa_Fogiv
;
210 exec
->FrontFace
= _mesa_FrontFace
;
211 exec
->Frustum
= _mesa_Frustum
;
212 exec
->GenLists
= _mesa_GenLists
;
213 exec
->GetBooleanv
= _mesa_GetBooleanv
;
214 exec
->GetClipPlane
= _mesa_GetClipPlane
;
215 exec
->GetDoublev
= _mesa_GetDoublev
;
216 exec
->GetError
= _mesa_GetError
;
217 exec
->GetFloatv
= _mesa_GetFloatv
;
218 exec
->GetIntegerv
= _mesa_GetIntegerv
;
219 exec
->GetLightfv
= _mesa_GetLightfv
;
220 exec
->GetLightiv
= _mesa_GetLightiv
;
221 exec
->GetMapdv
= _mesa_GetMapdv
;
222 exec
->GetMapfv
= _mesa_GetMapfv
;
223 exec
->GetMapiv
= _mesa_GetMapiv
;
224 exec
->GetMaterialfv
= _mesa_GetMaterialfv
;
225 exec
->GetMaterialiv
= _mesa_GetMaterialiv
;
226 exec
->GetPixelMapfv
= _mesa_GetPixelMapfv
;
227 exec
->GetPixelMapuiv
= _mesa_GetPixelMapuiv
;
228 exec
->GetPixelMapusv
= _mesa_GetPixelMapusv
;
229 exec
->GetPolygonStipple
= _mesa_GetPolygonStipple
;
230 exec
->GetString
= _mesa_GetString
;
231 exec
->GetTexEnvfv
= _mesa_GetTexEnvfv
;
232 exec
->GetTexEnviv
= _mesa_GetTexEnviv
;
233 exec
->GetTexGendv
= _mesa_GetTexGendv
;
234 exec
->GetTexGenfv
= _mesa_GetTexGenfv
;
235 exec
->GetTexGeniv
= _mesa_GetTexGeniv
;
236 exec
->GetTexImage
= _mesa_GetTexImage
;
237 exec
->GetTexLevelParameterfv
= _mesa_GetTexLevelParameterfv
;
238 exec
->GetTexLevelParameteriv
= _mesa_GetTexLevelParameteriv
;
239 exec
->GetTexParameterfv
= _mesa_GetTexParameterfv
;
240 exec
->GetTexParameteriv
= _mesa_GetTexParameteriv
;
241 exec
->Hint
= _mesa_Hint
;
242 exec
->IndexMask
= _mesa_IndexMask
;
243 exec
->Indexd
= _mesa_Indexd
;
244 exec
->Indexdv
= _mesa_Indexdv
;
245 exec
->Indexf
= _mesa_Indexf
;
246 exec
->Indexfv
= _mesa_Indexfv
;
247 exec
->Indexi
= _mesa_Indexi
;
248 exec
->Indexiv
= _mesa_Indexiv
;
249 exec
->Indexs
= _mesa_Indexs
;
250 exec
->Indexsv
= _mesa_Indexsv
;
251 exec
->InitNames
= _mesa_InitNames
;
252 exec
->IsEnabled
= _mesa_IsEnabled
;
253 exec
->IsList
= _mesa_IsList
;
254 exec
->LightModelf
= _mesa_LightModelf
;
255 exec
->LightModelfv
= _mesa_LightModelfv
;
256 exec
->LightModeli
= _mesa_LightModeli
;
257 exec
->LightModeliv
= _mesa_LightModeliv
;
258 exec
->Lightf
= _mesa_Lightf
;
259 exec
->Lightfv
= _mesa_Lightfv
;
260 exec
->Lighti
= _mesa_Lighti
;
261 exec
->Lightiv
= _mesa_Lightiv
;
262 exec
->LineStipple
= _mesa_LineStipple
;
263 exec
->LineWidth
= _mesa_LineWidth
;
264 exec
->ListBase
= _mesa_ListBase
;
265 exec
->LoadIdentity
= _mesa_LoadIdentity
;
266 exec
->LoadMatrixd
= _mesa_LoadMatrixd
;
267 exec
->LoadMatrixf
= _mesa_LoadMatrixf
;
268 exec
->LoadName
= _mesa_LoadName
;
269 exec
->LogicOp
= _mesa_LogicOp
;
270 exec
->Map1d
= _mesa_Map1d
;
271 exec
->Map1f
= _mesa_Map1f
;
272 exec
->Map2d
= _mesa_Map2d
;
273 exec
->Map2f
= _mesa_Map2f
;
274 exec
->MapGrid1d
= _mesa_MapGrid1d
;
275 exec
->MapGrid1f
= _mesa_MapGrid1f
;
276 exec
->MapGrid2d
= _mesa_MapGrid2d
;
277 exec
->MapGrid2f
= _mesa_MapGrid2f
;
278 exec
->Materialf
= _mesa_Materialf
;
279 exec
->Materialfv
= _mesa_Materialfv
;
280 exec
->Materiali
= _mesa_Materiali
;
281 exec
->Materialiv
= _mesa_Materialiv
;
282 exec
->MatrixMode
= _mesa_MatrixMode
;
283 exec
->MultMatrixd
= _mesa_MultMatrixd
;
284 exec
->MultMatrixf
= _mesa_MultMatrixf
;
285 exec
->NewList
= _mesa_NewList
;
286 exec
->Normal3b
= _mesa_Normal3b
;
287 exec
->Normal3bv
= _mesa_Normal3bv
;
288 exec
->Normal3d
= _mesa_Normal3d
;
289 exec
->Normal3dv
= _mesa_Normal3dv
;
290 exec
->Normal3f
= _mesa_Normal3f
;
291 exec
->Normal3fv
= _mesa_Normal3fv
;
292 exec
->Normal3i
= _mesa_Normal3i
;
293 exec
->Normal3iv
= _mesa_Normal3iv
;
294 exec
->Normal3s
= _mesa_Normal3s
;
295 exec
->Normal3sv
= _mesa_Normal3sv
;
296 exec
->Ortho
= _mesa_Ortho
;
297 exec
->PassThrough
= _mesa_PassThrough
;
298 exec
->PixelMapfv
= _mesa_PixelMapfv
;
299 exec
->PixelMapuiv
= _mesa_PixelMapuiv
;
300 exec
->PixelMapusv
= _mesa_PixelMapusv
;
301 exec
->PixelStoref
= _mesa_PixelStoref
;
302 exec
->PixelStorei
= _mesa_PixelStorei
;
303 exec
->PixelTransferf
= _mesa_PixelTransferf
;
304 exec
->PixelTransferi
= _mesa_PixelTransferi
;
305 exec
->PixelZoom
= _mesa_PixelZoom
;
306 exec
->PointSize
= _mesa_PointSize
;
307 exec
->PolygonMode
= _mesa_PolygonMode
;
308 exec
->PolygonOffset
= _mesa_PolygonOffset
;
309 exec
->PolygonStipple
= _mesa_PolygonStipple
;
310 exec
->PopAttrib
= _mesa_PopAttrib
;
311 exec
->PopMatrix
= _mesa_PopMatrix
;
312 exec
->PopName
= _mesa_PopName
;
313 exec
->PushAttrib
= _mesa_PushAttrib
;
314 exec
->PushMatrix
= _mesa_PushMatrix
;
315 exec
->PushName
= _mesa_PushName
;
316 exec
->RasterPos2d
= _mesa_RasterPos2d
;
317 exec
->RasterPos2dv
= _mesa_RasterPos2dv
;
318 exec
->RasterPos2f
= _mesa_RasterPos2f
;
319 exec
->RasterPos2fv
= _mesa_RasterPos2fv
;
320 exec
->RasterPos2i
= _mesa_RasterPos2i
;
321 exec
->RasterPos2iv
= _mesa_RasterPos2iv
;
322 exec
->RasterPos2s
= _mesa_RasterPos2s
;
323 exec
->RasterPos2sv
= _mesa_RasterPos2sv
;
324 exec
->RasterPos3d
= _mesa_RasterPos3d
;
325 exec
->RasterPos3dv
= _mesa_RasterPos3dv
;
326 exec
->RasterPos3f
= _mesa_RasterPos3f
;
327 exec
->RasterPos3fv
= _mesa_RasterPos3fv
;
328 exec
->RasterPos3i
= _mesa_RasterPos3i
;
329 exec
->RasterPos3iv
= _mesa_RasterPos3iv
;
330 exec
->RasterPos3s
= _mesa_RasterPos3s
;
331 exec
->RasterPos3sv
= _mesa_RasterPos3sv
;
332 exec
->RasterPos4d
= _mesa_RasterPos4d
;
333 exec
->RasterPos4dv
= _mesa_RasterPos4dv
;
334 exec
->RasterPos4f
= _mesa_RasterPos4f
;
335 exec
->RasterPos4fv
= _mesa_RasterPos4fv
;
336 exec
->RasterPos4i
= _mesa_RasterPos4i
;
337 exec
->RasterPos4iv
= _mesa_RasterPos4iv
;
338 exec
->RasterPos4s
= _mesa_RasterPos4s
;
339 exec
->RasterPos4sv
= _mesa_RasterPos4sv
;
340 exec
->ReadBuffer
= _mesa_ReadBuffer
;
341 exec
->ReadPixels
= _mesa_ReadPixels
;
342 exec
->Rectd
= _mesa_Rectd
;
343 exec
->Rectdv
= _mesa_Rectdv
;
344 exec
->Rectf
= _mesa_Rectf
;
345 exec
->Rectfv
= _mesa_Rectfv
;
346 exec
->Recti
= _mesa_Recti
;
347 exec
->Rectiv
= _mesa_Rectiv
;
348 exec
->Rects
= _mesa_Rects
;
349 exec
->Rectsv
= _mesa_Rectsv
;
350 exec
->RenderMode
= _mesa_RenderMode
;
351 exec
->Rotated
= _mesa_Rotated
;
352 exec
->Rotatef
= _mesa_Rotatef
;
353 exec
->Scaled
= _mesa_Scaled
;
354 exec
->Scalef
= _mesa_Scalef
;
355 exec
->Scissor
= _mesa_Scissor
;
356 exec
->SelectBuffer
= _mesa_SelectBuffer
;
357 exec
->ShadeModel
= _mesa_ShadeModel
;
358 exec
->StencilFunc
= _mesa_StencilFunc
;
359 exec
->StencilMask
= _mesa_StencilMask
;
360 exec
->StencilOp
= _mesa_StencilOp
;
361 exec
->TexCoord1d
= _mesa_TexCoord1d
;
362 exec
->TexCoord1dv
= _mesa_TexCoord1dv
;
363 exec
->TexCoord1f
= _mesa_TexCoord1f
;
364 exec
->TexCoord1fv
= _mesa_TexCoord1fv
;
365 exec
->TexCoord1i
= _mesa_TexCoord1i
;
366 exec
->TexCoord1iv
= _mesa_TexCoord1iv
;
367 exec
->TexCoord1s
= _mesa_TexCoord1s
;
368 exec
->TexCoord1sv
= _mesa_TexCoord1sv
;
369 exec
->TexCoord2d
= _mesa_TexCoord2d
;
370 exec
->TexCoord2dv
= _mesa_TexCoord2dv
;
371 exec
->TexCoord2f
= _mesa_TexCoord2f
;
372 exec
->TexCoord2fv
= _mesa_TexCoord2fv
;
373 exec
->TexCoord2i
= _mesa_TexCoord2i
;
374 exec
->TexCoord2iv
= _mesa_TexCoord2iv
;
375 exec
->TexCoord2s
= _mesa_TexCoord2s
;
376 exec
->TexCoord2sv
= _mesa_TexCoord2sv
;
377 exec
->TexCoord3d
= _mesa_TexCoord3d
;
378 exec
->TexCoord3dv
= _mesa_TexCoord3dv
;
379 exec
->TexCoord3f
= _mesa_TexCoord3f
;
380 exec
->TexCoord3fv
= _mesa_TexCoord3fv
;
381 exec
->TexCoord3i
= _mesa_TexCoord3i
;
382 exec
->TexCoord3iv
= _mesa_TexCoord3iv
;
383 exec
->TexCoord3s
= _mesa_TexCoord3s
;
384 exec
->TexCoord3sv
= _mesa_TexCoord3sv
;
385 exec
->TexCoord4d
= _mesa_TexCoord4d
;
386 exec
->TexCoord4dv
= _mesa_TexCoord4dv
;
387 exec
->TexCoord4f
= _mesa_TexCoord4f
;
388 exec
->TexCoord4fv
= _mesa_TexCoord4fv
;
389 exec
->TexCoord4i
= _mesa_TexCoord4i
;
390 exec
->TexCoord4iv
= _mesa_TexCoord4iv
;
391 exec
->TexCoord4s
= _mesa_TexCoord4s
;
392 exec
->TexCoord4sv
= _mesa_TexCoord4sv
;
393 exec
->TexEnvf
= _mesa_TexEnvf
;
394 exec
->TexEnvfv
= _mesa_TexEnvfv
;
395 exec
->TexEnvi
= _mesa_TexEnvi
;
396 exec
->TexEnviv
= _mesa_TexEnviv
;
397 exec
->TexGend
= _mesa_TexGend
;
398 exec
->TexGendv
= _mesa_TexGendv
;
399 exec
->TexGenf
= _mesa_TexGenf
;
400 exec
->TexGenfv
= _mesa_TexGenfv
;
401 exec
->TexGeni
= _mesa_TexGeni
;
402 exec
->TexGeniv
= _mesa_TexGeniv
;
403 exec
->TexImage1D
= _mesa_TexImage1D
;
404 exec
->TexImage2D
= _mesa_TexImage2D
;
405 exec
->TexParameterf
= _mesa_TexParameterf
;
406 exec
->TexParameterfv
= _mesa_TexParameterfv
;
407 exec
->TexParameteri
= _mesa_TexParameteri
;
408 exec
->TexParameteriv
= _mesa_TexParameteriv
;
409 exec
->Translated
= _mesa_Translated
;
410 exec
->Translatef
= _mesa_Translatef
;
411 exec
->Vertex2d
= _mesa_Vertex2d
;
412 exec
->Vertex2dv
= _mesa_Vertex2dv
;
413 exec
->Vertex2f
= _mesa_Vertex2f
;
414 exec
->Vertex2fv
= _mesa_Vertex2fv
;
415 exec
->Vertex2i
= _mesa_Vertex2i
;
416 exec
->Vertex2iv
= _mesa_Vertex2iv
;
417 exec
->Vertex2s
= _mesa_Vertex2s
;
418 exec
->Vertex2sv
= _mesa_Vertex2sv
;
419 exec
->Vertex3d
= _mesa_Vertex3d
;
420 exec
->Vertex3dv
= _mesa_Vertex3dv
;
421 exec
->Vertex3f
= _mesa_Vertex3f
;
422 exec
->Vertex3fv
= _mesa_Vertex3fv
;
423 exec
->Vertex3i
= _mesa_Vertex3i
;
424 exec
->Vertex3iv
= _mesa_Vertex3iv
;
425 exec
->Vertex3s
= _mesa_Vertex3s
;
426 exec
->Vertex3sv
= _mesa_Vertex3sv
;
427 exec
->Vertex4d
= _mesa_Vertex4d
;
428 exec
->Vertex4dv
= _mesa_Vertex4dv
;
429 exec
->Vertex4f
= _mesa_Vertex4f
;
430 exec
->Vertex4fv
= _mesa_Vertex4fv
;
431 exec
->Vertex4i
= _mesa_Vertex4i
;
432 exec
->Vertex4iv
= _mesa_Vertex4iv
;
433 exec
->Vertex4s
= _mesa_Vertex4s
;
434 exec
->Vertex4sv
= _mesa_Vertex4sv
;
435 exec
->Viewport
= _mesa_Viewport
;
438 exec
->AreTexturesResident
= _mesa_AreTexturesResident
;
439 exec
->ArrayElement
= _mesa_ArrayElement
;
440 exec
->BindTexture
= _mesa_BindTexture
;
441 exec
->ColorPointer
= _mesa_ColorPointer
;
442 exec
->CopyTexImage1D
= _mesa_CopyTexImage1D
;
443 exec
->CopyTexImage2D
= _mesa_CopyTexImage2D
;
444 exec
->CopyTexSubImage1D
= _mesa_CopyTexSubImage1D
;
445 exec
->CopyTexSubImage2D
= _mesa_CopyTexSubImage2D
;
446 exec
->DeleteTextures
= _mesa_DeleteTextures
;
447 exec
->DisableClientState
= _mesa_DisableClientState
;
448 exec
->DrawArrays
= _mesa_DrawArrays
;
449 exec
->DrawElements
= _mesa_DrawElements
;
450 exec
->EdgeFlagPointer
= _mesa_EdgeFlagPointer
;
451 exec
->EnableClientState
= _mesa_EnableClientState
;
452 exec
->GenTextures
= _mesa_GenTextures
;
453 exec
->GetPointerv
= _mesa_GetPointerv
;
454 exec
->IndexPointer
= _mesa_IndexPointer
;
455 exec
->Indexub
= _mesa_Indexub
;
456 exec
->Indexubv
= _mesa_Indexubv
;
457 exec
->InterleavedArrays
= _mesa_InterleavedArrays
;
458 exec
->IsTexture
= _mesa_IsTexture
;
459 exec
->NormalPointer
= _mesa_NormalPointer
;
460 exec
->PopClientAttrib
= _mesa_PopClientAttrib
;
461 exec
->PrioritizeTextures
= _mesa_PrioritizeTextures
;
462 exec
->PushClientAttrib
= _mesa_PushClientAttrib
;
463 exec
->TexCoordPointer
= _mesa_TexCoordPointer
;
464 exec
->TexSubImage1D
= _mesa_TexSubImage1D
;
465 exec
->TexSubImage2D
= _mesa_TexSubImage2D
;
466 exec
->VertexPointer
= _mesa_VertexPointer
;
469 exec
->CopyTexSubImage3D
= _mesa_CopyTexSubImage3D
;
470 exec
->DrawRangeElements
= _mesa_DrawRangeElements
;
471 exec
->TexImage3D
= _mesa_TexImage3D
;
472 exec
->TexSubImage3D
= _mesa_TexSubImage3D
;
474 /* OpenGL 1.2 GL_ARB_imaging */
475 exec
->BlendColor
= _mesa_BlendColor
;
476 exec
->BlendEquation
= _mesa_BlendEquation
;
477 exec
->ColorSubTable
= _mesa_ColorSubTable
;
478 exec
->ColorTable
= _mesa_ColorTable
;
479 exec
->ColorTableParameterfv
= _mesa_ColorTableParameterfv
;
480 exec
->ColorTableParameteriv
= _mesa_ColorTableParameteriv
;
481 exec
->ConvolutionFilter1D
= _mesa_ConvolutionFilter1D
;
482 exec
->ConvolutionFilter2D
= _mesa_ConvolutionFilter2D
;
483 exec
->ConvolutionParameterf
= _mesa_ConvolutionParameterf
;
484 exec
->ConvolutionParameterfv
= _mesa_ConvolutionParameterfv
;
485 exec
->ConvolutionParameteri
= _mesa_ConvolutionParameteri
;
486 exec
->ConvolutionParameteriv
= _mesa_ConvolutionParameteriv
;
487 exec
->CopyColorSubTable
= _mesa_CopyColorSubTable
;
488 exec
->CopyColorTable
= _mesa_CopyColorTable
;
489 exec
->CopyConvolutionFilter1D
= _mesa_CopyConvolutionFilter1D
;
490 exec
->CopyConvolutionFilter2D
= _mesa_CopyConvolutionFilter2D
;
491 exec
->GetColorTable
= _mesa_GetColorTable
;
492 exec
->GetColorTableParameterfv
= _mesa_GetColorTableParameterfv
;
493 exec
->GetColorTableParameteriv
= _mesa_GetColorTableParameteriv
;
494 exec
->GetConvolutionFilter
= _mesa_GetConvolutionFilter
;
495 exec
->GetConvolutionParameterfv
= _mesa_GetConvolutionParameterfv
;
496 exec
->GetConvolutionParameteriv
= _mesa_GetConvolutionParameteriv
;
497 exec
->GetHistogram
= _mesa_GetHistogram
;
498 exec
->GetHistogramParameterfv
= _mesa_GetHistogramParameterfv
;
499 exec
->GetHistogramParameteriv
= _mesa_GetHistogramParameteriv
;
500 exec
->GetMinmax
= _mesa_GetMinmax
;
501 exec
->GetMinmaxParameterfv
= _mesa_GetMinmaxParameterfv
;
502 exec
->GetMinmaxParameteriv
= _mesa_GetMinmaxParameteriv
;
503 exec
->GetSeparableFilter
= _mesa_GetSeparableFilter
;
504 exec
->Histogram
= _mesa_Histogram
;
505 exec
->Minmax
= _mesa_Minmax
;
506 exec
->ResetHistogram
= _mesa_ResetHistogram
;
507 exec
->ResetMinmax
= _mesa_ResetMinmax
;
508 exec
->SeparableFilter2D
= _mesa_SeparableFilter2D
;
510 /* 2. GL_EXT_blend_color */
512 exec
->BlendColorEXT
= _mesa_BlendColorEXT
;
515 /* 3. GL_EXT_polygon_offset */
516 exec
->PolygonOffsetEXT
= _mesa_PolygonOffsetEXT
;
518 /* 6. GL_EXT_texture3d */
520 exec
->CopyTexSubImage3DEXT
= _mesa_CopyTexSubImage3D
;
521 exec
->TexImage3DEXT
= _mesa_TexImage3DEXT
;
522 exec
->TexSubImage3DEXT
= _mesa_TexSubImage3D
;
525 /* 11. GL_EXT_histogram */
526 exec
->GetHistogramEXT
= _mesa_GetHistogram
;
527 exec
->GetHistogramParameterfvEXT
= _mesa_GetHistogramParameterfv
;
528 exec
->GetHistogramParameterivEXT
= _mesa_GetHistogramParameteriv
;
529 exec
->GetMinmaxEXT
= _mesa_GetMinmax
;
530 exec
->GetMinmaxParameterfvEXT
= _mesa_GetMinmaxParameterfv
;
531 exec
->GetMinmaxParameterivEXT
= _mesa_GetMinmaxParameteriv
;
533 /* ?. GL_SGIX_pixel_texture */
534 exec
->PixelTexGenSGIX
= _mesa_PixelTexGenSGIX
;
536 /* 15. GL_SGIS_pixel_texture */
537 exec
->PixelTexGenParameteriSGIS
= _mesa_PixelTexGenParameteriSGIS
;
538 exec
->PixelTexGenParameterivSGIS
= _mesa_PixelTexGenParameterivSGIS
;
539 exec
->PixelTexGenParameterfSGIS
= _mesa_PixelTexGenParameterfSGIS
;
540 exec
->PixelTexGenParameterfvSGIS
= _mesa_PixelTexGenParameterfvSGIS
;
541 exec
->GetPixelTexGenParameterivSGIS
= _mesa_GetPixelTexGenParameterivSGIS
;
542 exec
->GetPixelTexGenParameterfvSGIS
= _mesa_GetPixelTexGenParameterfvSGIS
;
544 /* 30. GL_EXT_vertex_array */
545 exec
->ColorPointerEXT
= _mesa_ColorPointerEXT
;
546 exec
->EdgeFlagPointerEXT
= _mesa_EdgeFlagPointerEXT
;
547 exec
->IndexPointerEXT
= _mesa_IndexPointerEXT
;
548 exec
->NormalPointerEXT
= _mesa_NormalPointerEXT
;
549 exec
->TexCoordPointerEXT
= _mesa_TexCoordPointerEXT
;
550 exec
->VertexPointerEXT
= _mesa_VertexPointerEXT
;
552 /* 37. GL_EXT_blend_minmax */
554 exec
->BlendEquationEXT
= _mesa_BlendEquationEXT
;
557 /* 54. GL_EXT_point_parameters */
558 exec
->PointParameterfEXT
= _mesa_PointParameterfEXT
;
559 exec
->PointParameterfvEXT
= _mesa_PointParameterfvEXT
;
561 /* 77. GL_PGI_misc_hints */
562 exec
->HintPGI
= _mesa_HintPGI
;
564 /* 78. GL_EXT_paletted_texture */
566 exec
->ColorTableEXT
= _mesa_ColorTableEXT
;
567 exec
->ColorSubTableEXT
= _mesa_ColorSubTableEXT
;
569 exec
->GetColorTableEXT
= _mesa_GetColorTable
;
570 exec
->GetColorTableParameterfvEXT
= _mesa_GetColorTableParameterfv
;
571 exec
->GetColorTableParameterivEXT
= _mesa_GetColorTableParameteriv
;
573 /* 97. GL_EXT_compiled_vertex_array */
574 exec
->LockArraysEXT
= _mesa_LockArraysEXT
;
575 exec
->UnlockArraysEXT
= _mesa_UnlockArraysEXT
;
577 /* 173. GL_INGR_blend_func_separate */
578 exec
->BlendFuncSeparateEXT
= _mesa_BlendFuncSeparateEXT
;
580 /* 196. GL_MESA_resize_buffers */
581 exec
->ResizeBuffersMESA
= _mesa_ResizeBuffersMESA
;
583 /* 197. GL_MESA_window_pos */
584 exec
->WindowPos2dMESA
= _mesa_WindowPos2dMESA
;
585 exec
->WindowPos2dvMESA
= _mesa_WindowPos2dvMESA
;
586 exec
->WindowPos2fMESA
= _mesa_WindowPos2fMESA
;
587 exec
->WindowPos2fvMESA
= _mesa_WindowPos2fvMESA
;
588 exec
->WindowPos2iMESA
= _mesa_WindowPos2iMESA
;
589 exec
->WindowPos2ivMESA
= _mesa_WindowPos2ivMESA
;
590 exec
->WindowPos2sMESA
= _mesa_WindowPos2sMESA
;
591 exec
->WindowPos2svMESA
= _mesa_WindowPos2svMESA
;
592 exec
->WindowPos3dMESA
= _mesa_WindowPos3dMESA
;
593 exec
->WindowPos3dvMESA
= _mesa_WindowPos3dvMESA
;
594 exec
->WindowPos3fMESA
= _mesa_WindowPos3fMESA
;
595 exec
->WindowPos3fvMESA
= _mesa_WindowPos3fvMESA
;
596 exec
->WindowPos3iMESA
= _mesa_WindowPos3iMESA
;
597 exec
->WindowPos3ivMESA
= _mesa_WindowPos3ivMESA
;
598 exec
->WindowPos3sMESA
= _mesa_WindowPos3sMESA
;
599 exec
->WindowPos3svMESA
= _mesa_WindowPos3svMESA
;
600 exec
->WindowPos4dMESA
= _mesa_WindowPos4dMESA
;
601 exec
->WindowPos4dvMESA
= _mesa_WindowPos4dvMESA
;
602 exec
->WindowPos4fMESA
= _mesa_WindowPos4fMESA
;
603 exec
->WindowPos4fvMESA
= _mesa_WindowPos4fvMESA
;
604 exec
->WindowPos4iMESA
= _mesa_WindowPos4iMESA
;
605 exec
->WindowPos4ivMESA
= _mesa_WindowPos4ivMESA
;
606 exec
->WindowPos4sMESA
= _mesa_WindowPos4sMESA
;
607 exec
->WindowPos4svMESA
= _mesa_WindowPos4svMESA
;
609 /* ARB 1. GL_ARB_multitexture */
610 exec
->ActiveTextureARB
= _mesa_ActiveTextureARB
;
611 exec
->ClientActiveTextureARB
= _mesa_ClientActiveTextureARB
;
612 exec
->MultiTexCoord1dARB
= _mesa_MultiTexCoord1dARB
;
613 exec
->MultiTexCoord1dvARB
= _mesa_MultiTexCoord1dvARB
;
614 exec
->MultiTexCoord1fARB
= _mesa_MultiTexCoord1fARB
;
615 exec
->MultiTexCoord1fvARB
= _mesa_MultiTexCoord1fvARB
;
616 exec
->MultiTexCoord1iARB
= _mesa_MultiTexCoord1iARB
;
617 exec
->MultiTexCoord1ivARB
= _mesa_MultiTexCoord1ivARB
;
618 exec
->MultiTexCoord1sARB
= _mesa_MultiTexCoord1sARB
;
619 exec
->MultiTexCoord1svARB
= _mesa_MultiTexCoord1svARB
;
620 exec
->MultiTexCoord2dARB
= _mesa_MultiTexCoord2dARB
;
621 exec
->MultiTexCoord2dvARB
= _mesa_MultiTexCoord2dvARB
;
622 exec
->MultiTexCoord2fARB
= _mesa_MultiTexCoord2fARB
;
623 exec
->MultiTexCoord2fvARB
= _mesa_MultiTexCoord2fvARB
;
624 exec
->MultiTexCoord2iARB
= _mesa_MultiTexCoord2iARB
;
625 exec
->MultiTexCoord2ivARB
= _mesa_MultiTexCoord2ivARB
;
626 exec
->MultiTexCoord2sARB
= _mesa_MultiTexCoord2sARB
;
627 exec
->MultiTexCoord2svARB
= _mesa_MultiTexCoord2svARB
;
628 exec
->MultiTexCoord3dARB
= _mesa_MultiTexCoord3dARB
;
629 exec
->MultiTexCoord3dvARB
= _mesa_MultiTexCoord3dvARB
;
630 exec
->MultiTexCoord3fARB
= _mesa_MultiTexCoord3fARB
;
631 exec
->MultiTexCoord3fvARB
= _mesa_MultiTexCoord3fvARB
;
632 exec
->MultiTexCoord3iARB
= _mesa_MultiTexCoord3iARB
;
633 exec
->MultiTexCoord3ivARB
= _mesa_MultiTexCoord3ivARB
;
634 exec
->MultiTexCoord3sARB
= _mesa_MultiTexCoord3sARB
;
635 exec
->MultiTexCoord3svARB
= _mesa_MultiTexCoord3svARB
;
636 exec
->MultiTexCoord4dARB
= _mesa_MultiTexCoord4dARB
;
637 exec
->MultiTexCoord4dvARB
= _mesa_MultiTexCoord4dvARB
;
638 exec
->MultiTexCoord4fARB
= _mesa_MultiTexCoord4fARB
;
639 exec
->MultiTexCoord4fvARB
= _mesa_MultiTexCoord4fvARB
;
640 exec
->MultiTexCoord4iARB
= _mesa_MultiTexCoord4iARB
;
641 exec
->MultiTexCoord4ivARB
= _mesa_MultiTexCoord4ivARB
;
642 exec
->MultiTexCoord4sARB
= _mesa_MultiTexCoord4sARB
;
643 exec
->MultiTexCoord4svARB
= _mesa_MultiTexCoord4svARB
;
645 /* ARB 3. GL_ARB_transpose_matrix */
646 exec
->LoadTransposeMatrixdARB
= _mesa_LoadTransposeMatrixdARB
;
647 exec
->LoadTransposeMatrixfARB
= _mesa_LoadTransposeMatrixfARB
;
648 exec
->MultTransposeMatrixdARB
= _mesa_MultTransposeMatrixdARB
;
649 exec
->MultTransposeMatrixfARB
= _mesa_MultTransposeMatrixfARB
;
651 /* ARB 12. GL_ARB_texture_compression */
652 exec
->CompressedTexImage3DARB
= _mesa_CompressedTexImage3DARB
;
653 exec
->CompressedTexImage2DARB
= _mesa_CompressedTexImage2DARB
;
654 exec
->CompressedTexImage1DARB
= _mesa_CompressedTexImage1DARB
;
655 exec
->CompressedTexSubImage3DARB
= _mesa_CompressedTexSubImage3DARB
;
656 exec
->CompressedTexSubImage2DARB
= _mesa_CompressedTexSubImage2DARB
;
657 exec
->CompressedTexSubImage1DARB
= _mesa_CompressedTexSubImage1DARB
;
658 exec
->GetCompressedTexImageARB
= _mesa_GetCompressedTexImageARB
;
664 /**********************************************************************/
665 /***** State update logic *****/
666 /**********************************************************************/
669 static void update_fog_mode( GLcontext
*ctx
)
671 int old_mode
= ctx
->FogMode
;
673 if (ctx
->Fog
.Enabled
) {
674 if (ctx
->Texture
.ReallyEnabled
)
675 ctx
->FogMode
= FOG_FRAGMENT
;
676 else if (ctx
->Hint
.Fog
== GL_NICEST
)
677 ctx
->FogMode
= FOG_FRAGMENT
;
679 ctx
->FogMode
= FOG_VERTEX
;
681 if (ctx
->Driver
.GetParameteri
)
682 if ((ctx
->Driver
.GetParameteri
)( ctx
, DD_HAVE_HARDWARE_FOG
))
683 ctx
->FogMode
= FOG_FRAGMENT
;
686 ctx
->FogMode
= FOG_NONE
;
689 if (old_mode
!= ctx
->FogMode
)
690 ctx
->NewState
|= NEW_FOG
;
695 * Recompute the value of ctx->RasterMask, etc. according to
696 * the current context.
698 static void update_rasterflags( GLcontext
*ctx
)
702 if (ctx
->Color
.AlphaEnabled
) ctx
->RasterMask
|= ALPHATEST_BIT
;
703 if (ctx
->Color
.BlendEnabled
) ctx
->RasterMask
|= BLEND_BIT
;
704 if (ctx
->Depth
.Test
) ctx
->RasterMask
|= DEPTH_BIT
;
705 if (ctx
->FogMode
== FOG_FRAGMENT
) ctx
->RasterMask
|= FOG_BIT
;
706 if (ctx
->Scissor
.Enabled
) ctx
->RasterMask
|= SCISSOR_BIT
;
707 if (ctx
->Stencil
.Enabled
) ctx
->RasterMask
|= STENCIL_BIT
;
708 if (ctx
->Visual
.RGBAflag
) {
709 const GLuint colorMask
= *((GLuint
*) &ctx
->Color
.ColorMask
);
710 if (colorMask
!= 0xffffffff) ctx
->RasterMask
|= MASKING_BIT
;
711 if (ctx
->Color
.ColorLogicOpEnabled
) ctx
->RasterMask
|= LOGIC_OP_BIT
;
712 if (ctx
->Texture
.ReallyEnabled
) ctx
->RasterMask
|= TEXTURE_BIT
;
715 if (ctx
->Color
.IndexMask
!= 0xffffffff) ctx
->RasterMask
|= MASKING_BIT
;
716 if (ctx
->Color
.IndexLogicOpEnabled
) ctx
->RasterMask
|= LOGIC_OP_BIT
;
719 if (ctx
->DrawBuffer
->UseSoftwareAlphaBuffers
720 && ctx
->Color
.ColorMask
[ACOMP
]
721 && ctx
->Color
.DrawBuffer
!= GL_NONE
)
722 ctx
->RasterMask
|= ALPHABUF_BIT
;
724 if ( ctx
->Viewport
.X
< 0
725 || ctx
->Viewport
.X
+ ctx
->Viewport
.Width
> ctx
->DrawBuffer
->Width
726 || ctx
->Viewport
.Y
< 0
727 || ctx
->Viewport
.Y
+ ctx
->Viewport
.Height
> ctx
->DrawBuffer
->Height
) {
728 ctx
->RasterMask
|= WINCLIP_BIT
;
731 if (ctx
->Depth
.OcclusionTest
)
732 ctx
->RasterMask
|= OCCLUSION_BIT
;
735 /* If we're not drawing to exactly one color buffer set the
736 * MULTI_DRAW_BIT flag. Also set it if we're drawing to no
737 * buffers or the RGBA or CI mask disables all writes.
739 ctx
->TriangleCaps
&= ~DD_MULTIDRAW
;
741 if (ctx
->Color
.MultiDrawBuffer
) {
742 ctx
->RasterMask
|= MULTI_DRAW_BIT
;
743 ctx
->TriangleCaps
|= DD_MULTIDRAW
;
745 else if (ctx
->Color
.DrawBuffer
==GL_NONE
) {
746 ctx
->RasterMask
|= MULTI_DRAW_BIT
;
747 ctx
->TriangleCaps
|= DD_MULTIDRAW
;
749 else if (ctx
->Visual
.RGBAflag
&& *((GLuint
*) ctx
->Color
.ColorMask
) == 0) {
750 /* all RGBA channels disabled */
751 ctx
->RasterMask
|= MULTI_DRAW_BIT
;
752 ctx
->TriangleCaps
|= DD_MULTIDRAW
;
754 else if (!ctx
->Visual
.RGBAflag
&& ctx
->Color
.IndexMask
==0) {
755 /* all color index bits disabled */
756 ctx
->RasterMask
|= MULTI_DRAW_BIT
;
757 ctx
->TriangleCaps
|= DD_MULTIDRAW
;
762 void gl_print_state( const char *msg
, GLuint state
)
765 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
768 (state
& NEW_LIGHTING
) ? "lighting, " : "",
769 (state
& NEW_RASTER_OPS
) ? "raster-ops, " : "",
770 (state
& NEW_TEXTURING
) ? "texturing, " : "",
771 (state
& NEW_POLYGON
) ? "polygon, " : "",
772 (state
& NEW_MODELVIEW
) ? "modelview, " : "",
773 (state
& NEW_PROJECTION
) ? "projection, " : "",
774 (state
& NEW_TEXTURE_MATRIX
) ? "texture-matrix, " : "",
775 (state
& NEW_USER_CLIP
) ? "user-clip, " : "",
776 (state
& NEW_TEXTURE_ENV
) ? "texture-env, " : "",
777 (state
& NEW_CLIENT_STATE
) ? "client-state, " : "",
778 (state
& NEW_FOG
) ? "fog, " : "",
779 (state
& NEW_NORMAL_TRANSFORM
) ? "normal-transform, " : "",
780 (state
& NEW_VIEWPORT
) ? "viewport, " : "",
781 (state
& NEW_TEXTURE_ENABLE
) ? "texture-enable, " : "");
785 void gl_print_enable_flags( const char *msg
, GLuint flags
)
788 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s\n",
791 (flags
& ENABLE_TEX0
) ? "tex-0, " : "",
792 (flags
& ENABLE_TEX1
) ? "tex-1, " : "",
793 (flags
& ENABLE_LIGHT
) ? "light, " : "",
794 (flags
& ENABLE_FOG
) ? "fog, " : "",
795 (flags
& ENABLE_USERCLIP
) ? "userclip, " : "",
796 (flags
& ENABLE_TEXGEN0
) ? "tex-gen-0, " : "",
797 (flags
& ENABLE_TEXGEN1
) ? "tex-gen-1, " : "",
798 (flags
& ENABLE_TEXMAT0
) ? "tex-mat-0, " : "",
799 (flags
& ENABLE_TEXMAT1
) ? "tex-mat-1, " : "",
800 (flags
& ENABLE_NORMALIZE
) ? "normalize, " : "",
801 (flags
& ENABLE_RESCALE
) ? "rescale, " : "");
806 * If ctx->NewState is non-zero then this function MUST be called before
807 * rendering any primitive. Basically, function pointers and miscellaneous
808 * flags are updated to reflect the current state of the state machine.
810 void gl_update_state( GLcontext
*ctx
)
814 if (MESA_VERBOSE
& VERBOSE_STATE
)
815 gl_print_state("", ctx
->NewState
);
817 if (ctx
->NewState
& NEW_CLIENT_STATE
)
818 gl_update_client_state( ctx
);
820 if ((ctx
->NewState
& NEW_TEXTURE_ENABLE
) &&
821 (ctx
->Enabled
& ENABLE_TEX_ANY
) != ctx
->Texture
.ReallyEnabled
)
822 ctx
->NewState
|= NEW_TEXTURING
| NEW_RASTER_OPS
;
824 if (ctx
->NewState
& NEW_TEXTURE_ENV
) {
825 if (ctx
->Texture
.Unit
[0].EnvMode
== ctx
->Texture
.Unit
[0].LastEnvMode
&&
826 ctx
->Texture
.Unit
[1].EnvMode
== ctx
->Texture
.Unit
[1].LastEnvMode
827 #if MAX_TEXTURE_UNITS > 2
828 && ctx
->Texture
.Unit
[2].EnvMode
== ctx
->Texture
.Unit
[2].LastEnvMode
)
831 ctx
->NewState
&= ~NEW_TEXTURE_ENV
;
833 ctx
->Texture
.Unit
[0].LastEnvMode
= ctx
->Texture
.Unit
[0].EnvMode
;
834 ctx
->Texture
.Unit
[1].LastEnvMode
= ctx
->Texture
.Unit
[1].EnvMode
;
835 #if MAX_TEXTURE_UNITS > 2
836 ctx
->Texture
.Unit
[2].LastEnvMode
= ctx
->Texture
.Unit
[2].EnvMode
;
840 if (ctx
->NewState
& NEW_TEXTURE_MATRIX
) {
841 ctx
->Enabled
&= ~(ENABLE_TEXMAT0
| ENABLE_TEXMAT1
| ENABLE_TEXMAT2
);
843 for (i
=0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
844 if (ctx
->TextureMatrix
[i
].flags
& MAT_DIRTY_ALL_OVER
) {
845 gl_matrix_analyze( &ctx
->TextureMatrix
[i
] );
846 ctx
->TextureMatrix
[i
].flags
&= ~MAT_DIRTY_DEPENDENTS
;
848 if (ctx
->Texture
.Unit
[i
].Enabled
&&
849 ctx
->TextureMatrix
[i
].type
!= MATRIX_IDENTITY
)
850 ctx
->Enabled
|= ENABLE_TEXMAT0
<< i
;
855 if (ctx
->NewState
& (NEW_TEXTURING
| NEW_TEXTURE_ENABLE
)) {
856 ctx
->Texture
.NeedNormals
= GL_FALSE
;
857 gl_update_dirty_texobjs(ctx
);
858 ctx
->Enabled
&= ~(ENABLE_TEXGEN0
| ENABLE_TEXGEN1
| ENABLE_TEXGEN2
);
859 ctx
->Texture
.ReallyEnabled
= 0;
861 for (i
=0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
862 if (ctx
->Texture
.Unit
[i
].Enabled
) {
863 gl_update_texture_unit( ctx
, &ctx
->Texture
.Unit
[i
] );
865 ctx
->Texture
.ReallyEnabled
|=
866 ctx
->Texture
.Unit
[i
].ReallyEnabled
<< (i
* 4);
868 if (ctx
->Texture
.Unit
[i
].GenFlags
!= 0) {
869 ctx
->Enabled
|= ENABLE_TEXGEN0
<< i
;
871 if (ctx
->Texture
.Unit
[i
].GenFlags
& TEXGEN_NEED_NORMALS
) {
872 ctx
->Texture
.NeedNormals
= GL_TRUE
;
873 ctx
->Texture
.NeedEyeCoords
= GL_TRUE
;
876 if (ctx
->Texture
.Unit
[i
].GenFlags
& TEXGEN_NEED_EYE_COORD
) {
877 ctx
->Texture
.NeedEyeCoords
= GL_TRUE
;
883 ctx
->NeedNormals
= (ctx
->Light
.Enabled
|| ctx
->Texture
.NeedNormals
);
886 if (ctx
->NewState
& NEW_FOG
) {
887 update_fog_mode(ctx
);
890 if (ctx
->NewState
& NEW_RASTER_OPS
) {
891 update_rasterflags(ctx
);
893 /* update scissor region */
894 ctx
->DrawBuffer
->Xmin
= 0;
895 ctx
->DrawBuffer
->Ymin
= 0;
896 ctx
->DrawBuffer
->Xmax
= ctx
->DrawBuffer
->Width
;
897 ctx
->DrawBuffer
->Ymax
= ctx
->DrawBuffer
->Height
;
898 if (ctx
->Scissor
.Enabled
) {
899 if (ctx
->Scissor
.X
> ctx
->DrawBuffer
->Xmin
) {
900 ctx
->DrawBuffer
->Xmin
= ctx
->Scissor
.X
;
902 if (ctx
->Scissor
.Y
> ctx
->DrawBuffer
->Ymin
) {
903 ctx
->DrawBuffer
->Ymin
= ctx
->Scissor
.Y
;
905 if (ctx
->Scissor
.X
+ ctx
->Scissor
.Width
< ctx
->DrawBuffer
->Xmax
) {
906 ctx
->DrawBuffer
->Xmax
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
;
908 if (ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
< ctx
->DrawBuffer
->Ymax
) {
909 ctx
->DrawBuffer
->Ymax
= ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
;
914 if (ctx
->NewState
& NEW_LIGHTING
) {
915 ctx
->TriangleCaps
&= ~(DD_TRI_LIGHT_TWOSIDE
|DD_LIGHTING_CULL
);
916 if (ctx
->Light
.Enabled
) {
917 if (ctx
->Light
.Model
.TwoSide
)
918 ctx
->TriangleCaps
|= (DD_TRI_LIGHT_TWOSIDE
|DD_LIGHTING_CULL
);
919 gl_update_lighting(ctx
);
923 if (ctx
->NewState
& (NEW_POLYGON
| NEW_LIGHTING
)) {
925 ctx
->TriangleCaps
&= ~DD_TRI_CULL_FRONT_BACK
;
927 if (ctx
->NewState
& NEW_POLYGON
) {
928 /* Setup CullBits bitmask */
929 if (ctx
->Polygon
.CullFlag
) {
930 ctx
->backface_sign
= 1;
931 switch(ctx
->Polygon
.CullFaceMode
) {
933 if(ctx
->Polygon
.FrontFace
==GL_CCW
)
934 ctx
->backface_sign
= -1;
935 ctx
->Polygon
.CullBits
= 1;
938 if(ctx
->Polygon
.FrontFace
!=GL_CCW
)
939 ctx
->backface_sign
= -1;
940 ctx
->Polygon
.CullBits
= 2;
943 case GL_FRONT_AND_BACK
:
944 ctx
->backface_sign
= 0;
945 ctx
->Polygon
.CullBits
= 0;
946 ctx
->TriangleCaps
|= DD_TRI_CULL_FRONT_BACK
;
951 ctx
->Polygon
.CullBits
= 3;
952 ctx
->backface_sign
= 0;
955 /* Any Polygon offsets enabled? */
956 ctx
->TriangleCaps
&= ~DD_TRI_OFFSET
;
958 if (ctx
->Polygon
.OffsetPoint
||
959 ctx
->Polygon
.OffsetLine
||
960 ctx
->Polygon
.OffsetFill
)
961 ctx
->TriangleCaps
|= DD_TRI_OFFSET
;
965 if (ctx
->NewState
& ~(NEW_CLIENT_STATE
| NEW_USER_CLIP
| NEW_POLYGON
))
966 gl_update_clipmask(ctx
);
968 if (ctx
->NewState
& (NEW_LIGHTING
|
976 ctx
->IndirectTriangles
= ctx
->TriangleCaps
& ~ctx
->Driver
.TriangleCaps
;
977 ctx
->IndirectTriangles
|= DD_SW_RASTERIZE
;
979 if (MESA_VERBOSE
&VERBOSE_CULL
)
980 gl_print_tri_caps("initial indirect tris", ctx
->IndirectTriangles
);
982 ctx
->Driver
.PointsFunc
= NULL
;
983 ctx
->Driver
.LineFunc
= NULL
;
984 ctx
->Driver
.TriangleFunc
= NULL
;
985 ctx
->Driver
.QuadFunc
= NULL
;
986 ctx
->Driver
.RectFunc
= NULL
;
987 ctx
->Driver
.RenderVBClippedTab
= NULL
;
988 ctx
->Driver
.RenderVBCulledTab
= NULL
;
989 ctx
->Driver
.RenderVBRawTab
= NULL
;
992 * Here the driver sets up all the ctx->Driver function pointers to
993 * it's specific, private functions.
995 ctx
->Driver
.UpdateState(ctx
);
997 if (MESA_VERBOSE
&VERBOSE_CULL
)
998 gl_print_tri_caps("indirect tris", ctx
->IndirectTriangles
);
1001 * In case the driver didn't hook in an optimized point, line or
1002 * triangle function we'll now select "core/fallback" point, line
1003 * and triangle functions.
1005 if (ctx
->IndirectTriangles
& DD_SW_RASTERIZE
) {
1006 gl_set_point_function(ctx
);
1007 gl_set_line_function(ctx
);
1008 gl_set_triangle_function(ctx
);
1009 gl_set_quad_function(ctx
);
1011 if ((ctx
->IndirectTriangles
&
1012 (DD_TRI_SW_RASTERIZE
|DD_QUAD_SW_RASTERIZE
|DD_TRI_CULL
)) ==
1013 (DD_TRI_SW_RASTERIZE
|DD_QUAD_SW_RASTERIZE
|DD_TRI_CULL
))
1014 ctx
->IndirectTriangles
&= ~DD_TRI_CULL
;
1017 if (MESA_VERBOSE
&VERBOSE_CULL
)
1018 gl_print_tri_caps("indirect tris 2", ctx
->IndirectTriangles
);
1020 gl_set_render_vb_function(ctx
);
1023 /* Should only be calc'd when !need_eye_coords and not culling.
1025 if (ctx
->NewState
& (NEW_MODELVIEW
|NEW_PROJECTION
)) {
1026 if (ctx
->NewState
& NEW_MODELVIEW
) {
1027 gl_matrix_analyze( &ctx
->ModelView
);
1028 ctx
->ProjectionMatrix
.flags
&= ~MAT_DIRTY_DEPENDENTS
;
1031 if (ctx
->NewState
& NEW_PROJECTION
) {
1032 gl_matrix_analyze( &ctx
->ProjectionMatrix
);
1033 ctx
->ProjectionMatrix
.flags
&= ~MAT_DIRTY_DEPENDENTS
;
1035 if (ctx
->Transform
.AnyClip
) {
1036 gl_update_userclip( ctx
);
1040 gl_calculate_model_project_matrix( ctx
);
1041 ctx
->ModelProjectWinMatrixUptodate
= 0;
1044 if (ctx
->NewState
& NEW_COLOR_MATRIX
) {
1045 gl_matrix_analyze( &ctx
->ColorMatrix
);
1048 /* Figure out whether we can light in object space or not. If we
1049 * can, find the current positions of the lights in object space
1051 if ((ctx
->Enabled
& (ENABLE_POINT_ATTEN
| ENABLE_LIGHT
| ENABLE_FOG
|
1052 ENABLE_TEXGEN0
| ENABLE_TEXGEN1
| ENABLE_TEXGEN2
)) &&
1053 (ctx
->NewState
& (NEW_LIGHTING
|
1061 GLboolean oldcoord
, oldnorm
;
1063 oldcoord
= ctx
->NeedEyeCoords
;
1064 oldnorm
= ctx
->NeedEyeNormals
;
1066 ctx
->NeedNormals
= (ctx
->Light
.Enabled
|| ctx
->Texture
.NeedNormals
);
1067 ctx
->NeedEyeCoords
= ((ctx
->Fog
.Enabled
&& ctx
->Hint
.Fog
!= GL_NICEST
) ||
1068 ctx
->Point
.Attenuated
);
1069 ctx
->NeedEyeNormals
= GL_FALSE
;
1071 if (ctx
->Light
.Enabled
) {
1072 if ((ctx
->Light
.Flags
& LIGHT_POSITIONAL
) ||
1073 ctx
->Light
.NeedVertices
||
1074 !TEST_MAT_FLAGS( &ctx
->ModelView
, MAT_FLAGS_LENGTH_PRESERVING
)) {
1075 /* Need length for attenuation or need angle for spotlights
1076 * or non-uniform scale matrix
1078 ctx
->NeedEyeCoords
= GL_TRUE
;
1080 ctx
->NeedEyeNormals
= ctx
->NeedEyeCoords
;
1082 if (ctx
->Texture
.ReallyEnabled
|| ctx
->RenderMode
==GL_FEEDBACK
) {
1083 if (ctx
->Texture
.NeedEyeCoords
) ctx
->NeedEyeCoords
= GL_TRUE
;
1084 if (ctx
->Texture
.NeedNormals
)
1085 ctx
->NeedNormals
= ctx
->NeedEyeNormals
= GL_TRUE
;
1088 ctx
->vb_proj_matrix
= &ctx
->ModelProjectMatrix
;
1090 if (ctx
->NeedEyeCoords
)
1091 ctx
->vb_proj_matrix
= &ctx
->ProjectionMatrix
;
1093 if (ctx
->Light
.Enabled
) {
1094 gl_update_lighting_function(ctx
);
1096 if ( (ctx
->NewState
& NEW_LIGHTING
) ||
1097 ((ctx
->NewState
& (NEW_MODELVIEW
| NEW_PROJECTION
)) &&
1098 !ctx
->NeedEyeCoords
) ||
1099 oldcoord
!= ctx
->NeedEyeCoords
||
1100 oldnorm
!= ctx
->NeedEyeNormals
) {
1101 gl_compute_light_positions(ctx
);
1104 ctx
->rescale_factor
= 1.0F
;
1106 if (ctx
->ModelView
.flags
& (MAT_FLAG_UNIFORM_SCALE
|
1107 MAT_FLAG_GENERAL_SCALE
|
1108 MAT_FLAG_GENERAL_3D
|
1112 GLfloat
*m
= ctx
->ModelView
.inv
;
1113 GLfloat f
= m
[2]*m
[2] + m
[6]*m
[6] + m
[10]*m
[10];
1114 if (f
> 1e-12 && (f
-1)*(f
-1) > 1e-12)
1115 ctx
->rescale_factor
= 1.0/GL_SQRT(f
);
1119 gl_update_normal_transform( ctx
);
1122 gl_update_pipelines(ctx
);
1130 * Return a bitmask of IMAGE_*_BIT flags which to indicate which
1131 * pixel transfer operations are enabled.
1134 _mesa_update_image_transfer_state(GLcontext
*ctx
)
1138 if (ctx
->Pixel
.RedScale
!= 1.0F
|| ctx
->Pixel
.RedBias
!= 0.0F
||
1139 ctx
->Pixel
.GreenScale
!= 1.0F
|| ctx
->Pixel
.GreenBias
!= 0.0F
||
1140 ctx
->Pixel
.BlueScale
!= 1.0F
|| ctx
->Pixel
.BlueBias
!= 0.0F
||
1141 ctx
->Pixel
.AlphaScale
!= 1.0F
|| ctx
->Pixel
.AlphaBias
!= 0.0F
)
1142 mask
|= IMAGE_SCALE_BIAS_BIT
;
1144 if (ctx
->Pixel
.IndexShift
|| ctx
->Pixel
.IndexOffset
)
1145 mask
|= IMAGE_SHIFT_OFFSET_BIT
;
1147 if (ctx
->Pixel
.MapColorFlag
)
1148 mask
|= IMAGE_MAP_COLOR_BIT
;
1150 if (ctx
->Pixel
.ColorTableEnabled
)
1151 mask
|= IMAGE_COLOR_TABLE_BIT
;
1153 if (ctx
->Pixel
.Convolution1DEnabled
||
1154 ctx
->Pixel
.Convolution2DEnabled
||
1155 ctx
->Pixel
.Separable2DEnabled
)
1156 mask
|= IMAGE_CONVOLUTION_BIT
;
1158 if (ctx
->Pixel
.PostConvolutionColorTableEnabled
)
1159 mask
|= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT
;
1161 if (ctx
->ColorMatrix
.type
!= MATRIX_IDENTITY
||
1162 ctx
->Pixel
.PostColorMatrixScale
[0] != 1.0F
||
1163 ctx
->Pixel
.PostColorMatrixBias
[0] != 0.0F
||
1164 ctx
->Pixel
.PostColorMatrixScale
[1] != 1.0F
||
1165 ctx
->Pixel
.PostColorMatrixBias
[1] != 0.0F
||
1166 ctx
->Pixel
.PostColorMatrixScale
[2] != 1.0F
||
1167 ctx
->Pixel
.PostColorMatrixBias
[2] != 0.0F
||
1168 ctx
->Pixel
.PostColorMatrixScale
[3] != 1.0F
||
1169 ctx
->Pixel
.PostColorMatrixBias
[3] != 0.0F
)
1170 mask
|= IMAGE_COLOR_MATRIX_BIT
;
1172 if (ctx
->Pixel
.PostColorMatrixColorTableEnabled
)
1173 mask
|= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT
;
1175 if (ctx
->Pixel
.HistogramEnabled
)
1176 mask
|= IMAGE_HISTOGRAM_BIT
;
1178 if (ctx
->Pixel
.MinMaxEnabled
)
1179 mask
|= IMAGE_MIN_MAX_BIT
;
1181 ctx
->ImageTransferState
= mask
;