mesa: Hide weirdness of 1D_ARRAY textures from Driver.CopyTexSubImage().
[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 *
9 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * 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 #include "glheader.h"
37
38 struct gl_buffer_object;
39 struct gl_context;
40 struct gl_display_list;
41 struct gl_framebuffer;
42 struct gl_pixelstore_attrib;
43 struct gl_program;
44 struct gl_renderbuffer;
45 struct gl_renderbuffer_attachment;
46 struct gl_shader;
47 struct gl_shader_program;
48 struct gl_texture_image;
49 struct gl_texture_object;
50
51 /* GL_ARB_vertex_buffer_object */
52 /* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return
53 * NULL) if buffer is unavailable for immediate mapping.
54 *
55 * Does GL_MAP_INVALIDATE_RANGE_BIT do this? It seems so, but it
56 * would require more book-keeping in the driver than seems necessary
57 * at this point.
58 *
59 * Does GL_MAP_INVALDIATE_BUFFER_BIT do this? Not really -- we don't
60 * want to provoke the driver to throw away the old storage, we will
61 * respect the contents of already referenced data.
62 */
63 #define MESA_MAP_NOWAIT_BIT 0x0040
64
65
66 /**
67 * Device driver function table.
68 * Core Mesa uses these function pointers to call into device drivers.
69 * Most of these functions directly correspond to OpenGL state commands.
70 * Core Mesa will call these functions after error checking has been done
71 * so that the drivers don't have to worry about error testing.
72 *
73 * Vertex transformation/clipping/lighting is patched into the T&L module.
74 * Rasterization functions are patched into the swrast module.
75 *
76 * Note: when new functions are added here, the drivers/common/driverfuncs.c
77 * file should be updated too!!!
78 */
79 struct dd_function_table {
80 /**
81 * Return a string as needed by glGetString().
82 * Only the GL_RENDERER query must be implemented. Otherwise, NULL can be
83 * returned.
84 */
85 const GLubyte * (*GetString)( struct gl_context *ctx, GLenum name );
86
87 /**
88 * Notify the driver after Mesa has made some internal state changes.
89 *
90 * This is in addition to any state change callbacks Mesa may already have
91 * made.
92 */
93 void (*UpdateState)( struct gl_context *ctx, GLbitfield new_state );
94
95 /**
96 * Get the width and height of the named buffer/window.
97 *
98 * Mesa uses this to determine when the driver's window size has changed.
99 * XXX OBSOLETE: this function will be removed in the future.
100 */
101 void (*GetBufferSize)( struct gl_framebuffer *buffer,
102 GLuint *width, GLuint *height );
103
104 /**
105 * Resize the given framebuffer to the given size.
106 * XXX OBSOLETE: this function will be removed in the future.
107 */
108 void (*ResizeBuffers)( struct gl_context *ctx, struct gl_framebuffer *fb,
109 GLuint width, GLuint height);
110
111 /**
112 * This is called whenever glFinish() is called.
113 */
114 void (*Finish)( struct gl_context *ctx );
115
116 /**
117 * This is called whenever glFlush() is called.
118 */
119 void (*Flush)( struct gl_context *ctx );
120
121 /**
122 * Clear the color/depth/stencil/accum buffer(s).
123 * \param buffers a bitmask of BUFFER_BIT_* flags indicating which
124 * renderbuffers need to be cleared.
125 */
126 void (*Clear)( struct gl_context *ctx, GLbitfield buffers );
127
128 /**
129 * Execute glAccum command.
130 */
131 void (*Accum)( struct gl_context *ctx, GLenum op, GLfloat value );
132
133
134 /**
135 * Execute glRasterPos, updating the ctx->Current.Raster fields
136 */
137 void (*RasterPos)( struct gl_context *ctx, const GLfloat v[4] );
138
139 /**
140 * \name Image-related functions
141 */
142 /*@{*/
143
144 /**
145 * Called by glDrawPixels().
146 * \p unpack describes how to unpack the source image data.
147 */
148 void (*DrawPixels)( struct gl_context *ctx,
149 GLint x, GLint y, GLsizei width, GLsizei height,
150 GLenum format, GLenum type,
151 const struct gl_pixelstore_attrib *unpack,
152 const GLvoid *pixels );
153
154 /**
155 * Called by glReadPixels().
156 */
157 void (*ReadPixels)( struct gl_context *ctx,
158 GLint x, GLint y, GLsizei width, GLsizei height,
159 GLenum format, GLenum type,
160 const struct gl_pixelstore_attrib *unpack,
161 GLvoid *dest );
162
163 /**
164 * Called by glCopyPixels().
165 */
166 void (*CopyPixels)( struct gl_context *ctx, GLint srcx, GLint srcy,
167 GLsizei width, GLsizei height,
168 GLint dstx, GLint dsty, GLenum type );
169
170 /**
171 * Called by glBitmap().
172 */
173 void (*Bitmap)( struct gl_context *ctx,
174 GLint x, GLint y, GLsizei width, GLsizei height,
175 const struct gl_pixelstore_attrib *unpack,
176 const GLubyte *bitmap );
177 /*@}*/
178
179
180 /**
181 * \name Texture image functions
182 */
183 /*@{*/
184
185 /**
186 * Choose actual hardware texture format given the texture target, the
187 * user-provided source image format and type and the desired internal
188 * format. In some cases, srcFormat and srcType can be GL_NONE.
189 * Note: target may be GL_TEXTURE_CUBE_MAP, but never
190 * GL_TEXTURE_CUBE_MAP_[POSITIVE/NEGATIVE]_[XYZ].
191 * Called by glTexImage(), etc.
192 */
193 gl_format (*ChooseTextureFormat)( struct gl_context *ctx,
194 GLenum target, GLint internalFormat,
195 GLenum srcFormat, GLenum srcType );
196
197 /**
198 * Determine sample counts support for a particular target and format
199 *
200 * \param ctx GL context
201 * \param target GL target enum
202 * \param internalFormat GL format enum
203 * \param samples Buffer to hold the returned sample counts.
204 * Drivers \b must \b not return more than 16 counts.
205 *
206 * \returns
207 * The number of sample counts actually written to \c samples. If
208 * \c internaFormat is not renderable, zero is returned.
209 */
210 size_t (*QuerySamplesForFormat)(struct gl_context *ctx,
211 GLenum target,
212 GLenum internalFormat,
213 int samples[16]);
214
215 /**
216 * Called by glTexImage[123]D() and glCopyTexImage[12]D()
217 * Allocate texture memory and copy the user's image to the buffer.
218 * The gl_texture_image fields, etc. will be fully initialized.
219 * The parameters are the same as glTexImage3D(), plus:
220 * \param dims 1, 2, or 3 indicating glTexImage1/2/3D()
221 * \param packing describes how to unpack the source data.
222 * \param texImage is the destination texture image.
223 */
224 void (*TexImage)(struct gl_context *ctx, GLuint dims,
225 struct gl_texture_image *texImage,
226 GLenum format, GLenum type, const GLvoid *pixels,
227 const struct gl_pixelstore_attrib *packing);
228
229 /**
230 * Called by glTexSubImage[123]D().
231 * Replace a subset of the target texture with new texel data.
232 */
233 void (*TexSubImage)(struct gl_context *ctx, GLuint dims,
234 struct gl_texture_image *texImage,
235 GLint xoffset, GLint yoffset, GLint zoffset,
236 GLsizei width, GLsizei height, GLint depth,
237 GLenum format, GLenum type,
238 const GLvoid *pixels,
239 const struct gl_pixelstore_attrib *packing);
240
241
242 /**
243 * Called by glGetTexImage().
244 */
245 void (*GetTexImage)( struct gl_context *ctx,
246 GLenum format, GLenum type, GLvoid *pixels,
247 struct gl_texture_image *texImage );
248
249 /**
250 * Called by glCopyTex[Sub]Image[123]D().
251 *
252 * This function should copy a rectangular region in the rb to a single
253 * destination slice, specified by @slice. In the case of 1D array
254 * textures (where one GL call can potentially affect multiple destination
255 * slices), core mesa takes care of calling this function multiple times,
256 * once for each scanline to be copied.
257 */
258 void (*CopyTexSubImage)(struct gl_context *ctx, GLuint dims,
259 struct gl_texture_image *texImage,
260 GLint xoffset, GLint yoffset, GLint slice,
261 struct gl_renderbuffer *rb,
262 GLint x, GLint y,
263 GLsizei width, GLsizei height);
264
265 /**
266 * Called by glGenerateMipmap() or when GL_GENERATE_MIPMAP_SGIS is enabled.
267 */
268 void (*GenerateMipmap)(struct gl_context *ctx, GLenum target,
269 struct gl_texture_object *texObj);
270
271 /**
272 * Called by glTexImage, glCompressedTexImage, glCopyTexImage
273 * and glTexStorage to check if the dimensions of the texture image
274 * are too large.
275 * \param target any GL_PROXY_TEXTURE_x target
276 * \return GL_TRUE if the image is OK, GL_FALSE if too large
277 */
278 GLboolean (*TestProxyTexImage)(struct gl_context *ctx, GLenum target,
279 GLint level, gl_format format,
280 GLint width, GLint height,
281 GLint depth, GLint border);
282 /*@}*/
283
284
285 /**
286 * \name Compressed texture functions
287 */
288 /*@{*/
289
290 /**
291 * Called by glCompressedTexImage[123]D().
292 */
293 void (*CompressedTexImage)(struct gl_context *ctx, GLuint dims,
294 struct gl_texture_image *texImage,
295 GLsizei imageSize, const GLvoid *data);
296
297 /**
298 * Called by glCompressedTexSubImage[123]D().
299 */
300 void (*CompressedTexSubImage)(struct gl_context *ctx, GLuint dims,
301 struct gl_texture_image *texImage,
302 GLint xoffset, GLint yoffset, GLint zoffset,
303 GLsizei width, GLint height, GLint depth,
304 GLenum format,
305 GLsizei imageSize, const GLvoid *data);
306
307 /**
308 * Called by glGetCompressedTexImage.
309 */
310 void (*GetCompressedTexImage)(struct gl_context *ctx,
311 struct gl_texture_image *texImage,
312 GLvoid *data);
313 /*@}*/
314
315 /**
316 * \name Texture object / image functions
317 */
318 /*@{*/
319
320 /**
321 * Called by glBindTexture().
322 */
323 void (*BindTexture)( struct gl_context *ctx, GLenum target,
324 struct gl_texture_object *tObj );
325
326 /**
327 * Called to allocate a new texture object. Drivers will usually
328 * allocate/return a subclass of gl_texture_object.
329 */
330 struct gl_texture_object * (*NewTextureObject)(struct gl_context *ctx,
331 GLuint name, GLenum target);
332 /**
333 * Called to delete/free a texture object. Drivers should free the
334 * object and any image data it contains.
335 */
336 void (*DeleteTexture)(struct gl_context *ctx,
337 struct gl_texture_object *texObj);
338
339 /** Called to allocate a new texture image object. */
340 struct gl_texture_image * (*NewTextureImage)(struct gl_context *ctx);
341
342 /** Called to free a texture image object returned by NewTextureImage() */
343 void (*DeleteTextureImage)(struct gl_context *ctx,
344 struct gl_texture_image *);
345
346 /** Called to allocate memory for a single texture image */
347 GLboolean (*AllocTextureImageBuffer)(struct gl_context *ctx,
348 struct gl_texture_image *texImage);
349
350 /** Free the memory for a single texture image */
351 void (*FreeTextureImageBuffer)(struct gl_context *ctx,
352 struct gl_texture_image *texImage);
353
354 /** Map a slice of a texture image into user space.
355 * Note: for GL_TEXTURE_1D_ARRAY, height must be 1, y must be 0 and slice
356 * indicates the 1D array index.
357 * \param texImage the texture image
358 * \param slice the 3D image slice or array texture slice
359 * \param x, y, w, h region of interest
360 * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT and
361 * GL_MAP_INVALIDATE_RANGE_BIT (if writing)
362 * \param mapOut returns start of mapping of region of interest
363 * \param rowStrideOut returns row stride (in bytes). In the case of a
364 * compressed texture, this is the byte stride between one row of blocks
365 * and another.
366 */
367 void (*MapTextureImage)(struct gl_context *ctx,
368 struct gl_texture_image *texImage,
369 GLuint slice,
370 GLuint x, GLuint y, GLuint w, GLuint h,
371 GLbitfield mode,
372 GLubyte **mapOut, GLint *rowStrideOut);
373
374 void (*UnmapTextureImage)(struct gl_context *ctx,
375 struct gl_texture_image *texImage,
376 GLuint slice);
377
378 /** For GL_ARB_texture_storage. Allocate memory for whole mipmap stack.
379 * All the gl_texture_images in the texture object will have their
380 * dimensions, format, etc. initialized already.
381 */
382 GLboolean (*AllocTextureStorage)(struct gl_context *ctx,
383 struct gl_texture_object *texObj,
384 GLsizei levels, GLsizei width,
385 GLsizei height, GLsizei depth);
386
387 /**
388 * Map a renderbuffer into user space.
389 * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT and
390 * GL_MAP_INVALIDATE_RANGE_BIT (if writing)
391 */
392 void (*MapRenderbuffer)(struct gl_context *ctx,
393 struct gl_renderbuffer *rb,
394 GLuint x, GLuint y, GLuint w, GLuint h,
395 GLbitfield mode,
396 GLubyte **mapOut, GLint *rowStrideOut);
397
398 void (*UnmapRenderbuffer)(struct gl_context *ctx,
399 struct gl_renderbuffer *rb);
400
401 /*@}*/
402
403
404 /**
405 * \name Vertex/fragment program functions
406 */
407 /*@{*/
408 /** Bind a vertex/fragment program */
409 void (*BindProgram)(struct gl_context *ctx, GLenum target, struct gl_program *prog);
410 /** Allocate a new program */
411 struct gl_program * (*NewProgram)(struct gl_context *ctx, GLenum target, GLuint id);
412 /** Delete a program */
413 void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog);
414 /**
415 * Notify driver that a program string (and GPU code) has been specified
416 * or modified. Return GL_TRUE or GL_FALSE to indicate if the program is
417 * supported by the driver.
418 */
419 GLboolean (*ProgramStringNotify)(struct gl_context *ctx, GLenum target,
420 struct gl_program *prog);
421
422 /**
423 * Notify driver that the sampler uniforms for the current program have
424 * changed. On some drivers, this may require shader recompiles.
425 */
426 void (*SamplerUniformChange)(struct gl_context *ctx, GLenum target,
427 struct gl_program *prog);
428
429 /** Query if program can be loaded onto hardware */
430 GLboolean (*IsProgramNative)(struct gl_context *ctx, GLenum target,
431 struct gl_program *prog);
432
433 /*@}*/
434
435 /**
436 * \name GLSL shader/program functions.
437 */
438 /*@{*/
439 /**
440 * Called when a shader program is linked.
441 *
442 * This gives drivers an opportunity to clone the IR and make their
443 * own transformations on it for the purposes of code generation.
444 */
445 GLboolean (*LinkShader)(struct gl_context *ctx, struct gl_shader_program *shader);
446 /*@}*/
447
448 /**
449 * \name State-changing functions.
450 *
451 * \note drawing functions are above.
452 *
453 * These functions are called by their corresponding OpenGL API functions.
454 * They are \e also called by the gl_PopAttrib() function!!!
455 * May add more functions like these to the device driver in the future.
456 */
457 /*@{*/
458 /** Specify the alpha test function */
459 void (*AlphaFunc)(struct gl_context *ctx, GLenum func, GLfloat ref);
460 /** Set the blend color */
461 void (*BlendColor)(struct gl_context *ctx, const GLfloat color[4]);
462 /** Set the blend equation */
463 void (*BlendEquationSeparate)(struct gl_context *ctx, GLenum modeRGB, GLenum modeA);
464 void (*BlendEquationSeparatei)(struct gl_context *ctx, GLuint buffer,
465 GLenum modeRGB, GLenum modeA);
466 /** Specify pixel arithmetic */
467 void (*BlendFuncSeparate)(struct gl_context *ctx,
468 GLenum sfactorRGB, GLenum dfactorRGB,
469 GLenum sfactorA, GLenum dfactorA);
470 void (*BlendFuncSeparatei)(struct gl_context *ctx, GLuint buffer,
471 GLenum sfactorRGB, GLenum dfactorRGB,
472 GLenum sfactorA, GLenum dfactorA);
473 /** Specify a plane against which all geometry is clipped */
474 void (*ClipPlane)(struct gl_context *ctx, GLenum plane, const GLfloat *equation );
475 /** Enable and disable writing of frame buffer color components */
476 void (*ColorMask)(struct gl_context *ctx, GLboolean rmask, GLboolean gmask,
477 GLboolean bmask, GLboolean amask );
478 void (*ColorMaskIndexed)(struct gl_context *ctx, GLuint buf, GLboolean rmask,
479 GLboolean gmask, GLboolean bmask, GLboolean amask);
480 /** Cause a material color to track the current color */
481 void (*ColorMaterial)(struct gl_context *ctx, GLenum face, GLenum mode);
482 /** Specify whether front- or back-facing facets can be culled */
483 void (*CullFace)(struct gl_context *ctx, GLenum mode);
484 /** Define front- and back-facing polygons */
485 void (*FrontFace)(struct gl_context *ctx, GLenum mode);
486 /** Specify the value used for depth buffer comparisons */
487 void (*DepthFunc)(struct gl_context *ctx, GLenum func);
488 /** Enable or disable writing into the depth buffer */
489 void (*DepthMask)(struct gl_context *ctx, GLboolean flag);
490 /** Specify mapping of depth values from NDC to window coordinates */
491 void (*DepthRange)(struct gl_context *ctx, GLclampd nearval, GLclampd farval);
492 /** Specify the current buffer for writing */
493 void (*DrawBuffer)( struct gl_context *ctx, GLenum buffer );
494 /** Specify the buffers for writing for fragment programs*/
495 void (*DrawBuffers)( struct gl_context *ctx, GLsizei n, const GLenum *buffers );
496 /** Enable or disable server-side gl capabilities */
497 void (*Enable)(struct gl_context *ctx, GLenum cap, GLboolean state);
498 /** Specify fog parameters */
499 void (*Fogfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params);
500 /** Specify implementation-specific hints */
501 void (*Hint)(struct gl_context *ctx, GLenum target, GLenum mode);
502 /** Set light source parameters.
503 * Note: for GL_POSITION and GL_SPOT_DIRECTION, params will have already
504 * been transformed to eye-space.
505 */
506 void (*Lightfv)(struct gl_context *ctx, GLenum light,
507 GLenum pname, const GLfloat *params );
508 /** Set the lighting model parameters */
509 void (*LightModelfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params);
510 /** Specify the line stipple pattern */
511 void (*LineStipple)(struct gl_context *ctx, GLint factor, GLushort pattern );
512 /** Specify the width of rasterized lines */
513 void (*LineWidth)(struct gl_context *ctx, GLfloat width);
514 /** Specify a logical pixel operation for color index rendering */
515 void (*LogicOpcode)(struct gl_context *ctx, GLenum opcode);
516 void (*PointParameterfv)(struct gl_context *ctx, GLenum pname,
517 const GLfloat *params);
518 /** Specify the diameter of rasterized points */
519 void (*PointSize)(struct gl_context *ctx, GLfloat size);
520 /** Select a polygon rasterization mode */
521 void (*PolygonMode)(struct gl_context *ctx, GLenum face, GLenum mode);
522 /** Set the scale and units used to calculate depth values */
523 void (*PolygonOffset)(struct gl_context *ctx, GLfloat factor, GLfloat units);
524 /** Set the polygon stippling pattern */
525 void (*PolygonStipple)(struct gl_context *ctx, const GLubyte *mask );
526 /* Specifies the current buffer for reading */
527 void (*ReadBuffer)( struct gl_context *ctx, GLenum buffer );
528 /** Set rasterization mode */
529 void (*RenderMode)(struct gl_context *ctx, GLenum mode );
530 /** Define the scissor box */
531 void (*Scissor)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
532 /** Select flat or smooth shading */
533 void (*ShadeModel)(struct gl_context *ctx, GLenum mode);
534 /** OpenGL 2.0 two-sided StencilFunc */
535 void (*StencilFuncSeparate)(struct gl_context *ctx, GLenum face, GLenum func,
536 GLint ref, GLuint mask);
537 /** OpenGL 2.0 two-sided StencilMask */
538 void (*StencilMaskSeparate)(struct gl_context *ctx, GLenum face, GLuint mask);
539 /** OpenGL 2.0 two-sided StencilOp */
540 void (*StencilOpSeparate)(struct gl_context *ctx, GLenum face, GLenum fail,
541 GLenum zfail, GLenum zpass);
542 /** Control the generation of texture coordinates */
543 void (*TexGen)(struct gl_context *ctx, GLenum coord, GLenum pname,
544 const GLfloat *params);
545 /** Set texture environment parameters */
546 void (*TexEnv)(struct gl_context *ctx, GLenum target, GLenum pname,
547 const GLfloat *param);
548 /** Set texture parameters */
549 void (*TexParameter)(struct gl_context *ctx, GLenum target,
550 struct gl_texture_object *texObj,
551 GLenum pname, const GLfloat *params);
552 /** Set the viewport */
553 void (*Viewport)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
554 /*@}*/
555
556
557 /**
558 * \name Vertex/pixel buffer object functions
559 */
560 /*@{*/
561 void (*BindBuffer)( struct gl_context *ctx, GLenum target,
562 struct gl_buffer_object *obj );
563
564 struct gl_buffer_object * (*NewBufferObject)( struct gl_context *ctx, GLuint buffer,
565 GLenum target );
566
567 void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj );
568
569 GLboolean (*BufferData)( struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
570 const GLvoid *data, GLenum usage,
571 struct gl_buffer_object *obj );
572
573 void (*BufferSubData)( struct gl_context *ctx, GLintptrARB offset,
574 GLsizeiptrARB size, const GLvoid *data,
575 struct gl_buffer_object *obj );
576
577 void (*GetBufferSubData)( struct gl_context *ctx,
578 GLintptrARB offset, GLsizeiptrARB size,
579 GLvoid *data, struct gl_buffer_object *obj );
580
581 void (*CopyBufferSubData)( struct gl_context *ctx,
582 struct gl_buffer_object *src,
583 struct gl_buffer_object *dst,
584 GLintptr readOffset, GLintptr writeOffset,
585 GLsizeiptr size );
586
587 /* May return NULL if MESA_MAP_NOWAIT_BIT is set in access:
588 */
589 void * (*MapBufferRange)( struct gl_context *ctx, GLintptr offset,
590 GLsizeiptr length, GLbitfield access,
591 struct gl_buffer_object *obj);
592
593 void (*FlushMappedBufferRange)(struct gl_context *ctx,
594 GLintptr offset, GLsizeiptr length,
595 struct gl_buffer_object *obj);
596
597 GLboolean (*UnmapBuffer)( struct gl_context *ctx,
598 struct gl_buffer_object *obj );
599 /*@}*/
600
601 /**
602 * \name Functions for GL_APPLE_object_purgeable
603 */
604 /*@{*/
605 /* variations on ObjectPurgeable */
606 GLenum (*BufferObjectPurgeable)( struct gl_context *ctx, struct gl_buffer_object *obj, GLenum option );
607 GLenum (*RenderObjectPurgeable)( struct gl_context *ctx, struct gl_renderbuffer *obj, GLenum option );
608 GLenum (*TextureObjectPurgeable)( struct gl_context *ctx, struct gl_texture_object *obj, GLenum option );
609
610 /* variations on ObjectUnpurgeable */
611 GLenum (*BufferObjectUnpurgeable)( struct gl_context *ctx, struct gl_buffer_object *obj, GLenum option );
612 GLenum (*RenderObjectUnpurgeable)( struct gl_context *ctx, struct gl_renderbuffer *obj, GLenum option );
613 GLenum (*TextureObjectUnpurgeable)( struct gl_context *ctx, struct gl_texture_object *obj, GLenum option );
614 /*@}*/
615
616 /**
617 * \name Functions for GL_EXT_framebuffer_{object,blit,discard}.
618 */
619 /*@{*/
620 struct gl_framebuffer * (*NewFramebuffer)(struct gl_context *ctx, GLuint name);
621 struct gl_renderbuffer * (*NewRenderbuffer)(struct gl_context *ctx, GLuint name);
622 void (*BindFramebuffer)(struct gl_context *ctx, GLenum target,
623 struct gl_framebuffer *drawFb,
624 struct gl_framebuffer *readFb);
625 void (*FramebufferRenderbuffer)(struct gl_context *ctx,
626 struct gl_framebuffer *fb,
627 GLenum attachment,
628 struct gl_renderbuffer *rb);
629 void (*RenderTexture)(struct gl_context *ctx,
630 struct gl_framebuffer *fb,
631 struct gl_renderbuffer_attachment *att);
632 void (*FinishRenderTexture)(struct gl_context *ctx,
633 struct gl_renderbuffer *rb);
634 void (*ValidateFramebuffer)(struct gl_context *ctx,
635 struct gl_framebuffer *fb);
636 /*@}*/
637 void (*BlitFramebuffer)(struct gl_context *ctx,
638 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
639 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
640 GLbitfield mask, GLenum filter);
641 void (*DiscardFramebuffer)(struct gl_context *ctx,
642 GLenum target, GLsizei numAttachments, const GLenum *attachments);
643
644 /**
645 * \name Query objects
646 */
647 /*@{*/
648 struct gl_query_object * (*NewQueryObject)(struct gl_context *ctx, GLuint id);
649 void (*DeleteQuery)(struct gl_context *ctx, struct gl_query_object *q);
650 void (*BeginQuery)(struct gl_context *ctx, struct gl_query_object *q);
651 void (*QueryCounter)(struct gl_context *ctx, struct gl_query_object *q);
652 void (*EndQuery)(struct gl_context *ctx, struct gl_query_object *q);
653 void (*CheckQuery)(struct gl_context *ctx, struct gl_query_object *q);
654 void (*WaitQuery)(struct gl_context *ctx, struct gl_query_object *q);
655 /*@}*/
656
657
658 /**
659 * \name Vertex Array objects
660 */
661 /*@{*/
662 struct gl_array_object * (*NewArrayObject)(struct gl_context *ctx, GLuint id);
663 void (*DeleteArrayObject)(struct gl_context *ctx, struct gl_array_object *obj);
664 void (*BindArrayObject)(struct gl_context *ctx, struct gl_array_object *obj);
665 /*@}*/
666
667 /**
668 * \name GLSL-related functions (ARB extensions and OpenGL 2.x)
669 */
670 /*@{*/
671 struct gl_shader *(*NewShader)(struct gl_context *ctx, GLuint name, GLenum type);
672 void (*DeleteShader)(struct gl_context *ctx, struct gl_shader *shader);
673 struct gl_shader_program *(*NewShaderProgram)(struct gl_context *ctx, GLuint name);
674 void (*DeleteShaderProgram)(struct gl_context *ctx,
675 struct gl_shader_program *shProg);
676 void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program *shProg);
677 /*@}*/
678
679
680 /**
681 * \name Support for multiple T&L engines
682 */
683 /*@{*/
684
685 /**
686 * Set by the driver-supplied T&L engine.
687 *
688 * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd().
689 */
690 GLuint CurrentExecPrimitive;
691
692 /**
693 * Current glBegin state of an in-progress compilation. May be
694 * GL_POINTS, GL_TRIANGLE_STRIP, etc. or PRIM_OUTSIDE_BEGIN_END
695 * or PRIM_UNKNOWN.
696 */
697 GLuint CurrentSavePrimitive;
698
699
700 #define FLUSH_STORED_VERTICES 0x1
701 #define FLUSH_UPDATE_CURRENT 0x2
702 /**
703 * Set by the driver-supplied T&L engine whenever vertices are buffered
704 * between glBegin()/glEnd() objects or __struct gl_contextRec::Current
705 * is not updated. A bitmask of the FLUSH_x values above.
706 *
707 * The dd_function_table::FlushVertices call below may be used to resolve
708 * these conditions.
709 */
710 GLbitfield NeedFlush;
711
712 /** Need to call SaveFlushVertices() upon state change? */
713 GLboolean SaveNeedFlush;
714
715 /* Called prior to any of the GLvertexformat functions being
716 * called. Paired with Driver.FlushVertices().
717 */
718 void (*BeginVertices)( struct gl_context *ctx );
719
720 /**
721 * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if
722 * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered
723 * vertices, if FLUSH_UPDATE_CURRENT bit is set updates
724 * __struct gl_contextRec::Current and gl_light_attrib::Material
725 *
726 * Note that the default T&L engine never clears the
727 * FLUSH_UPDATE_CURRENT bit, even after performing the update.
728 */
729 void (*FlushVertices)( struct gl_context *ctx, GLuint flags );
730 void (*SaveFlushVertices)( struct gl_context *ctx );
731
732 /**
733 * Give the driver the opportunity to hook in its own vtxfmt for
734 * compiling optimized display lists. This is called on each valid
735 * glBegin() during list compilation.
736 */
737 GLboolean (*NotifySaveBegin)( struct gl_context *ctx, GLenum mode );
738
739 /**
740 * Notify driver that the special derived value _NeedEyeCoords has
741 * changed.
742 */
743 void (*LightingSpaceChange)( struct gl_context *ctx );
744
745 /**
746 * Called by glNewList().
747 *
748 * Let the T&L component know what is going on with display lists
749 * in time to make changes to dispatch tables, etc.
750 */
751 void (*NewList)( struct gl_context *ctx, GLuint list, GLenum mode );
752 /**
753 * Called by glEndList().
754 *
755 * \sa dd_function_table::NewList.
756 */
757 void (*EndList)( struct gl_context *ctx );
758
759 /**
760 * Called by glCallList(s).
761 *
762 * Notify the T&L component before and after calling a display list.
763 */
764 void (*BeginCallList)( struct gl_context *ctx,
765 struct gl_display_list *dlist );
766 /**
767 * Called by glEndCallList().
768 *
769 * \sa dd_function_table::BeginCallList.
770 */
771 void (*EndCallList)( struct gl_context *ctx );
772
773 /**@}*/
774
775 /**
776 * \name GL_ARB_sync interfaces
777 */
778 /*@{*/
779 struct gl_sync_object * (*NewSyncObject)(struct gl_context *, GLenum);
780 void (*FenceSync)(struct gl_context *, struct gl_sync_object *, GLenum, GLbitfield);
781 void (*DeleteSyncObject)(struct gl_context *, struct gl_sync_object *);
782 void (*CheckSync)(struct gl_context *, struct gl_sync_object *);
783 void (*ClientWaitSync)(struct gl_context *, struct gl_sync_object *,
784 GLbitfield, GLuint64);
785 void (*ServerWaitSync)(struct gl_context *, struct gl_sync_object *,
786 GLbitfield, GLuint64);
787 /*@}*/
788
789 /** GL_NV_conditional_render */
790 void (*BeginConditionalRender)(struct gl_context *ctx, struct gl_query_object *q,
791 GLenum mode);
792 void (*EndConditionalRender)(struct gl_context *ctx, struct gl_query_object *q);
793
794 /**
795 * \name GL_OES_draw_texture interface
796 */
797 /*@{*/
798 void (*DrawTex)(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
799 GLfloat width, GLfloat height);
800 /*@}*/
801
802 /**
803 * \name GL_OES_EGL_image interface
804 */
805 void (*EGLImageTargetTexture2D)(struct gl_context *ctx, GLenum target,
806 struct gl_texture_object *texObj,
807 struct gl_texture_image *texImage,
808 GLeglImageOES image_handle);
809 void (*EGLImageTargetRenderbufferStorage)(struct gl_context *ctx,
810 struct gl_renderbuffer *rb,
811 void *image_handle);
812
813 /**
814 * \name GL_EXT_transform_feedback interface
815 */
816 struct gl_transform_feedback_object *
817 (*NewTransformFeedback)(struct gl_context *ctx, GLuint name);
818 void (*DeleteTransformFeedback)(struct gl_context *ctx,
819 struct gl_transform_feedback_object *obj);
820 void (*BeginTransformFeedback)(struct gl_context *ctx, GLenum mode,
821 struct gl_transform_feedback_object *obj);
822 void (*EndTransformFeedback)(struct gl_context *ctx,
823 struct gl_transform_feedback_object *obj);
824 void (*PauseTransformFeedback)(struct gl_context *ctx,
825 struct gl_transform_feedback_object *obj);
826 void (*ResumeTransformFeedback)(struct gl_context *ctx,
827 struct gl_transform_feedback_object *obj);
828
829 /**
830 * \name GL_NV_texture_barrier interface
831 */
832 void (*TextureBarrier)(struct gl_context *ctx);
833
834 /**
835 * \name GL_ARB_sampler_objects
836 */
837 struct gl_sampler_object * (*NewSamplerObject)(struct gl_context *ctx,
838 GLuint name);
839 void (*DeleteSamplerObject)(struct gl_context *ctx,
840 struct gl_sampler_object *samp);
841
842 /**
843 * \name Return a timestamp in nanoseconds as defined by GL_ARB_timer_query.
844 * This should be equivalent to glGetInteger64v(GL_TIMESTAMP);
845 */
846 uint64_t (*GetTimestamp)(struct gl_context *ctx);
847
848 /**
849 * \name GL_ARB_texture_multisample
850 */
851 void (*GetSamplePosition)(struct gl_context *ctx,
852 struct gl_framebuffer *fb,
853 GLuint index,
854 GLfloat *outValue);
855 };
856
857
858 /**
859 * Per-vertex functions.
860 *
861 * These are the functions which can appear between glBegin and glEnd.
862 * Depending on whether we're inside or outside a glBegin/End pair
863 * and whether we're in immediate mode or building a display list, these
864 * functions behave differently. This structure allows us to switch
865 * between those modes more easily.
866 *
867 * Generally, these pointers point to functions in the VBO module.
868 */
869 typedef struct {
870 void (GLAPIENTRYP ArrayElement)( GLint );
871 void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat );
872 void (GLAPIENTRYP Color3fv)( const GLfloat * );
873 void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat );
874 void (GLAPIENTRYP Color4fv)( const GLfloat * );
875 void (GLAPIENTRYP EdgeFlag)( GLboolean );
876 void (GLAPIENTRYP EvalCoord1f)( GLfloat );
877 void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * );
878 void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat );
879 void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * );
880 void (GLAPIENTRYP EvalPoint1)( GLint );
881 void (GLAPIENTRYP EvalPoint2)( GLint, GLint );
882 void (GLAPIENTRYP FogCoordfEXT)( GLfloat );
883 void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * );
884 void (GLAPIENTRYP Indexf)( GLfloat );
885 void (GLAPIENTRYP Indexfv)( const GLfloat * );
886 void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * );
887 void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat );
888 void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * );
889 void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat );
890 void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * );
891 void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat );
892 void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * );
893 void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat );
894 void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * );
895 void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat );
896 void (GLAPIENTRYP Normal3fv)( const GLfloat * );
897 void (GLAPIENTRYP SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat );
898 void (GLAPIENTRYP SecondaryColor3fvEXT)( const GLfloat * );
899 void (GLAPIENTRYP TexCoord1f)( GLfloat );
900 void (GLAPIENTRYP TexCoord1fv)( const GLfloat * );
901 void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat );
902 void (GLAPIENTRYP TexCoord2fv)( const GLfloat * );
903 void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat );
904 void (GLAPIENTRYP TexCoord3fv)( const GLfloat * );
905 void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat );
906 void (GLAPIENTRYP TexCoord4fv)( const GLfloat * );
907 void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat );
908 void (GLAPIENTRYP Vertex2fv)( const GLfloat * );
909 void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat );
910 void (GLAPIENTRYP Vertex3fv)( const GLfloat * );
911 void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat );
912 void (GLAPIENTRYP Vertex4fv)( const GLfloat * );
913 void (GLAPIENTRYP CallList)( GLuint );
914 void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * );
915 void (GLAPIENTRYP Begin)( GLenum );
916 void (GLAPIENTRYP End)( void );
917 void (GLAPIENTRYP PrimitiveRestartNV)( void );
918 /* Originally for GL_NV_vertex_program, now used only dlist.c and friends */
919 void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x );
920 void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v );
921 void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y );
922 void (GLAPIENTRYP VertexAttrib2fvNV)( GLuint index, const GLfloat *v );
923 void (GLAPIENTRYP VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z );
924 void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v );
925 void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
926 void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v );
927 /* GL_ARB_vertex_program */
928 void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x );
929 void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v );
930 void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y );
931 void (GLAPIENTRYP VertexAttrib2fvARB)( GLuint index, const GLfloat *v );
932 void (GLAPIENTRYP VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z );
933 void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v );
934 void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
935 void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v );
936
937 /* GL_EXT_gpu_shader4 / GL 3.0 */
938 void (GLAPIENTRYP VertexAttribI1i)( GLuint index, GLint x);
939 void (GLAPIENTRYP VertexAttribI2i)( GLuint index, GLint x, GLint y);
940 void (GLAPIENTRYP VertexAttribI3i)( GLuint index, GLint x, GLint y, GLint z);
941 void (GLAPIENTRYP VertexAttribI4i)( GLuint index, GLint x, GLint y, GLint z, GLint w);
942 void (GLAPIENTRYP VertexAttribI2iv)( GLuint index, const GLint *v);
943 void (GLAPIENTRYP VertexAttribI3iv)( GLuint index, const GLint *v);
944 void (GLAPIENTRYP VertexAttribI4iv)( GLuint index, const GLint *v);
945
946 void (GLAPIENTRYP VertexAttribI1ui)( GLuint index, GLuint x);
947 void (GLAPIENTRYP VertexAttribI2ui)( GLuint index, GLuint x, GLuint y);
948 void (GLAPIENTRYP VertexAttribI3ui)( GLuint index, GLuint x, GLuint y, GLuint z);
949 void (GLAPIENTRYP VertexAttribI4ui)( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
950 void (GLAPIENTRYP VertexAttribI2uiv)( GLuint index, const GLuint *v);
951 void (GLAPIENTRYP VertexAttribI3uiv)( GLuint index, const GLuint *v);
952 void (GLAPIENTRYP VertexAttribI4uiv)( GLuint index, const GLuint *v);
953
954 /* GL_ARB_vertex_type_10_10_10_2_rev / GL3.3 */
955 void (GLAPIENTRYP VertexP2ui)( GLenum type, GLuint value );
956 void (GLAPIENTRYP VertexP2uiv)( GLenum type, const GLuint *value);
957
958 void (GLAPIENTRYP VertexP3ui)( GLenum type, GLuint value );
959 void (GLAPIENTRYP VertexP3uiv)( GLenum type, const GLuint *value);
960
961 void (GLAPIENTRYP VertexP4ui)( GLenum type, GLuint value );
962 void (GLAPIENTRYP VertexP4uiv)( GLenum type, const GLuint *value);
963
964 void (GLAPIENTRYP TexCoordP1ui)( GLenum type, GLuint coords );
965 void (GLAPIENTRYP TexCoordP1uiv)( GLenum type, const GLuint *coords );
966
967 void (GLAPIENTRYP TexCoordP2ui)( GLenum type, GLuint coords );
968 void (GLAPIENTRYP TexCoordP2uiv)( GLenum type, const GLuint *coords );
969
970 void (GLAPIENTRYP TexCoordP3ui)( GLenum type, GLuint coords );
971 void (GLAPIENTRYP TexCoordP3uiv)( GLenum type, const GLuint *coords );
972
973 void (GLAPIENTRYP TexCoordP4ui)( GLenum type, GLuint coords );
974 void (GLAPIENTRYP TexCoordP4uiv)( GLenum type, const GLuint *coords );
975
976 void (GLAPIENTRYP MultiTexCoordP1ui)( GLenum texture, GLenum type, GLuint coords );
977 void (GLAPIENTRYP MultiTexCoordP1uiv)( GLenum texture, GLenum type, const GLuint *coords );
978 void (GLAPIENTRYP MultiTexCoordP2ui)( GLenum texture, GLenum type, GLuint coords );
979 void (GLAPIENTRYP MultiTexCoordP2uiv)( GLenum texture, GLenum type, const GLuint *coords );
980 void (GLAPIENTRYP MultiTexCoordP3ui)( GLenum texture, GLenum type, GLuint coords );
981 void (GLAPIENTRYP MultiTexCoordP3uiv)( GLenum texture, GLenum type, const GLuint *coords );
982 void (GLAPIENTRYP MultiTexCoordP4ui)( GLenum texture, GLenum type, GLuint coords );
983 void (GLAPIENTRYP MultiTexCoordP4uiv)( GLenum texture, GLenum type, const GLuint *coords );
984
985 void (GLAPIENTRYP NormalP3ui)( GLenum type, GLuint coords );
986 void (GLAPIENTRYP NormalP3uiv)( GLenum type, const GLuint *coords );
987
988 void (GLAPIENTRYP ColorP3ui)( GLenum type, GLuint color );
989 void (GLAPIENTRYP ColorP3uiv)( GLenum type, const GLuint *color );
990
991 void (GLAPIENTRYP ColorP4ui)( GLenum type, GLuint color );
992 void (GLAPIENTRYP ColorP4uiv)( GLenum type, const GLuint *color );
993
994 void (GLAPIENTRYP SecondaryColorP3ui)( GLenum type, GLuint color );
995 void (GLAPIENTRYP SecondaryColorP3uiv)( GLenum type, const GLuint *color );
996
997 void (GLAPIENTRYP VertexAttribP1ui)( GLuint index, GLenum type,
998 GLboolean normalized, GLuint value);
999 void (GLAPIENTRYP VertexAttribP2ui)( GLuint index, GLenum type,
1000 GLboolean normalized, GLuint value);
1001 void (GLAPIENTRYP VertexAttribP3ui)( GLuint index, GLenum type,
1002 GLboolean normalized, GLuint value);
1003 void (GLAPIENTRYP VertexAttribP4ui)( GLuint index, GLenum type,
1004 GLboolean normalized, GLuint value);
1005 void (GLAPIENTRYP VertexAttribP1uiv)( GLuint index, GLenum type,
1006 GLboolean normalized,
1007 const GLuint *value);
1008 void (GLAPIENTRYP VertexAttribP2uiv)( GLuint index, GLenum type,
1009 GLboolean normalized,
1010 const GLuint *value);
1011 void (GLAPIENTRYP VertexAttribP3uiv)( GLuint index, GLenum type,
1012 GLboolean normalized,
1013 const GLuint *value);
1014 void (GLAPIENTRYP VertexAttribP4uiv)( GLuint index, GLenum type,
1015 GLboolean normalized,
1016 const GLuint *value);
1017 } GLvertexformat;
1018
1019
1020 #endif /* DD_INCLUDED */