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