1 /* $Id: dd.h,v 1.52 2001/02/15 01:33:52 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
32 /* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */
34 struct gl_pixelstore_attrib
;
38 * Device Driver (DD) interface
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.
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.
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.
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.
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
73 * For more information about writing a device driver see the ddsample.c
74 * file and other device drivers (X/xmesa[1234].c, OSMesa/osmesa.c, etc)
78 * Look below in the dd_function_table struct definition for descriptions
79 * of each device driver function.
82 * In the future more function pointers may be added for glReadPixels
88 * RGBA = red/green/blue/alpha
89 * CI = color index (color mapped mode)
90 * mono = all pixels have the same color or index
92 * The write_ functions all take an array of mask flags which indicate
93 * whether or not the pixel should be written. One special case exists
94 * in the write_color_span function: if the mask array is NULL, then
95 * draw all pixels. This is an optimization used for glDrawPixels().
98 * X coordinates start at 0 at the left and increase to the right
99 * Y coordinates start at 0 at the bottom and increase upward
108 /* Mask bits sent to the driver Clear() function */
109 #define DD_FRONT_LEFT_BIT FRONT_LEFT_BIT /* 1 */
110 #define DD_FRONT_RIGHT_BIT FRONT_RIGHT_BIT /* 2 */
111 #define DD_BACK_LEFT_BIT BACK_LEFT_BIT /* 4 */
112 #define DD_BACK_RIGHT_BIT BACK_RIGHT_BIT /* 8 */
113 #define DD_DEPTH_BIT GL_DEPTH_BUFFER_BIT /* 0x00000100 */
114 #define DD_STENCIL_BIT GL_STENCIL_BUFFER_BIT /* 0x00000400 */
115 #define DD_ACCUM_BIT GL_ACCUM_BUFFER_BIT /* 0x00000200 */
123 /* Point, line, triangle, quadrilateral and rectangle rasterizer
124 * functions. These are specific to the tnl module and will shortly
125 * move to a driver interface specific to that module.
127 typedef void (*points_func
)( GLcontext
*ctx
, GLuint first
, GLuint last
);
129 typedef void (*line_func
)( GLcontext
*ctx
, GLuint v1
, GLuint v2
);
131 typedef void (*triangle_func
)( GLcontext
*ctx
,
132 GLuint v1
, GLuint v2
, GLuint v3
);
134 typedef void (*quad_func
)( GLcontext
*ctx
, GLuint v1
, GLuint v2
,
135 GLuint v3
, GLuint v4
);
137 typedef void (*render_func
)( GLcontext
*ctx
, GLuint start
, GLuint count
,
140 typedef void (*interp_func
)( GLcontext
*ctx
,
141 GLfloat t
, GLuint dst
, GLuint in
, GLuint out
,
142 GLboolean force_boundary
);
144 typedef void (*copy_pv_func
)( GLcontext
*ctx
, GLuint dst
, GLuint src
);
148 * Device Driver function table.
150 struct dd_function_table
{
152 /**********************************************************************
153 *** Mandatory functions: these functions must be implemented by ***
154 *** every device driver. ***
155 **********************************************************************/
157 const GLubyte
* (*GetString
)( GLcontext
*ctx
, GLenum name
);
158 /* Return a string as needed by glGetString().
159 * Only the GL_RENDERER token must be implemented. Otherwise,
160 * NULL can be returned.
163 void (*UpdateState
)( GLcontext
*ctx
, GLuint new_state
);
165 * UpdateState() is called whenver Mesa thinks the device driver should
166 * update its state and/or the other pointers (such as PointsFunc,
167 * LineFunc, or TriangleFunc).
170 void (*Clear
)( GLcontext
*ctx
, GLbitfield mask
, GLboolean all
,
171 GLint x
, GLint y
, GLint width
, GLint height
);
172 /* Clear the color/depth/stencil/accum buffer(s).
173 * 'mask' is a bitmask of the DD_*_BIT values defined above that indicates
174 * which buffers need to be cleared.
175 * If 'all' is true then the clear the whole buffer, else clear only the
176 * region defined by (x,y,width,height).
177 * This function must obey the glColorMask, glIndexMask and glStencilMask
178 * settings! Software Mesa can do masked clears if the device driver can't.
181 GLboolean (*SetDrawBuffer
)( GLcontext
*ctx
, GLenum buffer
);
183 * Specifies the current buffer for writing.
184 * The following values must be accepted when applicable:
185 * GL_FRONT_LEFT - this buffer always exists
186 * GL_BACK_LEFT - when double buffering
187 * GL_FRONT_RIGHT - when using stereo
188 * GL_BACK_RIGHT - when using stereo and double buffering
189 * The folowing values may optionally be accepted. Return GL_TRUE
190 * if accepted, GL_FALSE if not accepted. In practice, only drivers
191 * which can write to multiple color buffers at once should accept
193 * GL_FRONT - write to front left and front right if it exists
194 * GL_BACK - write to back left and back right if it exists
195 * GL_LEFT - write to front left and back left if it exists
196 * GL_RIGHT - write to right left and back right if they exist
197 * GL_FRONT_AND_BACK - write to all four buffers if they exist
198 * GL_NONE - disable buffer write in device driver.
201 void (*SetReadBuffer
)( GLcontext
*ctx
, GLframebuffer
*colorBuffer
,
204 * Specifies the current buffer for reading.
205 * colorBuffer will be one of:
206 * GL_FRONT_LEFT - this buffer always exists
207 * GL_BACK_LEFT - when double buffering
208 * GL_FRONT_RIGHT - when using stereo
209 * GL_BACK_RIGHT - when using stereo and double buffering
212 void (*GetBufferSize
)( GLcontext
*ctx
, GLuint
*width
, GLuint
*height
);
214 * Returns the width and height of the current color buffer.
219 *** Functions for writing pixels to the frame buffer:
222 void (*WriteRGBASpan
)( const GLcontext
*ctx
,
223 GLuint n
, GLint x
, GLint y
,
224 CONST GLchan rgba
[][4], const GLubyte mask
[] );
225 void (*WriteRGBSpan
)( const GLcontext
*ctx
,
226 GLuint n
, GLint x
, GLint y
,
227 CONST GLchan rgb
[][3], const GLubyte mask
[] );
228 /* Write a horizontal run of RGBA or RGB pixels.
229 * If mask is NULL, draw all pixels.
230 * If mask is not null, only draw pixel [i] when mask [i] is true.
233 void (*WriteMonoRGBASpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
234 const GLchan color
[4], const GLubyte mask
[] );
235 /* Write a horizontal run of RGBA pixels all with the same color.
238 void (*WriteRGBAPixels
)( const GLcontext
*ctx
,
239 GLuint n
, const GLint x
[], const GLint y
[],
240 CONST GLchan rgba
[][4], const GLubyte mask
[] );
241 /* Write array of RGBA pixels at random locations.
244 void (*WriteMonoRGBAPixels
)( const GLcontext
*ctx
,
245 GLuint n
, const GLint x
[], const GLint y
[],
246 const GLchan color
[4], const GLubyte mask
[] );
247 /* Write an array of mono-RGBA pixels at random locations.
250 void (*WriteCI32Span
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
251 const GLuint index
[], const GLubyte mask
[] );
252 void (*WriteCI8Span
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
253 const GLubyte index
[], const GLubyte mask
[] );
254 /* Write a horizontal run of CI pixels. One function is for 32bpp
255 * indexes and the other for 8bpp pixels (the common case). You mus
256 * implement both for color index mode.
259 void (*WriteMonoCISpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
260 GLuint colorIndex
, const GLubyte mask
[] );
261 /* Write a horizontal run of color index pixels using the color index
262 * last specified by the Index() function.
265 void (*WriteCI32Pixels
)( const GLcontext
*ctx
,
266 GLuint n
, const GLint x
[], const GLint y
[],
267 const GLuint index
[], const GLubyte mask
[] );
269 * Write a random array of CI pixels.
272 void (*WriteMonoCIPixels
)( const GLcontext
*ctx
,
273 GLuint n
, const GLint x
[], const GLint y
[],
274 GLuint colorIndex
, const GLubyte mask
[] );
275 /* Write a random array of color index pixels using the color index
276 * last specified by the Index() function.
281 *** Functions to read pixels from frame buffer:
284 void (*ReadCI32Span
)( const GLcontext
*ctx
,
285 GLuint n
, GLint x
, GLint y
, GLuint index
[] );
286 /* Read a horizontal run of color index pixels.
289 void (*ReadRGBASpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
291 /* Read a horizontal run of RGBA pixels.
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.
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.
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 **********************************************************************/
315 void (*Finish
)( GLcontext
*ctx
);
317 * This is called whenever glFinish() is called.
320 void (*Flush
)( GLcontext
*ctx
);
322 * This is called whenever glFlush() is called.
325 void (*Error
)( GLcontext
*ctx
);
327 * Called whenever an error is generated. ctx->ErrorValue contains
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.
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.
345 void (*ReadDepthSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
347 /* Read a horizontal span of values from the depth buffer.
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.
358 void (*ReadDepthPixels
)( GLcontext
*ctx
, GLuint n
,
359 const GLint x
[], const GLint y
[],
361 /* Read an array of randomly positioned depth values from the depth buffer.
367 *** For supporting hardware stencil buffers:
368 *** Either ALL or NONE of these functions must be implemented!
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.
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.
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.
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.
400 *** For hardware accumulation buffer:
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.
409 *** glDraw/Read/CopyPixels and glBitmap functions:
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.
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
,
426 /* Called by glReadPixels.
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.
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.
444 void (*ResizeBuffersMESA
)( GLcontext
*ctx
);
448 *** Texture image functions:
450 void (*TexImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
451 GLint internalFormat
,
452 GLint width
, GLint border
,
453 GLenum format
, GLenum type
, const GLvoid
*pixels
,
454 const struct gl_pixelstore_attrib
*packing
,
455 struct gl_texture_object
*texObj
,
456 struct gl_texture_image
*texImage
);
457 void (*TexImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
458 GLint internalFormat
,
459 GLint width
, GLint height
, GLint border
,
460 GLenum format
, GLenum type
, const GLvoid
*pixels
,
461 const struct gl_pixelstore_attrib
*packing
,
462 struct gl_texture_object
*texObj
,
463 struct gl_texture_image
*texImage
);
464 void (*TexImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
465 GLint internalFormat
,
466 GLint width
, GLint height
, GLint depth
, GLint border
,
467 GLenum format
, GLenum type
, const GLvoid
*pixels
,
468 const struct gl_pixelstore_attrib
*packing
,
469 struct gl_texture_object
*texObj
,
470 struct gl_texture_image
*texImage
);
471 /* Called by glTexImage1/2/3D.
472 * Will not be called if any glPixelTransfer operations are enabled.
474 * <target>, <level>, <format>, <type> and <pixels> are user specified.
475 * <packing> indicates the image packing of pixels.
476 * <texObj> is the target texture object.
477 * <texImage> is the target texture image. It will have the texture
478 * width, height, depth, border and internalFormat information.
479 * <retainInternalCopy> is returned by this function and indicates whether
480 * core Mesa should keep an internal copy of the texture image.
481 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
482 * should do the job. If GL_FALSE is returned, this function will be
483 * called a second time after the texture image has been unpacked into
484 * GLubytes. It may be easier for the driver to handle then.
487 void (*TexSubImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
488 GLint xoffset
, GLsizei width
,
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 (*TexSubImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
495 GLint xoffset
, GLint yoffset
,
496 GLsizei width
, GLsizei height
,
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 void (*TexSubImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
503 GLint xoffset
, GLint yoffset
, GLint zoffset
,
504 GLsizei width
, GLsizei height
, GLint depth
,
505 GLenum format
, GLenum type
,
506 const GLvoid
*pixels
,
507 const struct gl_pixelstore_attrib
*packing
,
508 struct gl_texture_object
*texObj
,
509 struct gl_texture_image
*texImage
);
510 /* Called by glTexSubImage1/2/3D.
511 * Will not be called if any glPixelTransfer operations are enabled.
513 * <target>, <level>, <xoffset>, <yoffset>, <zoffset>, <width>, <height>,
514 * <depth>, <format>, <type> and <pixels> are user specified.
515 * <packing> indicates the image packing of pixels.
516 * <texObj> is the target texture object.
517 * <texImage> is the target texture image. It will have the texture
518 * width, height, border and internalFormat information.
519 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
520 * should do the job. If GL_FALSE is returned, then TexImage1/2/3D will
521 * be called with the complete texture image.
524 GLboolean (*CopyTexImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
525 GLenum internalFormat
, GLint x
, GLint y
,
526 GLsizei width
, GLint border
);
527 GLboolean (*CopyTexImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
528 GLenum internalFormat
, GLint x
, GLint y
,
529 GLsizei width
, GLsizei height
, GLint border
);
530 /* Called by glCopyTexImage1D and glCopyTexImage2D.
531 * Will not be called if any glPixelTransfer operations are enabled.
532 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
536 GLboolean (*CopyTexSubImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
538 GLint x
, GLint y
, GLsizei width
);
539 GLboolean (*CopyTexSubImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
540 GLint xoffset
, GLint yoffset
,
542 GLsizei width
, GLsizei height
);
543 GLboolean (*CopyTexSubImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
544 GLint xoffset
, GLint yoffset
, GLint zoffset
,
546 GLsizei width
, GLsizei height
);
547 /* Called by glCopyTexSubImage1/2/3D.
548 * Will not be called if any glPixelTransfer operations are enabled.
549 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
553 GLboolean (*TestProxyTexImage
)(GLcontext
*ctx
, GLenum target
,
554 GLint level
, GLint internalFormat
,
555 GLenum format
, GLenum type
,
556 GLint width
, GLint height
,
557 GLint depth
, GLint border
);
558 /* Called by glTexImage[123]D when user specifies a proxy texture
559 * target. Return GL_TRUE if the proxy test passes, return GL_FALSE
564 *** Compressed texture functions:
567 void (*CompressedTexImage1D
)( GLcontext
*ctx
, GLenum target
,
568 GLint level
, GLint internalFormat
,
569 GLsizei width
, GLint border
,
570 GLsizei imageSize
, const GLvoid
*data
,
571 struct gl_texture_object
*texObj
,
572 struct gl_texture_image
*texImage
);
573 void (*CompressedTexImage2D
)( GLcontext
*ctx
, GLenum target
,
574 GLint level
, GLint internalFormat
,
575 GLsizei width
, GLsizei height
, GLint border
,
576 GLsizei imageSize
, const GLvoid
*data
,
577 struct gl_texture_object
*texObj
,
578 struct gl_texture_image
*texImage
);
579 void (*CompressedTexImage3D
)( GLcontext
*ctx
, GLenum target
,
580 GLint level
, GLint internalFormat
,
581 GLsizei width
, GLsizei height
, GLsizei depth
,
583 GLsizei imageSize
, const GLvoid
*data
,
584 struct gl_texture_object
*texObj
,
585 struct gl_texture_image
*texImage
);
586 /* Called by glCompressedTexImage1/2/3D.
588 * <target>, <level>, <internalFormat>, <data> are user specified.
589 * <texObj> is the target texture object.
590 * <texImage> is the target texture image. It will have the texture
591 * width, height, depth, border and internalFormat information.
592 * <retainInternalCopy> is returned by this function and indicates whether
593 * core Mesa should keep an internal copy of the texture image.
594 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
598 void (*CompressedTexSubImage1D
)(GLcontext
*ctx
, GLenum target
, GLint level
,
599 GLint xoffset
, GLsizei width
,
601 GLsizei imageSize
, const GLvoid
*data
,
602 struct gl_texture_object
*texObj
,
603 struct gl_texture_image
*texImage
);
604 void (*CompressedTexSubImage2D
)(GLcontext
*ctx
, GLenum target
, GLint level
,
605 GLint xoffset
, GLint yoffset
,
606 GLsizei width
, GLint height
,
608 GLsizei imageSize
, const GLvoid
*data
,
609 struct gl_texture_object
*texObj
,
610 struct gl_texture_image
*texImage
);
611 void (*CompressedTexSubImage3D
)(GLcontext
*ctx
, GLenum target
, GLint level
,
612 GLint xoffset
, GLint yoffset
, GLint zoffset
,
613 GLsizei width
, GLint height
, GLint depth
,
615 GLsizei imageSize
, const GLvoid
*data
,
616 struct gl_texture_object
*texObj
,
617 struct gl_texture_image
*texImage
);
618 /* Called by glCompressedTexSubImage1/2/3D.
620 * <target>, <level>, <x/z/zoffset>, <width>, <height>, <depth>,
621 * <imageSize>, and <data> are user specified.
622 * <texObj> is the target texture object.
623 * <texImage> is the target texture image. It will have the texture
624 * width, height, depth, border and internalFormat information.
625 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
629 GLboolean (*IsCompressedFormat
)(GLcontext
*ctx
, GLint internalFormat
);
630 /* Called to tell if a format is a compressed format.
633 void (*GetCompressedTexImage
)( GLcontext
*ctx
, GLenum target
,
634 GLint lod
, void *image
,
635 const struct gl_texture_object
*texObj
,
636 struct gl_texture_image
*texImage
);
637 /* Called by glGetCompressedTexImageARB.
638 * <target>, <lod>, <image> are specified by user.
639 * <texObj> is the source texture object.
640 * <texImage> is the source texture image.
643 GLint (*BaseCompressedTexFormat
)(GLcontext
*ctx
,
644 GLint internalFormat
);
645 /* Called to compute the base format for a specific compressed
646 * format. Return -1 if the internalFormat is not a specific
647 * compressed format that the driver recognizes.
648 * Example: if internalFormat==GL_COMPRESSED_RGB_FXT1_3DFX, return GL_RGB.
653 * return value differences between this function and
654 * SpecificCompressedTexFormat below.
657 GLint (*SpecificCompressedTexFormat
)(GLcontext
*ctx
,
658 GLint internalFormat
,
667 /* Called to turn a generic texture format into a specific
668 * texture format. For example, if a driver implements
669 * GL_3DFX_texture_compression_FXT1, this would map
670 * GL_COMPRESSED_RGBA_ARB to GL_COMPRESSED_RGBA_FXT1_3DFX.
672 * If the driver does not know how to handle the compressed
673 * format, then just return the generic format, and Mesa will
674 * do the right thing with it.
677 GLsizei (*CompressedImageSize
)(GLcontext
*ctx
,
678 GLenum internalFormat
,
679 GLuint numDimensions
,
683 /* Calculate the size of a compressed image, given the image's
684 * format and dimensions.
689 *** Texture object functions:
692 void (*BindTexture
)( GLcontext
*ctx
, GLenum target
,
693 struct gl_texture_object
*tObj
);
694 /* Called by glBindTexture().
697 void (*CreateTexture
)( GLcontext
*ctx
, struct gl_texture_object
*tObj
);
698 /* Called when a texture object is created.
701 void (*DeleteTexture
)( GLcontext
*ctx
, struct gl_texture_object
*tObj
);
702 /* Called when a texture object is about to be deallocated. Driver
703 * should free anything attached to the DriverData pointers.
706 GLboolean (*IsTextureResident
)( GLcontext
*ctx
,
707 struct gl_texture_object
*t
);
708 /* Called by glAreTextureResident().
711 void (*PrioritizeTexture
)( GLcontext
*ctx
, struct gl_texture_object
*t
,
713 /* Called by glPrioritizeTextures().
716 void (*ActiveTexture
)( GLcontext
*ctx
, GLuint texUnitNumber
);
717 /* Called by glActiveTextureARB to set current texture unit.
720 void (*UpdateTexturePalette
)( GLcontext
*ctx
,
721 struct gl_texture_object
*tObj
);
722 /* Called when the texture's color lookup table is changed.
723 * If tObj is NULL then the shared texture palette ctx->Texture.Palette
729 *** State-changing functions (drawing functions are above)
731 *** These functions are called by their corresponding OpenGL API functions.
732 *** They're ALSO called by the gl_PopAttrib() function!!!
733 *** May add more functions like these to the device driver in the future.
735 void (*AlphaFunc
)(GLcontext
*ctx
, GLenum func
, GLclampf ref
);
736 void (*BlendEquation
)(GLcontext
*ctx
, GLenum mode
);
737 void (*BlendFunc
)(GLcontext
*ctx
, GLenum sfactor
, GLenum dfactor
);
738 void (*BlendFuncSeparate
)(GLcontext
*ctx
,
739 GLenum sfactorRGB
, GLenum dfactorRGB
,
740 GLenum sfactorA
, GLenum dfactorA
);
741 void (*ClearColor
)(GLcontext
*ctx
, const GLchan color
[4]);
742 void (*ClearDepth
)(GLcontext
*ctx
, GLclampd d
);
743 void (*ClearIndex
)(GLcontext
*ctx
, GLuint index
);
744 void (*ClearStencil
)(GLcontext
*ctx
, GLint s
);
745 void (*ColorMask
)(GLcontext
*ctx
, GLboolean rmask
, GLboolean gmask
,
746 GLboolean bmask
, GLboolean amask
);
747 void (*CullFace
)(GLcontext
*ctx
, GLenum mode
);
748 void (*ClipPlane
)(GLcontext
*ctx
, GLenum plane
, const GLfloat
*equation
);
749 void (*FrontFace
)(GLcontext
*ctx
, GLenum mode
);
750 void (*DepthFunc
)(GLcontext
*ctx
, GLenum func
);
751 void (*DepthMask
)(GLcontext
*ctx
, GLboolean flag
);
752 void (*DepthRange
)(GLcontext
*ctx
, GLclampd nearval
, GLclampd farval
);
753 void (*Enable
)(GLcontext
* ctx
, GLenum cap
, GLboolean state
);
754 void (*Fogfv
)(GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
);
755 void (*Hint
)(GLcontext
*ctx
, GLenum target
, GLenum mode
);
756 void (*IndexMask
)(GLcontext
*ctx
, GLuint mask
);
757 void (*Lightfv
)(GLcontext
*ctx
, GLenum light
,
758 GLenum pname
, const GLfloat
*params
);
759 void (*LightModelfv
)(GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
);
760 void (*LineStipple
)(GLcontext
*ctx
, GLint factor
, GLushort pattern
);
761 void (*LineWidth
)(GLcontext
*ctx
, GLfloat width
);
762 void (*LogicOpcode
)(GLcontext
*ctx
, GLenum opcode
);
763 void (*PointParameterfv
)(GLcontext
*ctx
, GLenum pname
,
764 const GLfloat
*params
);
765 void (*PointSize
)(GLcontext
*ctx
, GLfloat size
);
766 void (*PolygonMode
)(GLcontext
*ctx
, GLenum face
, GLenum mode
);
767 void (*PolygonStipple
)(GLcontext
*ctx
, const GLubyte
*mask
);
768 void (*RenderMode
)(GLcontext
*ctx
, GLenum mode
);
769 void (*Scissor
)(GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
);
770 void (*ShadeModel
)(GLcontext
*ctx
, GLenum mode
);
771 void (*StencilFunc
)(GLcontext
*ctx
, GLenum func
, GLint ref
, GLuint mask
);
772 void (*StencilMask
)(GLcontext
*ctx
, GLuint mask
);
773 void (*StencilOp
)(GLcontext
*ctx
, GLenum fail
, GLenum zfail
, GLenum zpass
);
774 void (*TexGen
)(GLcontext
*ctx
, GLenum coord
, GLenum pname
,
775 const GLfloat
*params
);
776 void (*TexEnv
)(GLcontext
*ctx
, GLenum target
, GLenum pname
,
777 const GLfloat
*param
);
778 void (*TexParameter
)(GLcontext
*ctx
, GLenum target
,
779 struct gl_texture_object
*texObj
,
780 GLenum pname
, const GLfloat
*params
);
781 void (*TextureMatrix
)(GLcontext
*ctx
, GLuint unit
, const GLmatrix
*mat
);
782 void (*Viewport
)(GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
);
785 /*** State-query functions
787 *** Return GL_TRUE if query was completed, GL_FALSE otherwise.
789 GLboolean (*GetBooleanv
)(GLcontext
*ctx
, GLenum pname
, GLboolean
*result
);
790 GLboolean (*GetDoublev
)(GLcontext
*ctx
, GLenum pname
, GLdouble
*result
);
791 GLboolean (*GetFloatv
)(GLcontext
*ctx
, GLenum pname
, GLfloat
*result
);
792 GLboolean (*GetIntegerv
)(GLcontext
*ctx
, GLenum pname
, GLint
*result
);
793 GLboolean (*GetPointerv
)(GLcontext
*ctx
, GLenum pname
, GLvoid
**result
);
797 *** Vertex array functions
799 *** Called by the corresponding OpenGL functions.
801 void (*VertexPointer
)(GLcontext
*ctx
, GLint size
, GLenum type
,
802 GLsizei stride
, const GLvoid
*ptr
);
803 void (*NormalPointer
)(GLcontext
*ctx
, GLenum type
,
804 GLsizei stride
, const GLvoid
*ptr
);
805 void (*ColorPointer
)(GLcontext
*ctx
, GLint size
, GLenum type
,
806 GLsizei stride
, const GLvoid
*ptr
);
807 void (*FogCoordPointer
)(GLcontext
*ctx
, GLenum type
,
808 GLsizei stride
, const GLvoid
*ptr
);
809 void (*IndexPointer
)(GLcontext
*ctx
, GLenum type
,
810 GLsizei stride
, const GLvoid
*ptr
);
811 void (*SecondaryColorPointer
)(GLcontext
*ctx
, GLint size
, GLenum type
,
812 GLsizei stride
, const GLvoid
*ptr
);
813 void (*TexCoordPointer
)(GLcontext
*ctx
, GLint size
, GLenum type
,
814 GLsizei stride
, const GLvoid
*ptr
);
815 void (*EdgeFlagPointer
)(GLcontext
*ctx
, GLsizei stride
, const GLvoid
*ptr
);
822 void (*PipelineStart
)(GLcontext
*ctx
);
823 void (*PipelineFinish
)(GLcontext
*ctx
);
824 /* Called before and after all pipeline stages.
825 * These are a suitable place for grabbing/releasing hardware locks.
832 void (*RenderStart
)(GLcontext
*ctx
);
833 void (*RenderFinish
)(GLcontext
*ctx
);
834 /* Called before and after all rendering operations, including DrawPixels,
835 * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
836 * These are a suitable place for grabbing/releasing hardware locks.
839 void (*RenderPrimitive
)(GLcontext
*ctx
, GLenum mode
);
840 /* Called between RednerStart() and RenderFinish() to indicate the
841 * type of primitive we're about to draw. Mode will be one of the
842 * modes accepted by glBegin().
845 interp_func RenderInterp
;
846 copy_pv_func RenderCopyPV
;
847 void (*RenderClippedPolygon
)( GLcontext
*ctx
, const GLuint
*elts
, GLuint n
);
848 void (*RenderClippedLine
)( GLcontext
*ctx
, GLuint v0
, GLuint v1
);
849 /* Functions to interpolate between prebuilt vertices, copy flat-shade
850 * provoking color, and to render clipped primitives.
854 *** Parameters for _tnl_render_stage
856 points_func PointsFunc
; /* must now respect vb->elts */
858 triangle_func TriangleFunc
;
860 /* These functions are called in order to render points, lines,
861 * triangles and quads. These are only called via the T&L module.
864 render_func
*RenderTabVerts
;
865 render_func
*RenderTabElts
;
866 /* XXX Description???
869 void (*ResetLineStipple
)( GLcontext
*ctx
);
870 /* Reset the hardware's line stipple counter.
873 void (*BuildProjectedVertices
)( GLcontext
*ctx
,
874 GLuint start
, GLuint end
,
876 /* This function is called whenever new vertices are required for
877 * rendering. The vertices in question are those n such that start
878 * <= n < end. The new_inputs parameter indicates those fields of
879 * the vertex which need to be updated, if only a partial repair of
880 * the vertex is required.
882 * This function is called only from _tnl_render_stage in tnl/t_render.c.
886 GLboolean (*MultipassFunc
)( GLcontext
*ctx
, GLuint passno
);
887 /* Driver may request additional render passes by returning GL_TRUE
888 * when this function is called. This function will be called
889 * after the first pass, and passes will be made until the function
890 * returns GL_FALSE. If no function is registered, only one pass
893 * This function will be first invoked with passno == 1.
898 *** Support for multiple t&l engines
900 #define PRIM_OUTSIDE_BEGIN_END GL_POLYGON+1
901 #define PRIM_INSIDE_UNKNOWN_PRIM GL_POLYGON+2
902 #define PRIM_UNKNOWN GL_POLYGON+3
904 GLuint CurrentExecPrimitive
;
905 /* Set by the driver-supplied t&l engine. Set to
906 * PRIM_OUTSIDE_BEGIN_END when outside begin/end.
909 GLuint CurrentSavePrimitive
;
910 /* Current state of an in-progress compilation. May take on any of
911 * the additional values defined above.
916 #define FLUSH_STORED_VERTICES 0x1
917 #define FLUSH_UPDATE_CURRENT 0x2
919 /* Set by the driver-supplied t&l engine whenever vertices are
920 * buffered between begin/end objects or ctx->Current is not uptodate.
922 * The FlushVertices() call below may be used to resolve
926 void (*FlushVertices
)( GLcontext
*ctx
, GLuint flags
);
927 /* If inside begin/end, ASSERT(0).
929 * if (flags & FLUSH_STORED_VERTICES) flushes any buffered vertices,
930 * if (flags & FLUSH_UPDATE_CURRENT) updates ctx->Current
931 * and ctx->Light.Material
933 * Note that the default t&l engine never clears the
934 * FLUSH_UPDATE_CURRENT bit, even after performing the update.
937 void (*LightingSpaceChange
)( GLcontext
*ctx
);
938 /* Notify driver that the special derived value _NeedEyeCoords has
942 void (*NewList
)( GLcontext
*ctx
, GLuint list
, GLenum mode
);
943 void (*EndList
)( GLcontext
*ctx
);
944 /* Let the t&l component know what is going on with display lists
945 * in time to make changes to dispatch tables, etc.
946 * Called by glNewList() and glEndList(), respectively.
949 void (*BeginCallList
)( GLcontext
*ctx
, GLuint list
);
950 void (*EndCallList
)( GLcontext
*ctx
);
951 /* Notify the t&l component before and after calling a display list.
952 * Called by glCallList(s), but not recursively.
955 void (*MakeCurrent
)( GLcontext
*ctx
, GLframebuffer
*drawBuffer
,
956 GLframebuffer
*readBuffer
);
957 /* Let the t&l component know when the context becomes current.
961 void (*LockArraysEXT
)( GLcontext
*ctx
, GLint first
, GLsizei count
);
962 void (*UnlockArraysEXT
)( GLcontext
*ctx
);
963 /* Called by glLockArraysEXT() and glUnlockArraysEXT(), respectively.
971 * Transform/Clip/Lighting interface
974 void (*ArrayElement
)( GLint
); /* NOTE */
975 void (*Color3f
)( GLfloat
, GLfloat
, GLfloat
);
976 void (*Color3fv
)( const GLfloat
* );
977 void (*Color3ub
)( GLubyte
, GLubyte
, GLubyte
);
978 void (*Color3ubv
)( const GLubyte
* );
979 void (*Color4f
)( GLfloat
, GLfloat
, GLfloat
, GLfloat
);
980 void (*Color4fv
)( const GLfloat
* );
981 void (*Color4ub
)( GLubyte
, GLubyte
, GLubyte
, GLubyte
);
982 void (*Color4ubv
)( const GLubyte
* );
983 void (*EdgeFlag
)( GLboolean
);
984 void (*EdgeFlagv
)( const GLboolean
* );
985 void (*EvalCoord1f
)( GLfloat
); /* NOTE */
986 void (*EvalCoord1fv
)( const GLfloat
* ); /* NOTE */
987 void (*EvalCoord2f
)( GLfloat
, GLfloat
); /* NOTE */
988 void (*EvalCoord2fv
)( const GLfloat
* ); /* NOTE */
989 void (*EvalPoint1
)( GLint
); /* NOTE */
990 void (*EvalPoint2
)( GLint
, GLint
); /* NOTE */
991 void (*FogCoordfEXT
)( GLfloat
);
992 void (*FogCoordfvEXT
)( const GLfloat
* );
993 void (*Indexi
)( GLint
);
994 void (*Indexiv
)( const GLint
* );
995 void (*Materialfv
)( GLenum face
, GLenum pname
, const GLfloat
* ); /* NOTE */
996 void (*MultiTexCoord1fARB
)( GLenum
, GLfloat
);
997 void (*MultiTexCoord1fvARB
)( GLenum
, const GLfloat
* );
998 void (*MultiTexCoord2fARB
)( GLenum
, GLfloat
, GLfloat
);
999 void (*MultiTexCoord2fvARB
)( GLenum
, const GLfloat
* );
1000 void (*MultiTexCoord3fARB
)( GLenum
, GLfloat
, GLfloat
, GLfloat
);
1001 void (*MultiTexCoord3fvARB
)( GLenum
, const GLfloat
* );
1002 void (*MultiTexCoord4fARB
)( GLenum
, GLfloat
, GLfloat
, GLfloat
, GLfloat
);
1003 void (*MultiTexCoord4fvARB
)( GLenum
, const GLfloat
* );
1004 void (*Normal3f
)( GLfloat
, GLfloat
, GLfloat
);
1005 void (*Normal3fv
)( const GLfloat
* );
1006 void (*SecondaryColor3fEXT
)( GLfloat
, GLfloat
, GLfloat
);
1007 void (*SecondaryColor3fvEXT
)( const GLfloat
* );
1008 void (*SecondaryColor3ubEXT
)( GLubyte
, GLubyte
, GLubyte
);
1009 void (*SecondaryColor3ubvEXT
)( const GLubyte
* );
1010 void (*TexCoord1f
)( GLfloat
);
1011 void (*TexCoord1fv
)( const GLfloat
* );
1012 void (*TexCoord2f
)( GLfloat
, GLfloat
);
1013 void (*TexCoord2fv
)( const GLfloat
* );
1014 void (*TexCoord3f
)( GLfloat
, GLfloat
, GLfloat
);
1015 void (*TexCoord3fv
)( const GLfloat
* );
1016 void (*TexCoord4f
)( GLfloat
, GLfloat
, GLfloat
, GLfloat
);
1017 void (*TexCoord4fv
)( const GLfloat
* );
1018 void (*Vertex2f
)( GLfloat
, GLfloat
);
1019 void (*Vertex2fv
)( const GLfloat
* );
1020 void (*Vertex3f
)( GLfloat
, GLfloat
, GLfloat
);
1021 void (*Vertex3fv
)( const GLfloat
* );
1022 void (*Vertex4f
)( GLfloat
, GLfloat
, GLfloat
, GLfloat
);
1023 void (*Vertex4fv
)( const GLfloat
* );
1024 void (*CallList
)( GLuint
); /* NOTE */
1025 void (*Begin
)( GLenum
);
1026 void (*End
)( void );
1027 /* Drivers present a reduced set of the functions possible in
1028 * begin/end objects. Core mesa provides translation stubs for the
1029 * remaining functions to map down to these entrypoints.
1031 * These are the initial values to be installed into dispatch by
1032 * mesa. If the t&l driver wants to modify the dispatch table
1033 * while installed, it must do so itself. It would be possible for
1034 * the vertexformat to install it's own initial values for these
1035 * functions, but this way there is an obvious list of what is
1036 * expected of the driver.
1038 * If the driver wants to hook in entrypoints other than those
1039 * listed above, it must restore them to their original values in
1040 * the disable() callback, below.
1043 void (*Rectf
)( GLfloat
, GLfloat
, GLfloat
, GLfloat
);
1048 void (*DrawArrays
)( GLenum mode
, GLint start
, GLsizei count
);
1049 void (*DrawElements
)( GLenum mode
, GLsizei count
, GLenum type
,
1050 const GLvoid
*indices
);
1051 void (*DrawRangeElements
)(GLenum mode
, GLuint start
,
1052 GLuint end
, GLsizei count
,
1053 GLenum type
, const GLvoid
*indices
);
1054 /* These may or may not belong here. Heuristic: If an array is
1055 * enabled, the installed vertex format should support that array and
1056 * it's current size natively.
1059 void (*EvalMesh1
)( GLenum mode
, GLint i1
, GLint i2
);
1060 void (*EvalMesh2
)( GLenum mode
, GLint i1
, GLint i2
, GLint j1
, GLint j2
);
1061 /* If you don't support eval, fallback to the default vertex format
1062 * on receiving an eval call and use the pipeline mechanism to
1063 * provide partial t&l acceleration.
1065 * Mesa will provide a set of helper functions to do eval within
1066 * accelerated vertex formats, eventually...
1068 * Update: There seem to be issues re. maintaining correct values
1069 * for 'ctx->Current' in the face of Eval and T&L fallbacks...
1072 GLboolean prefer_float_colors
;
1073 /* Should core send non-standard colors to glColor4f or glColor4ub