dd.h revision 37a6211795cfd0a4431bdb7c676acf54f29df994
1/* $Id: dd.h,v 1.33 2000/09/28 18:30:39 brianp Exp $ */ 2 3/* 4 * Mesa 3-D graphics library 5 * Version: 3.5 6 * 7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. 8 * 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: 15 * 16 * The above copyright notice and this permission notice shall be included 17 * in all copies or substantial portions of the Software. 18 * 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. 25 */ 26 27 28 29#ifndef DD_INCLUDED 30#define DD_INCLUDED 31 32 33#include "macros.h" 34 35 36struct gl_pixelstore_attrib; 37 38 39struct vertex_buffer; 40struct immediate; 41struct gl_pipeline_stage; 42 43 44/* THIS FILE ONLY INCLUDED BY types.h !!!!! */ 45 46 47/* 48 * Device Driver (DD) interface 49 * 50 * 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. 58 * 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. 65 * 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. 70 * 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. 77 * 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 81 * for an example. 82 * 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) 85 * for examples. 86 * 87 * 88 * Look below in the dd_function_table struct definition for descriptions 89 * of each device driver function. 90 * 91 * 92 * In the future more function pointers may be added for glReadPixels 93 * glCopyPixels, etc. 94 * 95 * 96 * Notes: 97 * ------ 98 * RGBA = red/green/blue/alpha 99 * CI = color index (color mapped mode) 100 * mono = all pixels have the same color or index 101 * 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(). 106 * 107 * IN ALL CASES: 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 110 * 111 */ 112 113 114 115 116/* Used by the GetParameteri device driver function */ 117#define DD_HAVE_HARDWARE_FOG 3 118 119 120 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 */ 129 130 131 132/* 133 * Device Driver function table. 134 */ 135struct dd_function_table { 136 137 /********************************************************************** 138 *** Mandatory functions: these functions must be implemented by *** 139 *** every device driver. *** 140 **********************************************************************/ 141 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. 146 */ 147 148 void (*UpdateState)( GLcontext *ctx ); 149 /* 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). 153 */ 154 155 void (*ClearIndex)( GLcontext *ctx, GLuint index ); 156 /* 157 * Called whenever glClearIndex() is called. Set the index for clearing 158 * the color buffer when in color index mode. 159 */ 160 161 void (*ClearColor)( GLcontext *ctx, GLubyte red, GLubyte green, 162 GLubyte blue, GLubyte alpha ); 163 /* 164 * Called whenever glClearColor() is called. Set the color for clearing 165 * the color buffer when in RGBA mode. 166 */ 167 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. 179 */ 180 181 void (*Index)( GLcontext *ctx, GLuint index ); 182 /* 183 * Sets current color index for drawing flat-shaded primitives. 184 * This index should also be used in the "mono" drawing functions. 185 */ 186 187 void (*Color)( GLcontext *ctx, 188 GLubyte red, GLubyte green, GLubyte glue, GLubyte alpha ); 189 /* 190 * Sets current color for drawing flat-shaded primitives. 191 * This color should also be used in the "mono" drawing functions. 192 */ 193 194 GLboolean (*SetDrawBuffer)( GLcontext *ctx, GLenum buffer ); 195 /* 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 205 * these values. 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. 212 */ 213 214 void (*SetReadBuffer)( GLcontext *ctx, GLframebuffer *colorBuffer, 215 GLenum buffer ); 216 /* 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 223 */ 224 225 void (*GetBufferSize)( GLcontext *ctx, GLuint *width, GLuint *height ); 226 /* 227 * Returns the width and height of the current color buffer. 228 */ 229 230 231 /*** 232 *** Functions for writing pixels to the frame buffer: 233 ***/ 234 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. 244 */ 245 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. 250 */ 251 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. 256 */ 257 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. 262 */ 263 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. 271 */ 272 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. 277 */ 278 279 void (*WriteCI32Pixels)( const GLcontext *ctx, 280 GLuint n, const GLint x[], const GLint y[], 281 const GLuint index[], const GLubyte mask[] ); 282 /* 283 * Write a random array of CI pixels. 284 */ 285 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. 291 */ 292 293 294 /*** 295 *** Functions to read pixels from frame buffer: 296 ***/ 297 298 void (*ReadCI32Span)( const GLcontext *ctx, 299 GLuint n, GLint x, GLint y, GLuint index[] ); 300 /* Read a horizontal run of color index pixels. 301 */ 302 303 void (*ReadRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y, 304 GLubyte rgba[][4] ); 305 /* Read a horizontal run of RGBA pixels. 306 */ 307 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. 312 */ 313 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. 318 */ 319 320 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 **********************************************************************/ 328 329 void (*Finish)( GLcontext *ctx ); 330 /* 331 * This is called whenever glFinish() is called. 332 */ 333 334 void (*Flush)( GLcontext *ctx ); 335 /* 336 * This is called whenever glFlush() is called. 337 */ 338 339 void (*Error)( GLcontext *ctx ); 340 /* 341 * Called whenever an error is generated. ctx->ErrorValue contains 342 * the error value. 343 */ 344 345 void (*NearFar)( GLcontext *ctx, GLfloat nearVal, GLfloat farVal ); 346 /* 347 * Called from glFrustum and glOrtho to tell device driver the 348 * near and far clipping plane Z values. The 3Dfx driver, for example, 349 * uses this. 350 */ 351 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 356 * 357 * DD_MAX_TEXTURES number of texture sets/stages, usually 1 358 * 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 363 * per fragment fog 364 */ 365 366 367 /*** 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. 372 ***/ 373 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. 378 */ 379 380 void (*ReadDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y, 381 GLdepth depth[] ); 382 /* Read a horizontal span of values from the depth buffer. 383 */ 384 385 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. 391 */ 392 393 void (*ReadDepthPixels)( GLcontext *ctx, GLuint n, 394 const GLint x[], const GLint y[], 395 GLdepth depth[] ); 396 /* Read an array of randomly positioned depth values from the depth buffer. 397 */ 398 399 400 401 /*** 402 *** For supporting hardware stencil buffers: 403 *** Either ALL or NONE of these functions must be implemented! 404 ***/ 405 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. 411 */ 412 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. 416 */ 417 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. 425 */ 426 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. 431 */ 432 433 434 /*** 435 *** glDraw/Read/CopyPixels and glBitmap functions: 436 ***/ 437 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 446 * must do the job. 447 */ 448 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, 453 GLvoid *dest ); 454 /* Called by glReadPixels. 455 * Return GL_TRUE if operation completed, else return GL_FALSE. 456 * This function must respect all glPixelTransfer settings. 457 */ 458 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. 466 */ 467 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. 473 */ 474 475 476 /*** 477 *** Texture mapping functions: 478 ***/ 479 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. 491 */ 492 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. 501 */ 502 503 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. 524 * Arguments: 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. 536 */ 537 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. 563 * Arguments: 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. 573 */ 574 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 584 * should do the job. 585 */ 586 587 GLboolean (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level, 588 GLint xoffset, 589 GLint x, GLint y, GLsizei width ); 590 GLboolean (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level, 591 GLint xoffset, GLint yoffset, 592 GLint x, GLint y, 593 GLsizei width, GLsizei height ); 594 GLboolean (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level, 595 GLint xoffset, GLint yoffset, GLint zoffset, 596 GLint x, GLint y, 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 601 * should do the job. 602 */ 603 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. 618 */ 619 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 627 * if the test fails. 628 */ 629 630 GLboolean (*CompressedTexImage1D)( GLcontext *ctx, GLenum target, 631 GLint level, GLsizei imageSize, 632 const GLvoid *data, 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, 638 const GLvoid *data, 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, 644 const GLvoid *data, 645 struct gl_texture_object *texObj, 646 struct gl_texture_image *texImage, 647 GLboolean *retainInternalCopy); 648 /* Called by glCompressedTexImage1/2/3D. 649 * Arguments: 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 657 * should do the job. 658 */ 659 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. 682 * Arguments: 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 689 * should do the job. 690 */ 691 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. 699 */ 700 701 GLint (*SpecificCompressedTexFormat)(GLcontext *ctx, 702 GLint internalFormat, 703 GLint numDimensions, 704 GLint *levelp, 705 GLsizei *widthp, 706 GLsizei *heightp, 707 GLsizei *depthp, 708 GLint *borderp, 709 GLenum *formatp, 710 GLenum *typep); 711 /* Called to turn a generic texture format into a specific 712 * texture format. For example, if a driver implements 713 * GL_3DFX_texture_compression_FXT1, this would map 714 * GL_COMPRESSED_RGBA_ARB to GL_COMPRESSED_RGBA_FXT1_3DFX. 715 * 716 * If the driver does not know how to handle the compressed 717 * format, then just return the generic format, and Mesa will 718 * do the right thing with it. 719 */ 720 721 GLboolean (*IsCompressedFormat)(GLcontext *ctx, GLint internalFormat); 722 /* Called to tell if a format is a compressed format. 723 */ 724 725 GLsizei (*CompressedImageSize)(GLcontext *ctx, 726 GLenum internalFormat, 727 GLuint numDimensions, 728 GLuint width, 729 GLuint height, 730 GLuint depth); 731 /* Calculate the size of a compressed image, given the image's 732 * format and dimensions. 733 */ 734 735 void (*GetCompressedTexImage)( GLcontext *ctx, GLenum target, 736 GLint lod, void *image, 737 const struct gl_texture_object *texObj, 738 struct gl_texture_image *texImage ); 739 /* Called by glGetCompressedTexImageARB. 740 * <target>, <lod>, <image> are specified by user. 741 * <texObj> is the source texture object. 742 * <texImage> is the source texture image. 743 */ 744 745 void (*TexEnv)( GLcontext *ctx, GLenum target, GLenum pname, 746 const GLfloat *param ); 747 /* Called by glTexEnv*(). 748 */ 749 750 void (*TexParameter)( GLcontext *ctx, GLenum target, 751 struct gl_texture_object *texObj, 752 GLenum pname, const GLfloat *params ); 753 /* Called by glTexParameter*(). 754 * <target> is user specified 755 * <texObj> the texture object to modify 756 * <pname> is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER, 757 * GL_TEXTURE_WRAP_[STR], or GL_TEXTURE_BORDER_COLOR. 758 * <params> is user specified. 759 */ 760 761 void (*BindTexture)( GLcontext *ctx, GLenum target, 762 struct gl_texture_object *tObj ); 763 /* Called by glBindTexture(). 764 */ 765 766 void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj ); 767 /* Called when a texture object is about to be deallocated. Driver 768 * should free anything attached to the DriverData pointers. 769 */ 770 771 GLboolean (*IsTextureResident)( GLcontext *ctx, 772 struct gl_texture_object *t ); 773 /* Called by glAreTextureResident(). 774 */ 775 776 void (*PrioritizeTexture)( GLcontext *ctx, struct gl_texture_object *t, 777 GLclampf priority ); 778 /* Called by glPrioritizeTextures(). 779 */ 780 781 void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber ); 782 /* Called by glActiveTextureARB to set current texture unit. 783 */ 784 785 void (*UpdateTexturePalette)( GLcontext *ctx, 786 struct gl_texture_object *tObj ); 787 /* Called when the texture's color lookup table is changed. 788 * If tObj is NULL then the shared texture palette ctx->Texture.Palette 789 * is to be updated. 790 */ 791 792 793 794 /*** 795 *** Accelerated point, line, polygon, quad and rect functions: 796 ***/ 797 798 points_func PointsFunc; 799 line_func LineFunc; 800 triangle_func TriangleFunc; 801 quad_func QuadFunc; 802 rect_func RectFunc; 803 804 805 /*** 806 *** Transformation/Rendering functions 807 ***/ 808 809 void (*RenderStart)( GLcontext *ctx ); 810 void (*RenderFinish)( GLcontext *ctx ); 811 /* KW: These replace Begin and End, and have more relaxed semantics. 812 * They are called prior-to and after one or more vb flush, and are 813 * thus decoupled from the gl_begin/gl_end pairs, which are possibly 814 * more frequent. If a begin/end pair covers >1 vertex buffer, these 815 * are called at most once for the pair. (a bit broken at present) 816 */ 817 818 void (*RasterSetup)( struct vertex_buffer *VB, GLuint start, GLuint end ); 819 /* This function, if not NULL, is called whenever new window coordinates 820 * are put in the vertex buffer. The vertices in question are those n 821 * such that start <= n < end. 822 * The device driver can convert the window coords to its own specialized 823 * format. The 3Dfx driver uses this. 824 * 825 * Note: Deprecated in favour of RegisterPipelineStages, below. 826 */ 827 828 render_func *RenderVBClippedTab; 829 render_func *RenderVBCulledTab; 830 render_func *RenderVBRawTab; 831 /* These function tables allow the device driver to rasterize an 832 * entire begin/end group of primitives at once. See the 833 * gl_render_vb() function in vbrender.c for more details. 834 */ 835 836 void (*ReducedPrimitiveChange)( GLcontext *ctx, GLenum primitive ); 837 /* If registered, this will be called when rendering transitions between 838 * points, lines and triangles. It is not called on transitions between 839 * primtives such as GL_TRIANGLES and GL_TRIANGLE_STRIPS, or between 840 * triangles and quads or triangles and polygons. 841 */ 842 843 GLuint TriangleCaps; 844 /* Holds a list of the reasons why we might normally want to call 845 * render_triangle, but which are in fact implemented by the 846 * driver. The FX driver sets this to DD_TRI_CULL, and will soon 847 * implement DD_TRI_OFFSET. 848 */ 849 850 GLboolean (*MultipassFunc)( struct vertex_buffer *VB, GLuint passno ); 851 /* Driver may request additional render passes by returning GL_TRUE 852 * when this function is called. This function will be called 853 * after the first pass, and passes will be made until the function 854 * returns GL_FALSE. If no function is registered, only one pass 855 * is made. 856 * 857 * This function will be first invoked with passno == 1. 858 */ 859 860 /*** 861 *** NEW in Mesa 3.x 862 ***/ 863 864 void (*RegisterVB)( struct vertex_buffer *VB ); 865 void (*UnregisterVB)( struct vertex_buffer *VB ); 866 /* When Mesa creates a new vertex buffer it calls Driver.RegisterVB() 867 * so the device driver can allocate its own vertex buffer data and 868 * hook it to the VB->driver_data pointer. 869 * When Mesa destroys a vertex buffer it calls Driver.UnegisterVB() 870 * so the driver can deallocate its own data attached to VB->driver_data. 871 */ 872 873 874 void (*ResetVB)( struct vertex_buffer *VB ); 875 void (*ResetCvaVB)( struct vertex_buffer *VB, GLuint stages ); 876 /* Do any reset operations necessary to the driver data associated 877 * with these vertex buffers. 878 */ 879 880 GLuint RenderVectorFlags; 881 /* What do the render tables require of the vectors they deal 882 * with? 883 */ 884 885 GLuint (*RegisterPipelineStages)( struct gl_pipeline_stage *out, 886 const struct gl_pipeline_stage *in, 887 GLuint nr ); 888 /* Register new pipeline stages, or modify existing ones. See also 889 * the OptimizePipeline() functions. 890 */ 891 892 893 GLboolean (*BuildPrecalcPipeline)( GLcontext *ctx ); 894 GLboolean (*BuildEltPipeline)( GLcontext *ctx ); 895 /* Perform the full pipeline build, or return false. 896 */ 897 898 899 void (*OptimizePrecalcPipeline)( GLcontext *ctx, struct gl_pipeline *pipe ); 900 void (*OptimizeImmediatePipeline)( GLcontext *ctx, struct gl_pipeline *pipe); 901 /* Check to see if a fast path exists for this combination of stages 902 * in the precalc and immediate (elt) pipelines. 903 */ 904 905 906 /* 907 * State-changing functions (drawing functions are above) 908 * 909 * These functions are called by their corresponding OpenGL API functions. 910 * They're ALSO called by the gl_PopAttrib() function!!! 911 * May add more functions like these to the device driver in the future. 912 * This should reduce the amount of state checking that 913 * the driver's UpdateState() function must do. 914 */ 915 void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLclampf ref); 916 void (*BlendEquation)(GLcontext *ctx, GLenum mode); 917 void (*BlendFunc)(GLcontext *ctx, GLenum sfactor, GLenum dfactor); 918 void (*BlendFuncSeparate)( GLcontext *ctx, GLenum sfactorRGB, 919 GLenum dfactorRGB, GLenum sfactorA, 920 GLenum dfactorA ); 921 void (*ClearDepth)(GLcontext *ctx, GLclampd d); 922 void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask, 923 GLboolean bmask, GLboolean amask ); 924 void (*CullFace)(GLcontext *ctx, GLenum mode); 925 void (*FrontFace)(GLcontext *ctx, GLenum mode); 926 void (*DepthFunc)(GLcontext *ctx, GLenum func); 927 void (*DepthMask)(GLcontext *ctx, GLboolean flag); 928 void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval); 929 void (*Enable)(GLcontext* ctx, GLenum cap, GLboolean state); 930 void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params); 931 void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode); 932 void (*IndexMask)(GLcontext *ctx, GLuint mask); 933 void (*Lightfv)(GLcontext *ctx, GLenum light, 934 GLenum pname, const GLfloat *params, GLint nparams ); 935 void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params); 936 void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern ); 937 void (*LineWidth)(GLcontext *ctx, GLfloat width); 938 void (*LogicOpcode)(GLcontext *ctx, GLenum opcode); 939 void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode); 940 void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask ); 941 void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h); 942 void (*ShadeModel)(GLcontext *ctx, GLenum mode); 943 void (*ClearStencil)(GLcontext *ctx, GLint s); 944 void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask); 945 void (*StencilMask)(GLcontext *ctx, GLuint mask); 946 void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass); 947 void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h); 948 949 /* State-query functions 950 * 951 * Return GL_TRUE if query was completed, GL_FALSE otherwise. 952 */ 953 GLboolean (*GetBooleanv)(GLcontext *ctx, GLenum pname, GLboolean *result); 954 GLboolean (*GetDoublev)(GLcontext *ctx, GLenum pname, GLdouble *result); 955 GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result); 956 GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result); 957 GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result); 958}; 959 960 961 962#endif 963 964