dd.h revision b31b1f44f15f385f61e4cd42c10bb967cd2e5b91
1/**
2 * \file dd.h
3 * Device driver interfaces.
4 */
5
6/*
7 * Mesa 3-D graphics library
8 * Version:  6.3
9 *
10 * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30
31#ifndef DD_INCLUDED
32#define DD_INCLUDED
33
34/* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */
35
36struct gl_pixelstore_attrib;
37struct mesa_display_list;
38
39/**
40 * Device driver function table.
41 * Core Mesa uses these function pointers to call into device drivers.
42 * Most of these functions directly correspond to OpenGL state commands.
43 * Core Mesa will call these functions after error checking has been done
44 * so that the drivers don't have to worry about error testing.
45 *
46 * Vertex transformation/clipping/lighting is patched into the T&L module.
47 * Rasterization functions are patched into the swrast module.
48 *
49 * Note: when new functions are added here, the drivers/common/driverfuncs.c
50 * file should be updated too!!!
51 */
52struct dd_function_table {
53   /**
54    * Return a string as needed by glGetString().
55    *
56    * Only the GL_RENDERER token must be implemented.  Otherwise, NULL can be
57    * returned.
58    */
59   const GLubyte * (*GetString)( GLcontext *ctx, GLenum name );
60
61   /**
62    * Notify the driver after Mesa has made some internal state changes.
63    *
64    * This is in addition to any state change callbacks Mesa may already have
65    * made.
66    */
67   void (*UpdateState)( GLcontext *ctx, GLuint new_state );
68
69   /**
70    * Get the width and height of the named buffer/window.
71    *
72    * Mesa uses this to determine when the driver's window size has changed.
73    */
74   void (*GetBufferSize)( GLframebuffer *buffer,
75                          GLuint *width, GLuint *height );
76
77   /**
78    * Resize the given framebuffer to the given size.
79    */
80   void (*ResizeBuffers)( GLcontext *ctx, GLframebuffer *fb,
81                          GLuint width, GLuint height);
82
83   /**
84    * Called whenever an error is generated.
85    *
86    * __GLcontextRec::ErrorValue contains the error value.
87    */
88   void (*Error)( GLcontext *ctx );
89
90   /**
91    * This is called whenever glFinish() is called.
92    */
93   void (*Finish)( GLcontext *ctx );
94
95   /**
96    * This is called whenever glFlush() is called.
97    */
98   void (*Flush)( GLcontext *ctx );
99
100   /**
101    * Clear the color/depth/stencil/accum buffer(s).
102    *
103    * \param mask a bitmask of the DD_*_BIT values defined above that indicates
104    * which buffers need to be cleared.
105    * \param all if true then clear the whole buffer, else clear only the
106    * region defined by <tt>(x, y, width, height)</tt>.
107    *
108    * This function must obey the glColorMask(), glIndexMask() and
109    * glStencilMask() settings!
110    * Software Mesa can do masked clears if the device driver can't.
111    */
112   void (*Clear)( GLcontext *ctx, GLbitfield mask, GLboolean all,
113		  GLint x, GLint y, GLint width, GLint height );
114
115
116   /**
117    * \name For hardware accumulation buffer
118    */
119   /*@{*/
120   /**
121    * Execute glAccum command within the given scissor region.
122    */
123   void (*Accum)( GLcontext *ctx, GLenum op, GLfloat value,
124		  GLint xpos, GLint ypos, GLint width, GLint height );
125   /*@}*/
126
127
128   /**
129    * \name glDraw(), glRead(), glCopyPixels() and glBitmap() functions
130    */
131   /*@{*/
132
133   /**
134    * This is called by glDrawPixels().
135    *
136    * \p unpack describes how to unpack the source image data.
137    */
138   void (*DrawPixels)( GLcontext *ctx,
139		       GLint x, GLint y, GLsizei width, GLsizei height,
140		       GLenum format, GLenum type,
141		       const struct gl_pixelstore_attrib *unpack,
142		       const GLvoid *pixels );
143
144   /**
145    * Called by glReadPixels().
146    */
147   void (*ReadPixels)( GLcontext *ctx,
148		       GLint x, GLint y, GLsizei width, GLsizei height,
149		       GLenum format, GLenum type,
150		       const struct gl_pixelstore_attrib *unpack,
151		       GLvoid *dest );
152
153   /**
154    * Do a glCopyPixels().
155    *
156    * This function must respect all rasterization state, glPixelTransfer(),
157    * glPixelZoom(), etc.
158    */
159   void (*CopyPixels)( GLcontext *ctx, GLint srcx, GLint srcy,
160                       GLsizei width, GLsizei height,
161                       GLint dstx, GLint dsty, GLenum type );
162
163   /**
164    * This is called by glBitmap().
165    *
166    * Works the same as dd_function_table::DrawPixels, above.
167    */
168   void (*Bitmap)( GLcontext *ctx,
169		   GLint x, GLint y, GLsizei width, GLsizei height,
170		   const struct gl_pixelstore_attrib *unpack,
171		   const GLubyte *bitmap );
172   /*@}*/
173
174
175   /**
176    * \name Texture image functions
177    */
178   /*@{*/
179
180   /**
181    * Choose texture format.
182    *
183    * This is called by the \c _mesa_store_tex[sub]image[123]d() fallback
184    * functions.  The driver should examine \p internalFormat and return a
185    * pointer to an appropriate gl_texture_format.
186    */
187   const struct gl_texture_format *(*ChooseTextureFormat)( GLcontext *ctx,
188                      GLint internalFormat, GLenum srcFormat, GLenum srcType );
189
190   /**
191    * Called by glTexImage1D().
192    *
193    * \param target user specified.
194    * \param format user specified.
195    * \param type user specified.
196    * \param pixels user specified.
197    * \param packing indicates the image packing of pixels.
198    * \param texObj is the target texture object.
199    * \param texImage is the target texture image.  It will have the texture \p
200    * width, \p height, \p depth, \p border and \p internalFormat information.
201    *
202    * \p retainInternalCopy is returned by this function and indicates whether
203    * core Mesa should keep an internal copy of the texture image.
204    *
205    * Drivers should call a fallback routine from texstore.c if needed.
206    */
207   void (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level,
208                       GLint internalFormat,
209                       GLint width, GLint border,
210                       GLenum format, GLenum type, const GLvoid *pixels,
211                       const struct gl_pixelstore_attrib *packing,
212                       struct gl_texture_object *texObj,
213                       struct gl_texture_image *texImage );
214
215   /**
216    * Called by glTexImage2D().
217    *
218    * \sa dd_function_table::TexImage1D.
219    */
220   void (*TexImage2D)( GLcontext *ctx, GLenum target, GLint level,
221                       GLint internalFormat,
222                       GLint width, GLint height, GLint border,
223                       GLenum format, GLenum type, const GLvoid *pixels,
224                       const struct gl_pixelstore_attrib *packing,
225                       struct gl_texture_object *texObj,
226                       struct gl_texture_image *texImage );
227
228   /**
229    * Called by glTexImage3D().
230    *
231    * \sa dd_function_table::TexImage1D.
232    */
233   void (*TexImage3D)( GLcontext *ctx, GLenum target, GLint level,
234                       GLint internalFormat,
235                       GLint width, GLint height, GLint depth, GLint border,
236                       GLenum format, GLenum type, const GLvoid *pixels,
237                       const struct gl_pixelstore_attrib *packing,
238                       struct gl_texture_object *texObj,
239                       struct gl_texture_image *texImage );
240
241   /**
242    * Called by glTexSubImage1D().
243    *
244    * \param target user specified.
245    * \param level user specified.
246    * \param xoffset user specified.
247    * \param yoffset user specified.
248    * \param zoffset user specified.
249    * \param width user specified.
250    * \param height user specified.
251    * \param depth user specified.
252    * \param format user specified.
253    * \param type user specified.
254    * \param pixels user specified.
255    * \param packing indicates the image packing of pixels.
256    * \param texObj is the target texture object.
257    * \param texImage is the target texture image.  It will have the texture \p
258    * width, \p height, \p border and \p internalFormat information.
259    *
260    * The driver should use a fallback routine from texstore.c if needed.
261    */
262   void (*TexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
263                          GLint xoffset, GLsizei width,
264                          GLenum format, GLenum type,
265                          const GLvoid *pixels,
266                          const struct gl_pixelstore_attrib *packing,
267                          struct gl_texture_object *texObj,
268                          struct gl_texture_image *texImage );
269
270   /**
271    * Called by glTexSubImage2D().
272    *
273    * \sa dd_function_table::TexSubImage1D.
274    */
275   void (*TexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
276                          GLint xoffset, GLint yoffset,
277                          GLsizei width, GLsizei height,
278                          GLenum format, GLenum type,
279                          const GLvoid *pixels,
280                          const struct gl_pixelstore_attrib *packing,
281                          struct gl_texture_object *texObj,
282                          struct gl_texture_image *texImage );
283
284   /**
285    * Called by glTexSubImage3D().
286    *
287    * \sa dd_function_table::TexSubImage1D.
288    */
289   void (*TexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
290                          GLint xoffset, GLint yoffset, GLint zoffset,
291                          GLsizei width, GLsizei height, GLint depth,
292                          GLenum format, GLenum type,
293                          const GLvoid *pixels,
294                          const struct gl_pixelstore_attrib *packing,
295                          struct gl_texture_object *texObj,
296                          struct gl_texture_image *texImage );
297
298   /**
299    * Called by glGetTexImage().
300    */
301   void (*GetTexImage)( GLcontext *ctx, GLenum target, GLint level,
302                        GLenum format, GLenum type, GLvoid *pixels,
303                        const struct gl_texture_object *texObj,
304                        const struct gl_texture_image *texImage );
305
306   /**
307    * Called by glCopyTexImage1D().
308    *
309    * Drivers should use a fallback routine from texstore.c if needed.
310    */
311   void (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level,
312                           GLenum internalFormat, GLint x, GLint y,
313                           GLsizei width, GLint border );
314
315   /**
316    * Called by glCopyTexImage2D().
317    *
318    * Drivers should use a fallback routine from texstore.c if needed.
319    */
320   void (*CopyTexImage2D)( GLcontext *ctx, GLenum target, GLint level,
321                           GLenum internalFormat, GLint x, GLint y,
322                           GLsizei width, GLsizei height, GLint border );
323
324   /**
325    * Called by glCopyTexSubImage1D().
326    *
327    * Drivers should use a fallback routine from texstore.c if needed.
328    */
329   void (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
330                              GLint xoffset,
331                              GLint x, GLint y, GLsizei width );
332   /**
333    * Called by glCopyTexSubImage2D().
334    *
335    * Drivers should use a fallback routine from texstore.c if needed.
336    */
337   void (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
338                              GLint xoffset, GLint yoffset,
339                              GLint x, GLint y,
340                              GLsizei width, GLsizei height );
341   /**
342    * Called by glCopyTexSubImage3D().
343    *
344    * Drivers should use a fallback routine from texstore.c if needed.
345    */
346   void (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
347                              GLint xoffset, GLint yoffset, GLint zoffset,
348                              GLint x, GLint y,
349                              GLsizei width, GLsizei height );
350
351   /**
352    * Called by glTexImage[123]D when user specifies a proxy texture
353    * target.
354    *
355    * \return GL_TRUE if the proxy test passes, or GL_FALSE if the test fails.
356    */
357   GLboolean (*TestProxyTexImage)(GLcontext *ctx, GLenum target,
358                                  GLint level, GLint internalFormat,
359                                  GLenum format, GLenum type,
360                                  GLint width, GLint height,
361                                  GLint depth, GLint border);
362   /*@}*/
363
364
365   /**
366    * \name Compressed texture functions
367    */
368   /*@{*/
369
370   /**
371    * Called by glCompressedTexImage1D().
372    *
373    * \param target user specified.
374    * \param format user specified.
375    * \param type user specified.
376    * \param pixels user specified.
377    * \param packing indicates the image packing of pixels.
378    * \param texObj is the target texture object.
379    * \param texImage is the target texture image.  It will have the texture \p
380    * width, \p height, \p depth, \p border and \p internalFormat information.
381    *
382    * \a retainInternalCopy is returned by this function and indicates whether
383    * core Mesa should keep an internal copy of the texture image.
384    */
385   void (*CompressedTexImage1D)( GLcontext *ctx, GLenum target,
386                                 GLint level, GLint internalFormat,
387                                 GLsizei width, GLint border,
388                                 GLsizei imageSize, const GLvoid *data,
389                                 struct gl_texture_object *texObj,
390                                 struct gl_texture_image *texImage );
391   /**
392    * Called by glCompressedTexImage2D().
393    *
394    * \sa dd_function_table::CompressedTexImage1D.
395    */
396   void (*CompressedTexImage2D)( GLcontext *ctx, GLenum target,
397                                 GLint level, GLint internalFormat,
398                                 GLsizei width, GLsizei height, GLint border,
399                                 GLsizei imageSize, const GLvoid *data,
400                                 struct gl_texture_object *texObj,
401                                 struct gl_texture_image *texImage );
402   /**
403    * Called by glCompressedTexImage3D().
404    *
405    * \sa dd_function_table::CompressedTexImage3D.
406    */
407   void (*CompressedTexImage3D)( GLcontext *ctx, GLenum target,
408                                 GLint level, GLint internalFormat,
409                                 GLsizei width, GLsizei height, GLsizei depth,
410                                 GLint border,
411                                 GLsizei imageSize, const GLvoid *data,
412                                 struct gl_texture_object *texObj,
413                                 struct gl_texture_image *texImage );
414
415   /**
416    * Called by glCompressedTexSubImage1D().
417    *
418    * \param target user specified.
419    * \param level user specified.
420    * \param xoffset user specified.
421    * \param yoffset user specified.
422    * \param zoffset user specified.
423    * \param width user specified.
424    * \param height user specified.
425    * \param depth user specified.
426    * \param imageSize user specified.
427    * \param data user specified.
428    * \param texObj is the target texture object.
429    * \param texImage is the target texture image.  It will have the texture \p
430    * width, \p height, \p depth, \p border and \p internalFormat information.
431    */
432   void (*CompressedTexSubImage1D)(GLcontext *ctx, GLenum target, GLint level,
433                                   GLint xoffset, GLsizei width,
434                                   GLenum format,
435                                   GLsizei imageSize, const GLvoid *data,
436                                   struct gl_texture_object *texObj,
437                                   struct gl_texture_image *texImage);
438   /**
439    * Called by glCompressedTexSubImage2D().
440    *
441    * \sa dd_function_table::CompressedTexImage3D.
442    */
443   void (*CompressedTexSubImage2D)(GLcontext *ctx, GLenum target, GLint level,
444                                   GLint xoffset, GLint yoffset,
445                                   GLsizei width, GLint height,
446                                   GLenum format,
447                                   GLsizei imageSize, const GLvoid *data,
448                                   struct gl_texture_object *texObj,
449                                   struct gl_texture_image *texImage);
450   /**
451    * Called by glCompressedTexSubImage3D().
452    *
453    * \sa dd_function_table::CompressedTexImage3D.
454    */
455   void (*CompressedTexSubImage3D)(GLcontext *ctx, GLenum target, GLint level,
456                                   GLint xoffset, GLint yoffset, GLint zoffset,
457                                   GLsizei width, GLint height, GLint depth,
458                                   GLenum format,
459                                   GLsizei imageSize, const GLvoid *data,
460                                   struct gl_texture_object *texObj,
461                                   struct gl_texture_image *texImage);
462
463
464   /**
465    * Called by glGetCompressedTexImage.
466    */
467   void (*GetCompressedTexImage)(GLcontext *ctx, GLenum target, GLint level,
468                                 GLvoid *img,
469                                 const struct gl_texture_object *texObj,
470                                 const struct gl_texture_image *texImage);
471
472   /**
473    * Called to query number of bytes of storage needed to store the
474    * specified compressed texture.
475    */
476   GLuint (*CompressedTextureSize)( GLcontext *ctx, GLsizei width,
477                                    GLsizei height, GLsizei depth,
478                                    GLenum format );
479   /*@}*/
480
481   /**
482    * \name Texture object functions
483    */
484   /*@{*/
485
486   /**
487    * Called by glBindTexture().
488    */
489   void (*BindTexture)( GLcontext *ctx, GLenum target,
490                        struct gl_texture_object *tObj );
491
492   /**
493    * Called to allocate a new texture object.
494    * A new gl_texture_object should be returned.  The driver should
495    * attach to it any device-specific info it needs.
496    */
497   struct gl_texture_object * (*NewTextureObject)( GLcontext *ctx, GLuint name,
498                                                   GLenum target );
499   /**
500    * Called when a texture object is about to be deallocated.
501    *
502    * Driver should delete the gl_texture_object object and anything
503    * hanging off of it.
504    */
505   void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
506
507   /**
508    * Called to allocate a new texture image object.
509    */
510   struct gl_texture_image * (*NewTextureImage)( GLcontext *ctx );
511
512   /**
513    * Called to free tImage->Data.
514    */
515   void (*FreeTexImageData)( GLcontext *ctx, struct gl_texture_image *tImage );
516
517   /**
518    * Note: no context argument.  This function doesn't initially look
519    * like it belongs here, except that the driver is the only entity
520    * that knows for sure how the texture memory is allocated - via
521    * the above callbacks.  There is then an argument that the driver
522    * knows what memcpy paths might be fast.  Typically this is invoked with
523    *
524    * to -- a pointer into texture memory allocated by NewTextureImage() above.
525    * from -- a pointer into client memory or a mesa temporary.
526    * sz -- nr bytes to copy.
527    */
528   void* (*TextureMemCpy)( void *to, const void *from, size_t sz );
529
530   /**
531    * Called by glAreTextureResident().
532    */
533   GLboolean (*IsTextureResident)( GLcontext *ctx,
534                                   struct gl_texture_object *t );
535
536   /**
537    * Called by glPrioritizeTextures().
538    */
539   void (*PrioritizeTexture)( GLcontext *ctx,  struct gl_texture_object *t,
540                              GLclampf priority );
541
542   /**
543    * Called by glActiveTextureARB() to set current texture unit.
544    */
545   void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber );
546
547   /**
548    * Called when the texture's color lookup table is changed.
549    *
550    * If \p tObj is NULL then the shared texture palette
551    * gl_texture_object::Palette is to be updated.
552    */
553   void (*UpdateTexturePalette)( GLcontext *ctx,
554                                 struct gl_texture_object *tObj );
555   /*@}*/
556
557
558   /**
559    * \name Imaging functionality
560    */
561   /*@{*/
562   void (*CopyColorTable)( GLcontext *ctx,
563			   GLenum target, GLenum internalformat,
564			   GLint x, GLint y, GLsizei width );
565
566   void (*CopyColorSubTable)( GLcontext *ctx,
567			      GLenum target, GLsizei start,
568			      GLint x, GLint y, GLsizei width );
569
570   void (*CopyConvolutionFilter1D)( GLcontext *ctx, GLenum target,
571				    GLenum internalFormat,
572				    GLint x, GLint y, GLsizei width );
573
574   void (*CopyConvolutionFilter2D)( GLcontext *ctx, GLenum target,
575				    GLenum internalFormat,
576				    GLint x, GLint y,
577				    GLsizei width, GLsizei height );
578   /*@}*/
579
580
581   /**
582    * \name Vertex/fragment program functions
583    */
584   /*@{*/
585   /** Bind a vertex/fragment program */
586   void (*BindProgram)(GLcontext *ctx, GLenum target, struct program *prog);
587   /** Allocate a new program */
588   struct program * (*NewProgram)(GLcontext *ctx, GLenum target, GLuint id);
589   /** Delete a program */
590   void (*DeleteProgram)(GLcontext *ctx, struct program *prog);
591   /** Notify driver that a program string has been specified. */
592   void (*ProgramStringNotify)(GLcontext *ctx, GLenum target,
593			       struct program *prog);
594
595
596
597   /** Query if program can be loaded onto hardware */
598   GLboolean (*IsProgramNative)(GLcontext *ctx, GLenum target,
599				struct program *prog);
600
601   /*@}*/
602
603
604   /**
605    * \name State-changing functions.
606    *
607    * \note drawing functions are above.
608    *
609    * These functions are called by their corresponding OpenGL API functions.
610    * They are \e also called by the gl_PopAttrib() function!!!
611    * May add more functions like these to the device driver in the future.
612    */
613   /*@{*/
614   /** Specify the alpha test function */
615   void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLfloat ref);
616   /** Set the blend color */
617   void (*BlendColor)(GLcontext *ctx, const GLfloat color[4]);
618   /** Set the blend equation */
619   void (*BlendEquationSeparate)(GLcontext *ctx, GLenum modeRGB, GLenum modeA);
620   /** Specify pixel arithmetic */
621   void (*BlendFuncSeparate)(GLcontext *ctx,
622                             GLenum sfactorRGB, GLenum dfactorRGB,
623                             GLenum sfactorA, GLenum dfactorA);
624   /** Specify clear values for the color buffers */
625   void (*ClearColor)(GLcontext *ctx, const GLfloat color[4]);
626   /** Specify the clear value for the depth buffer */
627   void (*ClearDepth)(GLcontext *ctx, GLclampd d);
628   /** Specify the clear value for the color index buffers */
629   void (*ClearIndex)(GLcontext *ctx, GLuint index);
630   /** Specify the clear value for the stencil buffer */
631   void (*ClearStencil)(GLcontext *ctx, GLint s);
632   /** Specify a plane against which all geometry is clipped */
633   void (*ClipPlane)(GLcontext *ctx, GLenum plane, const GLfloat *equation );
634   /** Enable and disable writing of frame buffer color components */
635   void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
636                     GLboolean bmask, GLboolean amask );
637   /** Cause a material color to track the current color */
638   void (*ColorMaterial)(GLcontext *ctx, GLenum face, GLenum mode);
639   /** Specify whether front- or back-facing facets can be culled */
640   void (*CullFace)(GLcontext *ctx, GLenum mode);
641   /** Define front- and back-facing polygons */
642   void (*FrontFace)(GLcontext *ctx, GLenum mode);
643   /** Specify the value used for depth buffer comparisons */
644   void (*DepthFunc)(GLcontext *ctx, GLenum func);
645   /** Enable or disable writing into the depth buffer */
646   void (*DepthMask)(GLcontext *ctx, GLboolean flag);
647   /** Specify mapping of depth values from NDC to window coordinates */
648   void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval);
649   /** Specify the current buffer for writing */
650   void (*DrawBuffer)( GLcontext *ctx, GLenum buffer );
651   /** Specify the buffers for writing for fragment programs*/
652   void (*DrawBuffers)( GLcontext *ctx, GLsizei n, const GLenum *buffers );
653   /** Enable or disable server-side gl capabilities */
654   void (*Enable)(GLcontext *ctx, GLenum cap, GLboolean state);
655   /** Specify fog parameters */
656   void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
657   /** Specify implementation-specific hints */
658   void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode);
659   /** Control the writing of individual bits in the color index buffers */
660   void (*IndexMask)(GLcontext *ctx, GLuint mask);
661   /** Set light source parameters */
662   void (*Lightfv)(GLcontext *ctx, GLenum light,
663		   GLenum pname, const GLfloat *params );
664   /** Set the lighting model parameters */
665   void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
666   /** Specify the line stipple pattern */
667   void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern );
668   /** Specify the width of rasterized lines */
669   void (*LineWidth)(GLcontext *ctx, GLfloat width);
670   /** Specify a logical pixel operation for color index rendering */
671   void (*LogicOpcode)(GLcontext *ctx, GLenum opcode);
672   void (*PointParameterfv)(GLcontext *ctx, GLenum pname,
673                            const GLfloat *params);
674   /** Specify the diameter of rasterized points */
675   void (*PointSize)(GLcontext *ctx, GLfloat size);
676   /** Select a polygon rasterization mode */
677   void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode);
678   /** Set the scale and units used to calculate depth values */
679   void (*PolygonOffset)(GLcontext *ctx, GLfloat factor, GLfloat units);
680   /** Set the polygon stippling pattern */
681   void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask );
682   /* Specifies the current buffer for reading */
683   void (*ReadBuffer)( GLcontext *ctx, GLenum buffer );
684   /** Set rasterization mode */
685   void (*RenderMode)(GLcontext *ctx, GLenum mode );
686   /** Define the scissor box */
687   void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
688   /** Select flat or smooth shading */
689   void (*ShadeModel)(GLcontext *ctx, GLenum mode);
690   /** Set function and reference value for stencil testing */
691   void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
692   /** Control the writing of individual bits in the stencil planes */
693   void (*StencilMask)(GLcontext *ctx, GLuint mask);
694   /** Set stencil test actions */
695   void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass);
696   /** Set active stencil face (GL_EXT_stencil_two_side) */
697   void (*ActiveStencilFace)(GLcontext *ctx, GLuint face);
698   /** OpenGL 2.0 two-sided StencilFunc */
699   void (*StencilFuncSeparate)(GLcontext *ctx, GLenum face, GLenum func,
700                               GLint ref, GLuint mask);
701   /** OpenGL 2.0 two-sided StencilMask */
702   void (*StencilMaskSeparate)(GLcontext *ctx, GLenum face, GLuint mask);
703   /** OpenGL 2.0 two-sided StencilOp */
704   void (*StencilOpSeparate)(GLcontext *ctx, GLenum face, GLenum fail,
705                             GLenum zfail, GLenum zpass);
706   /** Control the generation of texture coordinates */
707   void (*TexGen)(GLcontext *ctx, GLenum coord, GLenum pname,
708		  const GLfloat *params);
709   /** Set texture environment parameters */
710   void (*TexEnv)(GLcontext *ctx, GLenum target, GLenum pname,
711                  const GLfloat *param);
712   /** Set texture parameters */
713   void (*TexParameter)(GLcontext *ctx, GLenum target,
714                        struct gl_texture_object *texObj,
715                        GLenum pname, const GLfloat *params);
716   void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat);
717   /** Set the viewport */
718   void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
719   /*@}*/
720
721
722   /**
723    * \name Vertex array functions
724    *
725    * Called by the corresponding OpenGL functions.
726    */
727   /*@{*/
728   void (*VertexPointer)(GLcontext *ctx, GLint size, GLenum type,
729			 GLsizei stride, const GLvoid *ptr);
730   void (*NormalPointer)(GLcontext *ctx, GLenum type,
731			 GLsizei stride, const GLvoid *ptr);
732   void (*ColorPointer)(GLcontext *ctx, GLint size, GLenum type,
733			GLsizei stride, const GLvoid *ptr);
734   void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
735			   GLsizei stride, const GLvoid *ptr);
736   void (*IndexPointer)(GLcontext *ctx, GLenum type,
737			GLsizei stride, const GLvoid *ptr);
738   void (*SecondaryColorPointer)(GLcontext *ctx, GLint size, GLenum type,
739				 GLsizei stride, const GLvoid *ptr);
740   void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type,
741			   GLsizei stride, const GLvoid *ptr);
742   void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);
743   void (*VertexAttribPointer)(GLcontext *ctx, GLuint index, GLint size,
744                               GLenum type, GLsizei stride, const GLvoid *ptr);
745   void (*LockArraysEXT)( GLcontext *ctx, GLint first, GLsizei count );
746   void (*UnlockArraysEXT)( GLcontext *ctx );
747   /*@}*/
748
749
750   /**
751    * \name State-query functions
752    *
753    * Return GL_TRUE if query was completed, GL_FALSE otherwise.
754    */
755   /*@{*/
756   /** Return the value or values of a selected parameter */
757   GLboolean (*GetBooleanv)(GLcontext *ctx, GLenum pname, GLboolean *result);
758   /** Return the value or values of a selected parameter */
759   GLboolean (*GetDoublev)(GLcontext *ctx, GLenum pname, GLdouble *result);
760   /** Return the value or values of a selected parameter */
761   GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result);
762   /** Return the value or values of a selected parameter */
763   GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result);
764   /** Return the value or values of a selected parameter */
765   GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result);
766   /*@}*/
767
768
769   /**
770    * \name Vertex/pixel buffer object functions
771    */
772#if FEATURE_ARB_vertex_buffer_object
773   /*@{*/
774   void (*BindBuffer)( GLcontext *ctx, GLenum target,
775		       struct gl_buffer_object *obj );
776
777   struct gl_buffer_object * (*NewBufferObject)( GLcontext *ctx, GLuint buffer,
778						 GLenum target );
779
780   void (*DeleteBuffer)( GLcontext *ctx, struct gl_buffer_object *obj );
781
782   void (*BufferData)( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
783		       const GLvoid *data, GLenum usage,
784		       struct gl_buffer_object *obj );
785
786   void (*BufferSubData)( GLcontext *ctx, GLenum target, GLintptrARB offset,
787			  GLsizeiptrARB size, const GLvoid *data,
788			  struct gl_buffer_object *obj );
789
790   void (*GetBufferSubData)( GLcontext *ctx, GLenum target,
791			     GLintptrARB offset, GLsizeiptrARB size,
792			     GLvoid *data, struct gl_buffer_object *obj );
793
794   void * (*MapBuffer)( GLcontext *ctx, GLenum target, GLenum access,
795			struct gl_buffer_object *obj );
796
797   GLboolean (*UnmapBuffer)( GLcontext *ctx, GLenum target,
798			     struct gl_buffer_object *obj );
799   /*@}*/
800#endif
801
802   /**
803    * \name Functions for GL_EXT_framebuffer_object
804    */
805#if FEATURE_EXT_framebuffer_object
806   /*@{*/
807   struct gl_framebuffer * (*NewFramebuffer)(GLcontext *ctx, GLuint name);
808   struct gl_renderbuffer * (*NewRenderbuffer)(GLcontext *ctx, GLuint name);
809   void (*FramebufferRenderbuffer)(GLcontext *ctx,
810                                   struct gl_renderbuffer_attachment *att,
811                                   struct gl_renderbuffer *rb);
812   void (*RenderbufferTexture)(GLcontext *ctx,
813                               struct gl_renderbuffer_attachment *att,
814                               struct gl_texture_object *texObj,
815                               GLenum texTarget, GLuint level, GLuint zoffset);
816   /*@}*/
817#endif
818
819
820   /**
821    * \name Support for multiple T&L engines
822    */
823   /*@{*/
824
825   /**
826    * Bitmask of state changes that require the current T&L module to be
827    * validated, using ValidateTnlModule() below.
828    */
829   GLuint NeedValidate;
830
831   /**
832    * Validate the current T&L module.
833    *
834    * This is called directly after UpdateState() when a state change that has
835    * occurred matches the dd_function_table::NeedValidate bitmask above.  This
836    * ensures all computed values are up to date, thus allowing the driver to
837    * decide if the current T&L module needs to be swapped out.
838    *
839    * This must be non-NULL if a driver installs a custom T&L module and sets
840    * the dd_function_table::NeedValidate bitmask, but may be NULL otherwise.
841    */
842   void (*ValidateTnlModule)( GLcontext *ctx, GLuint new_state );
843
844
845#define PRIM_OUTSIDE_BEGIN_END   GL_POLYGON+1
846#define PRIM_INSIDE_UNKNOWN_PRIM GL_POLYGON+2
847#define PRIM_UNKNOWN             GL_POLYGON+3
848
849   /**
850    * Set by the driver-supplied T&L engine.
851    *
852    * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd().
853    */
854   GLuint CurrentExecPrimitive;
855
856   /**
857    * Current state of an in-progress compilation.
858    *
859    * May take on any of the additional values PRIM_OUTSIDE_BEGIN_END,
860    * PRIM_INSIDE_UNKNOWN_PRIM or PRIM_UNKNOWN defined above.
861    */
862   GLuint CurrentSavePrimitive;
863
864
865#define FLUSH_STORED_VERTICES 0x1
866#define FLUSH_UPDATE_CURRENT  0x2
867   /**
868    * Set by the driver-supplied T&L engine whenever vertices are buffered
869    * between glBegin()/glEnd() objects or __GLcontextRec::Current is not
870    * updated.
871    *
872    * The dd_function_table::FlushVertices call below may be used to resolve
873    * these conditions.
874    */
875   GLuint NeedFlush;
876   GLuint SaveNeedFlush;
877
878   /**
879    * If inside glBegin()/glEnd(), it should ASSERT(0).  Otherwise, if
880    * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered
881    * vertices, if FLUSH_UPDATE_CURRENT bit is set updates
882    * __GLcontextRec::Current and gl_light_attrib::Material
883    *
884    * Note that the default T&L engine never clears the
885    * FLUSH_UPDATE_CURRENT bit, even after performing the update.
886    */
887   void (*FlushVertices)( GLcontext *ctx, GLuint flags );
888   void (*SaveFlushVertices)( GLcontext *ctx );
889
890   /**
891    * Give the driver the opportunity to hook in its own vtxfmt for
892    * compiling optimized display lists.  This is called on each valid
893    * glBegin() during list compilation.
894    */
895   GLboolean (*NotifySaveBegin)( GLcontext *ctx, GLenum mode );
896
897   /**
898    * Notify driver that the special derived value _NeedEyeCoords has
899    * changed.
900    */
901   void (*LightingSpaceChange)( GLcontext *ctx );
902
903   /**
904    * Let the T&L component know when the context becomes current.
905    */
906   void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
907			GLframebuffer *readBuffer );
908
909   /**
910    * Called by glNewList().
911    *
912    * Let the T&L component know what is going on with display lists
913    * in time to make changes to dispatch tables, etc.
914    */
915   void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode );
916   /**
917    * Called by glEndList().
918    *
919    * \sa dd_function_table::NewList.
920    */
921   void (*EndList)( GLcontext *ctx );
922
923   /**
924    * Called by glCallList(s).
925    *
926    * Notify the T&L component before and after calling a display list.
927    */
928   void (*BeginCallList)( GLcontext *ctx,
929			  struct mesa_display_list *dlist );
930   /**
931    * Called by glEndCallList().
932    *
933    * \sa dd_function_table::BeginCallList.
934    */
935   void (*EndCallList)( GLcontext *ctx );
936
937};
938
939
940/**
941 * Transform/Clip/Lighting interface
942 *
943 * Drivers present a reduced set of the functions possible in
944 * glBegin()/glEnd() objects.  Core mesa provides translation stubs for the
945 * remaining functions to map down to these entry points.
946 *
947 * These are the initial values to be installed into dispatch by
948 * mesa.  If the T&L driver wants to modify the dispatch table
949 * while installed, it must do so itself.  It would be possible for
950 * the vertexformat to install it's own initial values for these
951 * functions, but this way there is an obvious list of what is
952 * expected of the driver.
953 *
954 * If the driver wants to hook in entry points other than those
955 * listed, it must restore them to their original values in
956 * the disable() callback, below.
957 */
958typedef struct {
959   /**
960    * \name Vertex
961    */
962   /*@{*/
963   void (GLAPIENTRYP ArrayElement)( GLint ); /* NOTE */
964   void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat );
965   void (GLAPIENTRYP Color3fv)( const GLfloat * );
966   void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat );
967   void (GLAPIENTRYP Color4fv)( const GLfloat * );
968   void (GLAPIENTRYP EdgeFlag)( GLboolean );
969   void (GLAPIENTRYP EdgeFlagv)( const GLboolean * );
970   void (GLAPIENTRYP EvalCoord1f)( GLfloat );          /* NOTE */
971   void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * ); /* NOTE */
972   void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat ); /* NOTE */
973   void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * ); /* NOTE */
974   void (GLAPIENTRYP EvalPoint1)( GLint );             /* NOTE */
975   void (GLAPIENTRYP EvalPoint2)( GLint, GLint );      /* NOTE */
976   void (GLAPIENTRYP FogCoordfEXT)( GLfloat );
977   void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * );
978   void (GLAPIENTRYP Indexf)( GLfloat );
979   void (GLAPIENTRYP Indexfv)( const GLfloat * );
980   void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * ); /* NOTE */
981   void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat );
982   void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * );
983   void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat );
984   void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * );
985   void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat );
986   void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * );
987   void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat );
988   void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * );
989   void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat );
990   void (GLAPIENTRYP Normal3fv)( const GLfloat * );
991   void (GLAPIENTRYP SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat );
992   void (GLAPIENTRYP SecondaryColor3fvEXT)( const GLfloat * );
993   void (GLAPIENTRYP TexCoord1f)( GLfloat );
994   void (GLAPIENTRYP TexCoord1fv)( const GLfloat * );
995   void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat );
996   void (GLAPIENTRYP TexCoord2fv)( const GLfloat * );
997   void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat );
998   void (GLAPIENTRYP TexCoord3fv)( const GLfloat * );
999   void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat );
1000   void (GLAPIENTRYP TexCoord4fv)( const GLfloat * );
1001   void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat );
1002   void (GLAPIENTRYP Vertex2fv)( const GLfloat * );
1003   void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat );
1004   void (GLAPIENTRYP Vertex3fv)( const GLfloat * );
1005   void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat );
1006   void (GLAPIENTRYP Vertex4fv)( const GLfloat * );
1007   void (GLAPIENTRYP CallList)( GLuint );	/* NOTE */
1008   void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * );	/* NOTE */
1009   void (GLAPIENTRYP Begin)( GLenum );
1010   void (GLAPIENTRYP End)( void );
1011   void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x );
1012   void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v );
1013   void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y );
1014   void (GLAPIENTRYP VertexAttrib2fvNV)( GLuint index, const GLfloat *v );
1015   void (GLAPIENTRYP VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z );
1016   void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v );
1017   void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
1018   void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v );
1019   void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x );
1020   void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v );
1021   void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y );
1022   void (GLAPIENTRYP VertexAttrib2fvARB)( GLuint index, const GLfloat *v );
1023   void (GLAPIENTRYP VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z );
1024   void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v );
1025   void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
1026   void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v );
1027   /*@}*/
1028
1029   /*
1030    */
1031   void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat );
1032
1033   /**
1034    * \name Array
1035    */
1036   /*@{*/
1037   void (GLAPIENTRYP DrawArrays)( GLenum mode, GLint start, GLsizei count );
1038   void (GLAPIENTRYP DrawElements)( GLenum mode, GLsizei count, GLenum type,
1039			 const GLvoid *indices );
1040   void (GLAPIENTRYP DrawRangeElements)( GLenum mode, GLuint start,
1041			      GLuint end, GLsizei count,
1042			      GLenum type, const GLvoid *indices );
1043   /*@}*/
1044
1045   /**
1046    * \name Eval
1047    *
1048    * If you don't support eval, fallback to the default vertex format
1049    * on receiving an eval call and use the pipeline mechanism to
1050    * provide partial T&L acceleration.
1051    *
1052    * Mesa will provide a set of helper functions to do eval within
1053    * accelerated vertex formats, eventually...
1054    */
1055   /*@{*/
1056   void (GLAPIENTRYP EvalMesh1)( GLenum mode, GLint i1, GLint i2 );
1057   void (GLAPIENTRYP EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
1058   /*@}*/
1059
1060} GLvertexformat;
1061
1062
1063#endif /* DD_INCLUDED */
1064