1 /* $Id: dd.h,v 1.36 2000/10/30 13:32:00 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 types.h !!!!! */
35 struct gl_pixelstore_attrib
;
39 struct gl_pipeline_stage
;
44 * Device Driver (DD) interface
47 * All device driver functions are accessed through pointers in the
48 * dd_function_table struct (defined below) which is stored in the GLcontext
49 * struct. Since the device driver is strictly accessed trough a table of
50 * function pointers we can:
51 * 1. switch between a number of different device drivers at runtime.
52 * 2. use optimized functions dependant on current rendering state or
53 * frame buffer configuration.
55 * The function pointers in the dd_function_table struct are divided into
56 * two groups: mandatory and optional.
57 * Mandatory functions have to be implemented by every device driver.
58 * Optional functions may or may not be implemented by the device driver.
59 * The optional functions provide ways to take advantage of special hardware
60 * or optimized algorithms.
62 * The function pointers in the dd_function_table struct should first be
63 * initialized in the driver's "MakeCurrent" function. The "MakeCurrent"
64 * function is a little different in each device driver. See the X/Mesa,
65 * GLX, or OS/Mesa drivers for examples.
67 * Later, Mesa may call the dd_function_table's UpdateState() function.
68 * This function should initialize the dd_function_table's pointers again.
69 * The UpdateState() function is called whenever the core (GL) rendering
70 * state is changed in a way which may effect rasterization. For example,
71 * the TriangleFunc() pointer may have to point to different functions
72 * depending on whether smooth or flat shading is enabled.
74 * Note that the first argument to every device driver function is a
75 * GLcontext *. In turn, the GLcontext->DriverCtx pointer points to
76 * the driver-specific context struct. See the X/Mesa or OS/Mesa interface
79 * For more information about writing a device driver see the ddsample.c
80 * file and other device drivers (X/xmesa[1234].c, OSMesa/osmesa.c, etc)
84 * Look below in the dd_function_table struct definition for descriptions
85 * of each device driver function.
88 * In the future more function pointers may be added for glReadPixels
94 * RGBA = red/green/blue/alpha
95 * CI = color index (color mapped mode)
96 * mono = all pixels have the same color or index
98 * The write_ functions all take an array of mask flags which indicate
99 * whether or not the pixel should be written. One special case exists
100 * in the write_color_span function: if the mask array is NULL, then
101 * draw all pixels. This is an optimization used for glDrawPixels().
104 * X coordinates start at 0 at the left and increase to the right
105 * Y coordinates start at 0 at the bottom and increase upward
112 /* Used by the GetParameteri device driver function */
113 #define DD_HAVE_HARDWARE_FOG 3
117 /* Mask bits sent to the driver Clear() function */
118 #define DD_FRONT_LEFT_BIT FRONT_LEFT_BIT /* 1 */
119 #define DD_FRONT_RIGHT_BIT FRONT_RIGHT_BIT /* 2 */
120 #define DD_BACK_LEFT_BIT BACK_LEFT_BIT /* 4 */
121 #define DD_BACK_RIGHT_BIT BACK_RIGHT_BIT /* 8 */
122 #define DD_DEPTH_BIT GL_DEPTH_BUFFER_BIT /* 0x00000100 */
123 #define DD_STENCIL_BIT GL_STENCIL_BUFFER_BIT /* 0x00000400 */
124 #define DD_ACCUM_BIT GL_ACCUM_BUFFER_BIT /* 0x00000200 */
129 * Device Driver function table.
131 struct dd_function_table
{
133 /**********************************************************************
134 *** Mandatory functions: these functions must be implemented by ***
135 *** every device driver. ***
136 **********************************************************************/
138 const GLubyte
* (*GetString
)( GLcontext
*ctx
, GLenum name
);
139 /* Return a string as needed by glGetString().
140 * Only the GL_RENDERER token must be implemented. Otherwise,
141 * NULL can be returned.
144 GLuint UpdateStateNotify
;
146 * Tell mesa exactly when to call UpdateState. This is a bitwise
147 * or of the _NEW_* flags defined in types.h.
150 void (*UpdateState
)( GLcontext
*ctx
);
152 * UpdateState() is called whenver Mesa thinks the device driver should
153 * update its state and/or the other pointers (such as PointsFunc,
154 * LineFunc, or TriangleFunc).
157 void (*ClearIndex
)( GLcontext
*ctx
, GLuint index
);
159 * Called whenever glClearIndex() is called. Set the index for clearing
160 * the color buffer when in color index mode.
163 void (*ClearColor
)( GLcontext
*ctx
, GLchan red
, GLchan green
,
164 GLchan blue
, GLchan alpha
);
166 * Called whenever glClearColor() is called. Set the color for clearing
167 * the color buffer when in RGBA mode.
170 GLbitfield (*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. The driver should clear those
175 * buffers then return a new bitmask indicating which buffers should be
176 * cleared by software Mesa.
177 * If 'all' is true then the clear the whole buffer, else clear only the
178 * region defined by (x,y,width,height).
179 * This function must obey the glColorMask, glIndexMask and glStencilMask
180 * settings! Software Mesa can do masked clears if the device driver can't.
183 void (*Index
)( GLcontext
*ctx
, GLuint index
);
185 * Sets current color index for drawing flat-shaded primitives.
186 * This index should also be used in the "mono" drawing functions.
189 void (*Color
)( GLcontext
*ctx
,
190 GLchan red
, GLchan green
, GLchan glue
, GLchan alpha
);
192 * Sets current color for drawing flat-shaded primitives.
193 * This color should also be used in the "mono" drawing functions.
196 GLboolean (*SetDrawBuffer
)( GLcontext
*ctx
, GLenum buffer
);
198 * Specifies the current buffer for writing.
199 * The following values must be accepted when applicable:
200 * GL_FRONT_LEFT - this buffer always exists
201 * GL_BACK_LEFT - when double buffering
202 * GL_FRONT_RIGHT - when using stereo
203 * GL_BACK_RIGHT - when using stereo and double buffering
204 * The folowing values may optionally be accepted. Return GL_TRUE
205 * if accepted, GL_FALSE if not accepted. In practice, only drivers
206 * which can write to multiple color buffers at once should accept
208 * GL_FRONT - write to front left and front right if it exists
209 * GL_BACK - write to back left and back right if it exists
210 * GL_LEFT - write to front left and back left if it exists
211 * GL_RIGHT - write to right left and back right if they exist
212 * GL_FRONT_AND_BACK - write to all four buffers if they exist
213 * GL_NONE - disable buffer write in device driver.
216 void (*SetReadBuffer
)( GLcontext
*ctx
, GLframebuffer
*colorBuffer
,
219 * Specifies the current buffer for reading.
220 * colorBuffer will be one of:
221 * GL_FRONT_LEFT - this buffer always exists
222 * GL_BACK_LEFT - when double buffering
223 * GL_FRONT_RIGHT - when using stereo
224 * GL_BACK_RIGHT - when using stereo and double buffering
227 void (*GetBufferSize
)( GLcontext
*ctx
, GLuint
*width
, GLuint
*height
);
229 * Returns the width and height of the current color buffer.
234 *** Functions for writing pixels to the frame buffer:
237 void (*WriteRGBASpan
)( const GLcontext
*ctx
,
238 GLuint n
, GLint x
, GLint y
,
239 CONST GLchan rgba
[][4], const GLubyte mask
[] );
240 void (*WriteRGBSpan
)( const GLcontext
*ctx
,
241 GLuint n
, GLint x
, GLint y
,
242 CONST GLchan rgb
[][3], const GLubyte mask
[] );
243 /* Write a horizontal run of RGBA or RGB pixels.
244 * If mask is NULL, draw all pixels.
245 * If mask is not null, only draw pixel [i] when mask [i] is true.
248 void (*WriteMonoRGBASpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
249 const GLubyte mask
[] );
250 /* Write a horizontal run of RGBA pixels all with the color last
251 * specified by the Color function.
254 void (*WriteRGBAPixels
)( const GLcontext
*ctx
,
255 GLuint n
, const GLint x
[], const GLint y
[],
256 CONST GLchan rgba
[][4], const GLubyte mask
[] );
257 /* Write array of RGBA pixels at random locations.
260 void (*WriteMonoRGBAPixels
)( const GLcontext
*ctx
,
261 GLuint n
, const GLint x
[], const GLint y
[],
262 const GLubyte mask
[] );
263 /* Write an array of mono-RGBA pixels at random locations.
266 void (*WriteCI32Span
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
267 const GLuint index
[], const GLubyte mask
[] );
268 void (*WriteCI8Span
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
269 const GLubyte index
[], const GLubyte mask
[] );
270 /* Write a horizontal run of CI pixels. One function is for 32bpp
271 * indexes and the other for 8bpp pixels (the common case). You mus
272 * implement both for color index mode.
275 void (*WriteMonoCISpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
276 const GLubyte mask
[] );
277 /* Write a horizontal run of color index pixels using the color index
278 * last specified by the Index() function.
281 void (*WriteCI32Pixels
)( const GLcontext
*ctx
,
282 GLuint n
, const GLint x
[], const GLint y
[],
283 const GLuint index
[], const GLubyte mask
[] );
285 * Write a random array of CI pixels.
288 void (*WriteMonoCIPixels
)( const GLcontext
*ctx
,
289 GLuint n
, const GLint x
[], const GLint y
[],
290 const GLubyte mask
[] );
291 /* Write a random array of color index pixels using the color index
292 * last specified by the Index() function.
297 *** Functions to read pixels from frame buffer:
300 void (*ReadCI32Span
)( const GLcontext
*ctx
,
301 GLuint n
, GLint x
, GLint y
, GLuint index
[] );
302 /* Read a horizontal run of color index pixels.
305 void (*ReadRGBASpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
307 /* Read a horizontal run of RGBA pixels.
310 void (*ReadCI32Pixels
)( const GLcontext
*ctx
,
311 GLuint n
, const GLint x
[], const GLint y
[],
312 GLuint indx
[], const GLubyte mask
[] );
313 /* Read a random array of CI pixels.
316 void (*ReadRGBAPixels
)( const GLcontext
*ctx
,
317 GLuint n
, const GLint x
[], const GLint y
[],
318 GLchan rgba
[][4], const GLubyte mask
[] );
319 /* Read a random array of RGBA pixels.
323 /**********************************************************************
324 *** Optional functions: these functions may or may not be ***
325 *** implemented by the device driver. If the device driver ***
326 *** doesn't implement them it should never touch these pointers ***
327 *** since Mesa will either set them to NULL or point them at a ***
328 *** fall-back function. ***
329 **********************************************************************/
331 void (*Finish
)( GLcontext
*ctx
);
333 * This is called whenever glFinish() is called.
336 void (*Flush
)( GLcontext
*ctx
);
338 * This is called whenever glFlush() is called.
341 void (*Error
)( GLcontext
*ctx
);
343 * Called whenever an error is generated. ctx->ErrorValue contains
347 void (*NearFar
)( GLcontext
*ctx
, GLfloat nearVal
, GLfloat farVal
);
349 * Called from glFrustum and glOrtho to tell device driver the
350 * near and far clipping plane Z values. The 3Dfx driver, for example,
354 GLint (*GetParameteri
)( const GLcontext
*ctx
, GLint param
);
355 /* Query the device driver to get an integer parameter.
356 * Current parameters:
357 * DD_MAX_TEXTURE_SIZE return maximum texture size
359 * DD_MAX_TEXTURES number of texture sets/stages, usually 1
361 * DD_HAVE_HARDWARE_FOG the driver should return 1 (0 otherwise)
362 * when the hardware support per fragment
363 * fog for free (like the Voodoo Graphics)
364 * so the Mesa core will start to ever use
370 *** For supporting hardware Z buffers:
371 *** Either ALL or NONE of these functions must be implemented!
372 *** NOTE that Each depth value is a 32-bit GLuint. If the depth
373 *** buffer is less than 32 bits deep then the extra upperbits are zero.
376 void (*WriteDepthSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
377 const GLdepth depth
[], const GLubyte mask
[] );
378 /* Write a horizontal span of values into the depth buffer. Only write
379 * depth[i] value if mask[i] is nonzero.
382 void (*ReadDepthSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
384 /* Read a horizontal span of values from the depth buffer.
388 void (*WriteDepthPixels
)( GLcontext
*ctx
, GLuint n
,
389 const GLint x
[], const GLint y
[],
390 const GLdepth depth
[], const GLubyte mask
[] );
391 /* Write an array of randomly positioned depth values into the
392 * depth buffer. Only write depth[i] value if mask[i] is nonzero.
395 void (*ReadDepthPixels
)( GLcontext
*ctx
, GLuint n
,
396 const GLint x
[], const GLint y
[],
398 /* Read an array of randomly positioned depth values from the depth buffer.
404 *** For supporting hardware stencil buffers:
405 *** Either ALL or NONE of these functions must be implemented!
408 void (*WriteStencilSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
409 const GLstencil stencil
[], const GLubyte mask
[] );
410 /* Write a horizontal span of stencil values into the stencil buffer.
411 * If mask is NULL, write all stencil values.
412 * Else, only write stencil[i] if mask[i] is non-zero.
415 void (*ReadStencilSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
416 GLstencil stencil
[] );
417 /* Read a horizontal span of stencil values from the stencil buffer.
420 void (*WriteStencilPixels
)( GLcontext
*ctx
, GLuint n
,
421 const GLint x
[], const GLint y
[],
422 const GLstencil stencil
[],
423 const GLubyte mask
[] );
424 /* Write an array of stencil values into the stencil buffer.
425 * If mask is NULL, write all stencil values.
426 * Else, only write stencil[i] if mask[i] is non-zero.
429 void (*ReadStencilPixels
)( GLcontext
*ctx
, GLuint n
,
430 const GLint x
[], const GLint y
[],
431 GLstencil stencil
[] );
432 /* Read an array of stencil values from the stencil buffer.
437 *** glDraw/Read/CopyPixels and glBitmap functions:
440 GLboolean (*DrawPixels
)( GLcontext
*ctx
,
441 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
442 GLenum format
, GLenum type
,
443 const struct gl_pixelstore_attrib
*unpack
,
444 const GLvoid
*pixels
);
445 /* This is called by glDrawPixels.
446 * 'unpack' describes how to unpack the source image data.
447 * Return GL_TRUE if the driver succeeds, return GL_FALSE if core Mesa
451 GLboolean (*ReadPixels
)( GLcontext
*ctx
,
452 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
453 GLenum format
, GLenum type
,
454 const struct gl_pixelstore_attrib
*unpack
,
456 /* Called by glReadPixels.
457 * Return GL_TRUE if operation completed, else return GL_FALSE.
458 * This function must respect all glPixelTransfer settings.
461 GLboolean (*CopyPixels
)( GLcontext
*ctx
,
462 GLint srcx
, GLint srcy
,
463 GLsizei width
, GLsizei height
,
464 GLint dstx
, GLint dsty
, GLenum type
);
465 /* Do a glCopyPixels. Return GL_TRUE if operation completed, else
466 * return GL_FALSE. This function must respect all rasterization
467 * state, glPixelTransfer, glPixelZoom, etc.
470 GLboolean (*Bitmap
)( GLcontext
*ctx
,
471 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
472 const struct gl_pixelstore_attrib
*unpack
,
473 const GLubyte
*bitmap
);
474 /* This is called by glBitmap. Works the same as DrawPixels, above.
479 *** Texture mapping functions:
482 void (*TexImage
)( GLcontext
*ctx
, GLenum target
,
483 struct gl_texture_object
*tObj
, GLint level
,
484 GLint internalFormat
,
485 const struct gl_texture_image
*image
);
486 /* XXX this function is obsolete */
487 /* Called whenever a texture object's image is changed.
488 * texObject is the number of the texture object being changed.
489 * level indicates the mipmap level.
490 * internalFormat is the format in which the texture is to be stored.
491 * image is a pointer to a gl_texture_image struct which contains
492 * the actual image data.
495 void (*TexSubImage
)( GLcontext
*ctx
, GLenum target
,
496 struct gl_texture_object
*tObj
, GLint level
,
497 GLint xoffset
, GLint yoffset
,
498 GLsizei width
, GLsizei height
,
499 GLint internalFormat
,
500 const struct gl_texture_image
*image
);
501 /* XXX this function is obsolete */
502 /* Called from glTexSubImage() to define a sub-region of a texture.
506 GLboolean (*TexImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
507 GLenum format
, GLenum type
, const GLvoid
*pixels
,
508 const struct gl_pixelstore_attrib
*packing
,
509 struct gl_texture_object
*texObj
,
510 struct gl_texture_image
*texImage
,
511 GLboolean
*retainInternalCopy
);
512 GLboolean (*TexImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
513 GLenum format
, GLenum type
, const GLvoid
*pixels
,
514 const struct gl_pixelstore_attrib
*packing
,
515 struct gl_texture_object
*texObj
,
516 struct gl_texture_image
*texImage
,
517 GLboolean
*retainInternalCopy
);
518 GLboolean (*TexImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
519 GLenum format
, GLenum type
, const GLvoid
*pixels
,
520 const struct gl_pixelstore_attrib
*packing
,
521 struct gl_texture_object
*texObj
,
522 struct gl_texture_image
*texImage
,
523 GLboolean
*retainInternalCopy
);
524 /* Called by glTexImage1/2/3D.
525 * Will not be called if any glPixelTransfer operations are enabled.
527 * <target>, <level>, <format>, <type> and <pixels> are user specified.
528 * <packing> indicates the image packing of pixels.
529 * <texObj> is the target texture object.
530 * <texImage> is the target texture image. It will have the texture
531 * width, height, depth, border and internalFormat information.
532 * <retainInternalCopy> is returned by this function and indicates whether
533 * core Mesa should keep an internal copy of the texture image.
534 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
535 * should do the job. If GL_FALSE is returned, this function will be
536 * called a second time after the texture image has been unpacked into
537 * GLubytes. It may be easier for the driver to handle then.
540 GLboolean (*TexSubImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
541 GLint xoffset
, GLsizei width
,
542 GLenum format
, GLenum type
,
543 const GLvoid
*pixels
,
544 const struct gl_pixelstore_attrib
*packing
,
545 struct gl_texture_object
*texObj
,
546 struct gl_texture_image
*texImage
);
547 GLboolean (*TexSubImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
548 GLint xoffset
, GLint yoffset
,
549 GLsizei width
, GLsizei height
,
550 GLenum format
, GLenum type
,
551 const GLvoid
*pixels
,
552 const struct gl_pixelstore_attrib
*packing
,
553 struct gl_texture_object
*texObj
,
554 struct gl_texture_image
*texImage
);
555 GLboolean (*TexSubImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
556 GLint xoffset
, GLint yoffset
, GLint zoffset
,
557 GLsizei width
, GLsizei height
, GLint depth
,
558 GLenum format
, GLenum type
,
559 const GLvoid
*pixels
,
560 const struct gl_pixelstore_attrib
*packing
,
561 struct gl_texture_object
*texObj
,
562 struct gl_texture_image
*texImage
);
563 /* Called by glTexSubImage1/2/3D.
564 * Will not be called if any glPixelTransfer operations are enabled.
566 * <target>, <level>, <xoffset>, <yoffset>, <zoffset>, <width>, <height>,
567 * <depth>, <format>, <type> and <pixels> are user specified.
568 * <packing> indicates the image packing of pixels.
569 * <texObj> is the target texture object.
570 * <texImage> is the target texture image. It will have the texture
571 * width, height, border and internalFormat information.
572 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
573 * should do the job. If GL_FALSE is returned, then TexImage1/2/3D will
574 * be called with the complete texture image.
577 GLboolean (*CopyTexImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
578 GLenum internalFormat
, GLint x
, GLint y
,
579 GLsizei width
, GLint border
);
580 GLboolean (*CopyTexImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
581 GLenum internalFormat
, GLint x
, GLint y
,
582 GLsizei width
, GLsizei height
, GLint border
);
583 /* Called by glCopyTexImage1D and glCopyTexImage2D.
584 * Will not be called if any glPixelTransfer operations are enabled.
585 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
589 GLboolean (*CopyTexSubImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
591 GLint x
, GLint y
, GLsizei width
);
592 GLboolean (*CopyTexSubImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
593 GLint xoffset
, GLint yoffset
,
595 GLsizei width
, GLsizei height
);
596 GLboolean (*CopyTexSubImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
597 GLint xoffset
, GLint yoffset
, GLint zoffset
,
599 GLsizei width
, GLsizei height
);
600 /* Called by glCopyTexSubImage1/2/3D.
601 * Will not be called if any glPixelTransfer operations are enabled.
602 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
606 GLvoid
*(*GetTexImage
)( GLcontext
*ctx
, GLenum target
, GLint level
,
607 const struct gl_texture_object
*texObj
,
608 GLenum
*formatOut
, GLenum
*typeOut
,
609 GLboolean
*freeImageOut
);
610 /* Called by glGetTexImage or by core Mesa when a texture image
611 * is needed for software fallback rendering.
612 * Return the address of the texture image or NULL if failure.
613 * The image must be tightly packed (i.e. row stride = image width)
614 * Return the image's format and type in formatOut and typeOut.
615 * The format and type must be values which are accepted by glTexImage.
616 * Set the freeImageOut flag if the returned image should be deallocated
617 * with FREE() when finished.
618 * The size of the image can be deduced from the target and level.
619 * Core Mesa will perform any image format/type conversions that are needed.
622 GLboolean (*TestProxyTexImage
)(GLcontext
*ctx
, GLenum target
,
623 GLint level
, GLint internalFormat
,
624 GLenum format
, GLenum type
,
625 GLint width
, GLint height
,
626 GLint depth
, GLint border
);
627 /* Called by glTexImage[123]D when user specifies a proxy texture
628 * target. Return GL_TRUE if the proxy test passes, return GL_FALSE
632 GLboolean (*CompressedTexImage1D
)( GLcontext
*ctx
, GLenum target
,
633 GLint level
, GLsizei imageSize
,
635 struct gl_texture_object
*texObj
,
636 struct gl_texture_image
*texImage
,
637 GLboolean
*retainInternalCopy
);
638 GLboolean (*CompressedTexImage2D
)( GLcontext
*ctx
, GLenum target
,
639 GLint level
, GLsizei imageSize
,
641 struct gl_texture_object
*texObj
,
642 struct gl_texture_image
*texImage
,
643 GLboolean
*retainInternalCopy
);
644 GLboolean (*CompressedTexImage3D
)( GLcontext
*ctx
, GLenum target
,
645 GLint level
, GLsizei imageSize
,
647 struct gl_texture_object
*texObj
,
648 struct gl_texture_image
*texImage
,
649 GLboolean
*retainInternalCopy
);
650 /* Called by glCompressedTexImage1/2/3D.
652 * <target>, <level>, <internalFormat>, <data> are user specified.
653 * <texObj> is the target texture object.
654 * <texImage> is the target texture image. It will have the texture
655 * width, height, depth, border and internalFormat information.
656 * <retainInternalCopy> is returned by this function and indicates whether
657 * core Mesa should keep an internal copy of the texture image.
658 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
662 GLboolean (*CompressedTexSubImage1D
)( GLcontext
*ctx
, GLenum target
,
663 GLint level
, GLint xoffset
,
664 GLsizei width
, GLenum format
,
665 GLsizei imageSize
, const GLvoid
*data
,
666 struct gl_texture_object
*texObj
,
667 struct gl_texture_image
*texImage
);
668 GLboolean (*CompressedTexSubImage2D
)( GLcontext
*ctx
, GLenum target
,
669 GLint level
, GLint xoffset
,
670 GLint yoffset
, GLsizei width
,
671 GLint height
, GLenum format
,
672 GLsizei imageSize
, const GLvoid
*data
,
673 struct gl_texture_object
*texObj
,
674 struct gl_texture_image
*texImage
);
675 GLboolean (*CompressedTexSubImage3D
)( GLcontext
*ctx
, GLenum target
,
676 GLint level
, GLint xoffset
,
677 GLint yoffset
, GLint zoffset
,
678 GLsizei width
, GLint height
,
679 GLint depth
, GLenum format
,
680 GLsizei imageSize
, const GLvoid
*data
,
681 struct gl_texture_object
*texObj
,
682 struct gl_texture_image
*texImage
);
683 /* Called by glCompressedTexSubImage1/2/3D.
685 * <target>, <level>, <x/z/zoffset>, <width>, <height>, <depth>,
686 * <imageSize>, and <data> are user specified.
687 * <texObj> is the target texture object.
688 * <texImage> is the target texture image. It will have the texture
689 * width, height, depth, border and internalFormat information.
690 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
694 GLint (*BaseCompressedTexFormat
)(GLcontext
*ctx
,
695 GLint internalFormat
);
696 /* Called to compute the base format for a specific compressed
697 * format. Return -1 if the internalFormat is not a specific
698 * compressed format that the driver recognizes. Note the
699 * return value differences between this function and
700 * SpecificCompressedTexFormat below.
703 GLint (*SpecificCompressedTexFormat
)(GLcontext
*ctx
,
704 GLint internalFormat
,
713 /* Called to turn a generic texture format into a specific
714 * texture format. For example, if a driver implements
715 * GL_3DFX_texture_compression_FXT1, this would map
716 * GL_COMPRESSED_RGBA_ARB to GL_COMPRESSED_RGBA_FXT1_3DFX.
718 * If the driver does not know how to handle the compressed
719 * format, then just return the generic format, and Mesa will
720 * do the right thing with it.
723 GLboolean (*IsCompressedFormat
)(GLcontext
*ctx
, GLint internalFormat
);
724 /* Called to tell if a format is a compressed format.
727 GLsizei (*CompressedImageSize
)(GLcontext
*ctx
,
728 GLenum internalFormat
,
729 GLuint numDimensions
,
733 /* Calculate the size of a compressed image, given the image's
734 * format and dimensions.
737 void (*GetCompressedTexImage
)( GLcontext
*ctx
, GLenum target
,
738 GLint lod
, void *image
,
739 const struct gl_texture_object
*texObj
,
740 struct gl_texture_image
*texImage
);
741 /* Called by glGetCompressedTexImageARB.
742 * <target>, <lod>, <image> are specified by user.
743 * <texObj> is the source texture object.
744 * <texImage> is the source texture image.
747 void (*TexEnv
)( GLcontext
*ctx
, GLenum target
, GLenum pname
,
748 const GLfloat
*param
);
749 /* Called by glTexEnv*().
752 void (*TexParameter
)( GLcontext
*ctx
, GLenum target
,
753 struct gl_texture_object
*texObj
,
754 GLenum pname
, const GLfloat
*params
);
755 /* Called by glTexParameter*().
756 * <target> is user specified
757 * <texObj> the texture object to modify
758 * <pname> is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER,
759 * GL_TEXTURE_WRAP_[STR], or GL_TEXTURE_BORDER_COLOR.
760 * <params> is user specified.
763 void (*BindTexture
)( GLcontext
*ctx
, GLenum target
,
764 struct gl_texture_object
*tObj
);
765 /* Called by glBindTexture().
768 void (*DeleteTexture
)( GLcontext
*ctx
, struct gl_texture_object
*tObj
);
769 /* Called when a texture object is about to be deallocated. Driver
770 * should free anything attached to the DriverData pointers.
773 GLboolean (*IsTextureResident
)( GLcontext
*ctx
,
774 struct gl_texture_object
*t
);
775 /* Called by glAreTextureResident().
778 void (*PrioritizeTexture
)( GLcontext
*ctx
, struct gl_texture_object
*t
,
780 /* Called by glPrioritizeTextures().
783 void (*ActiveTexture
)( GLcontext
*ctx
, GLuint texUnitNumber
);
784 /* Called by glActiveTextureARB to set current texture unit.
787 void (*UpdateTexturePalette
)( GLcontext
*ctx
,
788 struct gl_texture_object
*tObj
);
789 /* Called when the texture's color lookup table is changed.
790 * If tObj is NULL then the shared texture palette ctx->Texture.Palette
797 *** Accelerated point, line, polygon, quad and rect functions:
800 points_func PointsFunc
;
802 triangle_func TriangleFunc
;
808 *** Transformation/Rendering functions
811 void (*RenderStart
)( GLcontext
*ctx
);
812 void (*RenderFinish
)( GLcontext
*ctx
);
813 /* KW: These replace Begin and End, and have more relaxed semantics.
814 * They are called prior-to and after one or more vb flush, and are
815 * thus decoupled from the gl_begin/gl_end pairs, which are possibly
816 * more frequent. If a begin/end pair covers >1 vertex buffer, these
817 * are called at most once for the pair. (a bit broken at present)
820 void (*RasterSetup
)( struct vertex_buffer
*VB
, GLuint start
, GLuint end
);
821 /* This function, if not NULL, is called whenever new window coordinates
822 * are put in the vertex buffer. The vertices in question are those n
823 * such that start <= n < end.
824 * The device driver can convert the window coords to its own specialized
825 * format. The 3Dfx driver uses this.
827 * Note: Deprecated in favour of RegisterPipelineStages, below.
830 render_func
*RenderVBClippedTab
;
831 render_func
*RenderVBCulledTab
;
832 render_func
*RenderVBRawTab
;
833 /* These function tables allow the device driver to rasterize an
834 * entire begin/end group of primitives at once. See the
835 * gl_render_vb() function in vbrender.c for more details.
838 void (*ReducedPrimitiveChange
)( GLcontext
*ctx
, GLenum primitive
);
839 /* If registered, this will be called when rendering transitions between
840 * points, lines and triangles. It is not called on transitions between
841 * primtives such as GL_TRIANGLES and GL_TRIANGLE_STRIPS, or between
842 * triangles and quads or triangles and polygons.
846 /* Holds a list of the reasons why we might normally want to call
847 * render_triangle, but which are in fact implemented by the
848 * driver. The FX driver sets this to DD_TRI_CULL, and will soon
849 * implement DD_TRI_OFFSET.
852 GLboolean (*MultipassFunc
)( struct vertex_buffer
*VB
, GLuint passno
);
853 /* Driver may request additional render passes by returning GL_TRUE
854 * when this function is called. This function will be called
855 * after the first pass, and passes will be made until the function
856 * returns GL_FALSE. If no function is registered, only one pass
859 * This function will be first invoked with passno == 1.
866 void (*RegisterVB
)( struct vertex_buffer
*VB
);
867 void (*UnregisterVB
)( struct vertex_buffer
*VB
);
868 /* When Mesa creates a new vertex buffer it calls Driver.RegisterVB()
869 * so the device driver can allocate its own vertex buffer data and
870 * hook it to the VB->driver_data pointer.
871 * When Mesa destroys a vertex buffer it calls Driver.UnegisterVB()
872 * so the driver can deallocate its own data attached to VB->driver_data.
876 void (*ResetVB
)( struct vertex_buffer
*VB
);
877 void (*ResetCvaVB
)( struct vertex_buffer
*VB
, GLuint stages
);
878 /* Do any reset operations necessary to the driver data associated
879 * with these vertex buffers.
882 GLuint RenderVectorFlags
;
883 /* What do the render tables require of the vectors they deal
887 GLuint (*RegisterPipelineStages
)( struct gl_pipeline_stage
*out
,
888 const struct gl_pipeline_stage
*in
,
890 /* Register new pipeline stages, or modify existing ones. See also
891 * the OptimizePipeline() functions.
895 GLboolean (*BuildPrecalcPipeline
)( GLcontext
*ctx
);
896 GLboolean (*BuildEltPipeline
)( GLcontext
*ctx
);
897 /* Perform the full pipeline build, or return false.
901 void (*OptimizePrecalcPipeline
)( GLcontext
*ctx
, struct gl_pipeline
*pipe
);
902 void (*OptimizeImmediatePipeline
)( GLcontext
*ctx
, struct gl_pipeline
*pipe
);
903 /* Check to see if a fast path exists for this combination of stages
904 * in the precalc and immediate (elt) pipelines.
909 * State-changing functions (drawing functions are above)
911 * These functions are called by their corresponding OpenGL API functions.
912 * They're ALSO called by the gl_PopAttrib() function!!!
913 * May add more functions like these to the device driver in the future.
914 * This should reduce the amount of state checking that
915 * the driver's UpdateState() function must do.
917 void (*AlphaFunc
)(GLcontext
*ctx
, GLenum func
, GLclampf ref
);
918 void (*BlendEquation
)(GLcontext
*ctx
, GLenum mode
);
919 void (*BlendFunc
)(GLcontext
*ctx
, GLenum sfactor
, GLenum dfactor
);
920 void (*BlendFuncSeparate
)( GLcontext
*ctx
, GLenum sfactorRGB
,
921 GLenum dfactorRGB
, GLenum sfactorA
,
923 void (*ClearDepth
)(GLcontext
*ctx
, GLclampd d
);
924 void (*ColorMask
)(GLcontext
*ctx
, GLboolean rmask
, GLboolean gmask
,
925 GLboolean bmask
, GLboolean amask
);
926 void (*CullFace
)(GLcontext
*ctx
, GLenum mode
);
927 void (*FrontFace
)(GLcontext
*ctx
, GLenum mode
);
928 void (*DepthFunc
)(GLcontext
*ctx
, GLenum func
);
929 void (*DepthMask
)(GLcontext
*ctx
, GLboolean flag
);
930 void (*DepthRange
)(GLcontext
*ctx
, GLclampd nearval
, GLclampd farval
);
931 void (*Enable
)(GLcontext
* ctx
, GLenum cap
, GLboolean state
);
932 void (*Fogfv
)(GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
);
933 void (*Hint
)(GLcontext
*ctx
, GLenum target
, GLenum mode
);
934 void (*IndexMask
)(GLcontext
*ctx
, GLuint mask
);
935 void (*Lightfv
)(GLcontext
*ctx
, GLenum light
,
936 GLenum pname
, const GLfloat
*params
, GLint nparams
);
937 void (*LightModelfv
)(GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
);
938 void (*LineStipple
)(GLcontext
*ctx
, GLint factor
, GLushort pattern
);
939 void (*LineWidth
)(GLcontext
*ctx
, GLfloat width
);
940 void (*LogicOpcode
)(GLcontext
*ctx
, GLenum opcode
);
941 void (*PolygonMode
)(GLcontext
*ctx
, GLenum face
, GLenum mode
);
942 void (*PolygonStipple
)(GLcontext
*ctx
, const GLubyte
*mask
);
943 void (*Scissor
)(GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
);
944 void (*ShadeModel
)(GLcontext
*ctx
, GLenum mode
);
945 void (*ClearStencil
)(GLcontext
*ctx
, GLint s
);
946 void (*StencilFunc
)(GLcontext
*ctx
, GLenum func
, GLint ref
, GLuint mask
);
947 void (*StencilMask
)(GLcontext
*ctx
, GLuint mask
);
948 void (*StencilOp
)(GLcontext
*ctx
, GLenum fail
, GLenum zfail
, GLenum zpass
);
949 void (*Viewport
)(GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
);
951 /* State-query functions
953 * Return GL_TRUE if query was completed, GL_FALSE otherwise.
955 GLboolean (*GetBooleanv
)(GLcontext
*ctx
, GLenum pname
, GLboolean
*result
);
956 GLboolean (*GetDoublev
)(GLcontext
*ctx
, GLenum pname
, GLdouble
*result
);
957 GLboolean (*GetFloatv
)(GLcontext
*ctx
, GLenum pname
, GLfloat
*result
);
958 GLboolean (*GetIntegerv
)(GLcontext
*ctx
, GLenum pname
, GLint
*result
);
959 GLboolean (*GetPointerv
)(GLcontext
*ctx
, GLenum pname
, GLvoid
**result
);