dd.h revision 1e1aac034c986a08248861363c0baa27dc2ae2d5
1/* $Id: dd.h,v 1.40 2000/11/13 20:02:56 keithw 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/* THIS FILE ONLY INCLUDED BY types.h !!!!! */ 33 34 35struct gl_pixelstore_attrib; 36struct vertex_buffer; 37struct immediate; 38struct gl_pipeline; 39struct gl_pipeline_stage; 40 41 42 43/* 44 * Device Driver (DD) interface 45 * 46 * 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. 54 * 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. 61 * 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. 66 * 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. 73 * 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 77 * for an example. 78 * 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) 81 * for examples. 82 * 83 * 84 * Look below in the dd_function_table struct definition for descriptions 85 * of each device driver function. 86 * 87 * 88 * In the future more function pointers may be added for glReadPixels 89 * glCopyPixels, etc. 90 * 91 * 92 * Notes: 93 * ------ 94 * RGBA = red/green/blue/alpha 95 * CI = color index (color mapped mode) 96 * mono = all pixels have the same color or index 97 * 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(). 102 * 103 * IN ALL CASES: 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 106 * 107 */ 108 109 110 111 112 113 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 */ 122 123 124 125/* 126 * Device Driver function table. 127 */ 128struct dd_function_table { 129 130 /********************************************************************** 131 *** Mandatory functions: these functions must be implemented by *** 132 *** every device driver. *** 133 **********************************************************************/ 134 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. 139 */ 140 141 GLuint UpdateStateNotify; 142 /* 143 * Tell mesa exactly when to call UpdateState. This is a bitwise 144 * or of the _NEW_* flags defined in types.h. 145 */ 146 147 void (*UpdateState)( GLcontext *ctx ); 148 /* 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). 152 */ 153 154 void (*ClearIndex)( GLcontext *ctx, GLuint index ); 155 /* 156 * Called whenever glClearIndex() is called. Set the index for clearing 157 * the color buffer when in color index mode. 158 */ 159 160 void (*ClearColor)( GLcontext *ctx, GLchan red, GLchan green, 161 GLchan blue, GLchan alpha ); 162 /* 163 * Called whenever glClearColor() is called. Set the color for clearing 164 * the color buffer when in RGBA mode. 165 */ 166 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. 178 */ 179 180 void (*Index)( GLcontext *ctx, GLuint index ); 181 /* 182 * Sets current color index for drawing flat-shaded primitives. 183 * This index should also be used in the "mono" drawing functions. 184 */ 185 186 void (*Color)( GLcontext *ctx, 187 GLchan red, GLchan green, GLchan glue, GLchan alpha ); 188 /* 189 * Sets current color for drawing flat-shaded primitives. 190 * This color should also be used in the "mono" drawing functions. 191 */ 192 193 GLboolean (*SetDrawBuffer)( GLcontext *ctx, GLenum buffer ); 194 /* 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 204 * these values. 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. 211 */ 212 213 void (*SetReadBuffer)( GLcontext *ctx, GLframebuffer *colorBuffer, 214 GLenum buffer ); 215 /* 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 222 */ 223 224 void (*GetBufferSize)( GLcontext *ctx, GLuint *width, GLuint *height ); 225 /* 226 * Returns the width and height of the current color buffer. 227 */ 228 229 230 /*** 231 *** Functions for writing pixels to the frame buffer: 232 ***/ 233 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. 243 */ 244 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. 249 */ 250 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. 255 */ 256 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. 261 */ 262 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. 270 */ 271 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. 276 */ 277 278 void (*WriteCI32Pixels)( const GLcontext *ctx, 279 GLuint n, const GLint x[], const GLint y[], 280 const GLuint index[], const GLubyte mask[] ); 281 /* 282 * Write a random array of CI pixels. 283 */ 284 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. 290 */ 291 292 293 /*** 294 *** Functions to read pixels from frame buffer: 295 ***/ 296 297 void (*ReadCI32Span)( const GLcontext *ctx, 298 GLuint n, GLint x, GLint y, GLuint index[] ); 299 /* Read a horizontal run of color index pixels. 300 */ 301 302 void (*ReadRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y, 303 GLchan rgba[][4] ); 304 /* Read a horizontal run of RGBA pixels. 305 */ 306 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. 311 */ 312 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. 317 */ 318 319 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 **********************************************************************/ 327 328 void (*Finish)( GLcontext *ctx ); 329 /* 330 * This is called whenever glFinish() is called. 331 */ 332 333 void (*Flush)( GLcontext *ctx ); 334 /* 335 * This is called whenever glFlush() is called. 336 */ 337 338 void (*Error)( GLcontext *ctx ); 339 /* 340 * Called whenever an error is generated. ctx->ErrorValue contains 341 * the error value. 342 */ 343 344 void (*NearFar)( GLcontext *ctx, GLfloat nearVal, GLfloat farVal ); 345 /* 346 * Called from glFrustum and glOrtho to tell device driver the 347 * near and far clipping plane Z values. The 3Dfx driver, for example, 348 * uses this. 349 */ 350 351 352 /*** 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. 357 ***/ 358 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. 363 */ 364 365 void (*ReadDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y, 366 GLdepth depth[] ); 367 /* Read a horizontal span of values from the depth buffer. 368 */ 369 370 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. 376 */ 377 378 void (*ReadDepthPixels)( GLcontext *ctx, GLuint n, 379 const GLint x[], const GLint y[], 380 GLdepth depth[] ); 381 /* Read an array of randomly positioned depth values from the depth buffer. 382 */ 383 384 385 386 /*** 387 *** For supporting hardware stencil buffers: 388 *** Either ALL or NONE of these functions must be implemented! 389 ***/ 390 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. 396 */ 397 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. 401 */ 402 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. 410 */ 411 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. 416 */ 417 418 419 /*** 420 *** glDraw/Read/CopyPixels and glBitmap functions: 421 ***/ 422 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 431 * must do the job. 432 */ 433 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, 438 GLvoid *dest ); 439 /* Called by glReadPixels. 440 * Return GL_TRUE if operation completed, else return GL_FALSE. 441 * This function must respect all glPixelTransfer settings. 442 */ 443 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. 451 */ 452 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. 458 */ 459 460 GLboolean (*Accum)( GLcontext *ctx, GLenum op, 461 GLfloat value, GLint xpos, GLint ypos, 462 GLint width, GLint height ); 463 /* Hardware accum buffer. 464 */ 465 466 /*** 467 *** Texture mapping functions: 468 ***/ 469 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. 490 * Arguments: 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. 502 */ 503 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. 529 * Arguments: 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. 539 */ 540 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 550 * should do the job. 551 */ 552 553 GLboolean (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level, 554 GLint xoffset, 555 GLint x, GLint y, GLsizei width ); 556 GLboolean (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level, 557 GLint xoffset, GLint yoffset, 558 GLint x, GLint y, 559 GLsizei width, GLsizei height ); 560 GLboolean (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level, 561 GLint xoffset, GLint yoffset, GLint zoffset, 562 GLint x, GLint y, 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 567 * should do the job. 568 */ 569 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. 584 */ 585 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 593 * if the test fails. 594 */ 595 596 GLboolean (*CompressedTexImage1D)( GLcontext *ctx, GLenum target, 597 GLint level, GLsizei imageSize, 598 const GLvoid *data, 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, 604 const GLvoid *data, 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, 610 const GLvoid *data, 611 struct gl_texture_object *texObj, 612 struct gl_texture_image *texImage, 613 GLboolean *retainInternalCopy); 614 /* Called by glCompressedTexImage1/2/3D. 615 * Arguments: 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 623 * should do the job. 624 */ 625 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. 648 * Arguments: 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 655 * should do the job. 656 */ 657 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. 665 */ 666 667 GLint (*SpecificCompressedTexFormat)(GLcontext *ctx, 668 GLint internalFormat, 669 GLint numDimensions, 670 GLint *levelp, 671 GLsizei *widthp, 672 GLsizei *heightp, 673 GLsizei *depthp, 674 GLint *borderp, 675 GLenum *formatp, 676 GLenum *typep); 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. 681 * 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. 685 */ 686 687 GLboolean (*IsCompressedFormat)(GLcontext *ctx, GLint internalFormat); 688 /* Called to tell if a format is a compressed format. 689 */ 690 691 GLsizei (*CompressedImageSize)(GLcontext *ctx, 692 GLenum internalFormat, 693 GLuint numDimensions, 694 GLuint width, 695 GLuint height, 696 GLuint depth); 697 /* Calculate the size of a compressed image, given the image's 698 * format and dimensions. 699 */ 700 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. 709 */ 710 711 void (*TexEnv)( GLcontext *ctx, GLenum target, GLenum pname, 712 const GLfloat *param ); 713 /* Called by glTexEnv*(). 714 */ 715 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. 725 */ 726 727 void (*BindTexture)( GLcontext *ctx, GLenum target, 728 struct gl_texture_object *tObj ); 729 /* Called by glBindTexture(). 730 */ 731 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. 735 */ 736 737 GLboolean (*IsTextureResident)( GLcontext *ctx, 738 struct gl_texture_object *t ); 739 /* Called by glAreTextureResident(). 740 */ 741 742 void (*PrioritizeTexture)( GLcontext *ctx, struct gl_texture_object *t, 743 GLclampf priority ); 744 /* Called by glPrioritizeTextures(). 745 */ 746 747 void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber ); 748 /* Called by glActiveTextureARB to set current texture unit. 749 */ 750 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 755 * is to be updated. 756 */ 757 758 759 760 /*** 761 *** Accelerated point, line, polygon, quad and rect functions: 762 ***/ 763 764 points_func PointsFunc; 765 line_func LineFunc; 766 triangle_func TriangleFunc; 767 quad_func QuadFunc; 768 rect_func RectFunc; 769 770 771 /*** 772 *** Transformation/Rendering functions 773 ***/ 774 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) 782 */ 783 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. 790 * 791 * Note: Deprecated in favour of RegisterPipelineStages, below. 792 */ 793 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. 800 */ 801 802 GLboolean (*MultipassFunc)( struct vertex_buffer *VB, GLuint passno ); 803 /* Driver may request additional render passes by returning GL_TRUE 804 * when this function is called. This function will be called 805 * after the first pass, and passes will be made until the function 806 * returns GL_FALSE. If no function is registered, only one pass 807 * is made. 808 * 809 * This function will be first invoked with passno == 1. 810 */ 811 812 /*** 813 *** NEW in Mesa 3.x 814 ***/ 815 void (*LightingSpaceChange)( GLcontext *ctx ); 816 /* Notify driver that the special derived value _NeedEyeCoords has 817 * changed. 818 */ 819 820 821 void (*RegisterVB)( struct vertex_buffer *VB ); 822 void (*UnregisterVB)( struct vertex_buffer *VB ); 823 /* When Mesa creates a new vertex buffer it calls Driver.RegisterVB() 824 * so the device driver can allocate its own vertex buffer data and 825 * hook it to the VB->driver_data pointer. 826 * When Mesa destroys a vertex buffer it calls Driver.UnegisterVB() 827 * so the driver can deallocate its own data attached to VB->driver_data. 828 */ 829 830 831 void (*ResetVB)( struct vertex_buffer *VB ); 832 void (*ResetCvaVB)( struct vertex_buffer *VB, GLuint stages ); 833 /* Do any reset operations necessary to the driver data associated 834 * with these vertex buffers. 835 */ 836 837 GLuint RenderVectorFlags; 838 /* What do the render tables require of the vectors they deal 839 * with? 840 */ 841 842 GLuint (*RegisterPipelineStages)( struct gl_pipeline_stage *out, 843 const struct gl_pipeline_stage *in, 844 GLuint nr ); 845 /* Register new pipeline stages, or modify existing ones. See also 846 * the OptimizePipeline() functions. 847 */ 848 849 850 GLboolean (*BuildPrecalcPipeline)( GLcontext *ctx ); 851 GLboolean (*BuildEltPipeline)( GLcontext *ctx ); 852 /* Perform the full pipeline build, or return false. 853 */ 854 855 856 void (*OptimizePrecalcPipeline)( GLcontext *ctx, struct gl_pipeline *pipe ); 857 void (*OptimizeImmediatePipeline)( GLcontext *ctx, struct gl_pipeline *pipe); 858 /* Check to see if a fast path exists for this combination of stages 859 * in the precalc and immediate (elt) pipelines. 860 */ 861 862 863 /* 864 * State-changing functions (drawing functions are above) 865 * 866 * These functions are called by their corresponding OpenGL API functions. 867 * They're ALSO called by the gl_PopAttrib() function!!! 868 * May add more functions like these to the device driver in the future. 869 * This should reduce the amount of state checking that 870 * the driver's UpdateState() function must do. 871 */ 872 void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLclampf ref); 873 void (*BlendEquation)(GLcontext *ctx, GLenum mode); 874 void (*BlendFunc)(GLcontext *ctx, GLenum sfactor, GLenum dfactor); 875 void (*BlendFuncSeparate)( GLcontext *ctx, GLenum sfactorRGB, 876 GLenum dfactorRGB, GLenum sfactorA, 877 GLenum dfactorA ); 878 void (*ClearDepth)(GLcontext *ctx, GLclampd d); 879 void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask, 880 GLboolean bmask, GLboolean amask ); 881 void (*CullFace)(GLcontext *ctx, GLenum mode); 882 void (*FrontFace)(GLcontext *ctx, GLenum mode); 883 void (*DepthFunc)(GLcontext *ctx, GLenum func); 884 void (*DepthMask)(GLcontext *ctx, GLboolean flag); 885 void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval); 886 void (*Enable)(GLcontext* ctx, GLenum cap, GLboolean state); 887 void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params); 888 void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode); 889 void (*IndexMask)(GLcontext *ctx, GLuint mask); 890 void (*Lightfv)(GLcontext *ctx, GLenum light, 891 GLenum pname, const GLfloat *params ); 892 void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params); 893 void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern ); 894 void (*LineWidth)(GLcontext *ctx, GLfloat width); 895 void (*LogicOpcode)(GLcontext *ctx, GLenum opcode); 896 void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode); 897 void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask ); 898 void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h); 899 void (*ShadeModel)(GLcontext *ctx, GLenum mode); 900 void (*ClearStencil)(GLcontext *ctx, GLint s); 901 void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask); 902 void (*StencilMask)(GLcontext *ctx, GLuint mask); 903 void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass); 904 void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h); 905 906 /* State-query functions 907 * 908 * Return GL_TRUE if query was completed, GL_FALSE otherwise. 909 */ 910 GLboolean (*GetBooleanv)(GLcontext *ctx, GLenum pname, GLboolean *result); 911 GLboolean (*GetDoublev)(GLcontext *ctx, GLenum pname, GLdouble *result); 912 GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result); 913 GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result); 914 GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result); 915}; 916 917 918 919#endif 920 921