dd.h revision ad2ac216fa0cbebc36530bf9e5256e902710b892
1/* $Id: dd.h,v 1.43 2000/11/24 10:25:05 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 mtypes.h !!!!! */ 33 34 35struct gl_pixelstore_attrib; 36struct vertex_buffer; 37struct gl_pipeline; 38struct gl_pipeline_stage; 39 40 41 42/* 43 * Device Driver (DD) interface 44 * 45 * 46 * All device driver functions are accessed through pointers in the 47 * dd_function_table struct (defined below) which is stored in the GLcontext 48 * struct. Since the device driver is strictly accessed trough a table of 49 * function pointers we can: 50 * 1. switch between a number of different device drivers at runtime. 51 * 2. use optimized functions dependant on current rendering state or 52 * frame buffer configuration. 53 * 54 * The function pointers in the dd_function_table struct are divided into 55 * two groups: mandatory and optional. 56 * Mandatory functions have to be implemented by every device driver. 57 * Optional functions may or may not be implemented by the device driver. 58 * The optional functions provide ways to take advantage of special hardware 59 * or optimized algorithms. 60 * 61 * The function pointers in the dd_function_table struct should first be 62 * initialized in the driver's "MakeCurrent" function. The "MakeCurrent" 63 * function is a little different in each device driver. See the X/Mesa, 64 * GLX, or OS/Mesa drivers for examples. 65 * 66 * Later, Mesa may call the dd_function_table's UpdateState() function. 67 * This function should initialize the dd_function_table's pointers again. 68 * The UpdateState() function is called whenever the core (GL) rendering 69 * state is changed in a way which may effect rasterization. For example, 70 * the TriangleFunc() pointer may have to point to different functions 71 * depending on whether smooth or flat shading is enabled. 72 * 73 * Note that the first argument to every device driver function is a 74 * GLcontext *. In turn, the GLcontext->DriverCtx pointer points to 75 * the driver-specific context struct. See the X/Mesa or OS/Mesa interface 76 * for an example. 77 * 78 * For more information about writing a device driver see the ddsample.c 79 * file and other device drivers (X/xmesa[1234].c, OSMesa/osmesa.c, etc) 80 * for examples. 81 * 82 * 83 * Look below in the dd_function_table struct definition for descriptions 84 * of each device driver function. 85 * 86 * 87 * In the future more function pointers may be added for glReadPixels 88 * glCopyPixels, etc. 89 * 90 * 91 * Notes: 92 * ------ 93 * RGBA = red/green/blue/alpha 94 * CI = color index (color mapped mode) 95 * mono = all pixels have the same color or index 96 * 97 * The write_ functions all take an array of mask flags which indicate 98 * whether or not the pixel should be written. One special case exists 99 * in the write_color_span function: if the mask array is NULL, then 100 * draw all pixels. This is an optimization used for glDrawPixels(). 101 * 102 * IN ALL CASES: 103 * X coordinates start at 0 at the left and increase to the right 104 * Y coordinates start at 0 at the bottom and increase upward 105 * 106 */ 107 108 109 110 111 112 113/* Mask bits sent to the driver Clear() function */ 114#define DD_FRONT_LEFT_BIT FRONT_LEFT_BIT /* 1 */ 115#define DD_FRONT_RIGHT_BIT FRONT_RIGHT_BIT /* 2 */ 116#define DD_BACK_LEFT_BIT BACK_LEFT_BIT /* 4 */ 117#define DD_BACK_RIGHT_BIT BACK_RIGHT_BIT /* 8 */ 118#define DD_DEPTH_BIT GL_DEPTH_BUFFER_BIT /* 0x00000100 */ 119#define DD_STENCIL_BIT GL_STENCIL_BUFFER_BIT /* 0x00000400 */ 120#define DD_ACCUM_BIT GL_ACCUM_BUFFER_BIT /* 0x00000200 */ 121 122 123 124 125 126 127 128/* Point, line, triangle, quadrilateral and rectangle rasterizer 129 * functions. These are specific to the tnl module and will shortly 130 * move to a driver interface specific to that module. 131 */ 132typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last ); 133 134typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ); 135 136typedef void (*triangle_func)( GLcontext *ctx, 137 GLuint v1, GLuint v2, GLuint v3, GLuint pv ); 138 139typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2, 140 GLuint v3, GLuint v4, GLuint pv ); 141 142typedef void (*render_func)( struct vertex_buffer *VB, 143 GLuint start, 144 GLuint count, 145 GLuint parity ); 146 147 148/* 149 * Device Driver function table. 150 */ 151struct dd_function_table { 152 153 /********************************************************************** 154 *** Mandatory functions: these functions must be implemented by *** 155 *** every device driver. *** 156 **********************************************************************/ 157 158 const GLubyte * (*GetString)( GLcontext *ctx, GLenum name ); 159 /* Return a string as needed by glGetString(). 160 * Only the GL_RENDERER token must be implemented. Otherwise, 161 * NULL can be returned. 162 */ 163 164 void (*UpdateState)( GLcontext *ctx ); 165 /* 166 * UpdateState() is called whenver Mesa thinks the device driver should 167 * update its state and/or the other pointers (such as PointsFunc, 168 * LineFunc, or TriangleFunc). 169 */ 170 171 void (*ClearIndex)( GLcontext *ctx, GLuint index ); 172 /* 173 * Called whenever glClearIndex() is called. Set the index for clearing 174 * the color buffer when in color index mode. 175 */ 176 177 void (*ClearColor)( GLcontext *ctx, GLchan red, GLchan green, 178 GLchan blue, GLchan alpha ); 179 /* 180 * Called whenever glClearColor() is called. Set the color for clearing 181 * the color buffer when in RGBA mode. 182 */ 183 184 GLbitfield (*Clear)( GLcontext *ctx, GLbitfield mask, GLboolean all, 185 GLint x, GLint y, GLint width, GLint height ); 186 /* Clear the color/depth/stencil/accum buffer(s). 187 * 'mask' is a bitmask of the DD_*_BIT values defined above that indicates 188 * which buffers need to be cleared. The driver should clear those 189 * buffers then return a new bitmask indicating which buffers should be 190 * cleared by software Mesa. 191 * If 'all' is true then the clear the whole buffer, else clear only the 192 * region defined by (x,y,width,height). 193 * This function must obey the glColorMask, glIndexMask and glStencilMask 194 * settings! Software Mesa can do masked clears if the device driver can't. 195 */ 196 197 GLboolean (*SetDrawBuffer)( GLcontext *ctx, GLenum buffer ); 198 /* 199 * Specifies the current buffer for writing. 200 * The following values must be accepted when applicable: 201 * GL_FRONT_LEFT - this buffer always exists 202 * GL_BACK_LEFT - when double buffering 203 * GL_FRONT_RIGHT - when using stereo 204 * GL_BACK_RIGHT - when using stereo and double buffering 205 * The folowing values may optionally be accepted. Return GL_TRUE 206 * if accepted, GL_FALSE if not accepted. In practice, only drivers 207 * which can write to multiple color buffers at once should accept 208 * these values. 209 * GL_FRONT - write to front left and front right if it exists 210 * GL_BACK - write to back left and back right if it exists 211 * GL_LEFT - write to front left and back left if it exists 212 * GL_RIGHT - write to right left and back right if they exist 213 * GL_FRONT_AND_BACK - write to all four buffers if they exist 214 * GL_NONE - disable buffer write in device driver. 215 */ 216 217 void (*SetReadBuffer)( GLcontext *ctx, GLframebuffer *colorBuffer, 218 GLenum buffer ); 219 /* 220 * Specifies the current buffer for reading. 221 * colorBuffer will be one of: 222 * GL_FRONT_LEFT - this buffer always exists 223 * GL_BACK_LEFT - when double buffering 224 * GL_FRONT_RIGHT - when using stereo 225 * GL_BACK_RIGHT - when using stereo and double buffering 226 */ 227 228 void (*GetBufferSize)( GLcontext *ctx, GLuint *width, GLuint *height ); 229 /* 230 * Returns the width and height of the current color buffer. 231 */ 232 233 234 /*** 235 *** Functions for writing pixels to the frame buffer: 236 ***/ 237 238 void (*WriteRGBASpan)( const GLcontext *ctx, 239 GLuint n, GLint x, GLint y, 240 CONST GLchan rgba[][4], const GLubyte mask[] ); 241 void (*WriteRGBSpan)( const GLcontext *ctx, 242 GLuint n, GLint x, GLint y, 243 CONST GLchan rgb[][3], const GLubyte mask[] ); 244 /* Write a horizontal run of RGBA or RGB pixels. 245 * If mask is NULL, draw all pixels. 246 * If mask is not null, only draw pixel [i] when mask [i] is true. 247 */ 248 249 void (*WriteMonoRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y, 250 const GLchan color[4], const GLubyte mask[] ); 251 /* Write a horizontal run of RGBA pixels all with the same color. 252 */ 253 254 void (*WriteRGBAPixels)( const GLcontext *ctx, 255 GLuint n, const GLint x[], const GLint y[], 256 CONST GLchan rgba[][4], const GLubyte mask[] ); 257 /* Write array of RGBA pixels at random locations. 258 */ 259 260 void (*WriteMonoRGBAPixels)( const GLcontext *ctx, 261 GLuint n, const GLint x[], const GLint y[], 262 const GLchan color[4], const GLubyte mask[] ); 263 /* Write an array of mono-RGBA pixels at random locations. 264 */ 265 266 void (*WriteCI32Span)( const GLcontext *ctx, GLuint n, GLint x, GLint y, 267 const GLuint index[], const GLubyte mask[] ); 268 void (*WriteCI8Span)( const GLcontext *ctx, GLuint n, GLint x, GLint y, 269 const GLubyte index[], const GLubyte mask[] ); 270 /* Write a horizontal run of CI pixels. One function is for 32bpp 271 * indexes and the other for 8bpp pixels (the common case). You mus 272 * implement both for color index mode. 273 */ 274 275 void (*WriteMonoCISpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y, 276 GLuint colorIndex, const GLubyte mask[] ); 277 /* Write a horizontal run of color index pixels using the color index 278 * last specified by the Index() function. 279 */ 280 281 void (*WriteCI32Pixels)( const GLcontext *ctx, 282 GLuint n, const GLint x[], const GLint y[], 283 const GLuint index[], const GLubyte mask[] ); 284 /* 285 * Write a random array of CI pixels. 286 */ 287 288 void (*WriteMonoCIPixels)( const GLcontext *ctx, 289 GLuint n, const GLint x[], const GLint y[], 290 GLuint colorIndex, const GLubyte mask[] ); 291 /* Write a random array of color index pixels using the color index 292 * last specified by the Index() function. 293 */ 294 295 296 /*** 297 *** Functions to read pixels from frame buffer: 298 ***/ 299 300 void (*ReadCI32Span)( const GLcontext *ctx, 301 GLuint n, GLint x, GLint y, GLuint index[] ); 302 /* Read a horizontal run of color index pixels. 303 */ 304 305 void (*ReadRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y, 306 GLchan rgba[][4] ); 307 /* Read a horizontal run of RGBA pixels. 308 */ 309 310 void (*ReadCI32Pixels)( const GLcontext *ctx, 311 GLuint n, const GLint x[], const GLint y[], 312 GLuint indx[], const GLubyte mask[] ); 313 /* Read a random array of CI pixels. 314 */ 315 316 void (*ReadRGBAPixels)( const GLcontext *ctx, 317 GLuint n, const GLint x[], const GLint y[], 318 GLchan rgba[][4], const GLubyte mask[] ); 319 /* Read a random array of RGBA pixels. 320 */ 321 322 323 /********************************************************************** 324 *** Optional functions: these functions may or may not be *** 325 *** implemented by the device driver. If the device driver *** 326 *** doesn't implement them it should never touch these pointers *** 327 *** since Mesa will either set them to NULL or point them at a *** 328 *** fall-back function. *** 329 **********************************************************************/ 330 331 void (*Finish)( GLcontext *ctx ); 332 /* 333 * This is called whenever glFinish() is called. 334 */ 335 336 void (*Flush)( GLcontext *ctx ); 337 /* 338 * This is called whenever glFlush() is called. 339 */ 340 341 void (*Error)( GLcontext *ctx ); 342 /* 343 * Called whenever an error is generated. ctx->ErrorValue contains 344 * the error value. 345 */ 346 347 348 /*** 349 *** For supporting hardware Z buffers: 350 *** Either ALL or NONE of these functions must be implemented! 351 *** NOTE that Each depth value is a 32-bit GLuint. If the depth 352 *** buffer is less than 32 bits deep then the extra upperbits are zero. 353 ***/ 354 355 void (*WriteDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y, 356 const GLdepth depth[], const GLubyte mask[] ); 357 /* Write a horizontal span of values into the depth buffer. Only write 358 * depth[i] value if mask[i] is nonzero. 359 */ 360 361 void (*ReadDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y, 362 GLdepth depth[] ); 363 /* Read a horizontal span of values from the depth buffer. 364 */ 365 366 367 void (*WriteDepthPixels)( GLcontext *ctx, GLuint n, 368 const GLint x[], const GLint y[], 369 const GLdepth depth[], const GLubyte mask[] ); 370 /* Write an array of randomly positioned depth values into the 371 * depth buffer. Only write depth[i] value if mask[i] is nonzero. 372 */ 373 374 void (*ReadDepthPixels)( GLcontext *ctx, GLuint n, 375 const GLint x[], const GLint y[], 376 GLdepth depth[] ); 377 /* Read an array of randomly positioned depth values from the depth buffer. 378 */ 379 380 381 382 /*** 383 *** For supporting hardware stencil buffers: 384 *** Either ALL or NONE of these functions must be implemented! 385 ***/ 386 387 void (*WriteStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y, 388 const GLstencil stencil[], const GLubyte mask[] ); 389 /* Write a horizontal span of stencil values into the stencil buffer. 390 * If mask is NULL, write all stencil values. 391 * Else, only write stencil[i] if mask[i] is non-zero. 392 */ 393 394 void (*ReadStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y, 395 GLstencil stencil[] ); 396 /* Read a horizontal span of stencil values from the stencil buffer. 397 */ 398 399 void (*WriteStencilPixels)( GLcontext *ctx, GLuint n, 400 const GLint x[], const GLint y[], 401 const GLstencil stencil[], 402 const GLubyte mask[] ); 403 /* Write an array of stencil values into the stencil buffer. 404 * If mask is NULL, write all stencil values. 405 * Else, only write stencil[i] if mask[i] is non-zero. 406 */ 407 408 void (*ReadStencilPixels)( GLcontext *ctx, GLuint n, 409 const GLint x[], const GLint y[], 410 GLstencil stencil[] ); 411 /* Read an array of stencil values from the stencil buffer. 412 */ 413 414 415 /*** 416 *** glDraw/Read/CopyPixels and glBitmap functions: 417 ***/ 418 419 GLboolean (*DrawPixels)( GLcontext *ctx, 420 GLint x, GLint y, GLsizei width, GLsizei height, 421 GLenum format, GLenum type, 422 const struct gl_pixelstore_attrib *unpack, 423 const GLvoid *pixels ); 424 /* This is called by glDrawPixels. 425 * 'unpack' describes how to unpack the source image data. 426 * Return GL_TRUE if the driver succeeds, return GL_FALSE if core Mesa 427 * must do the job. 428 */ 429 430 GLboolean (*ReadPixels)( GLcontext *ctx, 431 GLint x, GLint y, GLsizei width, GLsizei height, 432 GLenum format, GLenum type, 433 const struct gl_pixelstore_attrib *unpack, 434 GLvoid *dest ); 435 /* Called by glReadPixels. 436 * Return GL_TRUE if operation completed, else return GL_FALSE. 437 * This function must respect all glPixelTransfer settings. 438 */ 439 440 GLboolean (*CopyPixels)( GLcontext *ctx, 441 GLint srcx, GLint srcy, 442 GLsizei width, GLsizei height, 443 GLint dstx, GLint dsty, GLenum type ); 444 /* Do a glCopyPixels. Return GL_TRUE if operation completed, else 445 * return GL_FALSE. This function must respect all rasterization 446 * state, glPixelTransfer, glPixelZoom, etc. 447 */ 448 449 GLboolean (*Bitmap)( GLcontext *ctx, 450 GLint x, GLint y, GLsizei width, GLsizei height, 451 const struct gl_pixelstore_attrib *unpack, 452 const GLubyte *bitmap ); 453 /* This is called by glBitmap. Works the same as DrawPixels, above. 454 */ 455 456 GLboolean (*Accum)( GLcontext *ctx, GLenum op, 457 GLfloat value, GLint xpos, GLint ypos, 458 GLint width, GLint height ); 459 /* Hardware accum buffer. 460 */ 461 462 /*** 463 *** Texture mapping functions: 464 ***/ 465 466 GLboolean (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level, 467 GLenum format, GLenum type, const GLvoid *pixels, 468 const struct gl_pixelstore_attrib *packing, 469 struct gl_texture_object *texObj, 470 struct gl_texture_image *texImage, 471 GLboolean *retainInternalCopy ); 472 GLboolean (*TexImage2D)( GLcontext *ctx, GLenum target, GLint level, 473 GLenum format, GLenum type, const GLvoid *pixels, 474 const struct gl_pixelstore_attrib *packing, 475 struct gl_texture_object *texObj, 476 struct gl_texture_image *texImage, 477 GLboolean *retainInternalCopy ); 478 GLboolean (*TexImage3D)( GLcontext *ctx, GLenum target, GLint level, 479 GLenum format, GLenum type, const GLvoid *pixels, 480 const struct gl_pixelstore_attrib *packing, 481 struct gl_texture_object *texObj, 482 struct gl_texture_image *texImage, 483 GLboolean *retainInternalCopy ); 484 /* Called by glTexImage1/2/3D. 485 * Will not be called if any glPixelTransfer operations are enabled. 486 * Arguments: 487 * <target>, <level>, <format>, <type> and <pixels> are user specified. 488 * <packing> indicates the image packing of pixels. 489 * <texObj> is the target texture object. 490 * <texImage> is the target texture image. It will have the texture 491 * width, height, depth, border and internalFormat information. 492 * <retainInternalCopy> is returned by this function and indicates whether 493 * core Mesa should keep an internal copy of the texture image. 494 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa 495 * should do the job. If GL_FALSE is returned, this function will be 496 * called a second time after the texture image has been unpacked into 497 * GLubytes. It may be easier for the driver to handle then. 498 */ 499 500 GLboolean (*TexSubImage1D)( GLcontext *ctx, GLenum target, GLint level, 501 GLint xoffset, GLsizei width, 502 GLenum format, GLenum type, 503 const GLvoid *pixels, 504 const struct gl_pixelstore_attrib *packing, 505 struct gl_texture_object *texObj, 506 struct gl_texture_image *texImage ); 507 GLboolean (*TexSubImage2D)( GLcontext *ctx, GLenum target, GLint level, 508 GLint xoffset, GLint yoffset, 509 GLsizei width, GLsizei height, 510 GLenum format, GLenum type, 511 const GLvoid *pixels, 512 const struct gl_pixelstore_attrib *packing, 513 struct gl_texture_object *texObj, 514 struct gl_texture_image *texImage ); 515 GLboolean (*TexSubImage3D)( GLcontext *ctx, GLenum target, GLint level, 516 GLint xoffset, GLint yoffset, GLint zoffset, 517 GLsizei width, GLsizei height, GLint depth, 518 GLenum format, GLenum type, 519 const GLvoid *pixels, 520 const struct gl_pixelstore_attrib *packing, 521 struct gl_texture_object *texObj, 522 struct gl_texture_image *texImage ); 523 /* Called by glTexSubImage1/2/3D. 524 * Will not be called if any glPixelTransfer operations are enabled. 525 * Arguments: 526 * <target>, <level>, <xoffset>, <yoffset>, <zoffset>, <width>, <height>, 527 * <depth>, <format>, <type> and <pixels> are user specified. 528 * <packing> indicates the image packing of pixels. 529 * <texObj> is the target texture object. 530 * <texImage> is the target texture image. It will have the texture 531 * width, height, border and internalFormat information. 532 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa 533 * should do the job. If GL_FALSE is returned, then TexImage1/2/3D will 534 * be called with the complete texture image. 535 */ 536 537 GLboolean (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level, 538 GLenum internalFormat, GLint x, GLint y, 539 GLsizei width, GLint border ); 540 GLboolean (*CopyTexImage2D)( GLcontext *ctx, GLenum target, GLint level, 541 GLenum internalFormat, GLint x, GLint y, 542 GLsizei width, GLsizei height, GLint border ); 543 /* Called by glCopyTexImage1D and glCopyTexImage2D. 544 * Will not be called if any glPixelTransfer operations are enabled. 545 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa 546 * should do the job. 547 */ 548 549 GLboolean (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level, 550 GLint xoffset, 551 GLint x, GLint y, GLsizei width ); 552 GLboolean (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level, 553 GLint xoffset, GLint yoffset, 554 GLint x, GLint y, 555 GLsizei width, GLsizei height ); 556 GLboolean (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level, 557 GLint xoffset, GLint yoffset, GLint zoffset, 558 GLint x, GLint y, 559 GLsizei width, GLsizei height ); 560 /* Called by glCopyTexSubImage1/2/3D. 561 * Will not be called if any glPixelTransfer operations are enabled. 562 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa 563 * should do the job. 564 */ 565 566 GLvoid *(*GetTexImage)( GLcontext *ctx, GLenum target, GLint level, 567 const struct gl_texture_object *texObj, 568 GLenum *formatOut, GLenum *typeOut, 569 GLboolean *freeImageOut ); 570 /* Called by glGetTexImage or by core Mesa when a texture image 571 * is needed for software fallback rendering. 572 * Return the address of the texture image or NULL if failure. 573 * The image must be tightly packed (i.e. row stride = image width) 574 * Return the image's format and type in formatOut and typeOut. 575 * The format and type must be values which are accepted by glTexImage. 576 * Set the freeImageOut flag if the returned image should be deallocated 577 * with FREE() when finished. 578 * The size of the image can be deduced from the target and level. 579 * Core Mesa will perform any image format/type conversions that are needed. 580 */ 581 582 GLboolean (*TestProxyTexImage)(GLcontext *ctx, GLenum target, 583 GLint level, GLint internalFormat, 584 GLenum format, GLenum type, 585 GLint width, GLint height, 586 GLint depth, GLint border); 587 /* Called by glTexImage[123]D when user specifies a proxy texture 588 * target. Return GL_TRUE if the proxy test passes, return GL_FALSE 589 * if the test fails. 590 */ 591 592 GLboolean (*CompressedTexImage1D)( GLcontext *ctx, GLenum target, 593 GLint level, GLsizei imageSize, 594 const GLvoid *data, 595 struct gl_texture_object *texObj, 596 struct gl_texture_image *texImage, 597 GLboolean *retainInternalCopy); 598 GLboolean (*CompressedTexImage2D)( GLcontext *ctx, GLenum target, 599 GLint level, GLsizei imageSize, 600 const GLvoid *data, 601 struct gl_texture_object *texObj, 602 struct gl_texture_image *texImage, 603 GLboolean *retainInternalCopy); 604 GLboolean (*CompressedTexImage3D)( GLcontext *ctx, GLenum target, 605 GLint level, GLsizei imageSize, 606 const GLvoid *data, 607 struct gl_texture_object *texObj, 608 struct gl_texture_image *texImage, 609 GLboolean *retainInternalCopy); 610 /* Called by glCompressedTexImage1/2/3D. 611 * Arguments: 612 * <target>, <level>, <internalFormat>, <data> are user specified. 613 * <texObj> is the target texture object. 614 * <texImage> is the target texture image. It will have the texture 615 * width, height, depth, border and internalFormat information. 616 * <retainInternalCopy> is returned by this function and indicates whether 617 * core Mesa should keep an internal copy of the texture image. 618 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa 619 * should do the job. 620 */ 621 622 GLboolean (*CompressedTexSubImage1D)( GLcontext *ctx, GLenum target, 623 GLint level, GLint xoffset, 624 GLsizei width, GLenum format, 625 GLsizei imageSize, const GLvoid *data, 626 struct gl_texture_object *texObj, 627 struct gl_texture_image *texImage ); 628 GLboolean (*CompressedTexSubImage2D)( GLcontext *ctx, GLenum target, 629 GLint level, GLint xoffset, 630 GLint yoffset, GLsizei width, 631 GLint height, GLenum format, 632 GLsizei imageSize, const GLvoid *data, 633 struct gl_texture_object *texObj, 634 struct gl_texture_image *texImage ); 635 GLboolean (*CompressedTexSubImage3D)( GLcontext *ctx, GLenum target, 636 GLint level, GLint xoffset, 637 GLint yoffset, GLint zoffset, 638 GLsizei width, GLint height, 639 GLint depth, GLenum format, 640 GLsizei imageSize, const GLvoid *data, 641 struct gl_texture_object *texObj, 642 struct gl_texture_image *texImage ); 643 /* Called by glCompressedTexSubImage1/2/3D. 644 * Arguments: 645 * <target>, <level>, <x/z/zoffset>, <width>, <height>, <depth>, 646 * <imageSize>, and <data> are user specified. 647 * <texObj> is the target texture object. 648 * <texImage> is the target texture image. It will have the texture 649 * width, height, depth, border and internalFormat information. 650 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa 651 * should do the job. 652 */ 653 654 GLint (*BaseCompressedTexFormat)(GLcontext *ctx, 655 GLint internalFormat); 656 /* Called to compute the base format for a specific compressed 657 * format. Return -1 if the internalFormat is not a specific 658 * compressed format that the driver recognizes. Note the 659 * return value differences between this function and 660 * SpecificCompressedTexFormat below. 661 */ 662 663 GLint (*SpecificCompressedTexFormat)(GLcontext *ctx, 664 GLint internalFormat, 665 GLint numDimensions, 666 GLint *levelp, 667 GLsizei *widthp, 668 GLsizei *heightp, 669 GLsizei *depthp, 670 GLint *borderp, 671 GLenum *formatp, 672 GLenum *typep); 673 /* Called to turn a generic texture format into a specific 674 * texture format. For example, if a driver implements 675 * GL_3DFX_texture_compression_FXT1, this would map 676 * GL_COMPRESSED_RGBA_ARB to GL_COMPRESSED_RGBA_FXT1_3DFX. 677 * 678 * If the driver does not know how to handle the compressed 679 * format, then just return the generic format, and Mesa will 680 * do the right thing with it. 681 */ 682 683 GLboolean (*IsCompressedFormat)(GLcontext *ctx, GLint internalFormat); 684 /* Called to tell if a format is a compressed format. 685 */ 686 687 GLsizei (*CompressedImageSize)(GLcontext *ctx, 688 GLenum internalFormat, 689 GLuint numDimensions, 690 GLuint width, 691 GLuint height, 692 GLuint depth); 693 /* Calculate the size of a compressed image, given the image's 694 * format and dimensions. 695 */ 696 697 void (*GetCompressedTexImage)( GLcontext *ctx, GLenum target, 698 GLint lod, void *image, 699 const struct gl_texture_object *texObj, 700 struct gl_texture_image *texImage ); 701 /* Called by glGetCompressedTexImageARB. 702 * <target>, <lod>, <image> are specified by user. 703 * <texObj> is the source texture object. 704 * <texImage> is the source texture image. 705 */ 706 707 void (*TexEnv)( GLcontext *ctx, GLenum target, GLenum pname, 708 const GLfloat *param ); 709 /* Called by glTexEnv*(). 710 */ 711 712 void (*TexParameter)( GLcontext *ctx, GLenum target, 713 struct gl_texture_object *texObj, 714 GLenum pname, const GLfloat *params ); 715 /* Called by glTexParameter*(). 716 * <target> is user specified 717 * <texObj> the texture object to modify 718 * <pname> is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER, 719 * GL_TEXTURE_WRAP_[STR], or GL_TEXTURE_BORDER_COLOR. 720 * <params> is user specified. 721 */ 722 723 void (*BindTexture)( GLcontext *ctx, GLenum target, 724 struct gl_texture_object *tObj ); 725 /* Called by glBindTexture(). 726 */ 727 728 void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj ); 729 /* Called when a texture object is about to be deallocated. Driver 730 * should free anything attached to the DriverData pointers. 731 */ 732 733 GLboolean (*IsTextureResident)( GLcontext *ctx, 734 struct gl_texture_object *t ); 735 /* Called by glAreTextureResident(). 736 */ 737 738 void (*PrioritizeTexture)( GLcontext *ctx, struct gl_texture_object *t, 739 GLclampf priority ); 740 /* Called by glPrioritizeTextures(). 741 */ 742 743 void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber ); 744 /* Called by glActiveTextureARB to set current texture unit. 745 */ 746 747 void (*UpdateTexturePalette)( GLcontext *ctx, 748 struct gl_texture_object *tObj ); 749 /* Called when the texture's color lookup table is changed. 750 * If tObj is NULL then the shared texture palette ctx->Texture.Palette 751 * is to be updated. 752 */ 753 754 755 756 /*** 757 *** Accelerated point, line, polygon and quad functions: 758 ***/ 759 760 points_func PointsFunc; 761 line_func LineFunc; 762 triangle_func TriangleFunc; 763 quad_func QuadFunc; 764 765 766 /*** 767 *** Transformation/Rendering functions 768 ***/ 769 770 void (*RenderStart)( GLcontext *ctx ); 771 void (*RenderFinish)( GLcontext *ctx ); 772 /* KW: These replace Begin and End, and have more relaxed semantics. 773 * They are called prior-to and after one or more vb flush, and are 774 * thus decoupled from the gl_begin/gl_end pairs, which are possibly 775 * more frequent. If a begin/end pair covers >1 vertex buffer, these 776 * are called at most once for the pair. (a bit broken at present) 777 */ 778 779 void (*RasterSetup)( struct vertex_buffer *VB, GLuint start, GLuint end ); 780 /* This function, if not NULL, is called whenever new window coordinates 781 * are put in the vertex buffer. The vertices in question are those n 782 * such that start <= n < end. 783 * The device driver can convert the window coords to its own specialized 784 * format. The 3Dfx driver uses this. 785 * 786 * Note: Deprecated in favour of RegisterPipelineStages, below. 787 */ 788 789 render_func *RenderVBClippedTab; 790 render_func *RenderVBCulledTab; 791 render_func *RenderVBRawTab; 792 /* These function tables allow the device driver to rasterize an 793 * entire begin/end group of primitives at once. See the 794 * gl_render_vb() function in vbrender.c for more details. 795 */ 796 797 GLboolean (*MultipassFunc)( struct vertex_buffer *VB, GLuint passno ); 798 /* Driver may request additional render passes by returning GL_TRUE 799 * when this function is called. This function will be called 800 * after the first pass, and passes will be made until the function 801 * returns GL_FALSE. If no function is registered, only one pass 802 * is made. 803 * 804 * This function will be first invoked with passno == 1. 805 */ 806 807 /*** 808 *** NEW in Mesa 3.x 809 ***/ 810 811 void (*RegisterVB)( struct vertex_buffer *VB ); 812 void (*UnregisterVB)( struct vertex_buffer *VB ); 813 /* When Mesa creates a new vertex buffer it calls Driver.RegisterVB() 814 * so the device driver can allocate its own vertex buffer data and 815 * hook it to the VB->driver_data pointer. 816 * When Mesa destroys a vertex buffer it calls Driver.UnegisterVB() 817 * so the driver can deallocate its own data attached to VB->driver_data. 818 */ 819 820 821 822 GLboolean (*BuildPrecalcPipeline)( GLcontext *ctx ); 823 GLboolean (*BuildEltPipeline)( GLcontext *ctx ); 824 /* Perform the full pipeline build, or return false. 825 */ 826 827 828 /*** 829 *** Support for multiple t&l engines 830 ***/ 831 832#define FLUSH_INSIDE_BEGIN_END 0x1 833#define FLUSH_STORED_VERTICES 0x2 834#define FLUSH_UPDATE_CURRENT 0x4 835 836 GLuint NeedFlush; 837 /* Set by the driver-supplied t&l engine. 838 * Bitflags defined above are set whenever 839 * - the engine *might* be inside a begin/end object. 840 * - there *might* be buffered vertices to be flushed. 841 * - the ctx->Current values *might* not be uptodate. 842 * 843 * The FlushVertices() call below may be used to resolve 844 * these conditions. 845 */ 846 847 GLboolean (*FlushVertices)( GLcontext *ctx, GLuint flags ); 848 /* If inside begin/end, returns GL_FALSE. 849 * Otherwise, 850 * if (flags & FLUSH_STORED_VERTICES) flushes any buffered vertices, 851 * if (flags & FLUSH_UPDATE_CURRENT) updates ctx->Current, 852 * returns GL_TRUE. 853 * 854 * Note that the default t&l engine never clears the 855 * FLUSH_UPDATE_CURRENT bit, even after performing the update. 856 */ 857 858 void (*LightingSpaceChange)( GLcontext *ctx ); 859 /* Notify driver that the special derived value _NeedEyeCoords has 860 * changed. 861 */ 862 863 void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode ); 864 void (*EndList)( GLcontext *ctx ); 865 /* Let the t&l component know what is going on with display lists 866 * in time to make changes to dispatch tables, etc. 867 */ 868 869 void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer, 870 GLframebuffer *readBuffer ); 871 /* Let the t&l component know when the context becomes current. 872 */ 873 874 875 void (*LockArraysEXT)( GLcontext *ctx, GLint first, GLsizei count ); 876 void (*UnlockArraysEXT)( GLcontext *ctx ); 877 /* 878 */ 879 880 881 /* 882 * State-changing functions (drawing functions are above) 883 * 884 * These functions are called by their corresponding OpenGL API functions. 885 * They're ALSO called by the gl_PopAttrib() function!!! 886 * May add more functions like these to the device driver in the future. 887 * This should reduce the amount of state checking that 888 * the driver's UpdateState() function must do. 889 */ 890 void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLclampf ref); 891 void (*BlendEquation)(GLcontext *ctx, GLenum mode); 892 void (*BlendFunc)(GLcontext *ctx, GLenum sfactor, GLenum dfactor); 893 void (*BlendFuncSeparate)( GLcontext *ctx, GLenum sfactorRGB, 894 GLenum dfactorRGB, GLenum sfactorA, 895 GLenum dfactorA ); 896 void (*ClearDepth)(GLcontext *ctx, GLclampd d); 897 void (*ClearStencil)(GLcontext *ctx, GLint s); 898 void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask, 899 GLboolean bmask, GLboolean amask ); 900 void (*CullFace)(GLcontext *ctx, GLenum mode); 901 void (*ClipPlane)(GLcontext *ctx, GLenum plane, const GLfloat *equation ); 902 void (*FrontFace)(GLcontext *ctx, GLenum mode); 903 void (*DepthFunc)(GLcontext *ctx, GLenum func); 904 void (*DepthMask)(GLcontext *ctx, GLboolean flag); 905 void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval); 906 void (*Enable)(GLcontext* ctx, GLenum cap, GLboolean state); 907 void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params); 908 void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode); 909 void (*IndexMask)(GLcontext *ctx, GLuint mask); 910 void (*Lightfv)(GLcontext *ctx, GLenum light, 911 GLenum pname, const GLfloat *params ); 912 void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params); 913 void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern ); 914 void (*LineWidth)(GLcontext *ctx, GLfloat width); 915 void (*LogicOpcode)(GLcontext *ctx, GLenum opcode); 916 void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode); 917 void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask ); 918 void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h); 919 void (*ShadeModel)(GLcontext *ctx, GLenum mode); 920 void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask); 921 void (*StencilMask)(GLcontext *ctx, GLuint mask); 922 void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass); 923 void (*TexGen)(GLcontext *ctx, GLenum coord, GLenum pname, 924 const GLfloat *params ); 925 void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat); 926 void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h); 927 928 /* State-query functions 929 * 930 * Return GL_TRUE if query was completed, GL_FALSE otherwise. 931 */ 932 GLboolean (*GetBooleanv)(GLcontext *ctx, GLenum pname, GLboolean *result); 933 GLboolean (*GetDoublev)(GLcontext *ctx, GLenum pname, GLdouble *result); 934 GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result); 935 GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result); 936 GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result); 937 938 939 void (*VertexPointer)(GLcontext *ctx, GLint size, GLenum type, 940 GLsizei stride, const GLvoid *ptr); 941 void (*NormalPointer)(GLcontext *ctx, GLenum type, 942 GLsizei stride, const GLvoid *ptr); 943 void (*ColorPointer)(GLcontext *ctx, GLint size, GLenum type, 944 GLsizei stride, const GLvoid *ptr); 945 void (*FogCoordPointer)(GLcontext *ctx, GLenum type, 946 GLsizei stride, const GLvoid *ptr); 947 void (*IndexPointer)(GLcontext *ctx, GLenum type, 948 GLsizei stride, const GLvoid *ptr); 949 void (*SecondaryColorPointer)(GLcontext *ctx, GLint size, GLenum type, 950 GLsizei stride, const GLvoid *ptr); 951 void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type, 952 GLsizei stride, const GLvoid *ptr); 953 void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr); 954}; 955 956 957 958 959 960 961 962typedef struct { 963 964 void (*ArrayElement)( GLint ); /* NOTE */ 965 void (*Color3f)( GLfloat, GLfloat, GLfloat ); 966 void (*Color3fv)( const GLfloat * ); 967 void (*Color3ub)( GLubyte, GLubyte, GLubyte ); 968 void (*Color3ubv)( const GLubyte * ); 969 void (*Color4f)( GLfloat, GLfloat, GLfloat, GLfloat ); 970 void (*Color4fv)( const GLfloat * ); 971 void (*Color4ub)( GLubyte, GLubyte, GLubyte, GLubyte ); 972 void (*Color4ubv)( const GLubyte * ); 973 void (*EdgeFlag)( GLboolean ); 974 void (*EdgeFlagv)( const GLboolean * ); 975 void (*EvalCoord1f)( GLfloat ); /* NOTE */ 976 void (*EvalCoord1fv)( const GLfloat * ); /* NOTE */ 977 void (*EvalCoord2f)( GLfloat, GLfloat ); /* NOTE */ 978 void (*EvalCoord2fv)( const GLfloat * ); /* NOTE */ 979 void (*EvalPoint1)( GLint ); /* NOTE */ 980 void (*EvalPoint2)( GLint, GLint ); /* NOTE */ 981 void (*FogCoordfEXT)( GLfloat ); 982 void (*FogCoordfvEXT)( const GLfloat * ); 983 void (*Indexi)( GLint ); 984 void (*Indexiv)( const GLint * ); 985 void (*Materialfv)( GLenum face, GLenum pname, const GLfloat * ); /* NOTE */ 986 void (*MultiTexCoord1fARB)( GLenum, GLfloat ); 987 void (*MultiTexCoord1fvARB)( GLenum, const GLfloat * ); 988 void (*MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat ); 989 void (*MultiTexCoord2fvARB)( GLenum, const GLfloat * ); 990 void (*MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat ); 991 void (*MultiTexCoord3fvARB)( GLenum, const GLfloat * ); 992 void (*MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat ); 993 void (*MultiTexCoord4fvARB)( GLenum, const GLfloat * ); 994 void (*Normal3f)( GLfloat, GLfloat, GLfloat ); 995 void (*Normal3fv)( const GLfloat * ); 996 void (*SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat ); 997 void (*SecondaryColor3fvEXT)( const GLfloat * ); 998 void (*SecondaryColor3ubEXT)( GLubyte, GLubyte, GLubyte ); 999 void (*SecondaryColor3ubvEXT)( const GLubyte * ); 1000 void (*TexCoord1f)( GLfloat ); 1001 void (*TexCoord1fv)( const GLfloat * ); 1002 void (*TexCoord2f)( GLfloat, GLfloat ); 1003 void (*TexCoord2fv)( const GLfloat * ); 1004 void (*TexCoord3f)( GLfloat, GLfloat, GLfloat ); 1005 void (*TexCoord3fv)( const GLfloat * ); 1006 void (*TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat ); 1007 void (*TexCoord4fv)( const GLfloat * ); 1008 void (*Vertex2f)( GLfloat, GLfloat ); 1009 void (*Vertex2fv)( const GLfloat * ); 1010 void (*Vertex3f)( GLfloat, GLfloat, GLfloat ); 1011 void (*Vertex3fv)( const GLfloat * ); 1012 void (*Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat ); 1013 void (*Vertex4fv)( const GLfloat * ); 1014 void (*CallList)( GLuint ); /* NOTE */ 1015 void (*Begin)( GLenum ); 1016 void (*End)( void ); 1017 /* Drivers present a reduced set of the functions possible in 1018 * begin/end objects. Core mesa provides translation stubs for the 1019 * remaining functions to map down to these entrypoints. 1020 * 1021 * These are the initial values to be installed into dispatch by 1022 * mesa. If the t&l driver wants to modify the dispatch table 1023 * while installed, it must do so itself. It would be possible for 1024 * the vertexformat to install it's own initial values for these 1025 * functions, but this way there is an obvious list of what is 1026 * expected of the driver. 1027 * 1028 * If the driver wants to hook in entrypoints other than those 1029 * listed above, it must restore them to their original values in 1030 * the disable() callback, below. 1031 */ 1032 1033 void (*Rectf)( GLfloat, GLfloat, GLfloat, GLfloat ); 1034 /* 1035 */ 1036 1037 1038 void (*DrawArrays)( GLenum mode, GLint start, GLsizei count ); 1039 void (*DrawElements)( GLenum mode, GLsizei count, GLenum type, 1040 const GLvoid *indices ); 1041 void (*DrawRangeElements)(GLenum mode, GLuint start, 1042 GLuint end, GLsizei count, 1043 GLenum type, const GLvoid *indices); 1044 /* These may or may not belong here. Heuristic: If an array is 1045 * enabled, the installed vertex format should support that array and 1046 * it's current size natively. 1047 */ 1048 1049 void (*EvalMesh1)( GLenum mode, GLint i1, GLint i2 ); 1050 void (*EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); 1051 /* If you don't support eval, fallback to the default vertex format 1052 * on receiving an eval call and use the pipeline mechanism to 1053 * provide partial t&l acceleration. 1054 * 1055 * Mesa will provide a set of helper functions to do eval within 1056 * accelerated vertex formats, eventually... 1057 */ 1058 1059 GLboolean prefer_float_colors; 1060 /* Should core send non-standard colors to glColor4f or glColor4ub 1061 */ 1062 1063 1064} GLvertexformat; 1065 1066 1067#endif 1068 1069