dd.h revision 22144ab7552f0799bcfca506bf4ffa7f70a06649
1/* $Id: dd.h,v 1.58 2001/03/12 00:48:37 gareth Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version:  3.5
6 *
7 * Copyright (C) 1999-2001  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 drivers
74 * in OSmesa/ and X/ for examples.
75 *
76 * Look below in the dd_function_table struct definition for descriptions
77 * of each device driver function.
78 *
79 * More function pointers may be added as required.
80 *
81 *
82 * Notes:
83 * ------
84 *   RGBA = red/green/blue/alpha
85 *   CI = color index (color mapped mode)
86 *   mono = all pixels have the same color or index
87 *
88 *   The write_ functions all take an array of mask flags which indicate
89 *   whether or not the pixel should be written.  One special case exists
90 *   in the write_color_span function: if the mask array is NULL, then
91 *   draw all pixels.  This is an optimization used for glDrawPixels().
92 *
93 * IN ALL CASES:
94 *      X coordinates start at 0 at the left and increase to the right
95 *      Y coordinates start at 0 at the bottom and increase upward
96 *
97 */
98
99
100
101
102
103
104/* Mask bits sent to the driver Clear() function */
105#define DD_FRONT_LEFT_BIT  FRONT_LEFT_BIT         /* 1 */
106#define DD_FRONT_RIGHT_BIT FRONT_RIGHT_BIT        /* 2 */
107#define DD_BACK_LEFT_BIT   BACK_LEFT_BIT          /* 4 */
108#define DD_BACK_RIGHT_BIT  BACK_RIGHT_BIT         /* 8 */
109#define DD_DEPTH_BIT       GL_DEPTH_BUFFER_BIT    /* 0x00000100 */
110#define DD_STENCIL_BIT     GL_STENCIL_BUFFER_BIT  /* 0x00000400 */
111#define DD_ACCUM_BIT       GL_ACCUM_BUFFER_BIT    /* 0x00000200 */
112
113
114
115
116
117
118
119/* Point, line, triangle, quadrilateral and rectangle rasterizer
120 * functions.  These are specific to the tnl module and will shortly
121 * move to a driver interface specific to that module.
122 */
123typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last );
124
125typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
126
127typedef void (*triangle_func)( GLcontext *ctx,
128                               GLuint v1, GLuint v2, GLuint v3 );
129
130typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
131                           GLuint v3, GLuint v4 );
132
133typedef void (*render_func)( GLcontext *ctx, GLuint start, GLuint count,
134			     GLuint flags );
135
136typedef void (*interp_func)( GLcontext *ctx,
137			     GLfloat t, GLuint dst, GLuint in, GLuint out,
138			     GLboolean force_boundary );
139
140typedef void (*copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
141
142
143/*
144 * Device Driver function table.
145 */
146struct dd_function_table {
147
148   /**********************************************************************
149    *** Mandatory functions:  these functions must be implemented by   ***
150    *** every device driver.                                           ***
151    **********************************************************************/
152
153   const GLubyte * (*GetString)( GLcontext *ctx, GLenum name );
154   /* Return a string as needed by glGetString().
155    * Only the GL_RENDERER token must be implemented.  Otherwise,
156    * NULL can be returned.
157    */
158
159   void (*UpdateState)( GLcontext *ctx, GLuint new_state );
160   /*
161    * UpdateState() is called whenver Mesa thinks the device driver should
162    * update its state and/or the other pointers (such as PointsFunc,
163    * LineFunc, or TriangleFunc).
164    */
165
166   void (*Clear)( GLcontext *ctx, GLbitfield mask, GLboolean all,
167		  GLint x, GLint y, GLint width, GLint height );
168   /* Clear the color/depth/stencil/accum buffer(s).
169    * 'mask' is a bitmask of the DD_*_BIT values defined above that indicates
170    * which buffers need to be cleared.
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   void (*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   void (*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    */
416
417   void (*ReadPixels)( GLcontext *ctx,
418		       GLint x, GLint y, GLsizei width, GLsizei height,
419		       GLenum format, GLenum type,
420		       const struct gl_pixelstore_attrib *unpack,
421		       GLvoid *dest );
422   /* Called by glReadPixels.
423    */
424
425   void (*CopyPixels)( GLcontext *ctx,
426                            GLint srcx, GLint srcy,
427                            GLsizei width, GLsizei height,
428                            GLint dstx, GLint dsty, GLenum type );
429   /* Do a glCopyPixels.  This function must respect all rasterization
430    * state, glPixelTransfer, glPixelZoom, etc.
431    */
432
433   void (*Bitmap)( GLcontext *ctx,
434		   GLint x, GLint y, GLsizei width, GLsizei height,
435		   const struct gl_pixelstore_attrib *unpack,
436		   const GLubyte *bitmap );
437   /* This is called by glBitmap.  Works the same as DrawPixels, above.
438    */
439
440   void (*ResizeBuffersMESA)( GLcontext *ctx );
441
442
443   /***
444    *** Texture image functions:
445    ***/
446   void (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level,
447                       GLint internalFormat,
448                       GLint width, GLint border,
449                       GLenum format, GLenum type, const GLvoid *pixels,
450                       const struct gl_pixelstore_attrib *packing,
451                       struct gl_texture_object *texObj,
452                       struct gl_texture_image *texImage );
453   void (*TexImage2D)( GLcontext *ctx, GLenum target, GLint level,
454                       GLint internalFormat,
455                       GLint width, GLint height, GLint border,
456                       GLenum format, GLenum type, const GLvoid *pixels,
457                       const struct gl_pixelstore_attrib *packing,
458                       struct gl_texture_object *texObj,
459                       struct gl_texture_image *texImage );
460   void (*TexImage3D)( GLcontext *ctx, GLenum target, GLint level,
461                       GLint internalFormat,
462                       GLint width, GLint height, GLint depth, GLint border,
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   /* Called by glTexImage1/2/3D.
468    * Arguments:
469    *   <target>, <level>, <format>, <type> and <pixels> are user specified.
470    *   <packing> indicates the image packing of pixels.
471    *   <texObj> is the target texture object.
472    *   <texImage> is the target texture image.  It will have the texture
473    *      width, height, depth, border and internalFormat information.
474    *   <retainInternalCopy> is returned by this function and indicates whether
475    *      core Mesa should keep an internal copy of the texture image.
476    * Drivers should call a fallback routine from texstore.c if needed.
477    */
478
479   void (*TexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
480                          GLint xoffset, GLsizei width,
481                          GLenum format, GLenum type,
482                          const GLvoid *pixels,
483                          const struct gl_pixelstore_attrib *packing,
484                          struct gl_texture_object *texObj,
485                          struct gl_texture_image *texImage );
486   void (*TexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
487                          GLint xoffset, GLint yoffset,
488                          GLsizei width, GLsizei height,
489                          GLenum format, GLenum type,
490                          const GLvoid *pixels,
491                          const struct gl_pixelstore_attrib *packing,
492                          struct gl_texture_object *texObj,
493                          struct gl_texture_image *texImage );
494   void (*TexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
495                          GLint xoffset, GLint yoffset, GLint zoffset,
496                          GLsizei width, GLsizei height, GLint depth,
497                          GLenum format, GLenum type,
498                          const GLvoid *pixels,
499                          const struct gl_pixelstore_attrib *packing,
500                          struct gl_texture_object *texObj,
501                          struct gl_texture_image *texImage );
502   /* Called by glTexSubImage1/2/3D.
503    * Arguments:
504    *   <target>, <level>, <xoffset>, <yoffset>, <zoffset>, <width>, <height>,
505    *      <depth>, <format>, <type> and <pixels> are user specified.
506    *   <packing> indicates the image packing of pixels.
507    *   <texObj> is the target texture object.
508    *   <texImage> is the target texture image.  It will have the texture
509    *      width, height, border and internalFormat information.
510    * The driver should use a fallback routine from texstore.c if needed.
511    */
512
513   void (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level,
514                           GLenum internalFormat, GLint x, GLint y,
515                           GLsizei width, GLint border );
516   void (*CopyTexImage2D)( GLcontext *ctx, GLenum target, GLint level,
517                           GLenum internalFormat, GLint x, GLint y,
518                           GLsizei width, GLsizei height, GLint border );
519   /* Called by glCopyTexImage1D and glCopyTexImage2D.
520    * Drivers should use a fallback routine from texstore.c if needed.
521    */
522
523   void (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
524                              GLint xoffset,
525                              GLint x, GLint y, GLsizei width );
526   void (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
527                              GLint xoffset, GLint yoffset,
528                              GLint x, GLint y,
529                              GLsizei width, GLsizei height );
530   void (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
531                              GLint xoffset, GLint yoffset, GLint zoffset,
532                              GLint x, GLint y,
533                              GLsizei width, GLsizei height );
534   /* Called by glCopyTexSubImage1/2/3D.
535    * Drivers should use a fallback routine from texstore.c if needed.
536    */
537
538   GLboolean (*TestProxyTexImage)(GLcontext *ctx, GLenum target,
539                                  GLint level, GLint internalFormat,
540                                  GLenum format, GLenum type,
541                                  GLint width, GLint height,
542                                  GLint depth, GLint border);
543   /* Called by glTexImage[123]D when user specifies a proxy texture
544    * target.  Return GL_TRUE if the proxy test passes, return GL_FALSE
545    * if the test fails.
546    */
547
548   /***
549    *** Compressed texture functions:
550    ***/
551
552   void (*CompressedTexImage1D)( GLcontext *ctx, GLenum target,
553                                 GLint level, GLint internalFormat,
554                                 GLsizei width, GLint border,
555                                 GLsizei imageSize, const GLvoid *data,
556                                 struct gl_texture_object *texObj,
557                                 struct gl_texture_image *texImage );
558   void (*CompressedTexImage2D)( GLcontext *ctx, GLenum target,
559                                 GLint level, GLint internalFormat,
560                                 GLsizei width, GLsizei height, GLint border,
561                                 GLsizei imageSize, const GLvoid *data,
562                                 struct gl_texture_object *texObj,
563                                 struct gl_texture_image *texImage );
564   void (*CompressedTexImage3D)( GLcontext *ctx, GLenum target,
565                                 GLint level, GLint internalFormat,
566                                 GLsizei width, GLsizei height, GLsizei depth,
567                                 GLint border,
568                                 GLsizei imageSize, const GLvoid *data,
569                                 struct gl_texture_object *texObj,
570                                 struct gl_texture_image *texImage );
571   /* Called by glCompressedTexImage1/2/3D.
572    * Arguments:
573    *   <target>, <level>, <internalFormat>, <data> are user specified.
574    *   <texObj> is the target texture object.
575    *   <texImage> is the target texture image.  It will have the texture
576    *      width, height, depth, border and internalFormat information.
577    *   <retainInternalCopy> is returned by this function and indicates whether
578    *      core Mesa should keep an internal copy of the texture image.
579    * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
580    * should do the job.
581    */
582
583   void (*CompressedTexSubImage1D)(GLcontext *ctx, GLenum target, GLint level,
584                                   GLint xoffset, GLsizei width,
585                                   GLenum format,
586                                   GLsizei imageSize, const GLvoid *data,
587                                   struct gl_texture_object *texObj,
588                                   struct gl_texture_image *texImage);
589   void (*CompressedTexSubImage2D)(GLcontext *ctx, GLenum target, GLint level,
590                                   GLint xoffset, GLint yoffset,
591                                   GLsizei width, GLint height,
592                                   GLenum format,
593                                   GLsizei imageSize, const GLvoid *data,
594                                   struct gl_texture_object *texObj,
595                                   struct gl_texture_image *texImage);
596   void (*CompressedTexSubImage3D)(GLcontext *ctx, GLenum target, GLint level,
597                                   GLint xoffset, GLint yoffset, GLint zoffset,
598                                   GLsizei width, GLint height, GLint depth,
599                                   GLenum format,
600                                   GLsizei imageSize, const GLvoid *data,
601                                   struct gl_texture_object *texObj,
602                                   struct gl_texture_image *texImage);
603   /* Called by glCompressedTexSubImage1/2/3D.
604    * Arguments:
605    *   <target>, <level>, <x/z/zoffset>, <width>, <height>, <depth>,
606    *      <imageSize>, and <data> are user specified.
607    *   <texObj> is the target texture object.
608    *   <texImage> is the target texture image.  It will have the texture
609    *      width, height, depth, border and internalFormat information.
610    * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
611    * should do the job.
612    */
613
614   GLboolean (*IsCompressedFormat)(GLcontext *ctx, GLint internalFormat);
615   /* Called to tell if a format is a compressed format.
616    */
617
618   void (*GetCompressedTexImage)( GLcontext *ctx, GLenum target,
619                                  GLint lod, void *image,
620                                  const struct gl_texture_object *texObj,
621                                  struct gl_texture_image *texImage );
622   /* Called by glGetCompressedTexImageARB.
623    * <target>, <lod>, <image> are specified by user.
624    * <texObj> is the source texture object.
625    * <texImage> is the source texture image.
626    */
627
628   GLint (*BaseCompressedTexFormat)(GLcontext *ctx,
629                                    GLint internalFormat);
630   /* Called to compute the base format for a specific compressed
631    * format.  Return -1 if the internalFormat is not a specific
632    * compressed format that the driver recognizes.
633    * Example: if internalFormat==GL_COMPRESSED_RGB_FXT1_3DFX, return GL_RGB.
634    */
635
636#if 000
637   /* ... Note the
638    * return value differences between this function and
639    * SpecificCompressedTexFormat below.
640    */
641
642   GLint (*SpecificCompressedTexFormat)(GLcontext *ctx,
643                                        GLint      internalFormat,
644                                        GLint      numDimensions,
645                                        GLint     *levelp,
646                                        GLsizei   *widthp,
647                                        GLsizei   *heightp,
648                                        GLsizei   *depthp,
649                                        GLint     *borderp,
650                                        GLenum    *formatp,
651                                        GLenum    *typep);
652   /* Called to turn a generic texture format into a specific
653    * texture format.  For example, if a driver implements
654    * GL_3DFX_texture_compression_FXT1, this would map
655    * GL_COMPRESSED_RGBA_ARB to GL_COMPRESSED_RGBA_FXT1_3DFX.
656    *
657    * If the driver does not know how to handle the compressed
658    * format, then just return the generic format, and Mesa will
659    * do the right thing with it.
660    */
661
662   GLsizei (*CompressedImageSize)(GLcontext *ctx,
663                                  GLenum internalFormat,
664                                  GLuint numDimensions,
665                                  GLuint width,
666                                  GLuint height,
667                                  GLuint depth);
668   /* Calculate the size of a compressed image, given the image's
669    * format and dimensions.
670    */
671#endif
672
673   /***
674    *** Texture object functions:
675    ***/
676
677   void (*BindTexture)( GLcontext *ctx, GLenum target,
678                        struct gl_texture_object *tObj );
679   /* Called by glBindTexture().
680    */
681
682   void (*CreateTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
683   /* Called when a texture object is created.
684    */
685
686   void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
687   /* Called when a texture object is about to be deallocated.  Driver
688    * should free anything attached to the DriverData pointers.
689    */
690
691   GLboolean (*IsTextureResident)( GLcontext *ctx,
692                                   struct gl_texture_object *t );
693   /* Called by glAreTextureResident().
694    */
695
696   void (*PrioritizeTexture)( GLcontext *ctx,  struct gl_texture_object *t,
697                              GLclampf priority );
698   /* Called by glPrioritizeTextures().
699    */
700
701   void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber );
702   /* Called by glActiveTextureARB to set current texture unit.
703    */
704
705   void (*UpdateTexturePalette)( GLcontext *ctx,
706                                 struct gl_texture_object *tObj );
707   /* Called when the texture's color lookup table is changed.
708    * If tObj is NULL then the shared texture palette ctx->Texture.Palette
709    * is to be updated.
710    */
711
712
713   /***
714    *** State-changing functions (drawing functions are above)
715    ***
716    *** These functions are called by their corresponding OpenGL API functions.
717    *** They're ALSO called by the gl_PopAttrib() function!!!
718    *** May add more functions like these to the device driver in the future.
719    ***/
720   void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLchan ref);
721   void (*BlendColor)(GLcontext *ctx, const GLfloat color[4]);
722   void (*BlendEquation)(GLcontext *ctx, GLenum mode);
723   void (*BlendFunc)(GLcontext *ctx, GLenum sfactor, GLenum dfactor);
724   void (*BlendFuncSeparate)(GLcontext *ctx,
725                             GLenum sfactorRGB, GLenum dfactorRGB,
726                             GLenum sfactorA, GLenum dfactorA);
727   void (*ClearColor)(GLcontext *ctx, const GLchan color[4]);
728   void (*ClearDepth)(GLcontext *ctx, GLclampd d);
729   void (*ClearIndex)(GLcontext *ctx, GLuint index);
730   void (*ClearStencil)(GLcontext *ctx, GLint s);
731   void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
732                     GLboolean bmask, GLboolean amask );
733   void (*CullFace)(GLcontext *ctx, GLenum mode);
734   void (*ClipPlane)(GLcontext *ctx, GLenum plane, const GLfloat *equation );
735   void (*FrontFace)(GLcontext *ctx, GLenum mode);
736   void (*DepthFunc)(GLcontext *ctx, GLenum func);
737   void (*DepthMask)(GLcontext *ctx, GLboolean flag);
738   void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval);
739   void (*Enable)(GLcontext* ctx, GLenum cap, GLboolean state);
740   void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
741   void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode);
742   void (*IndexMask)(GLcontext *ctx, GLuint mask);
743   void (*Lightfv)(GLcontext *ctx, GLenum light,
744		   GLenum pname, const GLfloat *params );
745   void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
746   void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern );
747   void (*LineWidth)(GLcontext *ctx, GLfloat width);
748   void (*LogicOpcode)(GLcontext *ctx, GLenum opcode);
749   void (*PointParameterfv)(GLcontext *ctx, GLenum pname,
750                            const GLfloat *params);
751   void (*PointSize)(GLcontext *ctx, GLfloat size);
752   void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode);
753   void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask );
754   void (*RenderMode)(GLcontext *ctx, GLenum mode );
755   void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
756   void (*ShadeModel)(GLcontext *ctx, GLenum mode);
757   void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
758   void (*StencilMask)(GLcontext *ctx, GLuint mask);
759   void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass);
760   void (*TexGen)(GLcontext *ctx, GLenum coord, GLenum pname,
761		  const GLfloat *params);
762   void (*TexEnv)(GLcontext *ctx, GLenum target, GLenum pname,
763                  const GLfloat *param);
764   void (*TexParameter)(GLcontext *ctx, GLenum target,
765                        struct gl_texture_object *texObj,
766                        GLenum pname, const GLfloat *params);
767   void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat);
768   void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
769
770
771   /*** State-query functions
772    ***
773    *** Return GL_TRUE if query was completed, GL_FALSE otherwise.
774    ***/
775   GLboolean (*GetBooleanv)(GLcontext *ctx, GLenum pname, GLboolean *result);
776   GLboolean (*GetDoublev)(GLcontext *ctx, GLenum pname, GLdouble *result);
777   GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result);
778   GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result);
779   GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result);
780
781
782   /***
783    *** Vertex array functions
784    ***
785    *** Called by the corresponding OpenGL functions.
786    ***/
787   void (*VertexPointer)(GLcontext *ctx, GLint size, GLenum type,
788			 GLsizei stride, const GLvoid *ptr);
789   void (*NormalPointer)(GLcontext *ctx, GLenum type,
790			 GLsizei stride, const GLvoid *ptr);
791   void (*ColorPointer)(GLcontext *ctx, GLint size, GLenum type,
792			GLsizei stride, const GLvoid *ptr);
793   void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
794			   GLsizei stride, const GLvoid *ptr);
795   void (*IndexPointer)(GLcontext *ctx, GLenum type,
796			GLsizei stride, const GLvoid *ptr);
797   void (*SecondaryColorPointer)(GLcontext *ctx, GLint size, GLenum type,
798				 GLsizei stride, const GLvoid *ptr);
799   void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type,
800			   GLsizei stride, const GLvoid *ptr);
801   void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);
802
803
804   /***
805    *** TNL Pipeline
806    ***/
807
808   void (*PipelineStart)(GLcontext *ctx);
809   void (*PipelineFinish)(GLcontext *ctx);
810   /* Called before and after all pipeline stages.
811    * These are a suitable place for grabbing/releasing hardware locks.
812    */
813
814   /***
815    *** Rendering
816    ***/
817
818   void (*RenderStart)(GLcontext *ctx);
819   void (*RenderFinish)(GLcontext *ctx);
820   /* Called before and after all rendering operations, including DrawPixels,
821    * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
822    * These are a suitable place for grabbing/releasing hardware locks.
823    */
824
825   void (*RenderPrimitive)(GLcontext *ctx, GLenum mode);
826   /* Called between RednerStart() and RenderFinish() to indicate the
827    * type of primitive we're about to draw.  Mode will be one of the
828    * modes accepted by glBegin().
829    */
830
831   interp_func RenderInterp;
832   copy_pv_func RenderCopyPV;
833   void (*RenderClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n );
834   void (*RenderClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 );
835   /* Functions to interpolate between prebuilt vertices, copy flat-shade
836    * provoking color, and to render clipped primitives.
837    */
838
839   /***
840    *** Parameters for _tnl_render_stage
841    ***/
842   points_func           PointsFunc; /* must now respect vb->elts */
843   line_func             LineFunc;
844   triangle_func         TriangleFunc;
845   quad_func             QuadFunc;
846   /* These functions are called in order to render points, lines,
847    * triangles and quads.  These are only called via the T&L module.
848    */
849
850   render_func          *RenderTabVerts;
851   render_func          *RenderTabElts;
852   /* Render whole unclipped primitives (points, lines, linestrips,
853    * lineloops, etc).  The tables are indexed by the GL enum of the
854    * primitive to be rendered.
855    */
856
857   void (*ResetLineStipple)( GLcontext *ctx );
858   /* Reset the hardware's line stipple counter.
859    */
860
861   void (*BuildProjectedVertices)( GLcontext *ctx,
862				   GLuint start, GLuint end,
863				   GLuint new_inputs);
864   /* This function is called whenever new vertices are required for
865    * rendering.  The vertices in question are those n such that start
866    * <= n < end.  The new_inputs parameter indicates those fields of
867    * the vertex which need to be updated, if only a partial repair of
868    * the vertex is required.
869    *
870    * This function is called only from _tnl_render_stage in tnl/t_render.c.
871    */
872
873
874   GLboolean (*MultipassFunc)( GLcontext *ctx, GLuint passno );
875   /* Driver may request additional render passes by returning GL_TRUE
876    * when this function is called.  This function will be called
877    * after the first pass, and passes will be made until the function
878    * returns GL_FALSE.  If no function is registered, only one pass
879    * is made.
880    *
881    * This function will be first invoked with passno == 1.
882    */
883
884
885   /***
886    *** Support for multiple t&l engines
887    ***/
888
889   GLuint NeedValidate;
890   /* Bitmask of state changes that require the current tnl module to be
891    * validated, using ValidateTnlModule() below.
892    */
893
894   void (*ValidateTnlModule)( GLcontext *ctx, GLuint new_state );
895   /* Validate the current tnl module.  This is called directly after
896    * UpdateState() when a state change that has occured matches the
897    * NeedValidate bitmask above.  This ensures all computed values are
898    * up to date, thus allowing the driver to decide if the current tnl
899    * module needs to be swapped out.
900    *
901    * This must be non-NULL if a driver installs a custom tnl module and
902    * sets the NeedValidate bitmask, but may be NULL otherwise.
903    */
904
905
906#define PRIM_OUTSIDE_BEGIN_END   GL_POLYGON+1
907#define PRIM_INSIDE_UNKNOWN_PRIM GL_POLYGON+2
908#define PRIM_UNKNOWN             GL_POLYGON+3
909
910   GLuint CurrentExecPrimitive;
911   /* Set by the driver-supplied t&l engine.  Set to
912    * PRIM_OUTSIDE_BEGIN_END when outside begin/end.
913    */
914
915   GLuint CurrentSavePrimitive;
916   /* Current state of an in-progress compilation.  May take on any of
917    * the additional values defined above.
918    */
919
920
921#define FLUSH_STORED_VERTICES 0x1
922#define FLUSH_UPDATE_CURRENT  0x2
923   GLuint NeedFlush;
924   /* Set by the driver-supplied t&l engine whenever vertices are
925    * buffered between begin/end objects or ctx->Current is not uptodate.
926    *
927    * The FlushVertices() call below may be used to resolve
928    * these conditions.
929    */
930
931   void (*FlushVertices)( GLcontext *ctx, GLuint flags );
932   /* If inside begin/end, ASSERT(0).
933    * Otherwise,
934    *   if (flags & FLUSH_STORED_VERTICES) flushes any buffered vertices,
935    *   if (flags & FLUSH_UPDATE_CURRENT) updates ctx->Current
936    *                                     and ctx->Light.Material
937    *
938    * Note that the default t&l engine never clears the
939    * FLUSH_UPDATE_CURRENT bit, even after performing the update.
940    */
941
942   void (*LightingSpaceChange)( GLcontext *ctx );
943   /* Notify driver that the special derived value _NeedEyeCoords has
944    * changed.
945    */
946
947   void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode );
948   void (*EndList)( GLcontext *ctx );
949   /* Let the t&l component know what is going on with display lists
950    * in time to make changes to dispatch tables, etc.
951    * Called by glNewList() and glEndList(), respectively.
952    */
953
954   void (*BeginCallList)( GLcontext *ctx, GLuint list );
955   void (*EndCallList)( GLcontext *ctx );
956   /* Notify the t&l component before and after calling a display list.
957    * Called by glCallList(s), but not recursively.
958    */
959
960   void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
961			GLframebuffer *readBuffer );
962   /* Let the t&l component know when the context becomes current.
963    */
964
965
966   void (*LockArraysEXT)( GLcontext *ctx, GLint first, GLsizei count );
967   void (*UnlockArraysEXT)( GLcontext *ctx );
968   /* Called by glLockArraysEXT() and glUnlockArraysEXT(), respectively.
969    */
970
971};
972
973
974
975/*
976 * Transform/Clip/Lighting interface
977 */
978typedef struct {
979   void (*ArrayElement)( GLint ); /* NOTE */
980   void (*Color3f)( GLfloat, GLfloat, GLfloat );
981   void (*Color3fv)( const GLfloat * );
982   void (*Color3ub)( GLubyte, GLubyte, GLubyte );
983   void (*Color3ubv)( const GLubyte * );
984   void (*Color4f)( GLfloat, GLfloat, GLfloat, GLfloat );
985   void (*Color4fv)( const GLfloat * );
986   void (*Color4ub)( GLubyte, GLubyte, GLubyte, GLubyte );
987   void (*Color4ubv)( const GLubyte * );
988   void (*EdgeFlag)( GLboolean );
989   void (*EdgeFlagv)( const GLboolean * );
990   void (*EvalCoord1f)( GLfloat );          /* NOTE */
991   void (*EvalCoord1fv)( const GLfloat * ); /* NOTE */
992   void (*EvalCoord2f)( GLfloat, GLfloat ); /* NOTE */
993   void (*EvalCoord2fv)( const GLfloat * ); /* NOTE */
994   void (*EvalPoint1)( GLint );             /* NOTE */
995   void (*EvalPoint2)( GLint, GLint );      /* NOTE */
996   void (*FogCoordfEXT)( GLfloat );
997   void (*FogCoordfvEXT)( const GLfloat * );
998   void (*Indexi)( GLint );
999   void (*Indexiv)( const GLint * );
1000   void (*Materialfv)( GLenum face, GLenum pname, const GLfloat * ); /* NOTE */
1001   void (*MultiTexCoord1fARB)( GLenum, GLfloat );
1002   void (*MultiTexCoord1fvARB)( GLenum, const GLfloat * );
1003   void (*MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat );
1004   void (*MultiTexCoord2fvARB)( GLenum, const GLfloat * );
1005   void (*MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat );
1006   void (*MultiTexCoord3fvARB)( GLenum, const GLfloat * );
1007   void (*MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat );
1008   void (*MultiTexCoord4fvARB)( GLenum, const GLfloat * );
1009   void (*Normal3f)( GLfloat, GLfloat, GLfloat );
1010   void (*Normal3fv)( const GLfloat * );
1011   void (*SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat );
1012   void (*SecondaryColor3fvEXT)( const GLfloat * );
1013   void (*SecondaryColor3ubEXT)( GLubyte, GLubyte, GLubyte );
1014   void (*SecondaryColor3ubvEXT)( const GLubyte * );
1015   void (*TexCoord1f)( GLfloat );
1016   void (*TexCoord1fv)( const GLfloat * );
1017   void (*TexCoord2f)( GLfloat, GLfloat );
1018   void (*TexCoord2fv)( const GLfloat * );
1019   void (*TexCoord3f)( GLfloat, GLfloat, GLfloat );
1020   void (*TexCoord3fv)( const GLfloat * );
1021   void (*TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat );
1022   void (*TexCoord4fv)( const GLfloat * );
1023   void (*Vertex2f)( GLfloat, GLfloat );
1024   void (*Vertex2fv)( const GLfloat * );
1025   void (*Vertex3f)( GLfloat, GLfloat, GLfloat );
1026   void (*Vertex3fv)( const GLfloat * );
1027   void (*Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat );
1028   void (*Vertex4fv)( const GLfloat * );
1029   void (*CallList)( GLuint );	/* NOTE */
1030   void (*Begin)( GLenum );
1031   void (*End)( void );
1032   /* Drivers present a reduced set of the functions possible in
1033    * begin/end objects.  Core mesa provides translation stubs for the
1034    * remaining functions to map down to these entrypoints.
1035    *
1036    * These are the initial values to be installed into dispatch by
1037    * mesa.  If the t&l driver wants to modify the dispatch table
1038    * while installed, it must do so itself.  It would be possible for
1039    * the vertexformat to install it's own initial values for these
1040    * functions, but this way there is an obvious list of what is
1041    * expected of the driver.
1042    *
1043    * If the driver wants to hook in entrypoints other than those
1044    * listed above, it must restore them to their original values in
1045    * the disable() callback, below.
1046    */
1047
1048   void (*Rectf)( GLfloat, GLfloat, GLfloat, GLfloat );
1049   /*
1050    */
1051
1052   void (*DrawArrays)( GLenum mode, GLint start, GLsizei count );
1053   void (*DrawElements)( GLenum mode, GLsizei count, GLenum type,
1054			 const GLvoid *indices );
1055   void (*DrawRangeElements)( GLenum mode, GLuint start,
1056			      GLuint end, GLsizei count,
1057			      GLenum type, const GLvoid *indices );
1058   /* These may or may not belong here.  Heuristic: If an array is
1059    * enabled, the installed vertex format should support that array and
1060    * it's current size natively.
1061    */
1062
1063   void (*EvalMesh1)( GLenum mode, GLint i1, GLint i2 );
1064   void (*EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
1065   /* If you don't support eval, fallback to the default vertex format
1066    * on receiving an eval call and use the pipeline mechanism to
1067    * provide partial t&l acceleration.
1068    *
1069    * Mesa will provide a set of helper functions to do eval within
1070    * accelerated vertex formats, eventually...
1071    */
1072
1073   GLboolean prefer_float_colors;
1074   /* Should core try to send colors to glColor4f or glColor4chan,
1075    * where it has a choice?
1076    */
1077} GLvertexformat;
1078
1079
1080#endif /* DD_INCLUDED */
1081