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