dd.h revision 5c1e7fa6ee72f4403d9ec9d12830dd689b966e71
1afade9294af43c6b947b9aeaa1555883d5f853e3Chris Lattner/* $Id: dd.h,v 1.49 2001/01/29 20:47:39 keithw Exp $ */
27c0e022c5c4be4b11e199a53f73bbdd84e34aa80John Criswell
37c0e022c5c4be4b11e199a53f73bbdd84e34aa80John Criswell/*
47c0e022c5c4be4b11e199a53f73bbdd84e34aa80John Criswell * Mesa 3-D graphics library
57c0e022c5c4be4b11e199a53f73bbdd84e34aa80John Criswell * Version:  3.5
67c0e022c5c4be4b11e199a53f73bbdd84e34aa80John Criswell *
77c0e022c5c4be4b11e199a53f73bbdd84e34aa80John Criswell * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
87c0e022c5c4be4b11e199a53f73bbdd84e34aa80John Criswell *
9afade9294af43c6b947b9aeaa1555883d5f853e3Chris Lattner * Permission is hereby granted, free of charge, to any person obtaining a
10efdc0b505712d1ca4460def27e51c430f033d58dChris Lattner * copy of this software and associated documentation files (the "Software"),
11efdc0b505712d1ca4460def27e51c430f033d58dChris Lattner * to deal in the Software without restriction, including without limitation
12afade9294af43c6b947b9aeaa1555883d5f853e3Chris Lattner * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13afade9294af43c6b947b9aeaa1555883d5f853e3Chris Lattner * and/or sell copies of the Software, and to permit persons to whom the
14afade9294af43c6b947b9aeaa1555883d5f853e3Chris Lattner * Software is furnished to do so, subject to the following conditions:
15afade9294af43c6b947b9aeaa1555883d5f853e3Chris Lattner *
16e49603d79d220a795bd50684c8b1f503ee40f97fMisha Brukman * The above copyright notice and this permission notice shall be included
17afade9294af43c6b947b9aeaa1555883d5f853e3Chris Lattner * in all copies or substantial portions of the Software.
18afade9294af43c6b947b9aeaa1555883d5f853e3Chris Lattner *
19d1a85a744cc1001c2b7fc37cf37aca266964f519Brian Gaeke * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20e49603d79d220a795bd50684c8b1f503ee40f97fMisha Brukman * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21e49603d79d220a795bd50684c8b1f503ee40f97fMisha Brukman * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22afade9294af43c6b947b9aeaa1555883d5f853e3Chris Lattner * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
236520785dcd22012535934098942d57c07c7631c2Chris Lattner * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24afade9294af43c6b947b9aeaa1555883d5f853e3Chris Lattner * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
255e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner */
265da69c79f9c4490c6657c207430dfeb1060fc4ddChris Lattner
27551ccae044b0ff658fe629dd67edd5ffe75d10e8Reid Spencer
28551ccae044b0ff658fe629dd67edd5ffe75d10e8Reid Spencer
29551ccae044b0ff658fe629dd67edd5ffe75d10e8Reid Spencer#ifndef DD_INCLUDED
30fb4b96e77e2930bf3d0c148f1c3685b6a4434666Chris Lattner#define DD_INCLUDED
31c6b519d64ef55d39e66a49510d4703a49bf228ccChris Lattner
32d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke/* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */
33d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
34c6b519d64ef55d39e66a49510d4703a49bf228ccChris Lattnerstruct gl_pixelstore_attrib;
35d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
36d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
376db70ef879916e6115ac97eb76e4fea973652e2cChris Lattner/*
386db70ef879916e6115ac97eb76e4fea973652e2cChris Lattner *                      Device Driver (DD) interface
396db70ef879916e6115ac97eb76e4fea973652e2cChris Lattner *
406db70ef879916e6115ac97eb76e4fea973652e2cChris Lattner *
4147ae4a1cee5eec5767a11403c0fac7c91ec45461Chris Lattner * All device driver functions are accessed through pointers in the
4247ae4a1cee5eec5767a11403c0fac7c91ec45461Chris Lattner * dd_function_table struct (defined below) which is stored in the GLcontext
436db70ef879916e6115ac97eb76e4fea973652e2cChris Lattner * struct.  Since the device driver is strictly accessed trough a table of
446db70ef879916e6115ac97eb76e4fea973652e2cChris Lattner * function pointers we can:
45afade9294af43c6b947b9aeaa1555883d5f853e3Chris Lattner *   1. switch between a number of different device drivers at runtime.
466520785dcd22012535934098942d57c07c7631c2Chris Lattner *   2. use optimized functions dependant on current rendering state or
476520785dcd22012535934098942d57c07c7631c2Chris Lattner *      frame buffer configuration.
486520785dcd22012535934098942d57c07c7631c2Chris Lattner *
496520785dcd22012535934098942d57c07c7631c2Chris Lattner * The function pointers in the dd_function_table struct are divided into
506520785dcd22012535934098942d57c07c7631c2Chris Lattner * two groups:  mandatory and optional.
510cc8807029f577996a442b96d24c3346ed6de091Chris Lattner * Mandatory functions have to be implemented by every device driver.
526520785dcd22012535934098942d57c07c7631c2Chris Lattner * Optional functions may or may not be implemented by the device driver.
536520785dcd22012535934098942d57c07c7631c2Chris Lattner * The optional functions provide ways to take advantage of special hardware
546520785dcd22012535934098942d57c07c7631c2Chris Lattner * or optimized algorithms.
550cc8807029f577996a442b96d24c3346ed6de091Chris Lattner *
560cc8807029f577996a442b96d24c3346ed6de091Chris Lattner * The function pointers in the dd_function_table struct should first be
576520785dcd22012535934098942d57c07c7631c2Chris Lattner * initialized in the driver's "MakeCurrent" function.  The "MakeCurrent"
586520785dcd22012535934098942d57c07c7631c2Chris Lattner * function is a little different in each device driver.  See the X/Mesa,
590cc8807029f577996a442b96d24c3346ed6de091Chris Lattner * GLX, or OS/Mesa drivers for examples.
600cc8807029f577996a442b96d24c3346ed6de091Chris Lattner *
616520785dcd22012535934098942d57c07c7631c2Chris Lattner * Later, Mesa may call the dd_function_table's UpdateState() function.
626520785dcd22012535934098942d57c07c7631c2Chris Lattner * This function should initialize the dd_function_table's pointers again.
630cc8807029f577996a442b96d24c3346ed6de091Chris Lattner * The UpdateState() function is called whenever the core (GL) rendering
646520785dcd22012535934098942d57c07c7631c2Chris Lattner * state is changed in a way which may effect rasterization.  For example,
656520785dcd22012535934098942d57c07c7631c2Chris Lattner * the TriangleFunc() pointer may have to point to different functions
660cc8807029f577996a442b96d24c3346ed6de091Chris Lattner * depending on whether smooth or flat shading is enabled.
670cc8807029f577996a442b96d24c3346ed6de091Chris Lattner *
686520785dcd22012535934098942d57c07c7631c2Chris Lattner * Note that the first argument to every device driver function is a
696520785dcd22012535934098942d57c07c7631c2Chris Lattner * GLcontext *.  In turn, the GLcontext->DriverCtx pointer points to
700cc8807029f577996a442b96d24c3346ed6de091Chris Lattner * the driver-specific context struct.  See the X/Mesa or OS/Mesa interface
710cc8807029f577996a442b96d24c3346ed6de091Chris Lattner * for an example.
726520785dcd22012535934098942d57c07c7631c2Chris Lattner *
736520785dcd22012535934098942d57c07c7631c2Chris Lattner * For more information about writing a device driver see the ddsample.c
740cc8807029f577996a442b96d24c3346ed6de091Chris Lattner * file and other device drivers (X/xmesa[1234].c, OSMesa/osmesa.c, etc)
756520785dcd22012535934098942d57c07c7631c2Chris Lattner * for examples.
7644be25716628941b4cccccf56a28ee0ba2606850Chris Lattner *
776520785dcd22012535934098942d57c07c7631c2Chris Lattner *
785da69c79f9c4490c6657c207430dfeb1060fc4ddChris Lattner * Look below in the dd_function_table struct definition for descriptions
795da69c79f9c4490c6657c207430dfeb1060fc4ddChris Lattner * of each device driver function.
805da69c79f9c4490c6657c207430dfeb1060fc4ddChris Lattner *
81efdc0b505712d1ca4460def27e51c430f033d58dChris Lattner *
82efdc0b505712d1ca4460def27e51c430f033d58dChris Lattner * In the future more function pointers may be added for glReadPixels
836db70ef879916e6115ac97eb76e4fea973652e2cChris Lattner * glCopyPixels, etc.
846520785dcd22012535934098942d57c07c7631c2Chris Lattner *
8547ae4a1cee5eec5767a11403c0fac7c91ec45461Chris Lattner *
866520785dcd22012535934098942d57c07c7631c2Chris Lattner * Notes:
8710f22cb1a0f2755050218cd0e07221a0985c6b63Chris Lattner * ------
8810f22cb1a0f2755050218cd0e07221a0985c6b63Chris Lattner *   RGBA = red/green/blue/alpha
896520785dcd22012535934098942d57c07c7631c2Chris Lattner *   CI = color index (color mapped mode)
906520785dcd22012535934098942d57c07c7631c2Chris Lattner *   mono = all pixels have the same color or index
916520785dcd22012535934098942d57c07c7631c2Chris Lattner *
92ba386d943f4a83095d9c625cb0d46c1afe45ed1fChris Lattner *   The write_ functions all take an array of mask flags which indicate
93fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner *   whether or not the pixel should be written.  One special case exists
94fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner *   in the write_color_span function: if the mask array is NULL, then
95fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner *   draw all pixels.  This is an optimization used for glDrawPixels().
96fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner *
97fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner * IN ALL CASES:
98fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner *      X coordinates start at 0 at the left and increase to the right
99ba386d943f4a83095d9c625cb0d46c1afe45ed1fChris Lattner *      Y coordinates start at 0 at the bottom and increase upward
100ba386d943f4a83095d9c625cb0d46c1afe45ed1fChris Lattner *
101ba386d943f4a83095d9c625cb0d46c1afe45ed1fChris Lattner */
102ba386d943f4a83095d9c625cb0d46c1afe45ed1fChris Lattner
103fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner
10428b8ed90c75ce6c271500fa778fef252f267a5ffChris Lattner
10528b8ed90c75ce6c271500fa778fef252f267a5ffChris Lattner
10628b8ed90c75ce6c271500fa778fef252f267a5ffChris Lattner
107dbe48dcaec69ff78e39e2d5faf4323ade6fffb04Chris Lattner
108fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner/* Mask bits sent to the driver Clear() function */
109fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner#define DD_FRONT_LEFT_BIT  FRONT_LEFT_BIT         /* 1 */
110fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner#define DD_FRONT_RIGHT_BIT FRONT_RIGHT_BIT        /* 2 */
111fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner#define DD_BACK_LEFT_BIT   BACK_LEFT_BIT          /* 4 */
112fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner#define DD_BACK_RIGHT_BIT  BACK_RIGHT_BIT         /* 8 */
113c6b519d64ef55d39e66a49510d4703a49bf228ccChris Lattner#define DD_DEPTH_BIT       GL_DEPTH_BUFFER_BIT    /* 0x00000100 */
114c6b519d64ef55d39e66a49510d4703a49bf228ccChris Lattner#define DD_STENCIL_BIT     GL_STENCIL_BUFFER_BIT  /* 0x00000400 */
115c6b519d64ef55d39e66a49510d4703a49bf228ccChris Lattner#define DD_ACCUM_BIT       GL_ACCUM_BUFFER_BIT    /* 0x00000200 */
116c6b519d64ef55d39e66a49510d4703a49bf228ccChris Lattner
117fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner
118a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattner
119a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattner
1207546c3884a400b72d10fc19f120c6798b294a39dChris Lattner
121fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036Chris Lattner
122a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattner
123a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattner/* Point, line, triangle, quadrilateral and rectangle rasterizer
124ba386d943f4a83095d9c625cb0d46c1afe45ed1fChris Lattner * functions.  These are specific to the tnl module and will shortly
125be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner * move to a driver interface specific to that module.
126be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner */
1277546c3884a400b72d10fc19f120c6798b294a39dChris Lattnertypedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last );
1287546c3884a400b72d10fc19f120c6798b294a39dChris Lattner
1297546c3884a400b72d10fc19f120c6798b294a39dChris Lattnertypedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
1307546c3884a400b72d10fc19f120c6798b294a39dChris Lattner
1317546c3884a400b72d10fc19f120c6798b294a39dChris Lattnertypedef void (*triangle_func)( GLcontext *ctx,
1327546c3884a400b72d10fc19f120c6798b294a39dChris Lattner                               GLuint v1, GLuint v2, GLuint v3 );
1337546c3884a400b72d10fc19f120c6798b294a39dChris Lattner
134a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattnertypedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
135a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattner                           GLuint v3, GLuint v4 );
136a1cf1c8c87f10f12343ff6ae75f332390e7205abChris Lattner
137a1cf1c8c87f10f12343ff6ae75f332390e7205abChris Lattnertypedef void (*render_func)( GLcontext *ctx, GLuint start, GLuint count,
138a1cf1c8c87f10f12343ff6ae75f332390e7205abChris Lattner			     GLuint flags );
139a1cf1c8c87f10f12343ff6ae75f332390e7205abChris Lattner
140a1cf1c8c87f10f12343ff6ae75f332390e7205abChris Lattnertypedef void (*interp_func)( GLcontext *ctx,
1417546c3884a400b72d10fc19f120c6798b294a39dChris Lattner			     GLfloat t, GLuint dst, GLuint in, GLuint out,
1427546c3884a400b72d10fc19f120c6798b294a39dChris Lattner			     GLboolean force_boundary );
143a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattner
144a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattnertypedef void (*copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
145a269ec7b0a83d3b20730fd2d9f7c3ed5a552da90Chris Lattner
146a269ec7b0a83d3b20730fd2d9f7c3ed5a552da90Chris Lattner
147a269ec7b0a83d3b20730fd2d9f7c3ed5a552da90Chris Lattner/*
14890c18c5c69d9c451e5fdca1e4b4b95e8ed13291aChris Lattner * Device Driver function table.
149a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattner */
150a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattnerstruct dd_function_table {
15190c18c5c69d9c451e5fdca1e4b4b95e8ed13291aChris Lattner
15290c18c5c69d9c451e5fdca1e4b4b95e8ed13291aChris Lattner   /**********************************************************************
15390c18c5c69d9c451e5fdca1e4b4b95e8ed13291aChris Lattner    *** Mandatory functions:  these functions must be implemented by   ***
15490c18c5c69d9c451e5fdca1e4b4b95e8ed13291aChris Lattner    *** every device driver.                                           ***
15590c18c5c69d9c451e5fdca1e4b4b95e8ed13291aChris Lattner    **********************************************************************/
156a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattner
157a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattner   const GLubyte * (*GetString)( GLcontext *ctx, GLenum name );
158a75766a6c14b364b74b30546802e26d4b4b36a9bChris Lattner   /* Return a string as needed by glGetString().
1597546c3884a400b72d10fc19f120c6798b294a39dChris Lattner    * Only the GL_RENDERER token must be implemented.  Otherwise,
1607546c3884a400b72d10fc19f120c6798b294a39dChris Lattner    * NULL can be returned.
1617546c3884a400b72d10fc19f120c6798b294a39dChris Lattner    */
162be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner
163be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner   void (*UpdateState)( GLcontext *ctx, GLuint new_state );
164be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner   /*
165be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    * UpdateState() is called whenver Mesa thinks the device driver should
166be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    * update its state and/or the other pointers (such as PointsFunc,
167be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    * LineFunc, or TriangleFunc).
168be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    */
169be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner
170be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner   void (*Clear)( GLcontext *ctx, GLbitfield mask, GLboolean all,
171be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner		  GLint x, GLint y, GLint width, GLint height );
172be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner   /* Clear the color/depth/stencil/accum buffer(s).
173be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    * 'mask' is a bitmask of the DD_*_BIT values defined above that indicates
1745eda1f2f65941a24ef9a5a85addf4d90eb13fa9dChris Lattner    * which buffers need to be cleared.
1755eda1f2f65941a24ef9a5a85addf4d90eb13fa9dChris Lattner    * If 'all' is true then the clear the whole buffer, else clear only the
1765eda1f2f65941a24ef9a5a85addf4d90eb13fa9dChris Lattner    * region defined by (x,y,width,height).
1775eda1f2f65941a24ef9a5a85addf4d90eb13fa9dChris Lattner    * This function must obey the glColorMask, glIndexMask and glStencilMask
1785eda1f2f65941a24ef9a5a85addf4d90eb13fa9dChris Lattner    * settings!  Software Mesa can do masked clears if the device driver can't.
179be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    */
180be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner
181be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner   GLboolean (*SetDrawBuffer)( GLcontext *ctx, GLenum buffer );
182be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner   /*
183be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    * Specifies the current buffer for writing.
184be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    * The following values must be accepted when applicable:
185be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    *    GL_FRONT_LEFT - this buffer always exists
186be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    *    GL_BACK_LEFT - when double buffering
187be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    *    GL_FRONT_RIGHT - when using stereo
188be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    *    GL_BACK_RIGHT - when using stereo and double buffering
189be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    * The folowing values may optionally be accepted.  Return GL_TRUE
190be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    * if accepted, GL_FALSE if not accepted.  In practice, only drivers
191be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    * which can write to multiple color buffers at once should accept
192be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    * these values.
193be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    *    GL_FRONT - write to front left and front right if it exists
194be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    *    GL_BACK - write to back left and back right if it exists
195fb4b96e77e2930bf3d0c148f1c3685b6a4434666Chris Lattner    *    GL_LEFT - write to front left and back left if it exists
196be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    *    GL_RIGHT - write to right left and back right if they exist
197fb4b96e77e2930bf3d0c148f1c3685b6a4434666Chris Lattner    *    GL_FRONT_AND_BACK - write to all four buffers if they exist
198be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    *    GL_NONE - disable buffer write in device driver.
199be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    */
200be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner
201be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner   void (*SetReadBuffer)( GLcontext *ctx, GLframebuffer *colorBuffer,
202be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner                          GLenum buffer );
203be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner   /*
204be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    * Specifies the current buffer for reading.
205fb4b96e77e2930bf3d0c148f1c3685b6a4434666Chris Lattner    * colorBuffer will be one of:
206fb4b96e77e2930bf3d0c148f1c3685b6a4434666Chris Lattner    *    GL_FRONT_LEFT - this buffer always exists
207be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    *    GL_BACK_LEFT - when double buffering
208be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    *    GL_FRONT_RIGHT - when using stereo
209be21ca54e08339ede5dd4bbb882182d22e274988Chris Lattner    *    GL_BACK_RIGHT - when using stereo and double buffering
2105e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    */
2115e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
2125e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   void (*GetBufferSize)( GLcontext *ctx, GLuint *width, GLuint *height );
2135e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   /*
2145e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    * Returns the width and height of the current color buffer.
2155e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    */
2165e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
2175e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
2185e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   /***
2195e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    *** Functions for writing pixels to the frame buffer:
2205e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    ***/
221b12914bfc0f76a7a48357162d5f4c39a1343e69bChris Lattner
222b12914bfc0f76a7a48357162d5f4c39a1343e69bChris Lattner   void (*WriteRGBASpan)( const GLcontext *ctx,
2235e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                          GLuint n, GLint x, GLint y,
2245e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                          CONST GLchan rgba[][4], const GLubyte mask[] );
2255e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   void (*WriteRGBSpan)( const GLcontext *ctx,
2265e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                         GLuint n, GLint x, GLint y,
2275e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                         CONST GLchan rgb[][3], const GLubyte mask[] );
228b12914bfc0f76a7a48357162d5f4c39a1343e69bChris Lattner   /* Write a horizontal run of RGBA or RGB pixels.
2295e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    * If mask is NULL, draw all pixels.
2305e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    * If mask is not null, only draw pixel [i] when mask [i] is true.
2315e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    */
2325e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
2335e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   void (*WriteMonoRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
2345e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                              const GLchan color[4], const GLubyte mask[] );
2355e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   /* Write a horizontal run of RGBA pixels all with the same color.
2365e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    */
2375e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
2385e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   void (*WriteRGBAPixels)( const GLcontext *ctx,
2395e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                            GLuint n, const GLint x[], const GLint y[],
2405e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                            CONST GLchan rgba[][4], const GLubyte mask[] );
2415e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   /* Write array of RGBA pixels at random locations.
2425e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    */
2435e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
2445e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   void (*WriteMonoRGBAPixels)( const GLcontext *ctx,
2455e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                                GLuint n, const GLint x[], const GLint y[],
2465e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                                const GLchan color[4], const GLubyte mask[] );
2475e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   /* Write an array of mono-RGBA pixels at random locations.
2485e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    */
2495e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
2505e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   void (*WriteCI32Span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
2515e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                          const GLuint index[], const GLubyte mask[] );
2525e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   void (*WriteCI8Span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
2535e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                         const GLubyte index[], const GLubyte mask[] );
2545e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   /* Write a horizontal run of CI pixels.  One function is for 32bpp
2555e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    * indexes and the other for 8bpp pixels (the common case).  You mus
2565e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    * implement both for color index mode.
2575e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    */
2585e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
2595e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   void (*WriteMonoCISpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
2605e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                            GLuint colorIndex, const GLubyte mask[] );
2615e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   /* Write a horizontal run of color index pixels using the color index
2625e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    * last specified by the Index() function.
2635e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    */
2645e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
2655e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   void (*WriteCI32Pixels)( const GLcontext *ctx,
2665e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                            GLuint n, const GLint x[], const GLint y[],
2675e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                            const GLuint index[], const GLubyte mask[] );
2685e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner   /*
2695e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    * Write a random array of CI pixels.
2705e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner    */
2715e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
272891150f0b2a124a75c9f31516182ce864ae69ef8Chris Lattner   void (*WriteMonoCIPixels)( const GLcontext *ctx,
2735e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner                              GLuint n, const GLint x[], const GLint y[],
274891150f0b2a124a75c9f31516182ce864ae69ef8Chris Lattner                              GLuint colorIndex, const GLubyte mask[] );
275891150f0b2a124a75c9f31516182ce864ae69ef8Chris Lattner   /* Write a random array of color index pixels using the color index
276891150f0b2a124a75c9f31516182ce864ae69ef8Chris Lattner    * last specified by the Index() function.
277891150f0b2a124a75c9f31516182ce864ae69ef8Chris Lattner    */
2785e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
2795e783ab0b5fc3407ec59f1a598fdb9ef3b96b287Chris Lattner
280   /***
281    *** Functions to read pixels from frame buffer:
282    ***/
283
284   void (*ReadCI32Span)( const GLcontext *ctx,
285                         GLuint n, GLint x, GLint y, GLuint index[] );
286   /* Read a horizontal run of color index pixels.
287    */
288
289   void (*ReadRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
290                         GLchan rgba[][4] );
291   /* Read a horizontal run of RGBA pixels.
292    */
293
294   void (*ReadCI32Pixels)( const GLcontext *ctx,
295                           GLuint n, const GLint x[], const GLint y[],
296                           GLuint indx[], const GLubyte mask[] );
297   /* Read a random array of CI pixels.
298    */
299
300   void (*ReadRGBAPixels)( const GLcontext *ctx,
301                           GLuint n, const GLint x[], const GLint y[],
302                           GLchan rgba[][4], const GLubyte mask[] );
303   /* Read a random array of RGBA pixels.
304    */
305
306
307   /**********************************************************************
308    *** Optional functions:  these functions may or may not be         ***
309    *** implemented by the device driver.  If the device driver        ***
310    *** doesn't implement them it should never touch these pointers    ***
311    *** since Mesa will either set them to NULL or point them at a     ***
312    *** fall-back function.                                            ***
313    **********************************************************************/
314
315   void (*Finish)( GLcontext *ctx );
316   /*
317    * This is called whenever glFinish() is called.
318    */
319
320   void (*Flush)( GLcontext *ctx );
321   /*
322    * This is called whenever glFlush() is called.
323    */
324
325   void (*Error)( GLcontext *ctx );
326   /*
327    * Called whenever an error is generated.  ctx->ErrorValue contains
328    * the error value.
329    */
330
331
332   /***
333    *** For supporting hardware Z buffers:
334    *** Either ALL or NONE of these functions must be implemented!
335    *** NOTE that Each depth value is a 32-bit GLuint.  If the depth
336    *** buffer is less than 32 bits deep then the extra upperbits are zero.
337    ***/
338
339   void (*WriteDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
340                           const GLdepth depth[], const GLubyte mask[] );
341   /* Write a horizontal span of values into the depth buffer.  Only write
342    * depth[i] value if mask[i] is nonzero.
343    */
344
345   void (*ReadDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
346                          GLdepth depth[] );
347   /* Read a horizontal span of values from the depth buffer.
348    */
349
350
351   void (*WriteDepthPixels)( GLcontext *ctx, GLuint n,
352                             const GLint x[], const GLint y[],
353                             const GLdepth depth[], const GLubyte mask[] );
354   /* Write an array of randomly positioned depth values into the
355    * depth buffer.  Only write depth[i] value if mask[i] is nonzero.
356    */
357
358   void (*ReadDepthPixels)( GLcontext *ctx, GLuint n,
359                            const GLint x[], const GLint y[],
360                            GLdepth depth[] );
361   /* Read an array of randomly positioned depth values from the depth buffer.
362    */
363
364
365
366   /***
367    *** For supporting hardware stencil buffers:
368    *** Either ALL or NONE of these functions must be implemented!
369    ***/
370
371   void (*WriteStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
372                             const GLstencil stencil[], const GLubyte mask[] );
373   /* Write a horizontal span of stencil values into the stencil buffer.
374    * If mask is NULL, write all stencil values.
375    * Else, only write stencil[i] if mask[i] is non-zero.
376    */
377
378   void (*ReadStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
379                            GLstencil stencil[] );
380   /* Read a horizontal span of stencil values from the stencil buffer.
381    */
382
383   void (*WriteStencilPixels)( GLcontext *ctx, GLuint n,
384                               const GLint x[], const GLint y[],
385                               const GLstencil stencil[],
386                               const GLubyte mask[] );
387   /* Write an array of stencil values into the stencil buffer.
388    * If mask is NULL, write all stencil values.
389    * Else, only write stencil[i] if mask[i] is non-zero.
390    */
391
392   void (*ReadStencilPixels)( GLcontext *ctx, GLuint n,
393                              const GLint x[], const GLint y[],
394                              GLstencil stencil[] );
395   /* Read an array of stencil values from the stencil buffer.
396    */
397
398
399   /***
400    *** For hardware accumulation buffer:
401    ***/
402   void (*Accum)( GLcontext *ctx, GLenum op, GLfloat value,
403		  GLint xpos, GLint ypos, GLint width, GLint height );
404   /* Execute glAccum command within the given scissor region.
405    */
406
407
408   /***
409    *** glDraw/Read/CopyPixels and glBitmap functions:
410    ***/
411
412   void (*DrawPixels)( GLcontext *ctx,
413		       GLint x, GLint y, GLsizei width, GLsizei height,
414		       GLenum format, GLenum type,
415		       const struct gl_pixelstore_attrib *unpack,
416		       const GLvoid *pixels );
417   /* This is called by glDrawPixels.
418    * 'unpack' describes how to unpack the source image data.
419    */
420
421   void (*ReadPixels)( GLcontext *ctx,
422		       GLint x, GLint y, GLsizei width, GLsizei height,
423		       GLenum format, GLenum type,
424		       const struct gl_pixelstore_attrib *unpack,
425		       GLvoid *dest );
426   /* Called by glReadPixels.
427    */
428
429   void (*CopyPixels)( GLcontext *ctx,
430                            GLint srcx, GLint srcy,
431                            GLsizei width, GLsizei height,
432                            GLint dstx, GLint dsty, GLenum type );
433   /* Do a glCopyPixels.  This function must respect all rasterization
434    * state, glPixelTransfer, glPixelZoom, etc.
435    */
436
437   void (*Bitmap)( GLcontext *ctx,
438		   GLint x, GLint y, GLsizei width, GLsizei height,
439		   const struct gl_pixelstore_attrib *unpack,
440		   const GLubyte *bitmap );
441   /* This is called by glBitmap.  Works the same as DrawPixels, above.
442    */
443
444   void (*ResizeBuffersMESA)( GLcontext *ctx );
445
446
447   /***
448    *** Texture image functions:
449    ***/
450   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 (*CreateTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
705   /* Called when a texture object is created.
706    */
707
708   void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
709   /* Called when a texture object is about to be deallocated.  Driver
710    * should free anything attached to the DriverData pointers.
711    */
712
713   GLboolean (*IsTextureResident)( GLcontext *ctx,
714                                   struct gl_texture_object *t );
715   /* Called by glAreTextureResident().
716    */
717
718   void (*PrioritizeTexture)( GLcontext *ctx,  struct gl_texture_object *t,
719                              GLclampf priority );
720   /* Called by glPrioritizeTextures().
721    */
722
723   void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber );
724   /* Called by glActiveTextureARB to set current texture unit.
725    */
726
727   void (*UpdateTexturePalette)( GLcontext *ctx,
728                                 struct gl_texture_object *tObj );
729   /* Called when the texture's color lookup table is changed.
730    * If tObj is NULL then the shared texture palette ctx->Texture.Palette
731    * is to be updated.
732    */
733
734
735   /***
736    *** State-changing functions (drawing functions are above)
737    ***
738    *** These functions are called by their corresponding OpenGL API functions.
739    *** They're ALSO called by the gl_PopAttrib() function!!!
740    *** May add more functions like these to the device driver in the future.
741    ***/
742   void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLclampf ref);
743   void (*BlendEquation)(GLcontext *ctx, GLenum mode);
744   void (*BlendFunc)(GLcontext *ctx, GLenum sfactor, GLenum dfactor);
745   void (*BlendFuncSeparate)(GLcontext *ctx,
746                             GLenum sfactorRGB, GLenum dfactorRGB,
747                             GLenum sfactorA, GLenum dfactorA);
748   void (*ClearColor)(GLcontext *ctx, const GLchan color[4]);
749   void (*ClearDepth)(GLcontext *ctx, GLclampd d);
750   void (*ClearIndex)(GLcontext *ctx, GLuint index);
751   void (*ClearStencil)(GLcontext *ctx, GLint s);
752   void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
753                     GLboolean bmask, GLboolean amask );
754   void (*CullFace)(GLcontext *ctx, GLenum mode);
755   void (*ClipPlane)(GLcontext *ctx, GLenum plane, const GLfloat *equation );
756   void (*FrontFace)(GLcontext *ctx, GLenum mode);
757   void (*DepthFunc)(GLcontext *ctx, GLenum func);
758   void (*DepthMask)(GLcontext *ctx, GLboolean flag);
759   void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval);
760   void (*Enable)(GLcontext* ctx, GLenum cap, GLboolean state);
761   void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
762   void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode);
763   void (*IndexMask)(GLcontext *ctx, GLuint mask);
764   void (*Lightfv)(GLcontext *ctx, GLenum light,
765		   GLenum pname, const GLfloat *params );
766   void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
767   void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern );
768   void (*LineWidth)(GLcontext *ctx, GLfloat width);
769   void (*LogicOpcode)(GLcontext *ctx, GLenum opcode);
770   void (*PointParameterfv)(GLcontext *ctx, GLenum pname,
771                            const GLfloat *params);
772   void (*PointSize)(GLcontext *ctx, GLfloat size);
773   void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode);
774   void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask );
775   void (*RenderMode)(GLcontext *ctx, GLenum mode );
776   void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
777   void (*ShadeModel)(GLcontext *ctx, GLenum mode);
778   void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
779   void (*StencilMask)(GLcontext *ctx, GLuint mask);
780   void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass);
781   void (*TexGen)(GLcontext *ctx, GLenum coord, GLenum pname,
782		  const GLfloat *params);
783   void (*TexEnv)(GLcontext *ctx, GLenum target, GLenum pname,
784                  const GLfloat *param);
785   void (*TexParameter)(GLcontext *ctx, GLenum target,
786                        struct gl_texture_object *texObj,
787                        GLenum pname, const GLfloat *params);
788   void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat);
789   void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
790
791
792   /*** State-query functions
793    ***
794    *** Return GL_TRUE if query was completed, GL_FALSE otherwise.
795    ***/
796   GLboolean (*GetBooleanv)(GLcontext *ctx, GLenum pname, GLboolean *result);
797   GLboolean (*GetDoublev)(GLcontext *ctx, GLenum pname, GLdouble *result);
798   GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result);
799   GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result);
800   GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result);
801
802
803   /***
804    *** Vertex array functions
805    ***
806    *** Called by the corresponding OpenGL functions.
807    ***/
808   void (*VertexPointer)(GLcontext *ctx, GLint size, GLenum type,
809			 GLsizei stride, const GLvoid *ptr);
810   void (*NormalPointer)(GLcontext *ctx, GLenum type,
811			 GLsizei stride, const GLvoid *ptr);
812   void (*ColorPointer)(GLcontext *ctx, GLint size, GLenum type,
813			GLsizei stride, const GLvoid *ptr);
814   void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
815			   GLsizei stride, const GLvoid *ptr);
816   void (*IndexPointer)(GLcontext *ctx, GLenum type,
817			GLsizei stride, const GLvoid *ptr);
818   void (*SecondaryColorPointer)(GLcontext *ctx, GLint size, GLenum type,
819				 GLsizei stride, const GLvoid *ptr);
820   void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type,
821			   GLsizei stride, const GLvoid *ptr);
822   void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);
823
824
825
826   /***
827    *** Rendering
828    ***/
829
830   void (*RenderStart)(GLcontext *ctx);
831   void (*RenderFinish)(GLcontext *ctx);
832   /* Called before and after all rendering operations, including DrawPixels,
833    * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
834    * These are a suitable place for grabbing/releasing hardware locks.
835    */
836
837   void (*RenderPrimitive)(GLcontext *ctx, GLenum mode);
838   /* Called between RednerStart() and RenderFinish() to indicate the
839    * type of primitive we're about to draw.  Mode will be one of the
840    * modes accepted by glBegin().
841    */
842
843   interp_func RenderInterp;
844   copy_pv_func RenderCopyPV;
845   void (*RenderClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n );
846   void (*RenderClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 );
847   /* Functions to interpolate between prebuilt vertices, copy flat-shade
848    * provoking color, and to render clipped primitives.
849    */
850
851   /***
852    *** Parameters for _tnl_render_stage
853    ***/
854   points_func           PointsFunc; /* must now respect vb->elts */
855   line_func             LineFunc;
856   triangle_func         TriangleFunc;
857   quad_func             QuadFunc;
858   /* These functions are called in order to render points, lines,
859    * triangles and quads.  These are only called via the T&L module.
860    */
861
862   render_func          *RenderTabVerts;
863   render_func          *RenderTabElts;
864   /* XXX Description???
865    */
866
867   void (*ResetLineStipple)( GLcontext *ctx );
868   /* Reset the hardware's line stipple counter.
869    */
870
871   void (*BuildProjectedVertices)( GLcontext *ctx,
872				   GLuint start, GLuint end,
873				   GLuint new_inputs);
874   /* This function is called whenever new vertices are required for
875    * rendering.  The vertices in question are those n such that start
876    * <= n < end.  The new_inputs parameter indicates those fields of
877    * the vertex which need to be updated, if only a partial repair of
878    * the vertex is required.
879    *
880    * This function is called only from _tnl_render_stage in tnl/t_render.c.
881    */
882
883
884   GLboolean (*MultipassFunc)( GLcontext *ctx, GLuint passno );
885   /* Driver may request additional render passes by returning GL_TRUE
886    * when this function is called.  This function will be called
887    * after the first pass, and passes will be made until the function
888    * returns GL_FALSE.  If no function is registered, only one pass
889    * is made.
890    *
891    * This function will be first invoked with passno == 1.
892    */
893
894
895   /***
896    *** Support for multiple t&l engines
897    ***/
898#define PRIM_OUTSIDE_BEGIN_END   GL_POLYGON+1
899#define PRIM_INSIDE_UNKNOWN_PRIM GL_POLYGON+2
900#define PRIM_UNKNOWN             GL_POLYGON+3
901
902   GLuint CurrentExecPrimitive;
903   /* Set by the driver-supplied t&l engine.  Set to GL_POLYGON+1 when
904    * outside begin/end.
905    */
906
907   GLuint CurrentSavePrimitive;
908   /* Current state of an inprogress compilation.
909    */
910
911
912
913#define FLUSH_STORED_VERTICES 0x1
914#define FLUSH_UPDATE_CURRENT  0x2
915   GLuint NeedFlush;
916   /* Set by the driver-supplied t&l engine whenever vertices are
917    * buffered between begin/end objects or ctx->Current is not uptodate.
918    *
919    * The FlushVertices() call below may be used to resolve
920    * these conditions.
921    */
922
923   void (*FlushVertices)( GLcontext *ctx, GLuint flags );
924   /* If inside begin/end, ASSERT(0).
925    * Otherwise,
926    *   if (flags & FLUSH_STORED_VERTICES) flushes any buffered vertices,
927    *   if (flags & FLUSH_UPDATE_CURRENT) updates ctx->Current
928    *                                     and ctx->Light.Material
929    *   returns GL_TRUE.
930    *
931    * Note that the default t&l engine never clears the
932    * FLUSH_UPDATE_CURRENT bit, even after performing the update.
933    */
934
935   void (*LightingSpaceChange)( GLcontext *ctx );
936   /* Notify driver that the special derived value _NeedEyeCoords has
937    * changed.
938    */
939
940   void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode );
941   void (*EndList)( GLcontext *ctx );
942   /* Let the t&l component know what is going on with display lists
943    * in time to make changes to dispatch tables, etc.
944    * Called by glNewList() and glEndList(), respectively.
945    */
946
947   void (*BeginCallList)( GLcontext *ctx, GLuint list );
948   void (*EndCallList)( GLcontext *ctx );
949   /* Notify the t&l component before and after calling a display list.
950    * Called by glCallList(s), but not recursively.
951    */
952
953   void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
954			GLframebuffer *readBuffer );
955   /* Let the t&l component know when the context becomes current.
956    */
957
958
959   void (*LockArraysEXT)( GLcontext *ctx, GLint first, GLsizei count );
960   void (*UnlockArraysEXT)( GLcontext *ctx );
961   /* Called by glLockArraysEXT() and glUnlockArraysEXT(), respectively.
962    */
963
964};
965
966
967
968/*
969 * Transform/Clip/Lighting interface
970 */
971typedef struct {
972   void (*ArrayElement)( GLint ); /* NOTE */
973   void (*Color3f)( GLfloat, GLfloat, GLfloat );
974   void (*Color3fv)( const GLfloat * );
975   void (*Color3ub)( GLubyte, GLubyte, GLubyte );
976   void (*Color3ubv)( const GLubyte * );
977   void (*Color4f)( GLfloat, GLfloat, GLfloat, GLfloat );
978   void (*Color4fv)( const GLfloat * );
979   void (*Color4ub)( GLubyte, GLubyte, GLubyte, GLubyte );
980   void (*Color4ubv)( const GLubyte * );
981   void (*EdgeFlag)( GLboolean );
982   void (*EdgeFlagv)( const GLboolean * );
983   void (*EvalCoord1f)( GLfloat );          /* NOTE */
984   void (*EvalCoord1fv)( const GLfloat * ); /* NOTE */
985   void (*EvalCoord2f)( GLfloat, GLfloat ); /* NOTE */
986   void (*EvalCoord2fv)( const GLfloat * ); /* NOTE */
987   void (*EvalPoint1)( GLint );             /* NOTE */
988   void (*EvalPoint2)( GLint, GLint );      /* NOTE */
989   void (*FogCoordfEXT)( GLfloat );
990   void (*FogCoordfvEXT)( const GLfloat * );
991   void (*Indexi)( GLint );
992   void (*Indexiv)( const GLint * );
993   void (*Materialfv)( GLenum face, GLenum pname, const GLfloat * ); /* NOTE */
994   void (*MultiTexCoord1fARB)( GLenum, GLfloat );
995   void (*MultiTexCoord1fvARB)( GLenum, const GLfloat * );
996   void (*MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat );
997   void (*MultiTexCoord2fvARB)( GLenum, const GLfloat * );
998   void (*MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat );
999   void (*MultiTexCoord3fvARB)( GLenum, const GLfloat * );
1000   void (*MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat );
1001   void (*MultiTexCoord4fvARB)( GLenum, const GLfloat * );
1002   void (*Normal3f)( GLfloat, GLfloat, GLfloat );
1003   void (*Normal3fv)( const GLfloat * );
1004   void (*SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat );
1005   void (*SecondaryColor3fvEXT)( const GLfloat * );
1006   void (*SecondaryColor3ubEXT)( GLubyte, GLubyte, GLubyte );
1007   void (*SecondaryColor3ubvEXT)( const GLubyte * );
1008   void (*TexCoord1f)( GLfloat );
1009   void (*TexCoord1fv)( const GLfloat * );
1010   void (*TexCoord2f)( GLfloat, GLfloat );
1011   void (*TexCoord2fv)( const GLfloat * );
1012   void (*TexCoord3f)( GLfloat, GLfloat, GLfloat );
1013   void (*TexCoord3fv)( const GLfloat * );
1014   void (*TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat );
1015   void (*TexCoord4fv)( const GLfloat * );
1016   void (*Vertex2f)( GLfloat, GLfloat );
1017   void (*Vertex2fv)( const GLfloat * );
1018   void (*Vertex3f)( GLfloat, GLfloat, GLfloat );
1019   void (*Vertex3fv)( const GLfloat * );
1020   void (*Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat );
1021   void (*Vertex4fv)( const GLfloat * );
1022   void (*CallList)( GLuint );	/* NOTE */
1023   void (*Begin)( GLenum );
1024   void (*End)( void );
1025   /* Drivers present a reduced set of the functions possible in
1026    * begin/end objects.  Core mesa provides translation stubs for the
1027    * remaining functions to map down to these entrypoints.
1028    *
1029    * These are the initial values to be installed into dispatch by
1030    * mesa.  If the t&l driver wants to modify the dispatch table
1031    * while installed, it must do so itself.  It would be possible for
1032    * the vertexformat to install it's own initial values for these
1033    * functions, but this way there is an obvious list of what is
1034    * expected of the driver.
1035    *
1036    * If the driver wants to hook in entrypoints other than those
1037    * listed above, it must restore them to their original values in
1038    * the disable() callback, below.
1039    */
1040
1041   void (*Rectf)( GLfloat, GLfloat, GLfloat, GLfloat );
1042   /*
1043    */
1044
1045
1046   void (*DrawArrays)( GLenum mode, GLint start, GLsizei count );
1047   void (*DrawElements)( GLenum mode, GLsizei count, GLenum type,
1048			 const GLvoid *indices );
1049   void (*DrawRangeElements)(GLenum mode, GLuint start,
1050			     GLuint end, GLsizei count,
1051			     GLenum type, const GLvoid *indices);
1052   /* These may or may not belong here.  Heuristic: If an array is
1053    * enabled, the installed vertex format should support that array and
1054    * it's current size natively.
1055    */
1056
1057   void (*EvalMesh1)( GLenum mode, GLint i1, GLint i2 );
1058   void (*EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
1059   /* If you don't support eval, fallback to the default vertex format
1060    * on receiving an eval call and use the pipeline mechanism to
1061    * provide partial t&l acceleration.
1062    *
1063    * Mesa will provide a set of helper functions to do eval within
1064    * accelerated vertex formats, eventually...
1065    *
1066    * Update: There seem to be issues re. maintaining correct values
1067    * for 'ctx->Current' in the face of Eval and T&L fallbacks...
1068    */
1069
1070   GLboolean prefer_float_colors;
1071   /* Should core send non-standard colors to glColor4f or glColor4ub
1072    */
1073
1074
1075} GLvertexformat;
1076
1077
1078#endif
1079
1080