use BCOPY macro on FreeBSD
[mesa.git] / src / mesa / main / dd.h
1
2 /*
3 * Mesa 3-D graphics library
4 * Version: 3.3
5 *
6 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27
28 #ifndef DD_INCLUDED
29 #define DD_INCLUDED
30
31
32 #include "macros.h"
33
34
35 struct gl_pixelstore_attrib;
36
37
38 struct vertex_buffer;
39 struct immediate;
40 struct gl_pipeline_stage;
41
42
43 /* THIS FILE ONLY INCLUDED BY types.h !!!!! */
44
45
46 /*
47 * Device Driver (DD) interface
48 *
49 *
50 * All device driver functions are accessed through pointers in the
51 * dd_function_table struct (defined below) which is stored in the GLcontext
52 * struct. Since the device driver is strictly accessed trough a table of
53 * function pointers we can:
54 * 1. switch between a number of different device drivers at runtime.
55 * 2. use optimized functions dependant on current rendering state or
56 * frame buffer configuration.
57 *
58 * The function pointers in the dd_function_table struct are divided into
59 * two groups: mandatory and optional.
60 * Mandatory functions have to be implemented by every device driver.
61 * Optional functions may or may not be implemented by the device driver.
62 * The optional functions provide ways to take advantage of special hardware
63 * or optimized algorithms.
64 *
65 * The function pointers in the dd_function_table struct should first be
66 * initialized in the driver's "MakeCurrent" function. The "MakeCurrent"
67 * function is a little different in each device driver. See the X/Mesa,
68 * GLX, or OS/Mesa drivers for examples.
69 *
70 * Later, Mesa may call the dd_function_table's UpdateState() function.
71 * This function should initialize the dd_function_table's pointers again.
72 * The UpdateState() function is called whenever the core (GL) rendering
73 * state is changed in a way which may effect rasterization. For example,
74 * the TriangleFunc() pointer may have to point to different functions
75 * depending on whether smooth or flat shading is enabled.
76 *
77 * Note that the first argument to every device driver function is a
78 * GLcontext *. In turn, the GLcontext->DriverCtx pointer points to
79 * the driver-specific context struct. See the X/Mesa or OS/Mesa interface
80 * for an example.
81 *
82 * For more information about writing a device driver see the ddsample.c
83 * file and other device drivers (X/xmesa[1234].c, OSMesa/osmesa.c, etc)
84 * for examples.
85 *
86 *
87 * Look below in the dd_function_table struct definition for descriptions
88 * of each device driver function.
89 *
90 *
91 * In the future more function pointers may be added for glReadPixels
92 * glCopyPixels, etc.
93 *
94 *
95 * Notes:
96 * ------
97 * RGBA = red/green/blue/alpha
98 * CI = color index (color mapped mode)
99 * mono = all pixels have the same color or index
100 *
101 * The write_ functions all take an array of mask flags which indicate
102 * whether or not the pixel should be written. One special case exists
103 * in the write_color_span function: if the mask array is NULL, then
104 * draw all pixels. This is an optimization used for glDrawPixels().
105 *
106 * IN ALL CASES:
107 * X coordinates start at 0 at the left and increase to the right
108 * Y coordinates start at 0 at the bottom and increase upward
109 *
110 */
111
112
113
114
115 /* Used by the GetParameteri device driver function */
116 #define DD_HAVE_HARDWARE_FOG 3
117
118
119
120 /* Mask bits sent to the driver Clear() function */
121 #define DD_FRONT_LEFT_BIT FRONT_LEFT_BIT /* 1 */
122 #define DD_FRONT_RIGHT_BIT FRONT_RIGHT_BIT /* 2 */
123 #define DD_BACK_LEFT_BIT BACK_LEFT_BIT /* 4 */
124 #define DD_BACK_RIGHT_BIT BACK_RIGHT_BIT /* 8 */
125 #define DD_DEPTH_BIT GL_DEPTH_BUFFER_BIT /* 0x00000100 */
126 #define DD_STENCIL_BIT GL_STENCIL_BUFFER_BIT /* 0x00000400 */
127 #define DD_ACCUM_BIT GL_ACCUM_BUFFER_BIT /* 0x00000200 */
128
129
130
131 /*
132 * Device Driver function table.
133 */
134 struct dd_function_table {
135
136 /**********************************************************************
137 *** Mandatory functions: these functions must be implemented by ***
138 *** every device driver. ***
139 **********************************************************************/
140
141 const GLubyte * (*GetString)( GLcontext *ctx, GLenum name );
142 /* Return a string as needed by glGetString().
143 * Only the GL_RENDERER token must be implemented. Otherwise,
144 * NULL can be returned.
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, GLubyte red, GLubyte green,
161 GLubyte blue, GLubyte 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 GLubyte red, GLubyte green, GLubyte glue, GLubyte 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 GLubyte rgba[][4], const GLubyte mask[] );
237 void (*WriteRGBSpan)( const GLcontext *ctx,
238 GLuint n, GLint x, GLint y,
239 CONST GLubyte 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 GLubyte 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 GLubyte 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 GLubyte 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 GLboolean (*IndexMask)( GLcontext *ctx, GLuint mask );
339 /*
340 * Implements glIndexMask() if possible, else return GL_FALSE.
341 */
342
343 GLboolean (*ColorMask)( GLcontext *ctx,
344 GLboolean rmask, GLboolean gmask,
345 GLboolean bmask, GLboolean amask );
346 /*
347 * Implements glColorMask() if possible, else return GL_FALSE.
348 */
349
350 GLboolean (*LogicOp)( GLcontext *ctx, GLenum op );
351 /*
352 * Implements glLogicOp() if possible, else return GL_FALSE.
353 */
354
355 void (*Dither)( GLcontext *ctx, GLboolean enable );
356 /*
357 * Enable/disable dithering.
358 * NOTE: This function will be removed in the future in favor
359 * of the "Enable" driver function.
360 */
361
362 void (*Error)( GLcontext *ctx );
363 /*
364 * Called whenever an error is generated. ctx->ErrorValue contains
365 * the error value.
366 */
367
368 void (*NearFar)( GLcontext *ctx, GLfloat nearVal, GLfloat farVal );
369 /*
370 * Called from glFrustum and glOrtho to tell device driver the
371 * near and far clipping plane Z values. The 3Dfx driver, for example,
372 * uses this.
373 */
374
375 GLint (*GetParameteri)( const GLcontext *ctx, GLint param );
376 /* Query the device driver to get an integer parameter.
377 * Current parameters:
378 * DD_MAX_TEXTURE_SIZE return maximum texture size
379 *
380 * DD_MAX_TEXTURES number of texture sets/stages, usually 1
381 *
382 * DD_HAVE_HARDWARE_FOG the driver should return 1 (0 otherwise)
383 * when the hardware support per fragment
384 * fog for free (like the Voodoo Graphics)
385 * so the Mesa core will start to ever use
386 * per fragment fog
387 */
388
389
390 /***
391 *** For supporting hardware Z buffers:
392 *** Either ALL or NONE of these functions must be implemented!
393 *** NOTE that Each depth value is a 32-bit GLuint. If the depth
394 *** buffer is less than 32 bits deep then the extra upperbits are zero.
395 ***/
396
397 void (*WriteDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
398 const GLdepth depth[], const GLubyte mask[] );
399 /* Write a horizontal span of values into the depth buffer. Only write
400 * depth[i] value if mask[i] is nonzero.
401 */
402
403 void (*ReadDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
404 GLdepth depth[] );
405 /* Read a horizontal span of values from the depth buffer.
406 */
407
408
409 void (*WriteDepthPixels)( GLcontext *ctx, GLuint n,
410 const GLint x[], const GLint y[],
411 const GLdepth depth[], const GLubyte mask[] );
412 /* Write an array of randomly positioned depth values into the
413 * depth buffer. Only write depth[i] value if mask[i] is nonzero.
414 */
415
416 void (*ReadDepthPixels)( GLcontext *ctx, GLuint n,
417 const GLint x[], const GLint y[],
418 GLdepth depth[] );
419 /* Read an array of randomly positioned depth values from the depth buffer.
420 */
421
422
423
424 /***
425 *** For supporting hardware stencil buffers:
426 *** Either ALL or NONE of these functions must be implemented!
427 ***/
428
429 void (*WriteStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
430 const GLstencil stencil[], const GLubyte mask[] );
431 /* Write a horizontal span of stencil values into the stencil buffer.
432 * If mask is NULL, write all stencil values.
433 * Else, only write stencil[i] if mask[i] is non-zero.
434 */
435
436 void (*ReadStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
437 GLstencil stencil[] );
438 /* Read a horizontal span of stencil values from the stencil buffer.
439 */
440
441 void (*WriteStencilPixels)( GLcontext *ctx, GLuint n,
442 const GLint x[], const GLint y[],
443 const GLstencil stencil[],
444 const GLubyte mask[] );
445 /* Write an array of stencil values into the stencil buffer.
446 * If mask is NULL, write all stencil values.
447 * Else, only write stencil[i] if mask[i] is non-zero.
448 */
449
450 void (*ReadStencilPixels)( GLcontext *ctx, GLuint n,
451 const GLint x[], const GLint y[],
452 GLstencil stencil[] );
453 /* Read an array of stencil values from the stencil buffer.
454 */
455
456
457 /***
458 *** glDraw/Read/CopyPixels and glBitmap functions:
459 ***/
460
461 GLboolean (*DrawPixels)( GLcontext *ctx,
462 GLint x, GLint y, GLsizei width, GLsizei height,
463 GLenum format, GLenum type,
464 const struct gl_pixelstore_attrib *unpack,
465 const GLvoid *pixels );
466 /* This is called by glDrawPixels.
467 * 'unpack' describes how to unpack the source image data.
468 * Return GL_TRUE if the driver succeeds, return GL_FALSE if core Mesa
469 * must do the job.
470 */
471
472 GLboolean (*ReadPixels)( GLcontext *ctx,
473 GLint x, GLint y, GLsizei width, GLsizei height,
474 GLenum format, GLenum type,
475 const struct gl_pixelstore_attrib *unpack,
476 GLvoid *dest );
477 /* Called by glReadPixels.
478 * Return GL_TRUE if operation completed, else return GL_FALSE.
479 * This function must respect all glPixelTransfer settings.
480 */
481
482 GLboolean (*CopyPixels)( GLcontext *ctx,
483 GLint srcx, GLint srcy,
484 GLsizei width, GLsizei height,
485 GLint dstx, GLint dsty, GLenum type );
486 /* Do a glCopyPixels. Return GL_TRUE if operation completed, else
487 * return GL_FALSE. This function must respect all rasterization
488 * state, glPixelTransfer, glPixelZoom, etc.
489 */
490
491 GLboolean (*Bitmap)( GLcontext *ctx,
492 GLint x, GLint y, GLsizei width, GLsizei height,
493 const struct gl_pixelstore_attrib *unpack,
494 const GLubyte *bitmap );
495 /* This is called by glBitmap. Works the same as DrawPixels, above.
496 */
497
498
499 /***
500 *** Texture mapping functions:
501 ***/
502
503 void (*TexImage)( GLcontext *ctx, GLenum target,
504 struct gl_texture_object *tObj, GLint level,
505 GLint internalFormat,
506 const struct gl_texture_image *image );
507 /* XXX this function is obsolete */
508 /* Called whenever a texture object's image is changed.
509 * texObject is the number of the texture object being changed.
510 * level indicates the mipmap level.
511 * internalFormat is the format in which the texture is to be stored.
512 * image is a pointer to a gl_texture_image struct which contains
513 * the actual image data.
514 */
515
516 void (*TexSubImage)( GLcontext *ctx, GLenum target,
517 struct gl_texture_object *tObj, GLint level,
518 GLint xoffset, GLint yoffset,
519 GLsizei width, GLsizei height,
520 GLint internalFormat,
521 const struct gl_texture_image *image );
522 /* XXX this function is obsolete */
523 /* Called from glTexSubImage() to define a sub-region of a texture.
524 */
525
526
527 GLboolean (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level,
528 GLenum format, GLenum type, const GLvoid *pixels,
529 const struct gl_pixelstore_attrib *packing,
530 struct gl_texture_object *texObj,
531 struct gl_texture_image *texImage,
532 GLboolean *retainInternalCopy );
533 GLboolean (*TexImage2D)( GLcontext *ctx, GLenum target, GLint level,
534 GLenum format, GLenum type, const GLvoid *pixels,
535 const struct gl_pixelstore_attrib *packing,
536 struct gl_texture_object *texObj,
537 struct gl_texture_image *texImage,
538 GLboolean *retainInternalCopy );
539 GLboolean (*TexImage3D)( GLcontext *ctx, GLenum target, GLint level,
540 GLenum format, GLenum type, const GLvoid *pixels,
541 const struct gl_pixelstore_attrib *packing,
542 struct gl_texture_object *texObj,
543 struct gl_texture_image *texImage,
544 GLboolean *retainInternalCopy );
545 /* Called by glTexImage1/2/3D.
546 * Will not be called if any glPixelTransfer operations are enabled.
547 * Arguments:
548 * <target>, <level>, <format>, <type> and <pixels> are user specified.
549 * <packing> indicates the image packing of pixels.
550 * <texObj> is the target texture object.
551 * <texImage> is the target texture image. It will have the texture
552 * width, height, depth, border and internalFormat information.
553 * <retainInternalCopy> is returned by this function and indicates whether
554 * core Mesa should keep an internal copy of the texture image.
555 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
556 * should do the job. If GL_FALSE is returned, this function will be
557 * called a second time after the texture image has been unpacked into
558 * GLubytes. It may be easier for the driver to handle then.
559 */
560
561 GLboolean (*TexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
562 GLint xoffset, GLsizei width,
563 GLenum format, GLenum type,
564 const GLvoid *pixels,
565 const struct gl_pixelstore_attrib *packing,
566 struct gl_texture_object *texObj,
567 struct gl_texture_image *texImage );
568 GLboolean (*TexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
569 GLint xoffset, GLint yoffset,
570 GLsizei width, GLsizei height,
571 GLenum format, GLenum type,
572 const GLvoid *pixels,
573 const struct gl_pixelstore_attrib *packing,
574 struct gl_texture_object *texObj,
575 struct gl_texture_image *texImage );
576 GLboolean (*TexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
577 GLint xoffset, GLint yoffset, GLint zoffset,
578 GLsizei width, GLsizei height, GLint depth,
579 GLenum format, GLenum type,
580 const GLvoid *pixels,
581 const struct gl_pixelstore_attrib *packing,
582 struct gl_texture_object *texObj,
583 struct gl_texture_image *texImage );
584 /* Called by glTexSubImage1/2/3D.
585 * Will not be called if any glPixelTransfer operations are enabled.
586 * Arguments:
587 * <target>, <level>, <xoffset>, <yoffset>, <zoffset>, <width>, <height>,
588 * <depth>, <format>, <type> and <pixels> are user specified.
589 * <packing> indicates the image packing of pixels.
590 * <texObj> is the target texture object.
591 * <texImage> is the target texture image. It will have the texture
592 * width, height, border and internalFormat information.
593 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
594 * should do the job. If GL_FALSE is returned, then TexImage1/2/3D will
595 * be called with the complete texture image.
596 */
597
598 GLboolean (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level,
599 GLenum internalFormat, GLint x, GLint y,
600 GLsizei width, GLint border );
601 GLboolean (*CopyTexImage2D)( GLcontext *ctx, GLenum target, GLint level,
602 GLenum internalFormat, GLint x, GLint y,
603 GLsizei width, GLsizei height, GLint border );
604 /* Called by glCopyTexImage1D and glCopyTexImage2D.
605 * Will not be called if any glPixelTransfer operations are enabled.
606 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
607 * should do the job.
608 */
609
610 GLboolean (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
611 GLint xoffset,
612 GLint x, GLint y, GLsizei width );
613 GLboolean (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
614 GLint xoffset, GLint yoffset,
615 GLint x, GLint y,
616 GLsizei width, GLsizei height );
617 GLboolean (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
618 GLint xoffset, GLint yoffset, GLint zoffset,
619 GLint x, GLint y,
620 GLsizei width, GLsizei height );
621 /* Called by glCopyTexSubImage1/2/3D.
622 * Will not be called if any glPixelTransfer operations are enabled.
623 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
624 * should do the job.
625 */
626
627 GLvoid *(*GetTexImage)( GLcontext *ctx, GLenum target, GLint level,
628 const struct gl_texture_object *texObj,
629 GLenum *formatOut, GLenum *typeOut,
630 GLboolean *freeImageOut );
631 /* Called by glGetTexImage or by core Mesa when a texture image
632 * is needed for software fallback rendering.
633 * Return the address of the texture image or NULL if failure.
634 * The image must be tightly packed (i.e. row stride = image width)
635 * Return the image's format and type in formatOut and typeOut.
636 * The format and type must be values which are accepted by glTexImage.
637 * Set the freeImageOut flag if the returned image should be deallocated
638 * with FREE() when finished.
639 * The size of the image can be deduced from the target and level.
640 * Core Mesa will perform any image format/type conversions that are needed.
641 */
642
643 void (*TexEnv)( GLcontext *ctx, GLenum target, GLenum pname,
644 const GLfloat *param );
645 /* Called by glTexEnv*().
646 */
647
648 void (*TexParameter)( GLcontext *ctx, GLenum target,
649 struct gl_texture_object *texObj,
650 GLenum pname, const GLfloat *params );
651 /* Called by glTexParameter*().
652 * <target> is user specified
653 * <texObj> the texture object to modify
654 * <pname> is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER,
655 * GL_TEXTURE_WRAP_[STR], or GL_TEXTURE_BORDER_COLOR.
656 * <params> is user specified.
657 */
658
659 void (*BindTexture)( GLcontext *ctx, GLenum target,
660 struct gl_texture_object *tObj );
661 /* Called by glBindTexture().
662 */
663
664 void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
665 /* Called when a texture object is about to be deallocated. Driver
666 * should free anything attached to the DriverData pointers.
667 */
668
669 GLboolean (*IsTextureResident)( GLcontext *ctx,
670 struct gl_texture_object *t );
671 /* Called by glAreTextureResident().
672 */
673
674 void (*PrioritizeTexture)( GLcontext *ctx, struct gl_texture_object *t,
675 GLclampf priority );
676 /* Called by glPrioritizeTextures().
677 */
678
679 void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber );
680 /* Called by glActiveTextureARB to set current texture unit.
681 */
682
683 void (*UpdateTexturePalette)( GLcontext *ctx,
684 struct gl_texture_object *tObj );
685 /* Called when the texture's color lookup table is changed.
686 * If tObj is NULL then the shared texture palette ctx->Texture.Palette
687 * is to be updated.
688 */
689
690
691
692 /***
693 *** Accelerated point, line, polygon, glDrawPixels and glBitmap functions:
694 ***/
695
696 points_func PointsFunc;
697 line_func LineFunc;
698 triangle_func TriangleFunc;
699 quad_func QuadFunc;
700 rect_func RectFunc;
701
702
703 /***
704 *** Transformation/Rendering functions
705 ***/
706
707 void (*RenderStart)( GLcontext *ctx );
708 void (*RenderFinish)( GLcontext *ctx );
709 /* KW: These replace Begin and End, and have more relaxed semantics.
710 * They are called prior-to and after one or more vb flush, and are
711 * thus decoupled from the gl_begin/gl_end pairs, which are possibly
712 * more frequent. If a begin/end pair covers >1 vertex buffer, these
713 * are called at most once for the pair. (a bit broken at present)
714 */
715
716 void (*RasterSetup)( struct vertex_buffer *VB, GLuint start, GLuint end );
717 /* This function, if not NULL, is called whenever new window coordinates
718 * are put in the vertex buffer. The vertices in question are those n
719 * such that start <= n < end.
720 * The device driver can convert the window coords to its own specialized
721 * format. The 3Dfx driver uses this.
722 *
723 * Note: Deprecated in favour of RegisterPipelineStages, below.
724 */
725
726 render_func *RenderVBClippedTab;
727 render_func *RenderVBCulledTab;
728 render_func *RenderVBRawTab;
729 /* These function tables allow the device driver to rasterize an
730 * entire begin/end group of primitives at once. See the
731 * gl_render_vb() function in vbrender.c for more details.
732 */
733
734 void (*ReducedPrimitiveChange)( GLcontext *ctx, GLenum primitive );
735 /* If registered, this will be called when rendering transitions between
736 * points, lines and triangles. It is not called on transitions between
737 * primtives such as GL_TRIANGLES and GL_TRIANGLE_STRIPS, or between
738 * triangles and quads or triangles and polygons.
739 */
740
741 GLuint TriangleCaps;
742 /* Holds a list of the reasons why we might normally want to call
743 * render_triangle, but which are in fact implemented by the
744 * driver. The FX driver sets this to DD_TRI_CULL, and will soon
745 * implement DD_TRI_OFFSET.
746 */
747
748 GLboolean (*MultipassFunc)( struct vertex_buffer *VB, GLuint passno );
749 /* Driver may request additional render passes by returning GL_TRUE
750 * when this function is called. This function will be called
751 * after the first pass, and passes will be made until the function
752 * returns GL_FALSE. If no function is registered, only one pass
753 * is made.
754 *
755 * This function will be first invoked with passno == 1.
756 */
757
758 /***
759 *** NEW in Mesa 3.x
760 ***/
761
762 void (*RegisterVB)( struct vertex_buffer *VB );
763 void (*UnregisterVB)( struct vertex_buffer *VB );
764 /* Do any processing (eg allocate memory) required to set up a new
765 * vertex_buffer.
766 */
767
768
769 void (*ResetVB)( struct vertex_buffer *VB );
770 void (*ResetCvaVB)( struct vertex_buffer *VB, GLuint stages );
771 /* Do any reset operations necessary to the driver data associated
772 * with these vertex buffers.
773 */
774
775 GLuint RenderVectorFlags;
776 /* What do the render tables require of the vectors they deal
777 * with?
778 */
779
780 GLuint (*RegisterPipelineStages)( struct gl_pipeline_stage *out,
781 const struct gl_pipeline_stage *in,
782 GLuint nr );
783 /* Register new pipeline stages, or modify existing ones. See also
784 * the OptimizePipeline() functions.
785 */
786
787
788 GLboolean (*BuildPrecalcPipeline)( GLcontext *ctx );
789 GLboolean (*BuildEltPipeline)( GLcontext *ctx );
790 /* Perform the full pipeline build, or return false.
791 */
792
793
794 void (*OptimizePrecalcPipeline)( GLcontext *ctx, struct gl_pipeline *pipe );
795 void (*OptimizeImmediatePipeline)( GLcontext *ctx, struct gl_pipeline *pipe);
796 /* Check to see if a fast path exists for this combination of stages
797 * in the precalc and immediate (elt) pipelines.
798 */
799
800
801 /*
802 * State-changing functions (drawing functions are above)
803 *
804 * These functions are called by their corresponding OpenGL API functions.
805 * They're ALSO called by the gl_PopAttrib() function!!!
806 * May add more functions like these to the device driver in the future.
807 * This should reduce the amount of state checking that
808 * the driver's UpdateState() function must do.
809 */
810 void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLclampf ref);
811 void (*BlendEquation)(GLcontext *ctx, GLenum mode);
812 void (*BlendFunc)(GLcontext *ctx, GLenum sfactor, GLenum dfactor);
813 void (*BlendFuncSeparate)( GLcontext *ctx, GLenum sfactorRGB,
814 GLenum dfactorRGB, GLenum sfactorA,
815 GLenum dfactorA );
816 void (*ClearDepth)(GLcontext *ctx, GLclampd d);
817 void (*CullFace)(GLcontext *ctx, GLenum mode);
818 void (*FrontFace)(GLcontext *ctx, GLenum mode);
819 void (*DepthFunc)(GLcontext *ctx, GLenum func);
820 void (*DepthMask)(GLcontext *ctx, GLboolean flag);
821 void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval);
822 void (*Enable)(GLcontext* ctx, GLenum cap, GLboolean state);
823 void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
824 void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode);
825 void (*Lightfv)(GLcontext *ctx, GLenum light,
826 GLenum pname, const GLfloat *params, GLint nparams );
827 void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
828 void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern );
829 void (*LineWidth)(GLcontext *ctx, GLfloat width);
830 void (*LogicOpcode)(GLcontext *ctx, GLenum opcode);
831 void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode);
832 void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask );
833 void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
834 void (*ShadeModel)(GLcontext *ctx, GLenum mode);
835 void (*ClearStencil)(GLcontext *ctx, GLint s);
836 void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
837 void (*StencilMask)(GLcontext *ctx, GLuint mask);
838 void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass);
839 void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
840 };
841
842
843
844 #endif
845