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