dd.h revision 2aadbf41dfd4f63c6118d0ad2d8659d289cbe454
1/* $Id: dd.h,v 1.53 2001/02/19 20:02:37 brianp Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version:  3.5
6 *
7 * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
8 *
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:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
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.
25 */
26
27
28
29#ifndef DD_INCLUDED
30#define DD_INCLUDED
31
32/* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */
33
34struct gl_pixelstore_attrib;
35
36
37/*
38 *                      Device Driver (DD) interface
39 *
40 *
41 * All device driver functions are accessed through pointers in the
42 * dd_function_table struct (defined below) which is stored in the GLcontext
43 * struct.  Since the device driver is strictly accessed trough a table of
44 * function pointers we can:
45 *   1. switch between a number of different device drivers at runtime.
46 *   2. use optimized functions dependant on current rendering state or
47 *      frame buffer configuration.
48 *
49 * The function pointers in the dd_function_table struct are divided into
50 * two groups:  mandatory and optional.
51 * Mandatory functions have to be implemented by every device driver.
52 * Optional functions may or may not be implemented by the device driver.
53 * The optional functions provide ways to take advantage of special hardware
54 * or optimized algorithms.
55 *
56 * The function pointers in the dd_function_table struct should first be
57 * initialized in the driver's "MakeCurrent" function.  The "MakeCurrent"
58 * function is a little different in each device driver.  See the X/Mesa,
59 * GLX, or OS/Mesa drivers for examples.
60 *
61 * Later, Mesa may call the dd_function_table's UpdateState() function.
62 * This function should initialize the dd_function_table's pointers again.
63 * The UpdateState() function is called whenever the core (GL) rendering
64 * state is changed in a way which may effect rasterization.  For example,
65 * the TriangleFunc() pointer may have to point to different functions
66 * depending on whether smooth or flat shading is enabled.
67 *
68 * Note that the first argument to every device driver function is a
69 * GLcontext *.  In turn, the GLcontext->DriverCtx pointer points to
70 * the driver-specific context struct.  See the X/Mesa or OS/Mesa interface
71 * for an example.
72 *
73 * For more information about writing a device driver see the ddsample.c
74 * file and other device drivers (X/xmesa[1234].c, OSMesa/osmesa.c, etc)
75 * for examples.
76 *
77 *
78 * Look below in the dd_function_table struct definition for descriptions
79 * of each device driver function.
80 *
81 *
82 * In the future more function pointers may be added for glReadPixels
83 * glCopyPixels, etc.
84 *
85 *
86 * Notes:
87 * ------
88 *   RGBA = red/green/blue/alpha
89 *   CI = color index (color mapped mode)
90 *   mono = all pixels have the same color or index
91 *
92 *   The write_ functions all take an array of mask flags which indicate
93 *   whether or not the pixel should be written.  One special case exists
94 *   in the write_color_span function: if the mask array is NULL, then
95 *   draw all pixels.  This is an optimization used for glDrawPixels().
96 *
97 * IN ALL CASES:
98 *      X coordinates start at 0 at the left and increase to the right
99 *      Y coordinates start at 0 at the bottom and increase upward
100 *
101 */
102
103
104
105
106
107
108/* Mask bits sent to the driver Clear() function */
109#define DD_FRONT_LEFT_BIT  FRONT_LEFT_BIT         /* 1 */
110#define DD_FRONT_RIGHT_BIT FRONT_RIGHT_BIT        /* 2 */
111#define DD_BACK_LEFT_BIT   BACK_LEFT_BIT          /* 4 */
112#define DD_BACK_RIGHT_BIT  BACK_RIGHT_BIT         /* 8 */
113#define DD_DEPTH_BIT       GL_DEPTH_BUFFER_BIT    /* 0x00000100 */
114#define DD_STENCIL_BIT     GL_STENCIL_BUFFER_BIT  /* 0x00000400 */
115#define DD_ACCUM_BIT       GL_ACCUM_BUFFER_BIT    /* 0x00000200 */
116
117
118
119
120
121
122
123/* Point, line, triangle, quadrilateral and rectangle rasterizer
124 * functions.  These are specific to the tnl module and will shortly
125 * move to a driver interface specific to that module.
126 */
127typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last );
128
129typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
130
131typedef void (*triangle_func)( GLcontext *ctx,
132                               GLuint v1, GLuint v2, GLuint v3 );
133
134typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
135                           GLuint v3, GLuint v4 );
136
137typedef void (*render_func)( GLcontext *ctx, GLuint start, GLuint count,
138			     GLuint flags );
139
140typedef void (*interp_func)( GLcontext *ctx,
141			     GLfloat t, GLuint dst, GLuint in, GLuint out,
142			     GLboolean force_boundary );
143
144typedef void (*copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
145
146
147/*
148 * Device Driver function table.
149 */
150struct dd_function_table {
151
152   /**********************************************************************
153    *** Mandatory functions:  these functions must be implemented by   ***
154    *** every device driver.                                           ***
155    **********************************************************************/
156
157   const GLubyte * (*GetString)( GLcontext *ctx, GLenum name );
158   /* Return a string as needed by glGetString().
159    * Only the GL_RENDERER token must be implemented.  Otherwise,
160    * NULL can be returned.
161    */
162
163   void (*UpdateState)( GLcontext *ctx, GLuint new_state );
164   /*
165    * UpdateState() is called whenver Mesa thinks the device driver should
166    * update its state and/or the other pointers (such as PointsFunc,
167    * LineFunc, or TriangleFunc).
168    */
169
170   void (*Clear)( GLcontext *ctx, GLbitfield mask, GLboolean all,
171		  GLint x, GLint y, GLint width, GLint height );
172   /* Clear the color/depth/stencil/accum buffer(s).
173    * 'mask' is a bitmask of the DD_*_BIT values defined above that indicates
174    * which buffers need to be cleared.
175    * If 'all' is true then the clear the whole buffer, else clear only the
176    * region defined by (x,y,width,height).
177    * This function must obey the glColorMask, glIndexMask and glStencilMask
178    * settings!  Software Mesa can do masked clears if the device driver can't.
179    */
180
181   GLboolean (*SetDrawBuffer)( GLcontext *ctx, GLenum buffer );
182   /*
183    * Specifies the current buffer for writing.
184    * The following values must be accepted when applicable:
185    *    GL_FRONT_LEFT - this buffer always exists
186    *    GL_BACK_LEFT - when double buffering
187    *    GL_FRONT_RIGHT - when using stereo
188    *    GL_BACK_RIGHT - when using stereo and double buffering
189    * The folowing values may optionally be accepted.  Return GL_TRUE
190    * if accepted, GL_FALSE if not accepted.  In practice, only drivers
191    * which can write to multiple color buffers at once should accept
192    * these values.
193    *    GL_FRONT - write to front left and front right if it exists
194    *    GL_BACK - write to back left and back right if it exists
195    *    GL_LEFT - write to front left and back left if it exists
196    *    GL_RIGHT - write to right left and back right if they exist
197    *    GL_FRONT_AND_BACK - write to all four buffers if they exist
198    *    GL_NONE - disable buffer write in device driver.
199    */
200
201   void (*SetReadBuffer)( GLcontext *ctx, GLframebuffer *colorBuffer,
202                          GLenum buffer );
203   /*
204    * Specifies the current buffer for reading.
205    * colorBuffer will be one of:
206    *    GL_FRONT_LEFT - this buffer always exists
207    *    GL_BACK_LEFT - when double buffering
208    *    GL_FRONT_RIGHT - when using stereo
209    *    GL_BACK_RIGHT - when using stereo and double buffering
210    */
211
212   void (*GetBufferSize)( GLcontext *ctx, GLuint *width, GLuint *height );
213   /*
214    * Returns the width and height of the current color buffer.
215    */
216
217
218   /***
219    *** Functions for writing pixels to the frame buffer:
220    ***/
221
222   void (*WriteRGBASpan)( const GLcontext *ctx,
223                          GLuint n, GLint x, GLint y,
224                          CONST GLchan rgba[][4], const GLubyte mask[] );
225   void (*WriteRGBSpan)( const GLcontext *ctx,
226                         GLuint n, GLint x, GLint y,
227                         CONST GLchan rgb[][3], const GLubyte mask[] );
228   /* Write a horizontal run of RGBA or RGB pixels.
229    * If mask is NULL, draw all pixels.
230    * If mask is not null, only draw pixel [i] when mask [i] is true.
231    */
232
233   void (*WriteMonoRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
234                              const GLchan color[4], const GLubyte mask[] );
235   /* Write a horizontal run of RGBA pixels all with the same color.
236    */
237
238   void (*WriteRGBAPixels)( const GLcontext *ctx,
239                            GLuint n, const GLint x[], const GLint y[],
240                            CONST GLchan rgba[][4], const GLubyte mask[] );
241   /* Write array of RGBA pixels at random locations.
242    */
243
244   void (*WriteMonoRGBAPixels)( const GLcontext *ctx,
245                                GLuint n, const GLint x[], const GLint y[],
246                                const GLchan color[4], const GLubyte mask[] );
247   /* Write an array of mono-RGBA pixels at random locations.
248    */
249
250   void (*WriteCI32Span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
251                          const GLuint index[], const GLubyte mask[] );
252   void (*WriteCI8Span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
253                         const GLubyte index[], const GLubyte mask[] );
254   /* Write a horizontal run of CI pixels.  One function is for 32bpp
255    * indexes and the other for 8bpp pixels (the common case).  You mus
256    * implement both for color index mode.
257    */
258
259   void (*WriteMonoCISpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
260                            GLuint colorIndex, const GLubyte mask[] );
261   /* Write a horizontal run of color index pixels using the color index
262    * last specified by the Index() function.
263    */
264
265   void (*WriteCI32Pixels)( const GLcontext *ctx,
266                            GLuint n, const GLint x[], const GLint y[],
267                            const GLuint index[], const GLubyte mask[] );
268   /*
269    * Write a random array of CI pixels.
270    */
271
272   void (*WriteMonoCIPixels)( const GLcontext *ctx,
273                              GLuint n, const GLint x[], const GLint y[],
274                              GLuint colorIndex, const GLubyte mask[] );
275   /* Write a random array of color index pixels using the color index
276    * last specified by the Index() function.
277    */
278
279
280   /***
281    *** Functions to read pixels from frame buffer:
282    ***/
283
284   void (*ReadCI32Span)( const GLcontext *ctx,
285                         GLuint n, GLint x, GLint y, GLuint index[] );
286   /* Read a horizontal run of color index pixels.
287    */
288
289   void (*ReadRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
290                         GLchan rgba[][4] );
291   /* Read a horizontal run of RGBA pixels.
292    */
293
294   void (*ReadCI32Pixels)( const GLcontext *ctx,
295                           GLuint n, const GLint x[], const GLint y[],
296                           GLuint indx[], const GLubyte mask[] );
297   /* Read a random array of CI pixels.
298    */
299
300   void (*ReadRGBAPixels)( const GLcontext *ctx,
301                           GLuint n, const GLint x[], const GLint y[],
302                           GLchan rgba[][4], const GLubyte mask[] );
303   /* Read a random array of RGBA pixels.
304    */
305
306
307   /**********************************************************************
308    *** Optional functions:  these functions may or may not be         ***
309    *** implemented by the device driver.  If the device driver        ***
310    *** doesn't implement them it should never touch these pointers    ***
311    *** since Mesa will either set them to NULL or point them at a     ***
312    *** fall-back function.                                            ***
313    **********************************************************************/
314
315   void (*Finish)( GLcontext *ctx );
316   /*
317    * This is called whenever glFinish() is called.
318    */
319
320   void (*Flush)( GLcontext *ctx );
321   /*
322    * This is called whenever glFlush() is called.
323    */
324
325   void (*Error)( GLcontext *ctx );
326   /*
327    * Called whenever an error is generated.  ctx->ErrorValue contains
328    * the error value.
329    */
330
331
332   /***
333    *** For supporting hardware Z buffers:
334    *** Either ALL or NONE of these functions must be implemented!
335    *** NOTE that Each depth value is a 32-bit GLuint.  If the depth
336    *** buffer is less than 32 bits deep then the extra upperbits are zero.
337    ***/
338
339   void (*WriteDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
340                           const GLdepth depth[], const GLubyte mask[] );
341   /* Write a horizontal span of values into the depth buffer.  Only write
342    * depth[i] value if mask[i] is nonzero.
343    */
344
345   void (*ReadDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
346                          GLdepth depth[] );
347   /* Read a horizontal span of values from the depth buffer.
348    */
349
350
351   void (*WriteDepthPixels)( GLcontext *ctx, GLuint n,
352                             const GLint x[], const GLint y[],
353                             const GLdepth depth[], const GLubyte mask[] );
354   /* Write an array of randomly positioned depth values into the
355    * depth buffer.  Only write depth[i] value if mask[i] is nonzero.
356    */
357
358   void (*ReadDepthPixels)( GLcontext *ctx, GLuint n,
359                            const GLint x[], const GLint y[],
360                            GLdepth depth[] );
361   /* Read an array of randomly positioned depth values from the depth buffer.
362    */
363
364
365
366   /***
367    *** For supporting hardware stencil buffers:
368    *** Either ALL or NONE of these functions must be implemented!
369    ***/
370
371   void (*WriteStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
372                             const GLstencil stencil[], const GLubyte mask[] );
373   /* Write a horizontal span of stencil values into the stencil buffer.
374    * If mask is NULL, write all stencil values.
375    * Else, only write stencil[i] if mask[i] is non-zero.
376    */
377
378   void (*ReadStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
379                            GLstencil stencil[] );
380   /* Read a horizontal span of stencil values from the stencil buffer.
381    */
382
383   void (*WriteStencilPixels)( GLcontext *ctx, GLuint n,
384                               const GLint x[], const GLint y[],
385                               const GLstencil stencil[],
386                               const GLubyte mask[] );
387   /* Write an array of stencil values into the stencil buffer.
388    * If mask is NULL, write all stencil values.
389    * Else, only write stencil[i] if mask[i] is non-zero.
390    */
391
392   void (*ReadStencilPixels)( GLcontext *ctx, GLuint n,
393                              const GLint x[], const GLint y[],
394                              GLstencil stencil[] );
395   /* Read an array of stencil values from the stencil buffer.
396    */
397
398
399   /***
400    *** For hardware accumulation buffer:
401    ***/
402   void (*Accum)( GLcontext *ctx, GLenum op, GLfloat value,
403		  GLint xpos, GLint ypos, GLint width, GLint height );
404   /* Execute glAccum command within the given scissor region.
405    */
406
407
408   /***
409    *** glDraw/Read/CopyPixels and glBitmap functions:
410    ***/
411
412   void (*DrawPixels)( GLcontext *ctx,
413		       GLint x, GLint y, GLsizei width, GLsizei height,
414		       GLenum format, GLenum type,
415		       const struct gl_pixelstore_attrib *unpack,
416		       const GLvoid *pixels );
417   /* This is called by glDrawPixels.
418    * 'unpack' describes how to unpack the source image data.
419    */
420
421   void (*ReadPixels)( GLcontext *ctx,
422		       GLint x, GLint y, GLsizei width, GLsizei height,
423		       GLenum format, GLenum type,
424		       const struct gl_pixelstore_attrib *unpack,
425		       GLvoid *dest );
426   /* Called by glReadPixels.
427    */
428
429   void (*CopyPixels)( GLcontext *ctx,
430                            GLint srcx, GLint srcy,
431                            GLsizei width, GLsizei height,
432                            GLint dstx, GLint dsty, GLenum type );
433   /* Do a glCopyPixels.  This function must respect all rasterization
434    * state, glPixelTransfer, glPixelZoom, etc.
435    */
436
437   void (*Bitmap)( GLcontext *ctx,
438		   GLint x, GLint y, GLsizei width, GLsizei height,
439		   const struct gl_pixelstore_attrib *unpack,
440		   const GLubyte *bitmap );
441   /* This is called by glBitmap.  Works the same as DrawPixels, above.
442    */
443
444   void (*ResizeBuffersMESA)( GLcontext *ctx );
445
446
447   /***
448    *** Texture image functions:
449    ***/
450   void (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level,
451                       GLint internalFormat,
452                       GLint width, GLint border,
453                       GLenum format, GLenum type, const GLvoid *pixels,
454                       const struct gl_pixelstore_attrib *packing,
455                       struct gl_texture_object *texObj,
456                       struct gl_texture_image *texImage );
457   void (*TexImage2D)( GLcontext *ctx, GLenum target, GLint level,
458                       GLint internalFormat,
459                       GLint width, GLint height, GLint border,
460                       GLenum format, GLenum type, const GLvoid *pixels,
461                       const struct gl_pixelstore_attrib *packing,
462                       struct gl_texture_object *texObj,
463                       struct gl_texture_image *texImage );
464   void (*TexImage3D)( GLcontext *ctx, GLenum target, GLint level,
465                       GLint internalFormat,
466                       GLint width, GLint height, GLint depth, GLint border,
467                       GLenum format, GLenum type, const GLvoid *pixels,
468                       const struct gl_pixelstore_attrib *packing,
469                       struct gl_texture_object *texObj,
470                       struct gl_texture_image *texImage );
471   /* Called by glTexImage1/2/3D.
472    * Arguments:
473    *   <target>, <level>, <format>, <type> and <pixels> are user specified.
474    *   <packing> indicates the image packing of pixels.
475    *   <texObj> is the target texture object.
476    *   <texImage> is the target texture image.  It will have the texture
477    *      width, height, depth, border and internalFormat information.
478    *   <retainInternalCopy> is returned by this function and indicates whether
479    *      core Mesa should keep an internal copy of the texture image.
480    * Drivers should call a fallback routine from texstore.c if needed.
481    */
482
483   void (*TexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
484                          GLint xoffset, GLsizei width,
485                          GLenum format, GLenum type,
486                          const GLvoid *pixels,
487                          const struct gl_pixelstore_attrib *packing,
488                          struct gl_texture_object *texObj,
489                          struct gl_texture_image *texImage );
490   void (*TexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
491                          GLint xoffset, GLint yoffset,
492                          GLsizei width, GLsizei height,
493                          GLenum format, GLenum type,
494                          const GLvoid *pixels,
495                          const struct gl_pixelstore_attrib *packing,
496                          struct gl_texture_object *texObj,
497                          struct gl_texture_image *texImage );
498   void (*TexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
499                          GLint xoffset, GLint yoffset, GLint zoffset,
500                          GLsizei width, GLsizei height, GLint depth,
501                          GLenum format, GLenum type,
502                          const GLvoid *pixels,
503                          const struct gl_pixelstore_attrib *packing,
504                          struct gl_texture_object *texObj,
505                          struct gl_texture_image *texImage );
506   /* Called by glTexSubImage1/2/3D.
507    * Arguments:
508    *   <target>, <level>, <xoffset>, <yoffset>, <zoffset>, <width>, <height>,
509    *      <depth>, <format>, <type> and <pixels> are user specified.
510    *   <packing> indicates the image packing of pixels.
511    *   <texObj> is the target texture object.
512    *   <texImage> is the target texture image.  It will have the texture
513    *      width, height, border and internalFormat information.
514    * The driver should use a fallback routine from texstore.c if needed.
515    */
516
517   void (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level,
518                           GLenum internalFormat, GLint x, GLint y,
519                           GLsizei width, GLint border );
520   void (*CopyTexImage2D)( GLcontext *ctx, GLenum target, GLint level,
521                           GLenum internalFormat, GLint x, GLint y,
522                           GLsizei width, GLsizei height, GLint border );
523   /* Called by glCopyTexImage1D and glCopyTexImage2D.
524    * Drivers should use a fallback routine from texstore.c if needed.
525    */
526
527   void (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
528                              GLint xoffset,
529                              GLint x, GLint y, GLsizei width );
530   void (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
531                              GLint xoffset, GLint yoffset,
532                              GLint x, GLint y,
533                              GLsizei width, GLsizei height );
534   void (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
535                              GLint xoffset, GLint yoffset, GLint zoffset,
536                              GLint x, GLint y,
537                              GLsizei width, GLsizei height );
538   /* Called by glCopyTexSubImage1/2/3D.
539    * Drivers should use a fallback routine from texstore.c if needed.
540    */
541
542   GLboolean (*TestProxyTexImage)(GLcontext *ctx, GLenum target,
543                                  GLint level, GLint internalFormat,
544                                  GLenum format, GLenum type,
545                                  GLint width, GLint height,
546                                  GLint depth, GLint border);
547   /* Called by glTexImage[123]D when user specifies a proxy texture
548    * target.  Return GL_TRUE if the proxy test passes, return GL_FALSE
549    * if the test fails.
550    */
551
552   /***
553    *** Compressed texture functions:
554    ***/
555
556   void (*CompressedTexImage1D)( GLcontext *ctx, GLenum target,
557                                 GLint level, GLint internalFormat,
558                                 GLsizei width, GLint border,
559                                 GLsizei imageSize, const GLvoid *data,
560                                 struct gl_texture_object *texObj,
561                                 struct gl_texture_image *texImage );
562   void (*CompressedTexImage2D)( GLcontext *ctx, GLenum target,
563                                 GLint level, GLint internalFormat,
564                                 GLsizei width, GLsizei height, GLint border,
565                                 GLsizei imageSize, const GLvoid *data,
566                                 struct gl_texture_object *texObj,
567                                 struct gl_texture_image *texImage );
568   void (*CompressedTexImage3D)( GLcontext *ctx, GLenum target,
569                                 GLint level, GLint internalFormat,
570                                 GLsizei width, GLsizei height, GLsizei depth,
571                                 GLint border,
572                                 GLsizei imageSize, const GLvoid *data,
573                                 struct gl_texture_object *texObj,
574                                 struct gl_texture_image *texImage );
575   /* Called by glCompressedTexImage1/2/3D.
576    * Arguments:
577    *   <target>, <level>, <internalFormat>, <data> are user specified.
578    *   <texObj> is the target texture object.
579    *   <texImage> is the target texture image.  It will have the texture
580    *      width, height, depth, border and internalFormat information.
581    *   <retainInternalCopy> is returned by this function and indicates whether
582    *      core Mesa should keep an internal copy of the texture image.
583    * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
584    * should do the job.
585    */
586
587   void (*CompressedTexSubImage1D)(GLcontext *ctx, GLenum target, GLint level,
588                                   GLint xoffset, GLsizei width,
589                                   GLenum format,
590                                   GLsizei imageSize, const GLvoid *data,
591                                   struct gl_texture_object *texObj,
592                                   struct gl_texture_image *texImage);
593   void (*CompressedTexSubImage2D)(GLcontext *ctx, GLenum target, GLint level,
594                                   GLint xoffset, GLint yoffset,
595                                   GLsizei width, GLint height,
596                                   GLenum format,
597                                   GLsizei imageSize, const GLvoid *data,
598                                   struct gl_texture_object *texObj,
599                                   struct gl_texture_image *texImage);
600   void (*CompressedTexSubImage3D)(GLcontext *ctx, GLenum target, GLint level,
601                                   GLint xoffset, GLint yoffset, GLint zoffset,
602                                   GLsizei width, GLint height, GLint depth,
603                                   GLenum format,
604                                   GLsizei imageSize, const GLvoid *data,
605                                   struct gl_texture_object *texObj,
606                                   struct gl_texture_image *texImage);
607   /* Called by glCompressedTexSubImage1/2/3D.
608    * Arguments:
609    *   <target>, <level>, <x/z/zoffset>, <width>, <height>, <depth>,
610    *      <imageSize>, and <data> are user specified.
611    *   <texObj> is the target texture object.
612    *   <texImage> is the target texture image.  It will have the texture
613    *      width, height, depth, border and internalFormat information.
614    * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
615    * should do the job.
616    */
617
618   GLboolean (*IsCompressedFormat)(GLcontext *ctx, GLint internalFormat);
619   /* Called to tell if a format is a compressed format.
620    */
621
622   void (*GetCompressedTexImage)( GLcontext *ctx, GLenum target,
623                                  GLint lod, void *image,
624                                  const struct gl_texture_object *texObj,
625                                  struct gl_texture_image *texImage );
626   /* Called by glGetCompressedTexImageARB.
627    * <target>, <lod>, <image> are specified by user.
628    * <texObj> is the source texture object.
629    * <texImage> is the source texture image.
630    */
631
632   GLint (*BaseCompressedTexFormat)(GLcontext *ctx,
633                                    GLint internalFormat);
634   /* Called to compute the base format for a specific compressed
635    * format.  Return -1 if the internalFormat is not a specific
636    * compressed format that the driver recognizes.
637    * Example: if internalFormat==GL_COMPRESSED_RGB_FXT1_3DFX, return GL_RGB.
638    */
639
640#if 000
641   /* ... Note the
642    * return value differences between this function and
643    * SpecificCompressedTexFormat below.
644    */
645
646   GLint (*SpecificCompressedTexFormat)(GLcontext *ctx,
647                                        GLint      internalFormat,
648                                        GLint      numDimensions,
649                                        GLint     *levelp,
650                                        GLsizei   *widthp,
651                                        GLsizei   *heightp,
652                                        GLsizei   *depthp,
653                                        GLint     *borderp,
654                                        GLenum    *formatp,
655                                        GLenum    *typep);
656   /* Called to turn a generic texture format into a specific
657    * texture format.  For example, if a driver implements
658    * GL_3DFX_texture_compression_FXT1, this would map
659    * GL_COMPRESSED_RGBA_ARB to GL_COMPRESSED_RGBA_FXT1_3DFX.
660    *
661    * If the driver does not know how to handle the compressed
662    * format, then just return the generic format, and Mesa will
663    * do the right thing with it.
664    */
665
666   GLsizei (*CompressedImageSize)(GLcontext *ctx,
667                                  GLenum internalFormat,
668                                  GLuint numDimensions,
669                                  GLuint width,
670                                  GLuint height,
671                                  GLuint depth);
672   /* Calculate the size of a compressed image, given the image's
673    * format and dimensions.
674    */
675#endif
676
677   /***
678    *** Texture object functions:
679    ***/
680
681   void (*BindTexture)( GLcontext *ctx, GLenum target,
682                        struct gl_texture_object *tObj );
683   /* Called by glBindTexture().
684    */
685
686   void (*CreateTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
687   /* Called when a texture object is created.
688    */
689
690   void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
691   /* Called when a texture object is about to be deallocated.  Driver
692    * should free anything attached to the DriverData pointers.
693    */
694
695   GLboolean (*IsTextureResident)( GLcontext *ctx,
696                                   struct gl_texture_object *t );
697   /* Called by glAreTextureResident().
698    */
699
700   void (*PrioritizeTexture)( GLcontext *ctx,  struct gl_texture_object *t,
701                              GLclampf priority );
702   /* Called by glPrioritizeTextures().
703    */
704
705   void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber );
706   /* Called by glActiveTextureARB to set current texture unit.
707    */
708
709   void (*UpdateTexturePalette)( GLcontext *ctx,
710                                 struct gl_texture_object *tObj );
711   /* Called when the texture's color lookup table is changed.
712    * If tObj is NULL then the shared texture palette ctx->Texture.Palette
713    * is to be updated.
714    */
715
716
717   /***
718    *** State-changing functions (drawing functions are above)
719    ***
720    *** These functions are called by their corresponding OpenGL API functions.
721    *** They're ALSO called by the gl_PopAttrib() function!!!
722    *** May add more functions like these to the device driver in the future.
723    ***/
724   void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLclampf ref);
725   void (*BlendEquation)(GLcontext *ctx, GLenum mode);
726   void (*BlendFunc)(GLcontext *ctx, GLenum sfactor, GLenum dfactor);
727   void (*BlendFuncSeparate)(GLcontext *ctx,
728                             GLenum sfactorRGB, GLenum dfactorRGB,
729                             GLenum sfactorA, GLenum dfactorA);
730   void (*ClearColor)(GLcontext *ctx, const GLchan color[4]);
731   void (*ClearDepth)(GLcontext *ctx, GLclampd d);
732   void (*ClearIndex)(GLcontext *ctx, GLuint index);
733   void (*ClearStencil)(GLcontext *ctx, GLint s);
734   void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
735                     GLboolean bmask, GLboolean amask );
736   void (*CullFace)(GLcontext *ctx, GLenum mode);
737   void (*ClipPlane)(GLcontext *ctx, GLenum plane, const GLfloat *equation );
738   void (*FrontFace)(GLcontext *ctx, GLenum mode);
739   void (*DepthFunc)(GLcontext *ctx, GLenum func);
740   void (*DepthMask)(GLcontext *ctx, GLboolean flag);
741   void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval);
742   void (*Enable)(GLcontext* ctx, GLenum cap, GLboolean state);
743   void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
744   void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode);
745   void (*IndexMask)(GLcontext *ctx, GLuint mask);
746   void (*Lightfv)(GLcontext *ctx, GLenum light,
747		   GLenum pname, const GLfloat *params );
748   void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
749   void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern );
750   void (*LineWidth)(GLcontext *ctx, GLfloat width);
751   void (*LogicOpcode)(GLcontext *ctx, GLenum opcode);
752   void (*PointParameterfv)(GLcontext *ctx, GLenum pname,
753                            const GLfloat *params);
754   void (*PointSize)(GLcontext *ctx, GLfloat size);
755   void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode);
756   void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask );
757   void (*RenderMode)(GLcontext *ctx, GLenum mode );
758   void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
759   void (*ShadeModel)(GLcontext *ctx, GLenum mode);
760   void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
761   void (*StencilMask)(GLcontext *ctx, GLuint mask);
762   void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass);
763   void (*TexGen)(GLcontext *ctx, GLenum coord, GLenum pname,
764		  const GLfloat *params);
765   void (*TexEnv)(GLcontext *ctx, GLenum target, GLenum pname,
766                  const GLfloat *param);
767   void (*TexParameter)(GLcontext *ctx, GLenum target,
768                        struct gl_texture_object *texObj,
769                        GLenum pname, const GLfloat *params);
770   void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat);
771   void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
772
773
774   /*** State-query functions
775    ***
776    *** Return GL_TRUE if query was completed, GL_FALSE otherwise.
777    ***/
778   GLboolean (*GetBooleanv)(GLcontext *ctx, GLenum pname, GLboolean *result);
779   GLboolean (*GetDoublev)(GLcontext *ctx, GLenum pname, GLdouble *result);
780   GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result);
781   GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result);
782   GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result);
783
784
785   /***
786    *** Vertex array functions
787    ***
788    *** Called by the corresponding OpenGL functions.
789    ***/
790   void (*VertexPointer)(GLcontext *ctx, GLint size, GLenum type,
791			 GLsizei stride, const GLvoid *ptr);
792   void (*NormalPointer)(GLcontext *ctx, GLenum type,
793			 GLsizei stride, const GLvoid *ptr);
794   void (*ColorPointer)(GLcontext *ctx, GLint size, GLenum type,
795			GLsizei stride, const GLvoid *ptr);
796   void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
797			   GLsizei stride, const GLvoid *ptr);
798   void (*IndexPointer)(GLcontext *ctx, GLenum type,
799			GLsizei stride, const GLvoid *ptr);
800   void (*SecondaryColorPointer)(GLcontext *ctx, GLint size, GLenum type,
801				 GLsizei stride, const GLvoid *ptr);
802   void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type,
803			   GLsizei stride, const GLvoid *ptr);
804   void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);
805
806
807   /***
808    *** TNL Pipeline
809    ***/
810
811   void (*PipelineStart)(GLcontext *ctx);
812   void (*PipelineFinish)(GLcontext *ctx);
813   /* Called before and after all pipeline stages.
814    * These are a suitable place for grabbing/releasing hardware locks.
815    */
816
817   /***
818    *** Rendering
819    ***/
820
821   void (*RenderStart)(GLcontext *ctx);
822   void (*RenderFinish)(GLcontext *ctx);
823   /* Called before and after all rendering operations, including DrawPixels,
824    * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
825    * These are a suitable place for grabbing/releasing hardware locks.
826    */
827
828   void (*RenderPrimitive)(GLcontext *ctx, GLenum mode);
829   /* Called between RednerStart() and RenderFinish() to indicate the
830    * type of primitive we're about to draw.  Mode will be one of the
831    * modes accepted by glBegin().
832    */
833
834   interp_func RenderInterp;
835   copy_pv_func RenderCopyPV;
836   void (*RenderClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n );
837   void (*RenderClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 );
838   /* Functions to interpolate between prebuilt vertices, copy flat-shade
839    * provoking color, and to render clipped primitives.
840    */
841
842   /***
843    *** Parameters for _tnl_render_stage
844    ***/
845   points_func           PointsFunc; /* must now respect vb->elts */
846   line_func             LineFunc;
847   triangle_func         TriangleFunc;
848   quad_func             QuadFunc;
849   /* These functions are called in order to render points, lines,
850    * triangles and quads.  These are only called via the T&L module.
851    */
852
853   render_func          *RenderTabVerts;
854   render_func          *RenderTabElts;
855   /* XXX Description???
856    */
857
858   void (*ResetLineStipple)( GLcontext *ctx );
859   /* Reset the hardware's line stipple counter.
860    */
861
862   void (*BuildProjectedVertices)( GLcontext *ctx,
863				   GLuint start, GLuint end,
864				   GLuint new_inputs);
865   /* This function is called whenever new vertices are required for
866    * rendering.  The vertices in question are those n such that start
867    * <= n < end.  The new_inputs parameter indicates those fields of
868    * the vertex which need to be updated, if only a partial repair of
869    * the vertex is required.
870    *
871    * This function is called only from _tnl_render_stage in tnl/t_render.c.
872    */
873
874
875   GLboolean (*MultipassFunc)( GLcontext *ctx, GLuint passno );
876   /* Driver may request additional render passes by returning GL_TRUE
877    * when this function is called.  This function will be called
878    * after the first pass, and passes will be made until the function
879    * returns GL_FALSE.  If no function is registered, only one pass
880    * is made.
881    *
882    * This function will be first invoked with passno == 1.
883    */
884
885
886   /***
887    *** Support for multiple t&l engines
888    ***/
889#define PRIM_OUTSIDE_BEGIN_END   GL_POLYGON+1
890#define PRIM_INSIDE_UNKNOWN_PRIM GL_POLYGON+2
891#define PRIM_UNKNOWN             GL_POLYGON+3
892
893   GLuint CurrentExecPrimitive;
894   /* Set by the driver-supplied t&l engine.  Set to
895    * PRIM_OUTSIDE_BEGIN_END when outside begin/end.
896    */
897
898   GLuint CurrentSavePrimitive;
899   /* Current state of an in-progress compilation.  May take on any of
900    * the additional values defined above.
901    */
902
903
904
905#define FLUSH_STORED_VERTICES 0x1
906#define FLUSH_UPDATE_CURRENT  0x2
907   GLuint NeedFlush;
908   /* Set by the driver-supplied t&l engine whenever vertices are
909    * buffered between begin/end objects or ctx->Current is not uptodate.
910    *
911    * The FlushVertices() call below may be used to resolve
912    * these conditions.
913    */
914
915   void (*FlushVertices)( GLcontext *ctx, GLuint flags );
916   /* If inside begin/end, ASSERT(0).
917    * Otherwise,
918    *   if (flags & FLUSH_STORED_VERTICES) flushes any buffered vertices,
919    *   if (flags & FLUSH_UPDATE_CURRENT) updates ctx->Current
920    *                                     and ctx->Light.Material
921    *
922    * Note that the default t&l engine never clears the
923    * FLUSH_UPDATE_CURRENT bit, even after performing the update.
924    */
925
926   void (*LightingSpaceChange)( GLcontext *ctx );
927   /* Notify driver that the special derived value _NeedEyeCoords has
928    * changed.
929    */
930
931   void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode );
932   void (*EndList)( GLcontext *ctx );
933   /* Let the t&l component know what is going on with display lists
934    * in time to make changes to dispatch tables, etc.
935    * Called by glNewList() and glEndList(), respectively.
936    */
937
938   void (*BeginCallList)( GLcontext *ctx, GLuint list );
939   void (*EndCallList)( GLcontext *ctx );
940   /* Notify the t&l component before and after calling a display list.
941    * Called by glCallList(s), but not recursively.
942    */
943
944   void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
945			GLframebuffer *readBuffer );
946   /* Let the t&l component know when the context becomes current.
947    */
948
949
950   void (*LockArraysEXT)( GLcontext *ctx, GLint first, GLsizei count );
951   void (*UnlockArraysEXT)( GLcontext *ctx );
952   /* Called by glLockArraysEXT() and glUnlockArraysEXT(), respectively.
953    */
954
955};
956
957
958
959/*
960 * Transform/Clip/Lighting interface
961 */
962typedef struct {
963   void (*ArrayElement)( GLint ); /* NOTE */
964   void (*Color3f)( GLfloat, GLfloat, GLfloat );
965   void (*Color3fv)( const GLfloat * );
966   void (*Color3ub)( GLubyte, GLubyte, GLubyte );
967   void (*Color3ubv)( const GLubyte * );
968   void (*Color4f)( GLfloat, GLfloat, GLfloat, GLfloat );
969   void (*Color4fv)( const GLfloat * );
970   void (*Color4ub)( GLubyte, GLubyte, GLubyte, GLubyte );
971   void (*Color4ubv)( const GLubyte * );
972   void (*EdgeFlag)( GLboolean );
973   void (*EdgeFlagv)( const GLboolean * );
974   void (*EvalCoord1f)( GLfloat );          /* NOTE */
975   void (*EvalCoord1fv)( const GLfloat * ); /* NOTE */
976   void (*EvalCoord2f)( GLfloat, GLfloat ); /* NOTE */
977   void (*EvalCoord2fv)( const GLfloat * ); /* NOTE */
978   void (*EvalPoint1)( GLint );             /* NOTE */
979   void (*EvalPoint2)( GLint, GLint );      /* NOTE */
980   void (*FogCoordfEXT)( GLfloat );
981   void (*FogCoordfvEXT)( const GLfloat * );
982   void (*Indexi)( GLint );
983   void (*Indexiv)( const GLint * );
984   void (*Materialfv)( GLenum face, GLenum pname, const GLfloat * ); /* NOTE */
985   void (*MultiTexCoord1fARB)( GLenum, GLfloat );
986   void (*MultiTexCoord1fvARB)( GLenum, const GLfloat * );
987   void (*MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat );
988   void (*MultiTexCoord2fvARB)( GLenum, const GLfloat * );
989   void (*MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat );
990   void (*MultiTexCoord3fvARB)( GLenum, const GLfloat * );
991   void (*MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat );
992   void (*MultiTexCoord4fvARB)( GLenum, const GLfloat * );
993   void (*Normal3f)( GLfloat, GLfloat, GLfloat );
994   void (*Normal3fv)( const GLfloat * );
995   void (*SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat );
996   void (*SecondaryColor3fvEXT)( const GLfloat * );
997   void (*SecondaryColor3ubEXT)( GLubyte, GLubyte, GLubyte );
998   void (*SecondaryColor3ubvEXT)( const GLubyte * );
999   void (*TexCoord1f)( GLfloat );
1000   void (*TexCoord1fv)( const GLfloat * );
1001   void (*TexCoord2f)( GLfloat, GLfloat );
1002   void (*TexCoord2fv)( const GLfloat * );
1003   void (*TexCoord3f)( GLfloat, GLfloat, GLfloat );
1004   void (*TexCoord3fv)( const GLfloat * );
1005   void (*TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat );
1006   void (*TexCoord4fv)( const GLfloat * );
1007   void (*Vertex2f)( GLfloat, GLfloat );
1008   void (*Vertex2fv)( const GLfloat * );
1009   void (*Vertex3f)( GLfloat, GLfloat, GLfloat );
1010   void (*Vertex3fv)( const GLfloat * );
1011   void (*Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat );
1012   void (*Vertex4fv)( const GLfloat * );
1013   void (*CallList)( GLuint );	/* NOTE */
1014   void (*Begin)( GLenum );
1015   void (*End)( void );
1016   /* Drivers present a reduced set of the functions possible in
1017    * begin/end objects.  Core mesa provides translation stubs for the
1018    * remaining functions to map down to these entrypoints.
1019    *
1020    * These are the initial values to be installed into dispatch by
1021    * mesa.  If the t&l driver wants to modify the dispatch table
1022    * while installed, it must do so itself.  It would be possible for
1023    * the vertexformat to install it's own initial values for these
1024    * functions, but this way there is an obvious list of what is
1025    * expected of the driver.
1026    *
1027    * If the driver wants to hook in entrypoints other than those
1028    * listed above, it must restore them to their original values in
1029    * the disable() callback, below.
1030    */
1031
1032   void (*Rectf)( GLfloat, GLfloat, GLfloat, GLfloat );
1033   /*
1034    */
1035
1036
1037   void (*DrawArrays)( GLenum mode, GLint start, GLsizei count );
1038   void (*DrawElements)( GLenum mode, GLsizei count, GLenum type,
1039			 const GLvoid *indices );
1040   void (*DrawRangeElements)(GLenum mode, GLuint start,
1041			     GLuint end, GLsizei count,
1042			     GLenum type, const GLvoid *indices);
1043   /* These may or may not belong here.  Heuristic: If an array is
1044    * enabled, the installed vertex format should support that array and
1045    * it's current size natively.
1046    */
1047
1048   void (*EvalMesh1)( GLenum mode, GLint i1, GLint i2 );
1049   void (*EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
1050   /* If you don't support eval, fallback to the default vertex format
1051    * on receiving an eval call and use the pipeline mechanism to
1052    * provide partial t&l acceleration.
1053    *
1054    * Mesa will provide a set of helper functions to do eval within
1055    * accelerated vertex formats, eventually...
1056    *
1057    * Update: There seem to be issues re. maintaining correct values
1058    * for 'ctx->Current' in the face of Eval and T&L fallbacks...
1059    */
1060
1061   GLboolean prefer_float_colors;
1062   /* Should core send non-standard colors to glColor4f or glColor4ub
1063    */
1064
1065
1066} GLvertexformat;
1067
1068
1069#endif
1070
1071