1 /* $Id: dd.h,v 1.32 2000/09/14 23:13:51 brianp 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.
36 struct gl_pixelstore_attrib
;
41 struct gl_pipeline_stage
;
44 /* THIS FILE ONLY INCLUDED BY types.h !!!!! */
48 * Device Driver (DD) interface
51 * All device driver functions are accessed through pointers in the
52 * dd_function_table struct (defined below) which is stored in the GLcontext
53 * struct. Since the device driver is strictly accessed trough a table of
54 * function pointers we can:
55 * 1. switch between a number of different device drivers at runtime.
56 * 2. use optimized functions dependant on current rendering state or
57 * frame buffer configuration.
59 * The function pointers in the dd_function_table struct are divided into
60 * two groups: mandatory and optional.
61 * Mandatory functions have to be implemented by every device driver.
62 * Optional functions may or may not be implemented by the device driver.
63 * The optional functions provide ways to take advantage of special hardware
64 * or optimized algorithms.
66 * The function pointers in the dd_function_table struct should first be
67 * initialized in the driver's "MakeCurrent" function. The "MakeCurrent"
68 * function is a little different in each device driver. See the X/Mesa,
69 * GLX, or OS/Mesa drivers for examples.
71 * Later, Mesa may call the dd_function_table's UpdateState() function.
72 * This function should initialize the dd_function_table's pointers again.
73 * The UpdateState() function is called whenever the core (GL) rendering
74 * state is changed in a way which may effect rasterization. For example,
75 * the TriangleFunc() pointer may have to point to different functions
76 * depending on whether smooth or flat shading is enabled.
78 * Note that the first argument to every device driver function is a
79 * GLcontext *. In turn, the GLcontext->DriverCtx pointer points to
80 * the driver-specific context struct. See the X/Mesa or OS/Mesa interface
83 * For more information about writing a device driver see the ddsample.c
84 * file and other device drivers (X/xmesa[1234].c, OSMesa/osmesa.c, etc)
88 * Look below in the dd_function_table struct definition for descriptions
89 * of each device driver function.
92 * In the future more function pointers may be added for glReadPixels
98 * RGBA = red/green/blue/alpha
99 * CI = color index (color mapped mode)
100 * mono = all pixels have the same color or index
102 * The write_ functions all take an array of mask flags which indicate
103 * whether or not the pixel should be written. One special case exists
104 * in the write_color_span function: if the mask array is NULL, then
105 * draw all pixels. This is an optimization used for glDrawPixels().
108 * X coordinates start at 0 at the left and increase to the right
109 * Y coordinates start at 0 at the bottom and increase upward
116 /* Used by the GetParameteri device driver function */
117 #define DD_HAVE_HARDWARE_FOG 3
121 /* Mask bits sent to the driver Clear() function */
122 #define DD_FRONT_LEFT_BIT FRONT_LEFT_BIT /* 1 */
123 #define DD_FRONT_RIGHT_BIT FRONT_RIGHT_BIT /* 2 */
124 #define DD_BACK_LEFT_BIT BACK_LEFT_BIT /* 4 */
125 #define DD_BACK_RIGHT_BIT BACK_RIGHT_BIT /* 8 */
126 #define DD_DEPTH_BIT GL_DEPTH_BUFFER_BIT /* 0x00000100 */
127 #define DD_STENCIL_BIT GL_STENCIL_BUFFER_BIT /* 0x00000400 */
128 #define DD_ACCUM_BIT GL_ACCUM_BUFFER_BIT /* 0x00000200 */
133 * Device Driver function table.
135 struct dd_function_table
{
137 /**********************************************************************
138 *** Mandatory functions: these functions must be implemented by ***
139 *** every device driver. ***
140 **********************************************************************/
142 const GLubyte
* (*GetString
)( GLcontext
*ctx
, GLenum name
);
143 /* Return a string as needed by glGetString().
144 * Only the GL_RENDERER token must be implemented. Otherwise,
145 * NULL can be returned.
148 void (*UpdateState
)( GLcontext
*ctx
);
150 * UpdateState() is called whenver Mesa thinks the device driver should
151 * update its state and/or the other pointers (such as PointsFunc,
152 * LineFunc, or TriangleFunc).
155 void (*ClearIndex
)( GLcontext
*ctx
, GLuint index
);
157 * Called whenever glClearIndex() is called. Set the index for clearing
158 * the color buffer when in color index mode.
161 void (*ClearColor
)( GLcontext
*ctx
, GLubyte red
, GLubyte green
,
162 GLubyte blue
, GLubyte alpha
);
164 * Called whenever glClearColor() is called. Set the color for clearing
165 * the color buffer when in RGBA mode.
168 GLbitfield (*Clear
)( GLcontext
*ctx
, GLbitfield mask
, GLboolean all
,
169 GLint x
, GLint y
, GLint width
, GLint height
);
170 /* Clear the color/depth/stencil/accum buffer(s).
171 * 'mask' is a bitmask of the DD_*_BIT values defined above that indicates
172 * which buffers need to be cleared. The driver should clear those
173 * buffers then return a new bitmask indicating which buffers should be
174 * cleared by software Mesa.
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 void (*Index
)( GLcontext
*ctx
, GLuint index
);
183 * Sets current color index for drawing flat-shaded primitives.
184 * This index should also be used in the "mono" drawing functions.
187 void (*Color
)( GLcontext
*ctx
,
188 GLubyte red
, GLubyte green
, GLubyte glue
, GLubyte alpha
);
190 * Sets current color for drawing flat-shaded primitives.
191 * This color should also be used in the "mono" drawing functions.
194 GLboolean (*SetDrawBuffer
)( GLcontext
*ctx
, GLenum buffer
);
196 * Specifies the current buffer for writing.
197 * The following values must be accepted when applicable:
198 * GL_FRONT_LEFT - this buffer always exists
199 * GL_BACK_LEFT - when double buffering
200 * GL_FRONT_RIGHT - when using stereo
201 * GL_BACK_RIGHT - when using stereo and double buffering
202 * The folowing values may optionally be accepted. Return GL_TRUE
203 * if accepted, GL_FALSE if not accepted. In practice, only drivers
204 * which can write to multiple color buffers at once should accept
206 * GL_FRONT - write to front left and front right if it exists
207 * GL_BACK - write to back left and back right if it exists
208 * GL_LEFT - write to front left and back left if it exists
209 * GL_RIGHT - write to right left and back right if they exist
210 * GL_FRONT_AND_BACK - write to all four buffers if they exist
211 * GL_NONE - disable buffer write in device driver.
214 void (*SetReadBuffer
)( GLcontext
*ctx
, GLframebuffer
*colorBuffer
,
217 * Specifies the current buffer for reading.
218 * colorBuffer will be one of:
219 * GL_FRONT_LEFT - this buffer always exists
220 * GL_BACK_LEFT - when double buffering
221 * GL_FRONT_RIGHT - when using stereo
222 * GL_BACK_RIGHT - when using stereo and double buffering
225 void (*GetBufferSize
)( GLcontext
*ctx
, GLuint
*width
, GLuint
*height
);
227 * Returns the width and height of the current color buffer.
232 *** Functions for writing pixels to the frame buffer:
235 void (*WriteRGBASpan
)( const GLcontext
*ctx
,
236 GLuint n
, GLint x
, GLint y
,
237 CONST GLubyte rgba
[][4], const GLubyte mask
[] );
238 void (*WriteRGBSpan
)( const GLcontext
*ctx
,
239 GLuint n
, GLint x
, GLint y
,
240 CONST GLubyte rgb
[][3], const GLubyte mask
[] );
241 /* Write a horizontal run of RGBA or RGB pixels.
242 * If mask is NULL, draw all pixels.
243 * If mask is not null, only draw pixel [i] when mask [i] is true.
246 void (*WriteMonoRGBASpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
247 const GLubyte mask
[] );
248 /* Write a horizontal run of RGBA pixels all with the color last
249 * specified by the Color function.
252 void (*WriteRGBAPixels
)( const GLcontext
*ctx
,
253 GLuint n
, const GLint x
[], const GLint y
[],
254 CONST GLubyte rgba
[][4], const GLubyte mask
[] );
255 /* Write array of RGBA pixels at random locations.
258 void (*WriteMonoRGBAPixels
)( const GLcontext
*ctx
,
259 GLuint n
, const GLint x
[], const GLint y
[],
260 const GLubyte mask
[] );
261 /* Write an array of mono-RGBA pixels at random locations.
264 void (*WriteCI32Span
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
265 const GLuint index
[], const GLubyte mask
[] );
266 void (*WriteCI8Span
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
267 const GLubyte index
[], const GLubyte mask
[] );
268 /* Write a horizontal run of CI pixels. One function is for 32bpp
269 * indexes and the other for 8bpp pixels (the common case). You mus
270 * implement both for color index mode.
273 void (*WriteMonoCISpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
274 const GLubyte mask
[] );
275 /* Write a horizontal run of color index pixels using the color index
276 * last specified by the Index() function.
279 void (*WriteCI32Pixels
)( const GLcontext
*ctx
,
280 GLuint n
, const GLint x
[], const GLint y
[],
281 const GLuint index
[], const GLubyte mask
[] );
283 * Write a random array of CI pixels.
286 void (*WriteMonoCIPixels
)( const GLcontext
*ctx
,
287 GLuint n
, const GLint x
[], const GLint y
[],
288 const GLubyte mask
[] );
289 /* Write a random array of color index pixels using the color index
290 * last specified by the Index() function.
295 *** Functions to read pixels from frame buffer:
298 void (*ReadCI32Span
)( const GLcontext
*ctx
,
299 GLuint n
, GLint x
, GLint y
, GLuint index
[] );
300 /* Read a horizontal run of color index pixels.
303 void (*ReadRGBASpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
305 /* Read a horizontal run of RGBA pixels.
308 void (*ReadCI32Pixels
)( const GLcontext
*ctx
,
309 GLuint n
, const GLint x
[], const GLint y
[],
310 GLuint indx
[], const GLubyte mask
[] );
311 /* Read a random array of CI pixels.
314 void (*ReadRGBAPixels
)( const GLcontext
*ctx
,
315 GLuint n
, const GLint x
[], const GLint y
[],
316 GLubyte rgba
[][4], const GLubyte mask
[] );
317 /* Read a random array of RGBA pixels.
321 /**********************************************************************
322 *** Optional functions: these functions may or may not be ***
323 *** implemented by the device driver. If the device driver ***
324 *** doesn't implement them it should never touch these pointers ***
325 *** since Mesa will either set them to NULL or point them at a ***
326 *** fall-back function. ***
327 **********************************************************************/
329 void (*Finish
)( GLcontext
*ctx
);
331 * This is called whenever glFinish() is called.
334 void (*Flush
)( GLcontext
*ctx
);
336 * This is called whenever glFlush() is called.
339 void (*Error
)( GLcontext
*ctx
);
341 * Called whenever an error is generated. ctx->ErrorValue contains
345 void (*NearFar
)( GLcontext
*ctx
, GLfloat nearVal
, GLfloat farVal
);
347 * Called from glFrustum and glOrtho to tell device driver the
348 * near and far clipping plane Z values. The 3Dfx driver, for example,
352 GLint (*GetParameteri
)( const GLcontext
*ctx
, GLint param
);
353 /* Query the device driver to get an integer parameter.
354 * Current parameters:
355 * DD_MAX_TEXTURE_SIZE return maximum texture size
357 * DD_MAX_TEXTURES number of texture sets/stages, usually 1
359 * DD_HAVE_HARDWARE_FOG the driver should return 1 (0 otherwise)
360 * when the hardware support per fragment
361 * fog for free (like the Voodoo Graphics)
362 * so the Mesa core will start to ever use
368 *** For supporting hardware Z buffers:
369 *** Either ALL or NONE of these functions must be implemented!
370 *** NOTE that Each depth value is a 32-bit GLuint. If the depth
371 *** buffer is less than 32 bits deep then the extra upperbits are zero.
374 void (*WriteDepthSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
375 const GLdepth depth
[], const GLubyte mask
[] );
376 /* Write a horizontal span of values into the depth buffer. Only write
377 * depth[i] value if mask[i] is nonzero.
380 void (*ReadDepthSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
382 /* Read a horizontal span of values from the depth buffer.
386 void (*WriteDepthPixels
)( GLcontext
*ctx
, GLuint n
,
387 const GLint x
[], const GLint y
[],
388 const GLdepth depth
[], const GLubyte mask
[] );
389 /* Write an array of randomly positioned depth values into the
390 * depth buffer. Only write depth[i] value if mask[i] is nonzero.
393 void (*ReadDepthPixels
)( GLcontext
*ctx
, GLuint n
,
394 const GLint x
[], const GLint y
[],
396 /* Read an array of randomly positioned depth values from the depth buffer.
402 *** For supporting hardware stencil buffers:
403 *** Either ALL or NONE of these functions must be implemented!
406 void (*WriteStencilSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
407 const GLstencil stencil
[], const GLubyte mask
[] );
408 /* Write a horizontal span of stencil values into the stencil buffer.
409 * If mask is NULL, write all stencil values.
410 * Else, only write stencil[i] if mask[i] is non-zero.
413 void (*ReadStencilSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
414 GLstencil stencil
[] );
415 /* Read a horizontal span of stencil values from the stencil buffer.
418 void (*WriteStencilPixels
)( GLcontext
*ctx
, GLuint n
,
419 const GLint x
[], const GLint y
[],
420 const GLstencil stencil
[],
421 const GLubyte mask
[] );
422 /* Write an array of stencil values into the stencil buffer.
423 * If mask is NULL, write all stencil values.
424 * Else, only write stencil[i] if mask[i] is non-zero.
427 void (*ReadStencilPixels
)( GLcontext
*ctx
, GLuint n
,
428 const GLint x
[], const GLint y
[],
429 GLstencil stencil
[] );
430 /* Read an array of stencil values from the stencil buffer.
435 *** glDraw/Read/CopyPixels and glBitmap functions:
438 GLboolean (*DrawPixels
)( GLcontext
*ctx
,
439 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
440 GLenum format
, GLenum type
,
441 const struct gl_pixelstore_attrib
*unpack
,
442 const GLvoid
*pixels
);
443 /* This is called by glDrawPixels.
444 * 'unpack' describes how to unpack the source image data.
445 * Return GL_TRUE if the driver succeeds, return GL_FALSE if core Mesa
449 GLboolean (*ReadPixels
)( GLcontext
*ctx
,
450 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
451 GLenum format
, GLenum type
,
452 const struct gl_pixelstore_attrib
*unpack
,
454 /* Called by glReadPixels.
455 * Return GL_TRUE if operation completed, else return GL_FALSE.
456 * This function must respect all glPixelTransfer settings.
459 GLboolean (*CopyPixels
)( GLcontext
*ctx
,
460 GLint srcx
, GLint srcy
,
461 GLsizei width
, GLsizei height
,
462 GLint dstx
, GLint dsty
, GLenum type
);
463 /* Do a glCopyPixels. Return GL_TRUE if operation completed, else
464 * return GL_FALSE. This function must respect all rasterization
465 * state, glPixelTransfer, glPixelZoom, etc.
468 GLboolean (*Bitmap
)( GLcontext
*ctx
,
469 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
470 const struct gl_pixelstore_attrib
*unpack
,
471 const GLubyte
*bitmap
);
472 /* This is called by glBitmap. Works the same as DrawPixels, above.
477 *** Texture mapping functions:
480 void (*TexImage
)( GLcontext
*ctx
, GLenum target
,
481 struct gl_texture_object
*tObj
, GLint level
,
482 GLint internalFormat
,
483 const struct gl_texture_image
*image
);
484 /* XXX this function is obsolete */
485 /* Called whenever a texture object's image is changed.
486 * texObject is the number of the texture object being changed.
487 * level indicates the mipmap level.
488 * internalFormat is the format in which the texture is to be stored.
489 * image is a pointer to a gl_texture_image struct which contains
490 * the actual image data.
493 void (*TexSubImage
)( GLcontext
*ctx
, GLenum target
,
494 struct gl_texture_object
*tObj
, GLint level
,
495 GLint xoffset
, GLint yoffset
,
496 GLsizei width
, GLsizei height
,
497 GLint internalFormat
,
498 const struct gl_texture_image
*image
);
499 /* XXX this function is obsolete */
500 /* Called from glTexSubImage() to define a sub-region of a texture.
504 GLboolean (*TexImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
505 GLenum format
, GLenum type
, const GLvoid
*pixels
,
506 const struct gl_pixelstore_attrib
*packing
,
507 struct gl_texture_object
*texObj
,
508 struct gl_texture_image
*texImage
,
509 GLboolean
*retainInternalCopy
);
510 GLboolean (*TexImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
511 GLenum format
, GLenum type
, const GLvoid
*pixels
,
512 const struct gl_pixelstore_attrib
*packing
,
513 struct gl_texture_object
*texObj
,
514 struct gl_texture_image
*texImage
,
515 GLboolean
*retainInternalCopy
);
516 GLboolean (*TexImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
517 GLenum format
, GLenum type
, const GLvoid
*pixels
,
518 const struct gl_pixelstore_attrib
*packing
,
519 struct gl_texture_object
*texObj
,
520 struct gl_texture_image
*texImage
,
521 GLboolean
*retainInternalCopy
);
522 /* Called by glTexImage1/2/3D.
523 * Will not be called if any glPixelTransfer operations are enabled.
525 * <target>, <level>, <format>, <type> and <pixels> are user specified.
526 * <packing> indicates the image packing of pixels.
527 * <texObj> is the target texture object.
528 * <texImage> is the target texture image. It will have the texture
529 * width, height, depth, border and internalFormat information.
530 * <retainInternalCopy> is returned by this function and indicates whether
531 * core Mesa should keep an internal copy of the texture image.
532 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
533 * should do the job. If GL_FALSE is returned, this function will be
534 * called a second time after the texture image has been unpacked into
535 * GLubytes. It may be easier for the driver to handle then.
538 GLboolean (*TexSubImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
539 GLint xoffset
, GLsizei width
,
540 GLenum format
, GLenum type
,
541 const GLvoid
*pixels
,
542 const struct gl_pixelstore_attrib
*packing
,
543 struct gl_texture_object
*texObj
,
544 struct gl_texture_image
*texImage
);
545 GLboolean (*TexSubImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
546 GLint xoffset
, GLint yoffset
,
547 GLsizei width
, GLsizei height
,
548 GLenum format
, GLenum type
,
549 const GLvoid
*pixels
,
550 const struct gl_pixelstore_attrib
*packing
,
551 struct gl_texture_object
*texObj
,
552 struct gl_texture_image
*texImage
);
553 GLboolean (*TexSubImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
554 GLint xoffset
, GLint yoffset
, GLint zoffset
,
555 GLsizei width
, GLsizei height
, GLint depth
,
556 GLenum format
, GLenum type
,
557 const GLvoid
*pixels
,
558 const struct gl_pixelstore_attrib
*packing
,
559 struct gl_texture_object
*texObj
,
560 struct gl_texture_image
*texImage
);
561 /* Called by glTexSubImage1/2/3D.
562 * Will not be called if any glPixelTransfer operations are enabled.
564 * <target>, <level>, <xoffset>, <yoffset>, <zoffset>, <width>, <height>,
565 * <depth>, <format>, <type> and <pixels> are user specified.
566 * <packing> indicates the image packing of pixels.
567 * <texObj> is the target texture object.
568 * <texImage> is the target texture image. It will have the texture
569 * width, height, border and internalFormat information.
570 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
571 * should do the job. If GL_FALSE is returned, then TexImage1/2/3D will
572 * be called with the complete texture image.
575 GLboolean (*CopyTexImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
576 GLenum internalFormat
, GLint x
, GLint y
,
577 GLsizei width
, GLint border
);
578 GLboolean (*CopyTexImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
579 GLenum internalFormat
, GLint x
, GLint y
,
580 GLsizei width
, GLsizei height
, GLint border
);
581 /* Called by glCopyTexImage1D and glCopyTexImage2D.
582 * Will not be called if any glPixelTransfer operations are enabled.
583 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
587 GLboolean (*CopyTexSubImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
589 GLint x
, GLint y
, GLsizei width
);
590 GLboolean (*CopyTexSubImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
591 GLint xoffset
, GLint yoffset
,
593 GLsizei width
, GLsizei height
);
594 GLboolean (*CopyTexSubImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
595 GLint xoffset
, GLint yoffset
, GLint zoffset
,
597 GLsizei width
, GLsizei height
);
598 /* Called by glCopyTexSubImage1/2/3D.
599 * Will not be called if any glPixelTransfer operations are enabled.
600 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
604 GLvoid
*(*GetTexImage
)( GLcontext
*ctx
, GLenum target
, GLint level
,
605 const struct gl_texture_object
*texObj
,
606 GLenum
*formatOut
, GLenum
*typeOut
,
607 GLboolean
*freeImageOut
);
608 /* Called by glGetTexImage or by core Mesa when a texture image
609 * is needed for software fallback rendering.
610 * Return the address of the texture image or NULL if failure.
611 * The image must be tightly packed (i.e. row stride = image width)
612 * Return the image's format and type in formatOut and typeOut.
613 * The format and type must be values which are accepted by glTexImage.
614 * Set the freeImageOut flag if the returned image should be deallocated
615 * with FREE() when finished.
616 * The size of the image can be deduced from the target and level.
617 * Core Mesa will perform any image format/type conversions that are needed.
620 GLboolean (*TestProxyTexImage
)(GLcontext
*ctx
, GLenum target
,
621 GLint level
, GLint internalFormat
,
622 GLenum format
, GLenum type
,
623 GLint width
, GLint height
,
624 GLint depth
, GLint border
);
625 /* Called by glTexImage[123]D when user specifies a proxy texture
626 * target. Return GL_TRUE if the proxy test passes, return GL_FALSE
630 GLboolean (*CompressedTexImage1D
)( GLcontext
*ctx
, GLenum target
,
631 GLint level
, GLsizei imageSize
,
633 struct gl_texture_object
*texObj
,
634 struct gl_texture_image
*texImage
,
635 GLboolean
*retainInternalCopy
);
636 GLboolean (*CompressedTexImage2D
)( GLcontext
*ctx
, GLenum target
,
637 GLint level
, GLsizei imageSize
,
639 struct gl_texture_object
*texObj
,
640 struct gl_texture_image
*texImage
,
641 GLboolean
*retainInternalCopy
);
642 GLboolean (*CompressedTexImage3D
)( GLcontext
*ctx
, GLenum target
,
643 GLint level
, GLsizei imageSize
,
645 struct gl_texture_object
*texObj
,
646 struct gl_texture_image
*texImage
,
647 GLboolean
*retainInternalCopy
);
648 /* Called by glCompressedTexImage1/2/3D.
650 * <target>, <level>, <internalFormat>, <data> are user specified.
651 * <texObj> is the target texture object.
652 * <texImage> is the target texture image. It will have the texture
653 * width, height, depth, border and internalFormat information.
654 * <retainInternalCopy> is returned by this function and indicates whether
655 * core Mesa should keep an internal copy of the texture image.
656 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
660 GLboolean (*CompressedTexSubImage1D
)( GLcontext
*ctx
, GLenum target
,
661 GLint level
, GLint xoffset
,
662 GLsizei width
, GLenum format
,
663 GLsizei imageSize
, const GLvoid
*data
,
664 struct gl_texture_object
*texObj
,
665 struct gl_texture_image
*texImage
);
666 GLboolean (*CompressedTexSubImage2D
)( GLcontext
*ctx
, GLenum target
,
667 GLint level
, GLint xoffset
,
668 GLint yoffset
, GLsizei width
,
669 GLint height
, GLenum format
,
670 GLsizei imageSize
, const GLvoid
*data
,
671 struct gl_texture_object
*texObj
,
672 struct gl_texture_image
*texImage
);
673 GLboolean (*CompressedTexSubImage3D
)( GLcontext
*ctx
, GLenum target
,
674 GLint level
, GLint xoffset
,
675 GLint yoffset
, GLint zoffset
,
676 GLsizei width
, GLint height
,
677 GLint depth
, GLenum format
,
678 GLsizei imageSize
, const GLvoid
*data
,
679 struct gl_texture_object
*texObj
,
680 struct gl_texture_image
*texImage
);
681 /* Called by glCompressedTexSubImage1/2/3D.
683 * <target>, <level>, <x/z/zoffset>, <width>, <height>, <depth>,
684 * <imageSize>, and <data> are user specified.
685 * <texObj> is the target texture object.
686 * <texImage> is the target texture image. It will have the texture
687 * width, height, depth, border and internalFormat information.
688 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
692 GLint (*BaseCompressedTexFormat
)(GLcontext
*ctx
,
693 GLint internalFormat
);
694 /* Called to compute the base format for a specific compressed
695 * format. Return -1 if the internalFormat is not a specific
696 * compressed format that the driver recognizes. Note the
697 * return value differences between this function and
698 * SpecificCompressedTexFormat below.
701 GLint (*SpecificCompressedTexFormat
)(GLcontext
*ctx
,
702 GLint internalFormat
,
703 GLint numDimensions
);
704 /* Called to turn a generic texture format into a specific
705 * texture format. For example, if a driver implements
706 * GL_3DFX_texture_compression_FXT1, this would map
707 * GL_COMPRESSED_RGBA_ARB to GL_COMPRESSED_RGBA_FXT1_3DFX.
709 * If the driver does not know how to handle the compressed
710 * format, then just return the generic format, and Mesa will
711 * do the right thing with it.
714 GLboolean (*IsCompressedFormat
)(GLcontext
*ctx
, GLint internalFormat
);
715 /* Called to tell if a format is a compressed format.
718 GLsizei (*CompressedImageSize
)(GLcontext
*ctx
,
719 GLenum internalFormat
,
720 GLuint numDimensions
,
724 /* Calculate the size of a compressed image, given the image's
725 * format and dimensions.
728 void (*GetCompressedTexImage
)( GLcontext
*ctx
, GLenum target
,
729 GLint lod
, void *image
,
730 const struct gl_texture_object
*texObj
,
731 struct gl_texture_image
*texImage
);
732 /* Called by glGetCompressedTexImageARB.
733 * <target>, <lod>, <image> are specified by user.
734 * <texObj> is the source texture object.
735 * <texImage> is the source texture image.
738 void (*TexEnv
)( GLcontext
*ctx
, GLenum target
, GLenum pname
,
739 const GLfloat
*param
);
740 /* Called by glTexEnv*().
743 void (*TexParameter
)( GLcontext
*ctx
, GLenum target
,
744 struct gl_texture_object
*texObj
,
745 GLenum pname
, const GLfloat
*params
);
746 /* Called by glTexParameter*().
747 * <target> is user specified
748 * <texObj> the texture object to modify
749 * <pname> is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER,
750 * GL_TEXTURE_WRAP_[STR], or GL_TEXTURE_BORDER_COLOR.
751 * <params> is user specified.
754 void (*BindTexture
)( GLcontext
*ctx
, GLenum target
,
755 struct gl_texture_object
*tObj
);
756 /* Called by glBindTexture().
759 void (*DeleteTexture
)( GLcontext
*ctx
, struct gl_texture_object
*tObj
);
760 /* Called when a texture object is about to be deallocated. Driver
761 * should free anything attached to the DriverData pointers.
764 GLboolean (*IsTextureResident
)( GLcontext
*ctx
,
765 struct gl_texture_object
*t
);
766 /* Called by glAreTextureResident().
769 void (*PrioritizeTexture
)( GLcontext
*ctx
, struct gl_texture_object
*t
,
771 /* Called by glPrioritizeTextures().
774 void (*ActiveTexture
)( GLcontext
*ctx
, GLuint texUnitNumber
);
775 /* Called by glActiveTextureARB to set current texture unit.
778 void (*UpdateTexturePalette
)( GLcontext
*ctx
,
779 struct gl_texture_object
*tObj
);
780 /* Called when the texture's color lookup table is changed.
781 * If tObj is NULL then the shared texture palette ctx->Texture.Palette
788 *** Accelerated point, line, polygon, quad and rect functions:
791 points_func PointsFunc
;
793 triangle_func TriangleFunc
;
799 *** Transformation/Rendering functions
802 void (*RenderStart
)( GLcontext
*ctx
);
803 void (*RenderFinish
)( GLcontext
*ctx
);
804 /* KW: These replace Begin and End, and have more relaxed semantics.
805 * They are called prior-to and after one or more vb flush, and are
806 * thus decoupled from the gl_begin/gl_end pairs, which are possibly
807 * more frequent. If a begin/end pair covers >1 vertex buffer, these
808 * are called at most once for the pair. (a bit broken at present)
811 void (*RasterSetup
)( struct vertex_buffer
*VB
, GLuint start
, GLuint end
);
812 /* This function, if not NULL, is called whenever new window coordinates
813 * are put in the vertex buffer. The vertices in question are those n
814 * such that start <= n < end.
815 * The device driver can convert the window coords to its own specialized
816 * format. The 3Dfx driver uses this.
818 * Note: Deprecated in favour of RegisterPipelineStages, below.
821 render_func
*RenderVBClippedTab
;
822 render_func
*RenderVBCulledTab
;
823 render_func
*RenderVBRawTab
;
824 /* These function tables allow the device driver to rasterize an
825 * entire begin/end group of primitives at once. See the
826 * gl_render_vb() function in vbrender.c for more details.
829 void (*ReducedPrimitiveChange
)( GLcontext
*ctx
, GLenum primitive
);
830 /* If registered, this will be called when rendering transitions between
831 * points, lines and triangles. It is not called on transitions between
832 * primtives such as GL_TRIANGLES and GL_TRIANGLE_STRIPS, or between
833 * triangles and quads or triangles and polygons.
837 /* Holds a list of the reasons why we might normally want to call
838 * render_triangle, but which are in fact implemented by the
839 * driver. The FX driver sets this to DD_TRI_CULL, and will soon
840 * implement DD_TRI_OFFSET.
843 GLboolean (*MultipassFunc
)( struct vertex_buffer
*VB
, GLuint passno
);
844 /* Driver may request additional render passes by returning GL_TRUE
845 * when this function is called. This function will be called
846 * after the first pass, and passes will be made until the function
847 * returns GL_FALSE. If no function is registered, only one pass
850 * This function will be first invoked with passno == 1.
857 void (*RegisterVB
)( struct vertex_buffer
*VB
);
858 void (*UnregisterVB
)( struct vertex_buffer
*VB
);
859 /* When Mesa creates a new vertex buffer it calls Driver.RegisterVB()
860 * so the device driver can allocate its own vertex buffer data and
861 * hook it to the VB->driver_data pointer.
862 * When Mesa destroys a vertex buffer it calls Driver.UnegisterVB()
863 * so the driver can deallocate its own data attached to VB->driver_data.
867 void (*ResetVB
)( struct vertex_buffer
*VB
);
868 void (*ResetCvaVB
)( struct vertex_buffer
*VB
, GLuint stages
);
869 /* Do any reset operations necessary to the driver data associated
870 * with these vertex buffers.
873 GLuint RenderVectorFlags
;
874 /* What do the render tables require of the vectors they deal
878 GLuint (*RegisterPipelineStages
)( struct gl_pipeline_stage
*out
,
879 const struct gl_pipeline_stage
*in
,
881 /* Register new pipeline stages, or modify existing ones. See also
882 * the OptimizePipeline() functions.
886 GLboolean (*BuildPrecalcPipeline
)( GLcontext
*ctx
);
887 GLboolean (*BuildEltPipeline
)( GLcontext
*ctx
);
888 /* Perform the full pipeline build, or return false.
892 void (*OptimizePrecalcPipeline
)( GLcontext
*ctx
, struct gl_pipeline
*pipe
);
893 void (*OptimizeImmediatePipeline
)( GLcontext
*ctx
, struct gl_pipeline
*pipe
);
894 /* Check to see if a fast path exists for this combination of stages
895 * in the precalc and immediate (elt) pipelines.
900 * State-changing functions (drawing functions are above)
902 * These functions are called by their corresponding OpenGL API functions.
903 * They're ALSO called by the gl_PopAttrib() function!!!
904 * May add more functions like these to the device driver in the future.
905 * This should reduce the amount of state checking that
906 * the driver's UpdateState() function must do.
908 void (*AlphaFunc
)(GLcontext
*ctx
, GLenum func
, GLclampf ref
);
909 void (*BlendEquation
)(GLcontext
*ctx
, GLenum mode
);
910 void (*BlendFunc
)(GLcontext
*ctx
, GLenum sfactor
, GLenum dfactor
);
911 void (*BlendFuncSeparate
)( GLcontext
*ctx
, GLenum sfactorRGB
,
912 GLenum dfactorRGB
, GLenum sfactorA
,
914 void (*ClearDepth
)(GLcontext
*ctx
, GLclampd d
);
915 void (*ColorMask
)(GLcontext
*ctx
, GLboolean rmask
, GLboolean gmask
,
916 GLboolean bmask
, GLboolean amask
);
917 void (*CullFace
)(GLcontext
*ctx
, GLenum mode
);
918 void (*FrontFace
)(GLcontext
*ctx
, GLenum mode
);
919 void (*DepthFunc
)(GLcontext
*ctx
, GLenum func
);
920 void (*DepthMask
)(GLcontext
*ctx
, GLboolean flag
);
921 void (*DepthRange
)(GLcontext
*ctx
, GLclampd nearval
, GLclampd farval
);
922 void (*Enable
)(GLcontext
* ctx
, GLenum cap
, GLboolean state
);
923 void (*Fogfv
)(GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
);
924 void (*Hint
)(GLcontext
*ctx
, GLenum target
, GLenum mode
);
925 void (*IndexMask
)(GLcontext
*ctx
, GLuint mask
);
926 void (*Lightfv
)(GLcontext
*ctx
, GLenum light
,
927 GLenum pname
, const GLfloat
*params
, GLint nparams
);
928 void (*LightModelfv
)(GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
);
929 void (*LineStipple
)(GLcontext
*ctx
, GLint factor
, GLushort pattern
);
930 void (*LineWidth
)(GLcontext
*ctx
, GLfloat width
);
931 void (*LogicOpcode
)(GLcontext
*ctx
, GLenum opcode
);
932 void (*PolygonMode
)(GLcontext
*ctx
, GLenum face
, GLenum mode
);
933 void (*PolygonStipple
)(GLcontext
*ctx
, const GLubyte
*mask
);
934 void (*Scissor
)(GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
);
935 void (*ShadeModel
)(GLcontext
*ctx
, GLenum mode
);
936 void (*ClearStencil
)(GLcontext
*ctx
, GLint s
);
937 void (*StencilFunc
)(GLcontext
*ctx
, GLenum func
, GLint ref
, GLuint mask
);
938 void (*StencilMask
)(GLcontext
*ctx
, GLuint mask
);
939 void (*StencilOp
)(GLcontext
*ctx
, GLenum fail
, GLenum zfail
, GLenum zpass
);
940 void (*Viewport
)(GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
);
942 /* State-query functions
944 * Return GL_TRUE if query was completed, GL_FALSE otherwise.
946 GLboolean (*GetBooleanv
)(GLcontext
*ctx
, GLenum pname
, GLboolean
*result
);
947 GLboolean (*GetDoublev
)(GLcontext
*ctx
, GLenum pname
, GLdouble
*result
);
948 GLboolean (*GetFloatv
)(GLcontext
*ctx
, GLenum pname
, GLfloat
*result
);
949 GLboolean (*GetIntegerv
)(GLcontext
*ctx
, GLenum pname
, GLint
*result
);
950 GLboolean (*GetPointerv
)(GLcontext
*ctx
, GLenum pname
, GLvoid
**result
);