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