more work on GL_ARB_texture_compression
[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 GLboolean (*CompressedTexImage1D)( GLcontext *ctx, GLenum target,
644 GLint level, const GLvoid *data,
645 struct gl_texture_object *texObj,
646 struct gl_texture_image *texImage,
647 GLboolean *retainInternalCopy);
648 GLboolean (*CompressedTexImage2D)( GLcontext *ctx, GLenum target,
649 GLint level, const GLvoid *data,
650 struct gl_texture_object *texObj,
651 struct gl_texture_image *texImage,
652 GLboolean *retainInternalCopy);
653 GLboolean (*CompressedTexImage3D)( GLcontext *ctx, GLenum target,
654 GLint level, const GLvoid *data,
655 struct gl_texture_object *texObj,
656 struct gl_texture_image *texImage,
657 GLboolean *retainInternalCopy);
658 /* Called by glCompressedTexImage1/2/3D.
659 * Arguments:
660 * <target>, <level>, <internalFormat>, <data> are user specified.
661 * <texObj> is the target texture object.
662 * <texImage> is the target texture image. It will have the texture
663 * width, height, depth, border and internalFormat information.
664 * <retainInternalCopy> is returned by this function and indicates whether
665 * core Mesa should keep an internal copy of the texture image.
666 * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
667 * should do the job.
668 */
669
670
671 void (*TexEnv)( GLcontext *ctx, GLenum target, GLenum pname,
672 const GLfloat *param );
673 /* Called by glTexEnv*().
674 */
675
676 void (*TexParameter)( GLcontext *ctx, GLenum target,
677 struct gl_texture_object *texObj,
678 GLenum pname, const GLfloat *params );
679 /* Called by glTexParameter*().
680 * <target> is user specified
681 * <texObj> the texture object to modify
682 * <pname> is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER,
683 * GL_TEXTURE_WRAP_[STR], or GL_TEXTURE_BORDER_COLOR.
684 * <params> is user specified.
685 */
686
687 void (*BindTexture)( GLcontext *ctx, GLenum target,
688 struct gl_texture_object *tObj );
689 /* Called by glBindTexture().
690 */
691
692 void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
693 /* Called when a texture object is about to be deallocated. Driver
694 * should free anything attached to the DriverData pointers.
695 */
696
697 GLboolean (*IsTextureResident)( GLcontext *ctx,
698 struct gl_texture_object *t );
699 /* Called by glAreTextureResident().
700 */
701
702 void (*PrioritizeTexture)( GLcontext *ctx, struct gl_texture_object *t,
703 GLclampf priority );
704 /* Called by glPrioritizeTextures().
705 */
706
707 void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber );
708 /* Called by glActiveTextureARB to set current texture unit.
709 */
710
711 void (*UpdateTexturePalette)( GLcontext *ctx,
712 struct gl_texture_object *tObj );
713 /* Called when the texture's color lookup table is changed.
714 * If tObj is NULL then the shared texture palette ctx->Texture.Palette
715 * is to be updated.
716 */
717
718
719
720 /***
721 *** Accelerated point, line, polygon, glDrawPixels and glBitmap functions:
722 ***/
723
724 points_func PointsFunc;
725 line_func LineFunc;
726 triangle_func TriangleFunc;
727 quad_func QuadFunc;
728 rect_func RectFunc;
729
730
731 /***
732 *** Transformation/Rendering functions
733 ***/
734
735 void (*RenderStart)( GLcontext *ctx );
736 void (*RenderFinish)( GLcontext *ctx );
737 /* KW: These replace Begin and End, and have more relaxed semantics.
738 * They are called prior-to and after one or more vb flush, and are
739 * thus decoupled from the gl_begin/gl_end pairs, which are possibly
740 * more frequent. If a begin/end pair covers >1 vertex buffer, these
741 * are called at most once for the pair. (a bit broken at present)
742 */
743
744 void (*RasterSetup)( struct vertex_buffer *VB, GLuint start, GLuint end );
745 /* This function, if not NULL, is called whenever new window coordinates
746 * are put in the vertex buffer. The vertices in question are those n
747 * such that start <= n < end.
748 * The device driver can convert the window coords to its own specialized
749 * format. The 3Dfx driver uses this.
750 *
751 * Note: Deprecated in favour of RegisterPipelineStages, below.
752 */
753
754 render_func *RenderVBClippedTab;
755 render_func *RenderVBCulledTab;
756 render_func *RenderVBRawTab;
757 /* These function tables allow the device driver to rasterize an
758 * entire begin/end group of primitives at once. See the
759 * gl_render_vb() function in vbrender.c for more details.
760 */
761
762 void (*ReducedPrimitiveChange)( GLcontext *ctx, GLenum primitive );
763 /* If registered, this will be called when rendering transitions between
764 * points, lines and triangles. It is not called on transitions between
765 * primtives such as GL_TRIANGLES and GL_TRIANGLE_STRIPS, or between
766 * triangles and quads or triangles and polygons.
767 */
768
769 GLuint TriangleCaps;
770 /* Holds a list of the reasons why we might normally want to call
771 * render_triangle, but which are in fact implemented by the
772 * driver. The FX driver sets this to DD_TRI_CULL, and will soon
773 * implement DD_TRI_OFFSET.
774 */
775
776 GLboolean (*MultipassFunc)( struct vertex_buffer *VB, GLuint passno );
777 /* Driver may request additional render passes by returning GL_TRUE
778 * when this function is called. This function will be called
779 * after the first pass, and passes will be made until the function
780 * returns GL_FALSE. If no function is registered, only one pass
781 * is made.
782 *
783 * This function will be first invoked with passno == 1.
784 */
785
786 /***
787 *** NEW in Mesa 3.x
788 ***/
789
790 void (*RegisterVB)( struct vertex_buffer *VB );
791 void (*UnregisterVB)( struct vertex_buffer *VB );
792 /* Do any processing (eg allocate memory) required to set up a new
793 * vertex_buffer.
794 */
795
796
797 void (*ResetVB)( struct vertex_buffer *VB );
798 void (*ResetCvaVB)( struct vertex_buffer *VB, GLuint stages );
799 /* Do any reset operations necessary to the driver data associated
800 * with these vertex buffers.
801 */
802
803 GLuint RenderVectorFlags;
804 /* What do the render tables require of the vectors they deal
805 * with?
806 */
807
808 GLuint (*RegisterPipelineStages)( struct gl_pipeline_stage *out,
809 const struct gl_pipeline_stage *in,
810 GLuint nr );
811 /* Register new pipeline stages, or modify existing ones. See also
812 * the OptimizePipeline() functions.
813 */
814
815
816 GLboolean (*BuildPrecalcPipeline)( GLcontext *ctx );
817 GLboolean (*BuildEltPipeline)( GLcontext *ctx );
818 /* Perform the full pipeline build, or return false.
819 */
820
821
822 void (*OptimizePrecalcPipeline)( GLcontext *ctx, struct gl_pipeline *pipe );
823 void (*OptimizeImmediatePipeline)( GLcontext *ctx, struct gl_pipeline *pipe);
824 /* Check to see if a fast path exists for this combination of stages
825 * in the precalc and immediate (elt) pipelines.
826 */
827
828
829 /*
830 * State-changing functions (drawing functions are above)
831 *
832 * These functions are called by their corresponding OpenGL API functions.
833 * They're ALSO called by the gl_PopAttrib() function!!!
834 * May add more functions like these to the device driver in the future.
835 * This should reduce the amount of state checking that
836 * the driver's UpdateState() function must do.
837 */
838 void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLclampf ref);
839 void (*BlendEquation)(GLcontext *ctx, GLenum mode);
840 void (*BlendFunc)(GLcontext *ctx, GLenum sfactor, GLenum dfactor);
841 void (*BlendFuncSeparate)( GLcontext *ctx, GLenum sfactorRGB,
842 GLenum dfactorRGB, GLenum sfactorA,
843 GLenum dfactorA );
844 void (*ClearDepth)(GLcontext *ctx, GLclampd d);
845 void (*CullFace)(GLcontext *ctx, GLenum mode);
846 void (*FrontFace)(GLcontext *ctx, GLenum mode);
847 void (*DepthFunc)(GLcontext *ctx, GLenum func);
848 void (*DepthMask)(GLcontext *ctx, GLboolean flag);
849 void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval);
850 void (*Enable)(GLcontext* ctx, GLenum cap, GLboolean state);
851 void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
852 void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode);
853 void (*Lightfv)(GLcontext *ctx, GLenum light,
854 GLenum pname, const GLfloat *params, GLint nparams );
855 void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
856 void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern );
857 void (*LineWidth)(GLcontext *ctx, GLfloat width);
858 void (*LogicOpcode)(GLcontext *ctx, GLenum opcode);
859 void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode);
860 void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask );
861 void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
862 void (*ShadeModel)(GLcontext *ctx, GLenum mode);
863 void (*ClearStencil)(GLcontext *ctx, GLint s);
864 void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
865 void (*StencilMask)(GLcontext *ctx, GLuint mask);
866 void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass);
867 void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
868 };
869
870
871
872 #endif
873