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