1 /* $Id: dd.h,v 1.39 2000/11/10 17:36:42 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.
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
114 /* Mask bits sent to the driver Clear() function */
115 #define DD_FRONT_LEFT_BIT FRONT_LEFT_BIT /* 1 */
116 #define DD_FRONT_RIGHT_BIT FRONT_RIGHT_BIT /* 2 */
117 #define DD_BACK_LEFT_BIT BACK_LEFT_BIT /* 4 */
118 #define DD_BACK_RIGHT_BIT BACK_RIGHT_BIT /* 8 */
119 #define DD_DEPTH_BIT GL_DEPTH_BUFFER_BIT /* 0x00000100 */
120 #define DD_STENCIL_BIT GL_STENCIL_BUFFER_BIT /* 0x00000400 */
121 #define DD_ACCUM_BIT GL_ACCUM_BUFFER_BIT /* 0x00000200 */
126 * Device Driver function table.
128 struct dd_function_table
{
130 /**********************************************************************
131 *** Mandatory functions: these functions must be implemented by ***
132 *** every device driver. ***
133 **********************************************************************/
135 const GLubyte
* (*GetString
)( GLcontext
*ctx
, GLenum name
);
136 /* Return a string as needed by glGetString().
137 * Only the GL_RENDERER token must be implemented. Otherwise,
138 * NULL can be returned.
141 GLuint UpdateStateNotify
;
143 * Tell mesa exactly when to call UpdateState. This is a bitwise
144 * or of the _NEW_* flags defined in types.h.
147 void (*UpdateState
)( GLcontext
*ctx
);
149 * UpdateState() is called whenver Mesa thinks the device driver should
150 * update its state and/or the other pointers (such as PointsFunc,
151 * LineFunc, or TriangleFunc).
154 void (*ClearIndex
)( GLcontext
*ctx
, GLuint index
);
156 * Called whenever glClearIndex() is called. Set the index for clearing
157 * the color buffer when in color index mode.
160 void (*ClearColor
)( GLcontext
*ctx
, GLchan red
, GLchan green
,
161 GLchan blue
, GLchan alpha
);
163 * Called whenever glClearColor() is called. Set the color for clearing
164 * the color buffer when in RGBA mode.
167 GLbitfield (*Clear
)( GLcontext
*ctx
, GLbitfield mask
, GLboolean all
,
168 GLint x
, GLint y
, GLint width
, GLint height
);
169 /* Clear the color/depth/stencil/accum buffer(s).
170 * 'mask' is a bitmask of the DD_*_BIT values defined above that indicates
171 * which buffers need to be cleared. The driver should clear those
172 * buffers then return a new bitmask indicating which buffers should be
173 * cleared by software Mesa.
174 * If 'all' is true then the clear the whole buffer, else clear only the
175 * region defined by (x,y,width,height).
176 * This function must obey the glColorMask, glIndexMask and glStencilMask
177 * settings! Software Mesa can do masked clears if the device driver can't.
180 void (*Index
)( GLcontext
*ctx
, GLuint index
);
182 * Sets current color index for drawing flat-shaded primitives.
183 * This index should also be used in the "mono" drawing functions.
186 void (*Color
)( GLcontext
*ctx
,
187 GLchan red
, GLchan green
, GLchan glue
, GLchan alpha
);
189 * Sets current color for drawing flat-shaded primitives.
190 * This color should also be used in the "mono" drawing functions.
193 GLboolean (*SetDrawBuffer
)( GLcontext
*ctx
, GLenum buffer
);
195 * Specifies the current buffer for writing.
196 * The following values must be accepted when applicable:
197 * GL_FRONT_LEFT - this buffer always exists
198 * GL_BACK_LEFT - when double buffering
199 * GL_FRONT_RIGHT - when using stereo
200 * GL_BACK_RIGHT - when using stereo and double buffering
201 * The folowing values may optionally be accepted. Return GL_TRUE
202 * if accepted, GL_FALSE if not accepted. In practice, only drivers
203 * which can write to multiple color buffers at once should accept
205 * GL_FRONT - write to front left and front right if it exists
206 * GL_BACK - write to back left and back right if it exists
207 * GL_LEFT - write to front left and back left if it exists
208 * GL_RIGHT - write to right left and back right if they exist
209 * GL_FRONT_AND_BACK - write to all four buffers if they exist
210 * GL_NONE - disable buffer write in device driver.
213 void (*SetReadBuffer
)( GLcontext
*ctx
, GLframebuffer
*colorBuffer
,
216 * Specifies the current buffer for reading.
217 * colorBuffer will be one of:
218 * GL_FRONT_LEFT - this buffer always exists
219 * GL_BACK_LEFT - when double buffering
220 * GL_FRONT_RIGHT - when using stereo
221 * GL_BACK_RIGHT - when using stereo and double buffering
224 void (*GetBufferSize
)( GLcontext
*ctx
, GLuint
*width
, GLuint
*height
);
226 * Returns the width and height of the current color buffer.
231 *** Functions for writing pixels to the frame buffer:
234 void (*WriteRGBASpan
)( const GLcontext
*ctx
,
235 GLuint n
, GLint x
, GLint y
,
236 CONST GLchan rgba
[][4], const GLubyte mask
[] );
237 void (*WriteRGBSpan
)( const GLcontext
*ctx
,
238 GLuint n
, GLint x
, GLint y
,
239 CONST GLchan rgb
[][3], const GLubyte mask
[] );
240 /* Write a horizontal run of RGBA or RGB pixels.
241 * If mask is NULL, draw all pixels.
242 * If mask is not null, only draw pixel [i] when mask [i] is true.
245 void (*WriteMonoRGBASpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
246 const GLubyte mask
[] );
247 /* Write a horizontal run of RGBA pixels all with the color last
248 * specified by the Color function.
251 void (*WriteRGBAPixels
)( const GLcontext
*ctx
,
252 GLuint n
, const GLint x
[], const GLint y
[],
253 CONST GLchan rgba
[][4], const GLubyte mask
[] );
254 /* Write array of RGBA pixels at random locations.
257 void (*WriteMonoRGBAPixels
)( const GLcontext
*ctx
,
258 GLuint n
, const GLint x
[], const GLint y
[],
259 const GLubyte mask
[] );
260 /* Write an array of mono-RGBA pixels at random locations.
263 void (*WriteCI32Span
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
264 const GLuint index
[], const GLubyte mask
[] );
265 void (*WriteCI8Span
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
266 const GLubyte index
[], const GLubyte mask
[] );
267 /* Write a horizontal run of CI pixels. One function is for 32bpp
268 * indexes and the other for 8bpp pixels (the common case). You mus
269 * implement both for color index mode.
272 void (*WriteMonoCISpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
273 const GLubyte mask
[] );
274 /* Write a horizontal run of color index pixels using the color index
275 * last specified by the Index() function.
278 void (*WriteCI32Pixels
)( const GLcontext
*ctx
,
279 GLuint n
, const GLint x
[], const GLint y
[],
280 const GLuint index
[], const GLubyte mask
[] );
282 * Write a random array of CI pixels.
285 void (*WriteMonoCIPixels
)( const GLcontext
*ctx
,
286 GLuint n
, const GLint x
[], const GLint y
[],
287 const GLubyte mask
[] );
288 /* Write a random array of color index pixels using the color index
289 * last specified by the Index() function.
294 *** Functions to read pixels from frame buffer:
297 void (*ReadCI32Span
)( const GLcontext
*ctx
,
298 GLuint n
, GLint x
, GLint y
, GLuint index
[] );
299 /* Read a horizontal run of color index pixels.
302 void (*ReadRGBASpan
)( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
304 /* Read a horizontal run of RGBA pixels.
307 void (*ReadCI32Pixels
)( const GLcontext
*ctx
,
308 GLuint n
, const GLint x
[], const GLint y
[],
309 GLuint indx
[], const GLubyte mask
[] );
310 /* Read a random array of CI pixels.
313 void (*ReadRGBAPixels
)( const GLcontext
*ctx
,
314 GLuint n
, const GLint x
[], const GLint y
[],
315 GLchan rgba
[][4], const GLubyte mask
[] );
316 /* Read a random array of RGBA pixels.
320 /**********************************************************************
321 *** Optional functions: these functions may or may not be ***
322 *** implemented by the device driver. If the device driver ***
323 *** doesn't implement them it should never touch these pointers ***
324 *** since Mesa will either set them to NULL or point them at a ***
325 *** fall-back function. ***
326 **********************************************************************/
328 void (*Finish
)( GLcontext
*ctx
);
330 * This is called whenever glFinish() is called.
333 void (*Flush
)( GLcontext
*ctx
);
335 * This is called whenever glFlush() is called.
338 void (*Error
)( GLcontext
*ctx
);
340 * Called whenever an error is generated. ctx->ErrorValue contains
344 void (*NearFar
)( GLcontext
*ctx
, GLfloat nearVal
, GLfloat farVal
);
346 * Called from glFrustum and glOrtho to tell device driver the
347 * near and far clipping plane Z values. The 3Dfx driver, for example,
353 *** For supporting hardware Z buffers:
354 *** Either ALL or NONE of these functions must be implemented!
355 *** NOTE that Each depth value is a 32-bit GLuint. If the depth
356 *** buffer is less than 32 bits deep then the extra upperbits are zero.
359 void (*WriteDepthSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
360 const GLdepth depth
[], const GLubyte mask
[] );
361 /* Write a horizontal span of values into the depth buffer. Only write
362 * depth[i] value if mask[i] is nonzero.
365 void (*ReadDepthSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
367 /* Read a horizontal span of values from the depth buffer.
371 void (*WriteDepthPixels
)( GLcontext
*ctx
, GLuint n
,
372 const GLint x
[], const GLint y
[],
373 const GLdepth depth
[], const GLubyte mask
[] );
374 /* Write an array of randomly positioned depth values into the
375 * depth buffer. Only write depth[i] value if mask[i] is nonzero.
378 void (*ReadDepthPixels
)( GLcontext
*ctx
, GLuint n
,
379 const GLint x
[], const GLint y
[],
381 /* Read an array of randomly positioned depth values from the depth buffer.
387 *** For supporting hardware stencil buffers:
388 *** Either ALL or NONE of these functions must be implemented!
391 void (*WriteStencilSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
392 const GLstencil stencil
[], const GLubyte mask
[] );
393 /* Write a horizontal span of stencil values into the stencil buffer.
394 * If mask is NULL, write all stencil values.
395 * Else, only write stencil[i] if mask[i] is non-zero.
398 void (*ReadStencilSpan
)( GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
399 GLstencil stencil
[] );
400 /* Read a horizontal span of stencil values from the stencil buffer.
403 void (*WriteStencilPixels
)( GLcontext
*ctx
, GLuint n
,
404 const GLint x
[], const GLint y
[],
405 const GLstencil stencil
[],
406 const GLubyte mask
[] );
407 /* Write an array of stencil values into the stencil buffer.
408 * If mask is NULL, write all stencil values.
409 * Else, only write stencil[i] if mask[i] is non-zero.
412 void (*ReadStencilPixels
)( GLcontext
*ctx
, GLuint n
,
413 const GLint x
[], const GLint y
[],
414 GLstencil stencil
[] );
415 /* Read an array of stencil values from the stencil buffer.
420 *** glDraw/Read/CopyPixels and glBitmap functions:
423 GLboolean (*DrawPixels
)( GLcontext
*ctx
,
424 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
425 GLenum format
, GLenum type
,
426 const struct gl_pixelstore_attrib
*unpack
,
427 const GLvoid
*pixels
);
428 /* This is called by glDrawPixels.
429 * 'unpack' describes how to unpack the source image data.
430 * Return GL_TRUE if the driver succeeds, return GL_FALSE if core Mesa
434 GLboolean (*ReadPixels
)( GLcontext
*ctx
,
435 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
436 GLenum format
, GLenum type
,
437 const struct gl_pixelstore_attrib
*unpack
,
439 /* Called by glReadPixels.
440 * Return GL_TRUE if operation completed, else return GL_FALSE.
441 * This function must respect all glPixelTransfer settings.
444 GLboolean (*CopyPixels
)( GLcontext
*ctx
,
445 GLint srcx
, GLint srcy
,
446 GLsizei width
, GLsizei height
,
447 GLint dstx
, GLint dsty
, GLenum type
);
448 /* Do a glCopyPixels. Return GL_TRUE if operation completed, else
449 * return GL_FALSE. This function must respect all rasterization
450 * state, glPixelTransfer, glPixelZoom, etc.
453 GLboolean (*Bitmap
)( GLcontext
*ctx
,
454 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
455 const struct gl_pixelstore_attrib
*unpack
,
456 const GLubyte
*bitmap
);
457 /* This is called by glBitmap. Works the same as DrawPixels, above.
460 GLboolean (*Accum
)( GLcontext
*ctx
, GLenum op
,
461 GLfloat value
, GLint xpos
, GLint ypos
,
462 GLint width
, GLint height
);
463 /* Hardware accum buffer.
467 *** Texture mapping functions:
470 GLboolean (*TexImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
471 GLenum format
, GLenum type
, const GLvoid
*pixels
,
472 const struct gl_pixelstore_attrib
*packing
,
473 struct gl_texture_object
*texObj
,
474 struct gl_texture_image
*texImage
,
475 GLboolean
*retainInternalCopy
);
476 GLboolean (*TexImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
477 GLenum format
, GLenum type
, const GLvoid
*pixels
,
478 const struct gl_pixelstore_attrib
*packing
,
479 struct gl_texture_object
*texObj
,
480 struct gl_texture_image
*texImage
,
481 GLboolean
*retainInternalCopy
);
482 GLboolean (*TexImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
483 GLenum format
, GLenum type
, const GLvoid
*pixels
,
484 const struct gl_pixelstore_attrib
*packing
,
485 struct gl_texture_object
*texObj
,
486 struct gl_texture_image
*texImage
,
487 GLboolean
*retainInternalCopy
);
488 /* Called by glTexImage1/2/3D.
489 * Will not be called if any glPixelTransfer operations are enabled.
491 * <target>, <level>, <format>, <type> and <pixels> are user specified.
492 * <packing> indicates the image packing of pixels.
493 * <texObj> is the target texture object.
494 * <texImage> is the target texture image. It will have the texture
495 * width, height, depth, border and internalFormat information.
496 * <retainInternalCopy> is returned by this function and indicates whether
497 * core Mesa should keep an internal copy of the texture image.
498 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
499 * should do the job. If GL_FALSE is returned, this function will be
500 * called a second time after the texture image has been unpacked into
501 * GLubytes. It may be easier for the driver to handle then.
504 GLboolean (*TexSubImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
505 GLint xoffset
, GLsizei width
,
506 GLenum format
, GLenum type
,
507 const GLvoid
*pixels
,
508 const struct gl_pixelstore_attrib
*packing
,
509 struct gl_texture_object
*texObj
,
510 struct gl_texture_image
*texImage
);
511 GLboolean (*TexSubImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
512 GLint xoffset
, GLint yoffset
,
513 GLsizei width
, GLsizei height
,
514 GLenum format
, GLenum type
,
515 const GLvoid
*pixels
,
516 const struct gl_pixelstore_attrib
*packing
,
517 struct gl_texture_object
*texObj
,
518 struct gl_texture_image
*texImage
);
519 GLboolean (*TexSubImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
520 GLint xoffset
, GLint yoffset
, GLint zoffset
,
521 GLsizei width
, GLsizei height
, GLint depth
,
522 GLenum format
, GLenum type
,
523 const GLvoid
*pixels
,
524 const struct gl_pixelstore_attrib
*packing
,
525 struct gl_texture_object
*texObj
,
526 struct gl_texture_image
*texImage
);
527 /* Called by glTexSubImage1/2/3D.
528 * Will not be called if any glPixelTransfer operations are enabled.
530 * <target>, <level>, <xoffset>, <yoffset>, <zoffset>, <width>, <height>,
531 * <depth>, <format>, <type> and <pixels> are user specified.
532 * <packing> indicates the image packing of pixels.
533 * <texObj> is the target texture object.
534 * <texImage> is the target texture image. It will have the texture
535 * width, height, border and internalFormat information.
536 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
537 * should do the job. If GL_FALSE is returned, then TexImage1/2/3D will
538 * be called with the complete texture image.
541 GLboolean (*CopyTexImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
542 GLenum internalFormat
, GLint x
, GLint y
,
543 GLsizei width
, GLint border
);
544 GLboolean (*CopyTexImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
545 GLenum internalFormat
, GLint x
, GLint y
,
546 GLsizei width
, GLsizei height
, GLint border
);
547 /* Called by glCopyTexImage1D and glCopyTexImage2D.
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 (*CopyTexSubImage1D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
555 GLint x
, GLint y
, GLsizei width
);
556 GLboolean (*CopyTexSubImage2D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
557 GLint xoffset
, GLint yoffset
,
559 GLsizei width
, GLsizei height
);
560 GLboolean (*CopyTexSubImage3D
)( GLcontext
*ctx
, GLenum target
, GLint level
,
561 GLint xoffset
, GLint yoffset
, GLint zoffset
,
563 GLsizei width
, GLsizei height
);
564 /* Called by glCopyTexSubImage1/2/3D.
565 * Will not be called if any glPixelTransfer operations are enabled.
566 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
570 GLvoid
*(*GetTexImage
)( GLcontext
*ctx
, GLenum target
, GLint level
,
571 const struct gl_texture_object
*texObj
,
572 GLenum
*formatOut
, GLenum
*typeOut
,
573 GLboolean
*freeImageOut
);
574 /* Called by glGetTexImage or by core Mesa when a texture image
575 * is needed for software fallback rendering.
576 * Return the address of the texture image or NULL if failure.
577 * The image must be tightly packed (i.e. row stride = image width)
578 * Return the image's format and type in formatOut and typeOut.
579 * The format and type must be values which are accepted by glTexImage.
580 * Set the freeImageOut flag if the returned image should be deallocated
581 * with FREE() when finished.
582 * The size of the image can be deduced from the target and level.
583 * Core Mesa will perform any image format/type conversions that are needed.
586 GLboolean (*TestProxyTexImage
)(GLcontext
*ctx
, GLenum target
,
587 GLint level
, GLint internalFormat
,
588 GLenum format
, GLenum type
,
589 GLint width
, GLint height
,
590 GLint depth
, GLint border
);
591 /* Called by glTexImage[123]D when user specifies a proxy texture
592 * target. Return GL_TRUE if the proxy test passes, return GL_FALSE
596 GLboolean (*CompressedTexImage1D
)( GLcontext
*ctx
, GLenum target
,
597 GLint level
, GLsizei imageSize
,
599 struct gl_texture_object
*texObj
,
600 struct gl_texture_image
*texImage
,
601 GLboolean
*retainInternalCopy
);
602 GLboolean (*CompressedTexImage2D
)( GLcontext
*ctx
, GLenum target
,
603 GLint level
, GLsizei imageSize
,
605 struct gl_texture_object
*texObj
,
606 struct gl_texture_image
*texImage
,
607 GLboolean
*retainInternalCopy
);
608 GLboolean (*CompressedTexImage3D
)( GLcontext
*ctx
, GLenum target
,
609 GLint level
, GLsizei imageSize
,
611 struct gl_texture_object
*texObj
,
612 struct gl_texture_image
*texImage
,
613 GLboolean
*retainInternalCopy
);
614 /* Called by glCompressedTexImage1/2/3D.
616 * <target>, <level>, <internalFormat>, <data> are user specified.
617 * <texObj> is the target texture object.
618 * <texImage> is the target texture image. It will have the texture
619 * width, height, depth, border and internalFormat information.
620 * <retainInternalCopy> is returned by this function and indicates whether
621 * core Mesa should keep an internal copy of the texture image.
622 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
626 GLboolean (*CompressedTexSubImage1D
)( GLcontext
*ctx
, GLenum target
,
627 GLint level
, GLint xoffset
,
628 GLsizei width
, GLenum format
,
629 GLsizei imageSize
, const GLvoid
*data
,
630 struct gl_texture_object
*texObj
,
631 struct gl_texture_image
*texImage
);
632 GLboolean (*CompressedTexSubImage2D
)( GLcontext
*ctx
, GLenum target
,
633 GLint level
, GLint xoffset
,
634 GLint yoffset
, GLsizei width
,
635 GLint height
, GLenum format
,
636 GLsizei imageSize
, const GLvoid
*data
,
637 struct gl_texture_object
*texObj
,
638 struct gl_texture_image
*texImage
);
639 GLboolean (*CompressedTexSubImage3D
)( GLcontext
*ctx
, GLenum target
,
640 GLint level
, GLint xoffset
,
641 GLint yoffset
, GLint zoffset
,
642 GLsizei width
, GLint height
,
643 GLint depth
, GLenum format
,
644 GLsizei imageSize
, const GLvoid
*data
,
645 struct gl_texture_object
*texObj
,
646 struct gl_texture_image
*texImage
);
647 /* Called by glCompressedTexSubImage1/2/3D.
649 * <target>, <level>, <x/z/zoffset>, <width>, <height>, <depth>,
650 * <imageSize>, and <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 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
658 GLint (*BaseCompressedTexFormat
)(GLcontext
*ctx
,
659 GLint internalFormat
);
660 /* Called to compute the base format for a specific compressed
661 * format. Return -1 if the internalFormat is not a specific
662 * compressed format that the driver recognizes. Note the
663 * return value differences between this function and
664 * SpecificCompressedTexFormat below.
667 GLint (*SpecificCompressedTexFormat
)(GLcontext
*ctx
,
668 GLint internalFormat
,
677 /* Called to turn a generic texture format into a specific
678 * texture format. For example, if a driver implements
679 * GL_3DFX_texture_compression_FXT1, this would map
680 * GL_COMPRESSED_RGBA_ARB to GL_COMPRESSED_RGBA_FXT1_3DFX.
682 * If the driver does not know how to handle the compressed
683 * format, then just return the generic format, and Mesa will
684 * do the right thing with it.
687 GLboolean (*IsCompressedFormat
)(GLcontext
*ctx
, GLint internalFormat
);
688 /* Called to tell if a format is a compressed format.
691 GLsizei (*CompressedImageSize
)(GLcontext
*ctx
,
692 GLenum internalFormat
,
693 GLuint numDimensions
,
697 /* Calculate the size of a compressed image, given the image's
698 * format and dimensions.
701 void (*GetCompressedTexImage
)( GLcontext
*ctx
, GLenum target
,
702 GLint lod
, void *image
,
703 const struct gl_texture_object
*texObj
,
704 struct gl_texture_image
*texImage
);
705 /* Called by glGetCompressedTexImageARB.
706 * <target>, <lod>, <image> are specified by user.
707 * <texObj> is the source texture object.
708 * <texImage> is the source texture image.
711 void (*TexEnv
)( GLcontext
*ctx
, GLenum target
, GLenum pname
,
712 const GLfloat
*param
);
713 /* Called by glTexEnv*().
716 void (*TexParameter
)( GLcontext
*ctx
, GLenum target
,
717 struct gl_texture_object
*texObj
,
718 GLenum pname
, const GLfloat
*params
);
719 /* Called by glTexParameter*().
720 * <target> is user specified
721 * <texObj> the texture object to modify
722 * <pname> is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER,
723 * GL_TEXTURE_WRAP_[STR], or GL_TEXTURE_BORDER_COLOR.
724 * <params> is user specified.
727 void (*BindTexture
)( GLcontext
*ctx
, GLenum target
,
728 struct gl_texture_object
*tObj
);
729 /* Called by glBindTexture().
732 void (*DeleteTexture
)( GLcontext
*ctx
, struct gl_texture_object
*tObj
);
733 /* Called when a texture object is about to be deallocated. Driver
734 * should free anything attached to the DriverData pointers.
737 GLboolean (*IsTextureResident
)( GLcontext
*ctx
,
738 struct gl_texture_object
*t
);
739 /* Called by glAreTextureResident().
742 void (*PrioritizeTexture
)( GLcontext
*ctx
, struct gl_texture_object
*t
,
744 /* Called by glPrioritizeTextures().
747 void (*ActiveTexture
)( GLcontext
*ctx
, GLuint texUnitNumber
);
748 /* Called by glActiveTextureARB to set current texture unit.
751 void (*UpdateTexturePalette
)( GLcontext
*ctx
,
752 struct gl_texture_object
*tObj
);
753 /* Called when the texture's color lookup table is changed.
754 * If tObj is NULL then the shared texture palette ctx->Texture.Palette
761 *** Accelerated point, line, polygon, quad and rect functions:
764 points_func PointsFunc
;
766 triangle_func TriangleFunc
;
772 *** Transformation/Rendering functions
775 void (*RenderStart
)( GLcontext
*ctx
);
776 void (*RenderFinish
)( GLcontext
*ctx
);
777 /* KW: These replace Begin and End, and have more relaxed semantics.
778 * They are called prior-to and after one or more vb flush, and are
779 * thus decoupled from the gl_begin/gl_end pairs, which are possibly
780 * more frequent. If a begin/end pair covers >1 vertex buffer, these
781 * are called at most once for the pair. (a bit broken at present)
784 void (*RasterSetup
)( struct vertex_buffer
*VB
, GLuint start
, GLuint end
);
785 /* This function, if not NULL, is called whenever new window coordinates
786 * are put in the vertex buffer. The vertices in question are those n
787 * such that start <= n < end.
788 * The device driver can convert the window coords to its own specialized
789 * format. The 3Dfx driver uses this.
791 * Note: Deprecated in favour of RegisterPipelineStages, below.
794 render_func
*RenderVBClippedTab
;
795 render_func
*RenderVBCulledTab
;
796 render_func
*RenderVBRawTab
;
797 /* These function tables allow the device driver to rasterize an
798 * entire begin/end group of primitives at once. See the
799 * gl_render_vb() function in vbrender.c for more details.
802 void (*ReducedPrimitiveChange
)( GLcontext
*ctx
, GLenum primitive
);
803 /* If registered, this will be called when rendering transitions between
804 * points, lines and triangles. It is not called on transitions between
805 * primtives such as GL_TRIANGLES and GL_TRIANGLE_STRIPS, or between
806 * triangles and quads or triangles and polygons.
809 GLboolean (*MultipassFunc
)( struct vertex_buffer
*VB
, GLuint passno
);
810 /* Driver may request additional render passes by returning GL_TRUE
811 * when this function is called. This function will be called
812 * after the first pass, and passes will be made until the function
813 * returns GL_FALSE. If no function is registered, only one pass
816 * This function will be first invoked with passno == 1.
823 void (*RegisterVB
)( struct vertex_buffer
*VB
);
824 void (*UnregisterVB
)( struct vertex_buffer
*VB
);
825 /* When Mesa creates a new vertex buffer it calls Driver.RegisterVB()
826 * so the device driver can allocate its own vertex buffer data and
827 * hook it to the VB->driver_data pointer.
828 * When Mesa destroys a vertex buffer it calls Driver.UnegisterVB()
829 * so the driver can deallocate its own data attached to VB->driver_data.
833 void (*ResetVB
)( struct vertex_buffer
*VB
);
834 void (*ResetCvaVB
)( struct vertex_buffer
*VB
, GLuint stages
);
835 /* Do any reset operations necessary to the driver data associated
836 * with these vertex buffers.
839 GLuint RenderVectorFlags
;
840 /* What do the render tables require of the vectors they deal
844 GLuint (*RegisterPipelineStages
)( struct gl_pipeline_stage
*out
,
845 const struct gl_pipeline_stage
*in
,
847 /* Register new pipeline stages, or modify existing ones. See also
848 * the OptimizePipeline() functions.
852 GLboolean (*BuildPrecalcPipeline
)( GLcontext
*ctx
);
853 GLboolean (*BuildEltPipeline
)( GLcontext
*ctx
);
854 /* Perform the full pipeline build, or return false.
858 void (*OptimizePrecalcPipeline
)( GLcontext
*ctx
, struct gl_pipeline
*pipe
);
859 void (*OptimizeImmediatePipeline
)( GLcontext
*ctx
, struct gl_pipeline
*pipe
);
860 /* Check to see if a fast path exists for this combination of stages
861 * in the precalc and immediate (elt) pipelines.
866 * State-changing functions (drawing functions are above)
868 * These functions are called by their corresponding OpenGL API functions.
869 * They're ALSO called by the gl_PopAttrib() function!!!
870 * May add more functions like these to the device driver in the future.
871 * This should reduce the amount of state checking that
872 * the driver's UpdateState() function must do.
874 void (*AlphaFunc
)(GLcontext
*ctx
, GLenum func
, GLclampf ref
);
875 void (*BlendEquation
)(GLcontext
*ctx
, GLenum mode
);
876 void (*BlendFunc
)(GLcontext
*ctx
, GLenum sfactor
, GLenum dfactor
);
877 void (*BlendFuncSeparate
)( GLcontext
*ctx
, GLenum sfactorRGB
,
878 GLenum dfactorRGB
, GLenum sfactorA
,
880 void (*ClearDepth
)(GLcontext
*ctx
, GLclampd d
);
881 void (*ColorMask
)(GLcontext
*ctx
, GLboolean rmask
, GLboolean gmask
,
882 GLboolean bmask
, GLboolean amask
);
883 void (*CullFace
)(GLcontext
*ctx
, GLenum mode
);
884 void (*FrontFace
)(GLcontext
*ctx
, GLenum mode
);
885 void (*DepthFunc
)(GLcontext
*ctx
, GLenum func
);
886 void (*DepthMask
)(GLcontext
*ctx
, GLboolean flag
);
887 void (*DepthRange
)(GLcontext
*ctx
, GLclampd nearval
, GLclampd farval
);
888 void (*Enable
)(GLcontext
* ctx
, GLenum cap
, GLboolean state
);
889 void (*Fogfv
)(GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
);
890 void (*Hint
)(GLcontext
*ctx
, GLenum target
, GLenum mode
);
891 void (*IndexMask
)(GLcontext
*ctx
, GLuint mask
);
892 void (*Lightfv
)(GLcontext
*ctx
, GLenum light
,
893 GLenum pname
, const GLfloat
*params
, GLint nparams
);
894 void (*LightModelfv
)(GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
);
895 void (*LineStipple
)(GLcontext
*ctx
, GLint factor
, GLushort pattern
);
896 void (*LineWidth
)(GLcontext
*ctx
, GLfloat width
);
897 void (*LogicOpcode
)(GLcontext
*ctx
, GLenum opcode
);
898 void (*PolygonMode
)(GLcontext
*ctx
, GLenum face
, GLenum mode
);
899 void (*PolygonStipple
)(GLcontext
*ctx
, const GLubyte
*mask
);
900 void (*Scissor
)(GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
);
901 void (*ShadeModel
)(GLcontext
*ctx
, GLenum mode
);
902 void (*ClearStencil
)(GLcontext
*ctx
, GLint s
);
903 void (*StencilFunc
)(GLcontext
*ctx
, GLenum func
, GLint ref
, GLuint mask
);
904 void (*StencilMask
)(GLcontext
*ctx
, GLuint mask
);
905 void (*StencilOp
)(GLcontext
*ctx
, GLenum fail
, GLenum zfail
, GLenum zpass
);
906 void (*Viewport
)(GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
);
908 /* State-query functions
910 * Return GL_TRUE if query was completed, GL_FALSE otherwise.
912 GLboolean (*GetBooleanv
)(GLcontext
*ctx
, GLenum pname
, GLboolean
*result
);
913 GLboolean (*GetDoublev
)(GLcontext
*ctx
, GLenum pname
, GLdouble
*result
);
914 GLboolean (*GetFloatv
)(GLcontext
*ctx
, GLenum pname
, GLfloat
*result
);
915 GLboolean (*GetIntegerv
)(GLcontext
*ctx
, GLenum pname
, GLint
*result
);
916 GLboolean (*GetPointerv
)(GLcontext
*ctx
, GLenum pname
, GLvoid
**result
);