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