texture compression
[mesa.git] / src / mesa / main / dd.h
1 /**
2 * \file dd.h
3 * Device driver interfaces.
4 */
5
6 /*
7 * Mesa 3-D graphics library
8 * Version: 4.1
9 *
10 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30
31 #ifndef DD_INCLUDED
32 #define DD_INCLUDED
33
34 /* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */
35
36 struct gl_pixelstore_attrib;
37
38 /* Mask bits sent to the driver Clear() function */
39 #define DD_FRONT_LEFT_BIT FRONT_LEFT_BIT /* 1 */
40 #define DD_FRONT_RIGHT_BIT FRONT_RIGHT_BIT /* 2 */
41 #define DD_BACK_LEFT_BIT BACK_LEFT_BIT /* 4 */
42 #define DD_BACK_RIGHT_BIT BACK_RIGHT_BIT /* 8 */
43 #define DD_AUX0 AUX0_BIT /* future use */
44 #define DD_AUX1 AUX1_BIT /* future use */
45 #define DD_AUX2 AUX2_BIT /* future use */
46 #define DD_AUX3 AUX3_BIT /* future use */
47 #define DD_DEPTH_BIT GL_DEPTH_BUFFER_BIT /* 0x00000100 */
48 #define DD_ACCUM_BIT GL_ACCUM_BUFFER_BIT /* 0x00000200 */
49 #define DD_STENCIL_BIT GL_STENCIL_BUFFER_BIT /* 0x00000400 */
50
51
52 /**
53 * Device driver function table.
54 * Core Mesa uses these function pointers to call into device drivers.
55 * Most of these functions directly correspond to OpenGL state commands.
56 * Core Mesa will call these functions after error checking has been done
57 * so that the drivers don't have to worry about error testing.
58 *
59 * Vertex transformation/clipping/lighting is patched into the T&L module.
60 * Rasterization functions are patched into the swrast module.
61 */
62 struct dd_function_table {
63 /**
64 * Return a string as needed by glGetString().
65 *
66 * Only the GL_RENDERER token must be implemented. Otherwise, NULL can be
67 * returned.
68 */
69 const GLubyte * (*GetString)( GLcontext *ctx, GLenum name );
70
71 /**
72 * Notify the driver after Mesa has made some internal state changes.
73 *
74 * This is in addition to any state change callbacks Mesa may already have
75 * made.
76 */
77 void (*UpdateState)( GLcontext *ctx, GLuint new_state );
78
79 /**
80 * Clear the color/depth/stencil/accum buffer(s).
81 *
82 * \param mask a bitmask of the DD_*_BIT values defined above that indicates
83 * which buffers need to be cleared.
84 * \param all if true then clear the whole buffer, else clear only the
85 * region defined by <tt>(x, y, width, height)</tt>.
86 *
87 * This function must obey the glColorMask(), glIndexMask() and glStencilMask()
88 * settings!
89 * Software Mesa can do masked clears if the device driver can't.
90 */
91 void (*Clear)( GLcontext *ctx, GLbitfield mask, GLboolean all,
92 GLint x, GLint y, GLint width, GLint height );
93
94 /**
95 * Specify the current buffer for writing.
96 *
97 * Called via glDrawBuffer(). Note the driver must organize fallbacks (e.g.
98 * with swrast) if it cannot implement the requested mode.
99 */
100 void (*DrawBuffer)( GLcontext *ctx, GLenum buffer );
101
102 /**
103 * Specifies the current buffer for reading.
104 *
105 * Called via glReadBuffer().
106 */
107 void (*ReadBuffer)( GLcontext *ctx, GLenum buffer );
108
109 /**
110 * Get the width and height of the named buffer/window.
111 *
112 * Mesa uses this to determine when the driver's window size has changed.
113 */
114 void (*GetBufferSize)( GLframebuffer *buffer,
115 GLuint *width, GLuint *height );
116
117 /**
118 * Resize the driver's depth/stencil/accum/back buffers to match the
119 * size given in the GLframebuffer struct.
120 *
121 * This is typically called when Mesa detects that a window size has changed.
122 */
123 void (*ResizeBuffers)( GLframebuffer *buffer );
124
125 /**
126 * This is called whenever glFinish() is called.
127 */
128 void (*Finish)( GLcontext *ctx );
129
130 /**
131 * This is called whenever glFlush() is called.
132 */
133 void (*Flush)( GLcontext *ctx );
134
135 /**
136 * Called whenever an error is generated.
137 *
138 * __GLcontextRec::ErrorValue contains the error value.
139 */
140 void (*Error)( GLcontext *ctx );
141
142
143 /**
144 * \name For hardware accumulation buffer
145 */
146 /*@{*/
147 /**
148 * Execute glAccum command within the given scissor region.
149 */
150 void (*Accum)( GLcontext *ctx, GLenum op, GLfloat value,
151 GLint xpos, GLint ypos, GLint width, GLint height );
152 /*@}*/
153
154
155 /**
156 * \name glDraw(), glRead(), glCopyPixels() and glBitmap() functions
157 */
158 /*@{*/
159
160 /**
161 * This is called by glDrawPixels().
162 *
163 * \p unpack describes how to unpack the source image data.
164 */
165 void (*DrawPixels)( GLcontext *ctx,
166 GLint x, GLint y, GLsizei width, GLsizei height,
167 GLenum format, GLenum type,
168 const struct gl_pixelstore_attrib *unpack,
169 const GLvoid *pixels );
170
171 /**
172 * Called by glReadPixels().
173 */
174 void (*ReadPixels)( GLcontext *ctx,
175 GLint x, GLint y, GLsizei width, GLsizei height,
176 GLenum format, GLenum type,
177 const struct gl_pixelstore_attrib *unpack,
178 GLvoid *dest );
179
180 /**
181 * Do a glCopyPixels().
182 *
183 * This function must respect all rasterization state, glPixelTransfer(),
184 * glPixelZoom(), etc.
185 */
186 void (*CopyPixels)( GLcontext *ctx,
187 GLint srcx, GLint srcy,
188 GLsizei width, GLsizei height,
189 GLint dstx, GLint dsty, GLenum type );
190
191 /**
192 * This is called by glBitmap().
193 *
194 * Works the same as dd_function_table::DrawPixels, above.
195 */
196 void (*Bitmap)( GLcontext *ctx,
197 GLint x, GLint y, GLsizei width, GLsizei height,
198 const struct gl_pixelstore_attrib *unpack,
199 const GLubyte *bitmap );
200 /*@}*/
201
202
203 /**
204 * \name Texture image functions
205 */
206 /*@{*/
207
208 /**
209 * Choose texture format.
210 *
211 * This is called by the \c _mesa_store_tex[sub]image[123]d() fallback
212 * functions. The driver should examine \p internalFormat and return a
213 * pointer to an appropriate gl_texture_format.
214 */
215 const struct gl_texture_format *
216 (*ChooseTextureFormat)( GLcontext *ctx, GLint internalFormat,
217 GLenum srcFormat, GLenum srcType );
218
219 /**
220 * Called by glTexImage1D().
221 *
222 * \param target user specified.
223 * \param format user specified.
224 * \param type user specified.
225 * \param pixels user specified.
226 * \param packing indicates the image packing of pixels.
227 * \param texObj is the target texture object.
228 * \param texImage is the target texture image. It will have the texture \p
229 * width, \p height, \p depth, \p border and \p internalFormat information.
230 *
231 * \p retainInternalCopy is returned by this function and indicates whether
232 * core Mesa should keep an internal copy of the texture image.
233 *
234 * Drivers should call a fallback routine from texstore.c if needed.
235 */
236 void (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level,
237 GLint internalFormat,
238 GLint width, GLint border,
239 GLenum format, GLenum type, const GLvoid *pixels,
240 const struct gl_pixelstore_attrib *packing,
241 struct gl_texture_object *texObj,
242 struct gl_texture_image *texImage );
243
244 /**
245 * Called by glTexImage2D().
246 *
247 * \sa dd_function_table::TexImage1D.
248 */
249 void (*TexImage2D)( GLcontext *ctx, GLenum target, GLint level,
250 GLint internalFormat,
251 GLint width, GLint height, GLint border,
252 GLenum format, GLenum type, const GLvoid *pixels,
253 const struct gl_pixelstore_attrib *packing,
254 struct gl_texture_object *texObj,
255 struct gl_texture_image *texImage );
256
257 /**
258 * Called by glTexImage3D().
259 *
260 * \sa dd_function_table::TexImage1D.
261 */
262 void (*TexImage3D)( GLcontext *ctx, GLenum target, GLint level,
263 GLint internalFormat,
264 GLint width, GLint height, GLint depth, GLint border,
265 GLenum format, GLenum type, const GLvoid *pixels,
266 const struct gl_pixelstore_attrib *packing,
267 struct gl_texture_object *texObj,
268 struct gl_texture_image *texImage );
269
270 /**
271 * Called by glTexSubImage1D().
272 *
273 * \param target user specified.
274 * \param level user specified.
275 * \param xoffset user specified.
276 * \param yoffset user specified.
277 * \param zoffset user specified.
278 * \param width user specified.
279 * \param height user specified.
280 * \param depth user specified.
281 * \param format user specified.
282 * \param type user specified.
283 * \param pixels user specified.
284 * \param packing indicates the image packing of pixels.
285 * \param texObj is the target texture object.
286 * \param texImage is the target texture image. It will have the texture \p
287 * width, \p height, \p border and \p internalFormat information.
288 *
289 * The driver should use a fallback routine from texstore.c if needed.
290 */
291 void (*TexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
292 GLint xoffset, GLsizei width,
293 GLenum format, GLenum type,
294 const GLvoid *pixels,
295 const struct gl_pixelstore_attrib *packing,
296 struct gl_texture_object *texObj,
297 struct gl_texture_image *texImage );
298
299 /**
300 * Called by glTexSubImage2D().
301 *
302 * \sa dd_function_table::TexSubImage1D.
303 */
304 void (*TexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
305 GLint xoffset, GLint yoffset,
306 GLsizei width, GLsizei height,
307 GLenum format, GLenum type,
308 const GLvoid *pixels,
309 const struct gl_pixelstore_attrib *packing,
310 struct gl_texture_object *texObj,
311 struct gl_texture_image *texImage );
312
313 /**
314 * Called by glTexSubImage3D().
315 *
316 * \sa dd_function_table::TexSubImage1D.
317 */
318 void (*TexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
319 GLint xoffset, GLint yoffset, GLint zoffset,
320 GLsizei width, GLsizei height, GLint depth,
321 GLenum format, GLenum type,
322 const GLvoid *pixels,
323 const struct gl_pixelstore_attrib *packing,
324 struct gl_texture_object *texObj,
325 struct gl_texture_image *texImage );
326
327 /**
328 * Called by glCopyTexImage1D().
329 *
330 * Drivers should use a fallback routine from texstore.c if needed.
331 */
332 void (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level,
333 GLenum internalFormat, GLint x, GLint y,
334 GLsizei width, GLint border );
335
336 /**
337 * Called by glCopyTexImage2D().
338 *
339 * Drivers should use a fallback routine from texstore.c if needed.
340 */
341 void (*CopyTexImage2D)( GLcontext *ctx, GLenum target, GLint level,
342 GLenum internalFormat, GLint x, GLint y,
343 GLsizei width, GLsizei height, GLint border );
344
345 /**
346 * Called by glCopyTexSubImage1D().
347 *
348 * Drivers should use a fallback routine from texstore.c if needed.
349 */
350 void (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
351 GLint xoffset,
352 GLint x, GLint y, GLsizei width );
353 /**
354 * Called by glCopyTexSubImage2D().
355 *
356 * Drivers should use a fallback routine from texstore.c if needed.
357 */
358 void (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
359 GLint xoffset, GLint yoffset,
360 GLint x, GLint y,
361 GLsizei width, GLsizei height );
362 /**
363 * Called by glCopyTexSubImage3D().
364 *
365 * Drivers should use a fallback routine from texstore.c if needed.
366 */
367 void (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
368 GLint xoffset, GLint yoffset, GLint zoffset,
369 GLint x, GLint y,
370 GLsizei width, GLsizei height );
371
372 /**
373 * Called by glTexImage[123]D when user specifies a proxy texture
374 * target.
375 *
376 * \return GL_TRUE if the proxy test passes, or GL_FALSE if the test fails.
377 */
378 GLboolean (*TestProxyTexImage)(GLcontext *ctx, GLenum target,
379 GLint level, GLint internalFormat,
380 GLenum format, GLenum type,
381 GLint width, GLint height,
382 GLint depth, GLint border);
383 /*@}*/
384
385
386 /**
387 * \name Compressed texture functions
388 */
389 /*@{*/
390
391 /**
392 * Called by glCompressedTexImage1D().
393 *
394 * \param target user specified.
395 * \param format user specified.
396 * \param type user specified.
397 * \param pixels user specified.
398 * \param packing indicates the image packing of pixels.
399 * \param texObj is the target texture object.
400 * \param texImage is the target texture image. It will have the texture \p
401 * width, \p height, \p depth, \p border and \p internalFormat information.
402 *
403 * \a retainInternalCopy is returned by this function and indicates whether
404 * core Mesa should keep an internal copy of the texture image.
405 */
406 void (*CompressedTexImage1D)( GLcontext *ctx, GLenum target,
407 GLint level, GLint internalFormat,
408 GLsizei width, GLint border,
409 GLsizei imageSize, const GLvoid *data,
410 struct gl_texture_object *texObj,
411 struct gl_texture_image *texImage );
412 /**
413 * Called by glCompressedTexImage2D().
414 *
415 * \sa dd_function_table::CompressedTexImage1D.
416 */
417 void (*CompressedTexImage2D)( GLcontext *ctx, GLenum target,
418 GLint level, GLint internalFormat,
419 GLsizei width, GLsizei height, GLint border,
420 GLsizei imageSize, const GLvoid *data,
421 struct gl_texture_object *texObj,
422 struct gl_texture_image *texImage );
423 /**
424 * Called by glCompressedTexImage3D().
425 *
426 * \sa dd_function_table::CompressedTexImage3D.
427 */
428 void (*CompressedTexImage3D)( GLcontext *ctx, GLenum target,
429 GLint level, GLint internalFormat,
430 GLsizei width, GLsizei height, GLsizei depth,
431 GLint border,
432 GLsizei imageSize, const GLvoid *data,
433 struct gl_texture_object *texObj,
434 struct gl_texture_image *texImage );
435
436 /**
437 * Called by glCompressedTexSubImage1D().
438 *
439 * \param target user specified.
440 * \param level user specified.
441 * \param xoffset user specified.
442 * \param yoffset user specified.
443 * \param zoffset user specified.
444 * \param width user specified.
445 * \param height user specified.
446 * \param depth user specified.
447 * \param imageSize user specified.
448 * \param data user specified.
449 * \param texObj is the target texture object.
450 * \param texImage is the target texture image. It will have the texture \p
451 * width, \p height, \p depth, \p border and \p internalFormat information.
452 */
453 void (*CompressedTexSubImage1D)(GLcontext *ctx, GLenum target, GLint level,
454 GLint xoffset, GLsizei width,
455 GLenum format,
456 GLsizei imageSize, const GLvoid *data,
457 struct gl_texture_object *texObj,
458 struct gl_texture_image *texImage);
459 /**
460 * Called by glCompressedTexSubImage2D().
461 *
462 * \sa dd_function_table::CompressedTexImage3D.
463 */
464 void (*CompressedTexSubImage2D)(GLcontext *ctx, GLenum target, GLint level,
465 GLint xoffset, GLint yoffset,
466 GLsizei width, GLint height,
467 GLenum format,
468 GLsizei imageSize, const GLvoid *data,
469 struct gl_texture_object *texObj,
470 struct gl_texture_image *texImage);
471 /**
472 * Called by glCompressedTexSubImage3D().
473 *
474 * \sa dd_function_table::CompressedTexImage3D.
475 */
476 void (*CompressedTexSubImage3D)(GLcontext *ctx, GLenum target, GLint level,
477 GLint xoffset, GLint yoffset, GLint zoffset,
478 GLsizei width, GLint height, GLint depth,
479 GLenum format,
480 GLsizei imageSize, const GLvoid *data,
481 struct gl_texture_object *texObj,
482 struct gl_texture_image *texImage);
483 /**
484 * Called to validate a certain compressed format.
485 */
486 GLboolean (*IsCompressedFormat)( GLcontext *ctx, GLenum internalFormat );
487 /**
488 * Called to get bytes of storage needed for the given texture size and
489 * compressed format.
490 */
491 GLuint (*CompressedTextureSize)( GLcontext *ctx,
492 GLsizei width, GLsizei height, GLsizei depth,
493 GLenum format );
494 /*@}*/
495
496 /**
497 * \name Texture object functions
498 */
499 /*@{*/
500
501 /**
502 * Called by glBindTexture().
503 */
504 void (*BindTexture)( GLcontext *ctx, GLenum target,
505 struct gl_texture_object *tObj );
506
507 /**
508 * Called when a texture object is created.
509 */
510 void (*CreateTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
511
512 /**
513 * Called to allocate a new texture object.
514 *
515 * \note This function pointer should be initialized by drivers \e before
516 * calling _mesa_initialize_context() since context initialization involves
517 * allocating some texture objects!
518 */
519 struct gl_texture_object * (*NewTextureObject)( GLcontext *ctx, GLuint name,
520 GLenum target );
521 /**
522 * Called when a texture object is about to be deallocated.
523 *
524 * Driver should free anything attached to the DriverData pointers.
525 */
526 void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
527
528 /**
529 * Called to allocate a new texture image object.
530 */
531 struct gl_texture_image * (*NewTextureImage)( GLcontext *ctx );
532
533 /**
534 * Called by glAreTextureResident().
535 */
536 GLboolean (*IsTextureResident)( GLcontext *ctx,
537 struct gl_texture_object *t );
538
539 /**
540 * Called by glPrioritizeTextures().
541 */
542 void (*PrioritizeTexture)( GLcontext *ctx, struct gl_texture_object *t,
543 GLclampf priority );
544
545 /**
546 * Called by glActiveTextureARB() to set current texture unit.
547 */
548 void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber );
549
550 /**
551 * Called when the texture's color lookup table is changed.
552 *
553 * If \p tObj is NULL then the shared texture palette
554 * gl_texture_object::Palette is to be updated.
555 */
556 void (*UpdateTexturePalette)( GLcontext *ctx,
557 struct gl_texture_object *tObj );
558 /*@}*/
559
560
561 /**
562 * \name Imaging functionality
563 */
564 /*@{*/
565 void (*CopyColorTable)( GLcontext *ctx,
566 GLenum target, GLenum internalformat,
567 GLint x, GLint y, GLsizei width );
568
569 void (*CopyColorSubTable)( GLcontext *ctx,
570 GLenum target, GLsizei start,
571 GLint x, GLint y, GLsizei width );
572
573 void (*CopyConvolutionFilter1D)( GLcontext *ctx, GLenum target,
574 GLenum internalFormat,
575 GLint x, GLint y, GLsizei width );
576
577 void (*CopyConvolutionFilter2D)( GLcontext *ctx, GLenum target,
578 GLenum internalFormat,
579 GLint x, GLint y,
580 GLsizei width, GLsizei height );
581 /*@}*/
582
583
584 /**
585 * \name State-changing functions.
586 *
587 * \note drawing functions are above.
588 *
589 * These functions are called by their corresponding OpenGL API functions.
590 * They are \e also called by the gl_PopAttrib() function!!!
591 * May add more functions like these to the device driver in the future.
592 */
593 /*@{*/
594 /** Specify the alpha test function */
595 void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLfloat ref);
596 /** Set the blend color */
597 void (*BlendColor)(GLcontext *ctx, const GLfloat color[4]);
598 /** Set the blend equation */
599 void (*BlendEquation)(GLcontext *ctx, GLenum mode);
600 /** Specify pixel arithmetic */
601 void (*BlendFunc)(GLcontext *ctx, GLenum sfactor, GLenum dfactor);
602 void (*BlendFuncSeparate)(GLcontext *ctx,
603 GLenum sfactorRGB, GLenum dfactorRGB,
604 GLenum sfactorA, GLenum dfactorA);
605 /** Specify clear values for the color buffers */
606 void (*ClearColor)(GLcontext *ctx, const GLfloat color[4]);
607 /** Specify the clear value for the depth buffer */
608 void (*ClearDepth)(GLcontext *ctx, GLclampd d);
609 /** Specify the clear value for the color index buffers */
610 void (*ClearIndex)(GLcontext *ctx, GLuint index);
611 /** Specify the clear value for the stencil buffer */
612 void (*ClearStencil)(GLcontext *ctx, GLint s);
613 /** Specify a plane against which all geometry is clipped */
614 void (*ClipPlane)(GLcontext *ctx, GLenum plane, const GLfloat *equation );
615 /** Enable and disable writing of frame buffer color components */
616 void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
617 GLboolean bmask, GLboolean amask );
618 /** Cause a material color to track the current color */
619 void (*ColorMaterial)(GLcontext *ctx, GLenum face, GLenum mode);
620 /** Specify whether front- or back-facing facets can be culled */
621 void (*CullFace)(GLcontext *ctx, GLenum mode);
622 /** Define front- and back-facing polygons */
623 void (*FrontFace)(GLcontext *ctx, GLenum mode);
624 /** Specify the value used for depth buffer comparisons */
625 void (*DepthFunc)(GLcontext *ctx, GLenum func);
626 /** Enable or disable writing into the depth buffer */
627 void (*DepthMask)(GLcontext *ctx, GLboolean flag);
628 /** Specify mapping of depth values from normalized device coordinates to window coordinates */
629 void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval);
630 /** Enable or disable server-side gl capabilities */
631 void (*Enable)(GLcontext *ctx, GLenum cap, GLboolean state);
632 /** Specify fog parameters */
633 void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
634 /** Specify implementation-specific hints */
635 void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode);
636 /** Control the writing of individual bits in the color index buffers */
637 void (*IndexMask)(GLcontext *ctx, GLuint mask);
638 /** Set light source parameters */
639 void (*Lightfv)(GLcontext *ctx, GLenum light,
640 GLenum pname, const GLfloat *params );
641 /** Set the lighting model parameters */
642 void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
643 /** Specify the line stipple pattern */
644 void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern );
645 /** Specify the width of rasterized lines */
646 void (*LineWidth)(GLcontext *ctx, GLfloat width);
647 /** Specify a logical pixel operation for color index rendering */
648 void (*LogicOpcode)(GLcontext *ctx, GLenum opcode);
649 void (*PointParameterfv)(GLcontext *ctx, GLenum pname,
650 const GLfloat *params);
651 /** Specify the diameter of rasterized points */
652 void (*PointSize)(GLcontext *ctx, GLfloat size);
653 /** Select a polygon rasterization mode */
654 void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode);
655 /** Set the scale and units used to calculate depth values */
656 void (*PolygonOffset)(GLcontext *ctx, GLfloat factor, GLfloat units);
657 /** Set the polygon stippling pattern */
658 void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask );
659 /** Set rasterization mode */
660 void (*RenderMode)(GLcontext *ctx, GLenum mode );
661 /** Define the scissor box */
662 void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
663 /** Select flat or smooth shading */
664 void (*ShadeModel)(GLcontext *ctx, GLenum mode);
665 /** Set function and reference value for stencil testing */
666 void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
667 /** Control the writing of individual bits in the stencil planes */
668 void (*StencilMask)(GLcontext *ctx, GLuint mask);
669 /** Set stencil test actions */
670 void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass);
671 void (*ActiveStencilFace)(GLcontext *ctx, GLuint face);
672 /** Control the generation of texture coordinates */
673 void (*TexGen)(GLcontext *ctx, GLenum coord, GLenum pname,
674 const GLfloat *params);
675 /** Set texture environment parameters */
676 void (*TexEnv)(GLcontext *ctx, GLenum target, GLenum pname,
677 const GLfloat *param);
678 /** Set texture parameters */
679 void (*TexParameter)(GLcontext *ctx, GLenum target,
680 struct gl_texture_object *texObj,
681 GLenum pname, const GLfloat *params);
682 void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat);
683 /** Set the viewport */
684 void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
685 /*@}*/
686
687
688 /**
689 * \name Vertex array functions
690 *
691 * Called by the corresponding OpenGL functions.
692 */
693 /*@{*/
694 void (*VertexPointer)(GLcontext *ctx, GLint size, GLenum type,
695 GLsizei stride, const GLvoid *ptr);
696 void (*NormalPointer)(GLcontext *ctx, GLenum type,
697 GLsizei stride, const GLvoid *ptr);
698 void (*ColorPointer)(GLcontext *ctx, GLint size, GLenum type,
699 GLsizei stride, const GLvoid *ptr);
700 void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
701 GLsizei stride, const GLvoid *ptr);
702 void (*IndexPointer)(GLcontext *ctx, GLenum type,
703 GLsizei stride, const GLvoid *ptr);
704 void (*SecondaryColorPointer)(GLcontext *ctx, GLint size, GLenum type,
705 GLsizei stride, const GLvoid *ptr);
706 void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type,
707 GLsizei stride, const GLvoid *ptr);
708 void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);
709 void (*VertexAttribPointer)(GLcontext *ctx, GLuint index, GLint size,
710 GLenum type, GLsizei stride, const GLvoid *ptr);
711 /*@}*/
712
713
714 /**
715 * \name State-query functions
716 *
717 * Return GL_TRUE if query was completed, GL_FALSE otherwise.
718 */
719 /*@{*/
720 /** Return the value or values of a selected parameter */
721 GLboolean (*GetBooleanv)(GLcontext *ctx, GLenum pname, GLboolean *result);
722 /** Return the value or values of a selected parameter */
723 GLboolean (*GetDoublev)(GLcontext *ctx, GLenum pname, GLdouble *result);
724 /** Return the value or values of a selected parameter */
725 GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result);
726 /** Return the value or values of a selected parameter */
727 GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result);
728 /** Return the value or values of a selected parameter */
729 GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result);
730 /*@}*/
731
732
733 /**
734 * \name Vertex buffer object functions
735 */
736 #if FEATURE_ARB_vertex_buffer_object
737 /*@{*/
738 void (*BindBuffer)( GLcontext *ctx, GLenum target,
739 struct gl_buffer_object *obj );
740
741 struct gl_buffer_object * (*NewBufferObject)( GLcontext *ctx, GLuint buffer,
742 GLenum target );
743
744 void (*DeleteBuffer)( GLcontext *ctx, struct gl_buffer_object *obj );
745
746 void (*BufferData)( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
747 const GLvoid *data, GLenum usage,
748 struct gl_buffer_object *obj );
749
750 void (*BufferSubData)( GLcontext *ctx, GLenum target, GLintptrARB offset,
751 GLsizeiptrARB size, const GLvoid *data,
752 struct gl_buffer_object *obj );
753
754 void (*GetBufferSubData)( GLcontext *ctx, GLenum target,
755 GLintptrARB offset, GLsizeiptrARB size,
756 GLvoid *data, struct gl_buffer_object *obj );
757
758 void * (*MapBuffer)( GLcontext *ctx, GLenum target, GLenum access,
759 struct gl_buffer_object *obj );
760
761 GLboolean (*UnmapBuffer)( GLcontext *ctx, GLenum target,
762 struct gl_buffer_object *obj );
763 /*@}*/
764 #endif
765
766 /**
767 * \name Support for multiple T&L engines
768 */
769 /*@{*/
770
771 /**
772 * Bitmask of state changes that require the current T&L module to be
773 * validated, using ValidateTnlModule() below.
774 */
775 GLuint NeedValidate;
776
777 /**
778 * Validate the current T&L module.
779 *
780 * This is called directly after UpdateState() when a state change that has
781 * occurred matches the dd_function_table::NeedValidate bitmask above. This
782 * ensures all computed values are up to date, thus allowing the driver to
783 * decide if the current T&L module needs to be swapped out.
784 *
785 * This must be non-NULL if a driver installs a custom T&L module and sets
786 * the dd_function_table::NeedValidate bitmask, but may be NULL otherwise.
787 */
788 void (*ValidateTnlModule)( GLcontext *ctx, GLuint new_state );
789
790
791 #define PRIM_OUTSIDE_BEGIN_END GL_POLYGON+1
792 #define PRIM_INSIDE_UNKNOWN_PRIM GL_POLYGON+2
793 #define PRIM_UNKNOWN GL_POLYGON+3
794
795 /**
796 * Set by the driver-supplied T&L engine.
797 *
798 * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd().
799 */
800 GLuint CurrentExecPrimitive;
801
802 /**
803 * Current state of an in-progress compilation.
804 *
805 * May take on any of the additional values PRIM_OUTSIDE_BEGIN_END,
806 * PRIM_INSIDE_UNKNOWN_PRIM or PRIM_UNKNOWN defined above.
807 */
808 GLuint CurrentSavePrimitive;
809
810
811 #define FLUSH_STORED_VERTICES 0x1
812 #define FLUSH_UPDATE_CURRENT 0x2
813 /**
814 * Set by the driver-supplied T&L engine whenever vertices are buffered
815 * between glBegin()/glEnd() objects or __GLcontextRec::Current is not
816 * updated.
817 *
818 * The dd_function_table::FlushVertices call below may be used to resolve
819 * these conditions.
820 */
821 GLuint NeedFlush;
822
823 /**
824 * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if
825 * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered
826 * vertices, if FLUSH_UPDATE_CURRENT bit is set updates
827 * __GLcontextRec::Current and gl_light_attrib::Material
828 *
829 * Note that the default T&L engine never clears the
830 * FLUSH_UPDATE_CURRENT bit, even after performing the update.
831 */
832 void (*FlushVertices)( GLcontext *ctx, GLuint flags );
833
834 /**
835 * Notify driver that the special derived value _NeedEyeCoords has
836 * changed.
837 */
838 void (*LightingSpaceChange)( GLcontext *ctx );
839
840 /**
841 * Called by glNewList().
842 *
843 * Let the T&L component know what is going on with display lists
844 * in time to make changes to dispatch tables, etc.
845 */
846 void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode );
847 /**
848 * Called by glEndList().
849 *
850 * \sa dd_function_table::NewList.
851 */
852 void (*EndList)( GLcontext *ctx );
853
854 /**
855 * Called by glCallList(s), but not recursively.
856 *
857 * Notify the T&L component before and after calling a display list.
858 * Called by glCallList(s), but not recursively.
859 */
860 void (*BeginCallList)( GLcontext *ctx, GLuint list );
861 /**
862 * Called by glEndCallList().
863 *
864 * \sa dd_function_table::BeginCallList.
865 */
866 void (*EndCallList)( GLcontext *ctx );
867
868 /**
869 * Let the T&L component know when the context becomes current.
870 */
871 void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
872 GLframebuffer *readBuffer );
873
874 /**
875 * Called by glLockArraysEXT().
876 */
877 void (*LockArraysEXT)( GLcontext *ctx, GLint first, GLsizei count );
878 /**
879 * Called by UnlockArraysEXT().
880 */
881 void (*UnlockArraysEXT)( GLcontext *ctx );
882 /*@}*/
883
884 };
885
886
887 /**
888 * Transform/Clip/Lighting interface
889 *
890 * Drivers present a reduced set of the functions possible in
891 * glBegin()/glEnd() objects. Core mesa provides translation stubs for the
892 * remaining functions to map down to these entry points.
893 *
894 * These are the initial values to be installed into dispatch by
895 * mesa. If the T&L driver wants to modify the dispatch table
896 * while installed, it must do so itself. It would be possible for
897 * the vertexformat to install it's own initial values for these
898 * functions, but this way there is an obvious list of what is
899 * expected of the driver.
900 *
901 * If the driver wants to hook in entry points other than those
902 * listed, it must restore them to their original values in
903 * the disable() callback, below.
904 */
905 typedef struct {
906 /**
907 * \name Vertex
908 */
909 /*@{*/
910 void (GLAPIENTRYP ArrayElement)( GLint ); /* NOTE */
911 void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat );
912 void (GLAPIENTRYP Color3fv)( const GLfloat * );
913 void (GLAPIENTRYP Color3ub)( GLubyte, GLubyte, GLubyte );
914 void (GLAPIENTRYP Color3ubv)( const GLubyte * );
915 void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat );
916 void (GLAPIENTRYP Color4fv)( const GLfloat * );
917 void (GLAPIENTRYP Color4ub)( GLubyte, GLubyte, GLubyte, GLubyte );
918 void (GLAPIENTRYP Color4ubv)( const GLubyte * );
919 void (GLAPIENTRYP EdgeFlag)( GLboolean );
920 void (GLAPIENTRYP EdgeFlagv)( const GLboolean * );
921 void (GLAPIENTRYP EvalCoord1f)( GLfloat ); /* NOTE */
922 void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * ); /* NOTE */
923 void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat ); /* NOTE */
924 void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * ); /* NOTE */
925 void (GLAPIENTRYP EvalPoint1)( GLint ); /* NOTE */
926 void (GLAPIENTRYP EvalPoint2)( GLint, GLint ); /* NOTE */
927 void (GLAPIENTRYP FogCoordfEXT)( GLfloat );
928 void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * );
929 void (GLAPIENTRYP Indexi)( GLint );
930 void (GLAPIENTRYP Indexiv)( const GLint * );
931 void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * ); /* NOTE */
932 void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat );
933 void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * );
934 void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat );
935 void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * );
936 void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat );
937 void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * );
938 void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat );
939 void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * );
940 void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat );
941 void (GLAPIENTRYP Normal3fv)( const GLfloat * );
942 void (GLAPIENTRYP SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat );
943 void (GLAPIENTRYP SecondaryColor3fvEXT)( const GLfloat * );
944 void (GLAPIENTRYP SecondaryColor3ubEXT)( GLubyte, GLubyte, GLubyte );
945 void (GLAPIENTRYP SecondaryColor3ubvEXT)( const GLubyte * );
946 void (GLAPIENTRYP TexCoord1f)( GLfloat );
947 void (GLAPIENTRYP TexCoord1fv)( const GLfloat * );
948 void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat );
949 void (GLAPIENTRYP TexCoord2fv)( const GLfloat * );
950 void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat );
951 void (GLAPIENTRYP TexCoord3fv)( const GLfloat * );
952 void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat );
953 void (GLAPIENTRYP TexCoord4fv)( const GLfloat * );
954 void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat );
955 void (GLAPIENTRYP Vertex2fv)( const GLfloat * );
956 void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat );
957 void (GLAPIENTRYP Vertex3fv)( const GLfloat * );
958 void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat );
959 void (GLAPIENTRYP Vertex4fv)( const GLfloat * );
960 void (GLAPIENTRYP CallList)( GLuint ); /* NOTE */
961 void (GLAPIENTRYP Begin)( GLenum );
962 void (GLAPIENTRYP End)( void );
963 void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
964 void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v );
965 /*@}*/
966
967 /*
968 */
969 void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat );
970
971 /**
972 * \name Array
973 *
974 * These may or may not belong here. Heuristic: if an array is
975 * enabled, the installed vertex format should support that array and
976 * its current size natively.
977 */
978 /*@{*/
979 void (GLAPIENTRYP DrawArrays)( GLenum mode, GLint start, GLsizei count );
980 void (GLAPIENTRYP DrawElements)( GLenum mode, GLsizei count, GLenum type,
981 const GLvoid *indices );
982 void (GLAPIENTRYP DrawRangeElements)( GLenum mode, GLuint start,
983 GLuint end, GLsizei count,
984 GLenum type, const GLvoid *indices );
985 /*@}*/
986
987 /**
988 * \name Eval
989 *
990 * If you don't support eval, fallback to the default vertex format
991 * on receiving an eval call and use the pipeline mechanism to
992 * provide partial T&L acceleration.
993 *
994 * Mesa will provide a set of helper functions to do eval within
995 * accelerated vertex formats, eventually...
996 */
997 /*@{*/
998 void (GLAPIENTRYP EvalMesh1)( GLenum mode, GLint i1, GLint i2 );
999 void (GLAPIENTRYP EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
1000 /*@}*/
1001
1002 /**
1003 * Should core try to send colors to glColor4f or glColor4chan,
1004 * where it has a choice?
1005 */
1006 GLboolean prefer_float_colors;
1007 } GLvertexformat;
1008
1009
1010 #endif /* DD_INCLUDED */