Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 1 | /* |
| 2 | ** License Applicability. Except to the extent portions of this file are |
| 3 | ** made subject to an alternative license as permitted in the SGI Free |
| 4 | ** Software License B, Version 1.1 (the "License"), the contents of this |
| 5 | ** file are subject only to the provisions of the License. You may not use |
| 6 | ** this file except in compliance with the License. You may obtain a copy |
| 7 | ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 |
| 8 | ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: |
| 9 | ** |
| 10 | ** http://oss.sgi.com/projects/FreeB |
| 11 | ** |
| 12 | ** Note that, as provided in the License, the Software is distributed on an |
| 13 | ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS |
| 14 | ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND |
| 15 | ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A |
| 16 | ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. |
| 17 | ** |
| 18 | ** Original Code. The Original Code is: OpenGL Sample Implementation, |
| 19 | ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, |
| 20 | ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. |
| 21 | ** Copyright in any portions created by third parties is as indicated |
| 22 | ** elsewhere herein. All Rights Reserved. |
| 23 | ** |
| 24 | ** Additional Notice Provisions: The application programming interfaces |
| 25 | ** established by SGI in conjunction with the Original Code are The |
| 26 | ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released |
| 27 | ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version |
| 28 | ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X |
| 29 | ** Window System(R) (Version 1.3), released October 19, 1998. This software |
| 30 | ** was created using the OpenGL(R) version 1.2.1 Sample Implementation |
| 31 | ** published by SGI, but has not been independently verified as being |
| 32 | ** compliant with the OpenGL(R) version 1.2.1 Specification. |
| 33 | */ |
| 34 | /* $XFree86: xc/lib/GL/glx/glxclient.h,v 1.21 2004/02/09 23:46:31 alanh Exp $ */ |
| 35 | |
| 36 | /** |
| 37 | * \file glxclient.h |
| 38 | * Direct rendering support added by Precision Insight, Inc. |
| 39 | * |
| 40 | * \author Kevin E. Martin <kevin@precisioninsight.com> |
| 41 | */ |
| 42 | |
| 43 | #ifndef _GLX_client_h_ |
| 44 | #define _GLX_client_h_ |
| 45 | #define NEED_REPLIES |
| 46 | #define NEED_EVENTS |
| 47 | #include <X11/Xproto.h> |
| 48 | #include <X11/Xlibint.h> |
| 49 | #define GLX_GLXEXT_PROTOTYPES |
| 50 | #include <GL/glx.h> |
| 51 | #include <GL/glxext.h> |
| 52 | #include <string.h> |
| 53 | #include <stdlib.h> |
| 54 | #include <stdio.h> |
Adam Jackson | ad919c3 | 2004-11-15 15:31:32 +0000 | [diff] [blame] | 55 | #ifdef WIN32 |
| 56 | #include <stdint.h> |
| 57 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 58 | #include "GL/glxint.h" |
| 59 | #include "GL/glxproto.h" |
| 60 | #include "GL/internal/glcore.h" |
| 61 | #include "glapitable.h" |
Ian Romanick | fdb0763 | 2005-02-22 22:36:31 +0000 | [diff] [blame] | 62 | #include "glxextensions.h" |
Kristian Høgsberg | 4a22ae8 | 2007-01-07 08:12:01 -0500 | [diff] [blame] | 63 | #include "glxhash.h" |
Ian Romanick | 711555d | 2005-08-03 23:05:25 +0000 | [diff] [blame] | 64 | #if defined( USE_XTHREADS ) |
Ian Romanick | 7adcedc | 2005-08-01 16:30:24 +0000 | [diff] [blame] | 65 | # include <X11/Xthreads.h> |
Ian Romanick | 02986cb | 2005-04-18 16:59:53 +0000 | [diff] [blame] | 66 | #elif defined( PTHREADS ) |
| 67 | # include <pthread.h> |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 68 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 69 | |
| 70 | #define GLX_MAJOR_VERSION 1 /* current version numbers */ |
| 71 | #define GLX_MINOR_VERSION 4 |
| 72 | |
| 73 | #define __GLX_MAX_TEXTURE_UNITS 32 |
| 74 | |
Kristian Høgsberg | aceccda | 2007-05-10 15:52:22 -0400 | [diff] [blame] | 75 | typedef struct __GLXscreenConfigsRec __GLXscreenConfigs; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 76 | typedef struct __GLXcontextRec __GLXcontext; |
Kristian Høgsberg | aceccda | 2007-05-10 15:52:22 -0400 | [diff] [blame] | 77 | typedef struct __GLXdrawableRec __GLXdrawable; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 78 | typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate; |
| 79 | typedef struct _glapi_table __GLapi; |
| 80 | |
| 81 | /************************************************************************/ |
| 82 | |
| 83 | #ifdef GLX_DIRECT_RENDERING |
| 84 | |
Kristian Høgsberg | aceccda | 2007-05-10 15:52:22 -0400 | [diff] [blame] | 85 | #define containerOf(ptr, type, member) \ |
| 86 | (type *)( (char *)ptr - offsetof(type,member) ) |
| 87 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 88 | #include <GL/internal/dri_interface.h> |
| 89 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Display dependent methods. This structure is initialized during the |
| 93 | * \c driCreateDisplay call. |
| 94 | */ |
| 95 | struct __DRIdisplayRec { |
| 96 | /** |
| 97 | * Method to destroy the private DRI display data. |
| 98 | */ |
| 99 | void (*destroyDisplay)(Display *dpy, void *displayPrivate); |
| 100 | |
| 101 | /** |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 102 | * Opaque pointer to private per display direct rendering data. |
| 103 | * \c NULL if direct rendering is not supported on this display. |
| 104 | */ |
| 105 | struct __DRIdisplayPrivateRec *private; |
| 106 | |
| 107 | /** |
| 108 | * Array of pointers to methods to create and initialize the private DRI |
| 109 | * screen data. |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 110 | */ |
Ian Romanick | e9dbe58 | 2005-07-24 07:38:23 +0000 | [diff] [blame] | 111 | PFNCREATENEWSCREENFUNC * createNewScreen; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | |
| 115 | /* |
| 116 | ** We keep a linked list of these structures, one per DRI device driver. |
| 117 | */ |
| 118 | struct __DRIdriverRec { |
| 119 | const char *name; |
| 120 | void *handle; |
Ian Romanick | e9dbe58 | 2005-07-24 07:38:23 +0000 | [diff] [blame] | 121 | PFNCREATENEWSCREENFUNC createNewScreenFunc; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 122 | struct __DRIdriverRec *next; |
| 123 | }; |
| 124 | |
| 125 | /* |
| 126 | ** Function to create and DRI display data and initialize the display |
| 127 | ** dependent methods. |
| 128 | */ |
| 129 | extern void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp); |
| 130 | |
| 131 | extern __DRIdriver *driGetDriver(Display *dpy, int scrNum); |
| 132 | |
| 133 | extern void DRI_glXUseXFont( Font font, int first, int count, int listbase ); |
| 134 | |
| 135 | /* |
| 136 | ** Functions to obtain driver configuration information from a direct |
| 137 | ** rendering client application |
| 138 | */ |
| 139 | extern const char *glXGetScreenDriver (Display *dpy, int scrNum); |
| 140 | |
| 141 | extern const char *glXGetDriverConfig (const char *driverName); |
| 142 | |
Ian Romanick | 5f1ba3e | 2005-07-26 02:44:01 +0000 | [diff] [blame] | 143 | extern Bool __glXWindowExists(Display *dpy, GLXDrawable draw); |
| 144 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 145 | #endif |
| 146 | |
| 147 | /************************************************************************/ |
| 148 | |
| 149 | #define __GL_CLIENT_ATTRIB_STACK_DEPTH 16 |
| 150 | |
| 151 | typedef struct __GLXpixelStoreModeRec { |
| 152 | GLboolean swapEndian; |
| 153 | GLboolean lsbFirst; |
| 154 | GLuint rowLength; |
| 155 | GLuint imageHeight; |
| 156 | GLuint imageDepth; |
| 157 | GLuint skipRows; |
| 158 | GLuint skipPixels; |
| 159 | GLuint skipImages; |
| 160 | GLuint alignment; |
| 161 | } __GLXpixelStoreMode; |
| 162 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 163 | |
| 164 | typedef struct __GLXattributeRec { |
Ian Romanick | fdb0763 | 2005-02-22 22:36:31 +0000 | [diff] [blame] | 165 | GLuint mask; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 166 | |
Ian Romanick | fdb0763 | 2005-02-22 22:36:31 +0000 | [diff] [blame] | 167 | /** |
| 168 | * Pixel storage state. Most of the pixel store mode state is kept |
| 169 | * here and used by the client code to manage the packing and |
| 170 | * unpacking of data sent to/received from the server. |
| 171 | */ |
| 172 | __GLXpixelStoreMode storePack, storeUnpack; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 173 | |
Ian Romanick | fdb0763 | 2005-02-22 22:36:31 +0000 | [diff] [blame] | 174 | /** |
| 175 | * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically |
| 176 | * disabled? |
| 177 | */ |
| 178 | GLboolean NoDrawArraysProtocol; |
| 179 | |
| 180 | /** |
| 181 | * Vertex Array storage state. The vertex array component |
| 182 | * state is stored here and is used to manage the packing of |
| 183 | * DrawArrays data sent to the server. |
| 184 | */ |
| 185 | struct array_state_vector * array_state; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 186 | } __GLXattribute; |
| 187 | |
| 188 | typedef struct __GLXattributeMachineRec { |
| 189 | __GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; |
| 190 | __GLXattribute **stackPointer; |
| 191 | } __GLXattributeMachine; |
| 192 | |
| 193 | /** |
| 194 | * GLX state that needs to be kept on the client. One of these records |
| 195 | * exist for each context that has been made current by this client. |
| 196 | */ |
| 197 | struct __GLXcontextRec { |
| 198 | /** |
| 199 | * \name Drawing command buffer. |
| 200 | * |
| 201 | * Drawing commands are packed into this buffer before being sent as a |
| 202 | * single GLX protocol request. The buffer is sent when it overflows or |
| 203 | * is flushed by \c __glXFlushRenderBuffer. \c pc is the next location |
| 204 | * in the buffer to be filled. \c limit is described above in the buffer |
| 205 | * slop discussion. |
| 206 | * |
| 207 | * Commands that require large amounts of data to be transfered will |
| 208 | * also use this buffer to hold a header that describes the large |
| 209 | * command. |
| 210 | * |
| 211 | * These must be the first 6 fields since they are static initialized |
| 212 | * in the dummy context in glxext.c |
| 213 | */ |
| 214 | /*@{*/ |
| 215 | GLubyte *buf; |
| 216 | GLubyte *pc; |
| 217 | GLubyte *limit; |
| 218 | GLubyte *bufEnd; |
| 219 | GLint bufSize; |
| 220 | /*@}*/ |
| 221 | |
| 222 | /** |
| 223 | * The XID of this rendering context. When the context is created a |
| 224 | * new XID is allocated. This is set to None when the context is |
| 225 | * destroyed but is still current to some thread. In this case the |
| 226 | * context will be freed on next MakeCurrent. |
| 227 | */ |
| 228 | XID xid; |
| 229 | |
| 230 | /** |
| 231 | * The XID of the \c shareList context. |
| 232 | */ |
| 233 | XID share_xid; |
| 234 | |
| 235 | /** |
| 236 | * Visual id. |
| 237 | * |
| 238 | * \deprecated |
| 239 | * This filed has been largely been replaced by the \c mode field, but |
| 240 | * the work is not quite done. |
| 241 | */ |
| 242 | VisualID vid; |
| 243 | |
| 244 | /** |
| 245 | * Screen number. |
| 246 | */ |
| 247 | GLint screen; |
Kristian Høgsberg | aceccda | 2007-05-10 15:52:22 -0400 | [diff] [blame] | 248 | __GLXscreenConfigs *psc; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 249 | |
| 250 | /** |
| 251 | * \c GL_TRUE if the context was created with ImportContext, which |
| 252 | * means the server-side context was created by another X client. |
| 253 | */ |
| 254 | GLboolean imported; |
| 255 | |
| 256 | /** |
| 257 | * The context tag returned by MakeCurrent when this context is made |
| 258 | * current. This tag is used to identify the context that a thread has |
| 259 | * current so that proper server context management can be done. It is |
| 260 | * used for all context specific commands (i.e., \c Render, \c RenderLarge, |
| 261 | * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old |
| 262 | * context)). |
| 263 | */ |
| 264 | GLXContextTag currentContextTag; |
| 265 | |
| 266 | /** |
| 267 | * \name Rendering mode |
| 268 | * |
| 269 | * The rendering mode is kept on the client as well as the server. |
| 270 | * When \c glRenderMode is called, the buffer associated with the |
| 271 | * previous rendering mode (feedback or select) is filled. |
| 272 | */ |
| 273 | /*@{*/ |
| 274 | GLenum renderMode; |
| 275 | GLfloat *feedbackBuf; |
| 276 | GLuint *selectBuf; |
| 277 | /*@}*/ |
| 278 | |
| 279 | /** |
| 280 | * This is \c GL_TRUE if the pixel unpack modes are such that an image |
| 281 | * can be unpacked from the clients memory by just copying. It may |
| 282 | * still be true that the server will have to do some work. This |
| 283 | * just promises that a straight copy will fetch the correct bytes. |
| 284 | */ |
| 285 | GLboolean fastImageUnpack; |
| 286 | |
| 287 | /** |
| 288 | * Fill newImage with the unpacked form of \c oldImage getting it |
| 289 | * ready for transport to the server. |
| 290 | */ |
| 291 | void (*fillImage)(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum, |
| 292 | GLenum, const GLvoid*, GLubyte*, GLubyte*); |
| 293 | |
| 294 | /** |
Ian Romanick | 29206ae | 2005-07-29 17:30:18 +0000 | [diff] [blame] | 295 | * Client side attribs. |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 296 | */ |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 297 | __GLXattributeMachine attributes; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 298 | |
| 299 | /** |
| 300 | * Client side error code. This is set when client side gl API |
| 301 | * routines need to set an error because of a bad enumerant or |
| 302 | * running out of memory, etc. |
| 303 | */ |
| 304 | GLenum error; |
| 305 | |
| 306 | /** |
| 307 | * Whether this context does direct rendering. |
| 308 | */ |
| 309 | Bool isDirect; |
| 310 | |
| 311 | /** |
| 312 | * \c dpy of current display for this context. Will be \c NULL if not |
| 313 | * current to any display, or if this is the "dummy context". |
| 314 | */ |
| 315 | Display *currentDpy; |
| 316 | |
| 317 | /** |
| 318 | * The current drawable for this context. Will be None if this |
| 319 | * context is not current to any drawable. currentReadable is below. |
| 320 | */ |
| 321 | GLXDrawable currentDrawable; |
| 322 | |
| 323 | /** |
| 324 | * \name GL Constant Strings |
| 325 | * |
| 326 | * Constant strings that describe the server implementation |
| 327 | * These pertain to GL attributes, not to be confused with |
| 328 | * GLX versioning attributes. |
| 329 | */ |
| 330 | /*@{*/ |
| 331 | GLubyte *vendor; |
| 332 | GLubyte *renderer; |
| 333 | GLubyte *version; |
| 334 | GLubyte *extensions; |
| 335 | /*@}*/ |
| 336 | |
| 337 | /** |
| 338 | * Record the dpy this context was created on for later freeing |
| 339 | */ |
| 340 | Display *createDpy; |
| 341 | |
| 342 | /** |
| 343 | * Maximum small render command size. This is the smaller of 64k and |
| 344 | * the size of the above buffer. |
| 345 | */ |
| 346 | GLint maxSmallRenderCommandSize; |
| 347 | |
| 348 | /** |
| 349 | * Major opcode for the extension. Copied here so a lookup isn't |
| 350 | * needed. |
| 351 | */ |
| 352 | GLint majorOpcode; |
| 353 | |
| 354 | #ifdef GLX_DIRECT_RENDERING |
| 355 | /** |
| 356 | * Per context direct rendering interface functions and data. |
| 357 | */ |
| 358 | __DRIcontext driContext; |
Kristian Høgsberg | 4a22ae8 | 2007-01-07 08:12:01 -0500 | [diff] [blame] | 359 | |
| 360 | /** |
| 361 | * Pointer to the mode used to create this context. |
| 362 | */ |
| 363 | const __GLcontextModes * mode; |
Kristian Høgsberg | 8ed5c7c | 2007-05-10 18:38:49 -0400 | [diff] [blame] | 364 | |
| 365 | /** |
| 366 | * XID for the server side drm_context_t |
| 367 | */ |
| 368 | XID hwContextID; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 369 | #endif |
| 370 | |
| 371 | /** |
| 372 | * \c GLXFBConfigID used to create this context. May be \c None. This |
| 373 | * field has been replaced by the \c mode field. |
| 374 | * |
| 375 | * \since Internal API version 20030317. |
| 376 | * |
| 377 | * \deprecated |
| 378 | * This filed has been largely been replaced by the \c mode field, but |
| 379 | * the work is not quite done. |
| 380 | */ |
| 381 | GLXFBConfigID fbconfigID; |
| 382 | |
| 383 | /** |
| 384 | * The current read-drawable for this context. Will be None if this |
| 385 | * context is not current to any drawable. |
| 386 | * |
| 387 | * \since Internal API version 20030606. |
| 388 | */ |
| 389 | GLXDrawable currentReadable; |
| 390 | |
| 391 | /** |
| 392 | * Pointer to client-state data that is private to libGL. This is only |
| 393 | * used for indirect rendering contexts. |
| 394 | * |
| 395 | * No internal API version change was made for this change. Client-side |
| 396 | * drivers should NEVER use this data or even care that it exists. |
| 397 | */ |
| 398 | void * client_state_private; |
Ian Romanick | fdb0763 | 2005-02-22 22:36:31 +0000 | [diff] [blame] | 399 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 400 | /** |
| 401 | * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE. |
| 402 | */ |
| 403 | int renderType; |
| 404 | |
| 405 | /** |
| 406 | * \name Raw server GL version |
| 407 | * |
| 408 | * True core GL version supported by the server. This is the raw value |
| 409 | * returned by the server, and it may not reflect what is actually |
| 410 | * supported (or reported) by the client-side library. |
| 411 | */ |
| 412 | /*@{*/ |
| 413 | int server_major; /**< Major version number. */ |
| 414 | int server_minor; /**< Minor version number. */ |
| 415 | /*@}*/ |
Ian Romanick | fdb0763 | 2005-02-22 22:36:31 +0000 | [diff] [blame] | 416 | |
| 417 | char gl_extension_bits[ __GL_EXT_BYTES ]; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 418 | }; |
| 419 | |
| 420 | #define __glXSetError(gc,code) \ |
| 421 | if (!(gc)->error) { \ |
| 422 | (gc)->error = code; \ |
| 423 | } |
| 424 | |
| 425 | extern void __glFreeAttributeState(__GLXcontext *); |
| 426 | |
| 427 | /************************************************************************/ |
| 428 | |
| 429 | /** |
| 430 | * The size of the largest drawing command known to the implementation |
| 431 | * that will use the GLXRender GLX command. In this case it is |
| 432 | * \c glPolygonStipple. |
| 433 | */ |
| 434 | #define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156 |
| 435 | |
| 436 | /** |
| 437 | * To keep the implementation fast, the code uses a "limit" pointer |
| 438 | * to determine when the drawing command buffer is too full to hold |
| 439 | * another fixed size command. This constant defines the amount of |
| 440 | * space that must always be available in the drawing command buffer |
| 441 | * at all times for the implementation to work. It is important that |
| 442 | * the number be just large enough, but not so large as to reduce the |
| 443 | * efficacy of the buffer. The "+32" is just to keep the code working |
| 444 | * in case somebody counts wrong. |
| 445 | */ |
| 446 | #define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32) |
| 447 | |
| 448 | /** |
| 449 | * This implementation uses a smaller threshold for switching |
| 450 | * to the RenderLarge protocol than the protcol requires so that |
| 451 | * large copies don't occur. |
| 452 | */ |
| 453 | #define __GLX_RENDER_CMD_SIZE_LIMIT 4096 |
| 454 | |
| 455 | /** |
| 456 | * One of these records exists per screen of the display. It contains |
| 457 | * a pointer to the config data for that screen (if the screen supports GL). |
| 458 | */ |
Kristian Høgsberg | aceccda | 2007-05-10 15:52:22 -0400 | [diff] [blame] | 459 | struct __GLXscreenConfigsRec { |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 460 | /** |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 461 | * GLX extension string reported by the X-server. |
| 462 | */ |
| 463 | const char *serverGLXexts; |
| 464 | |
| 465 | /** |
| 466 | * GLX extension string to be reported to applications. This is the |
| 467 | * set of extensions that the application can actually use. |
| 468 | */ |
| 469 | char *effectiveGLXexts; |
| 470 | |
| 471 | #ifdef GLX_DIRECT_RENDERING |
| 472 | /** |
| 473 | * Per screen direct rendering interface functions and data. |
| 474 | */ |
| 475 | __DRIscreen driScreen; |
Kristian Høgsberg | 4a22ae8 | 2007-01-07 08:12:01 -0500 | [diff] [blame] | 476 | __glxHashTable *drawHash; |
Kristian Høgsberg | aceccda | 2007-05-10 15:52:22 -0400 | [diff] [blame] | 477 | Display *dpy; |
| 478 | int scr; |
Kristian Høgsberg | ac3e838 | 2007-05-15 15:17:30 -0400 | [diff] [blame] | 479 | |
| 480 | #ifdef __DRI_COPY_SUB_BUFFER |
| 481 | __DRIcopySubBufferExtension *copySubBuffer; |
| 482 | #endif |
| 483 | |
Kristian Høgsberg | efaf90b | 2007-05-15 16:09:44 -0400 | [diff] [blame] | 484 | #ifdef __DRI_SWAP_CONTROL |
| 485 | __DRIswapControlExtension *swapControl; |
| 486 | #endif |
| 487 | |
Kristian Høgsberg | 78a6aa5 | 2007-05-16 14:10:29 -0400 | [diff] [blame] | 488 | #ifdef __DRI_ALLOCATE |
| 489 | __DRIallocateExtension *allocate; |
| 490 | #endif |
| 491 | |
Kristian Høgsberg | a7a0a2b | 2007-05-16 15:50:40 -0400 | [diff] [blame^] | 492 | #ifdef __DRI_FRAME_TRACKING |
| 493 | __DRIframeTrackingExtension *frameTracking; |
| 494 | #endif |
| 495 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 496 | #endif |
| 497 | |
| 498 | /** |
Ian Romanick | c39bf5e | 2005-07-24 06:29:14 +0000 | [diff] [blame] | 499 | * Linked list of configurations for this screen. |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 500 | */ |
| 501 | __GLcontextModes *configs; |
Ian Romanick | c39bf5e | 2005-07-24 06:29:14 +0000 | [diff] [blame] | 502 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 503 | /** |
| 504 | * Per-screen dynamic GLX extension tracking. The \c direct_support |
| 505 | * field only contains enough bits for 64 extensions. Should libGL |
| 506 | * ever need to track more than 64 GLX extensions, we can safely grow |
| 507 | * this field. The \c __GLXscreenConfigs structure is not used outside |
| 508 | * libGL. |
| 509 | */ |
| 510 | /*@{*/ |
| 511 | unsigned char direct_support[8]; |
| 512 | GLboolean ext_list_first_time; |
| 513 | /*@}*/ |
| 514 | |
Kristian Høgsberg | aceccda | 2007-05-10 15:52:22 -0400 | [diff] [blame] | 515 | }; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 516 | |
| 517 | /** |
| 518 | * Per display private data. One of these records exists for each display |
| 519 | * that is using the OpenGL (GLX) extension. |
| 520 | */ |
| 521 | struct __GLXdisplayPrivateRec { |
| 522 | /** |
| 523 | * Back pointer to the display |
| 524 | */ |
| 525 | Display *dpy; |
| 526 | |
| 527 | /** |
| 528 | * The \c majorOpcode is common to all connections to the same server. |
| 529 | * It is also copied into the context structure. |
| 530 | */ |
| 531 | int majorOpcode; |
| 532 | |
| 533 | /** |
| 534 | * \name Server Version |
| 535 | * |
| 536 | * Major and minor version returned by the server during initialization. |
| 537 | */ |
| 538 | /*@{*/ |
| 539 | int majorVersion, minorVersion; |
| 540 | /*@}*/ |
| 541 | |
| 542 | /** |
| 543 | * \name Storage for the servers GLX vendor and versions strings. |
| 544 | * |
| 545 | * These are the same for all screens on this display. These fields will |
| 546 | * be filled in on demand. |
| 547 | */ |
| 548 | /*@{*/ |
| 549 | const char *serverGLXvendor; |
| 550 | const char *serverGLXversion; |
| 551 | /*@}*/ |
| 552 | |
| 553 | /** |
| 554 | * Configurations of visuals for all screens on this display. |
| 555 | * Also, per screen data which now includes the server \c GLX_EXTENSION |
| 556 | * string. |
| 557 | */ |
| 558 | __GLXscreenConfigs *screenConfigs; |
| 559 | |
| 560 | #ifdef GLX_DIRECT_RENDERING |
| 561 | /** |
| 562 | * Per display direct rendering interface functions and data. |
| 563 | */ |
| 564 | __DRIdisplay driDisplay; |
| 565 | #endif |
| 566 | }; |
| 567 | |
Kristian Høgsberg | aceccda | 2007-05-10 15:52:22 -0400 | [diff] [blame] | 568 | #ifdef GLX_DIRECT_RENDERING |
| 569 | |
| 570 | struct __GLXdrawableRec { |
| 571 | XID drawable; |
| 572 | __GLXscreenConfigs *psc; |
| 573 | __DRIdrawable driDrawable; |
| 574 | }; |
| 575 | |
| 576 | #endif |
| 577 | |
| 578 | |
| 579 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 580 | void __glXFreeContext(__GLXcontext*); |
| 581 | |
| 582 | extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*); |
| 583 | |
| 584 | extern void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber, |
| 585 | GLint totalRequests, |
| 586 | const GLvoid * data, GLint dataLen); |
| 587 | |
| 588 | extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint, |
| 589 | const GLvoid *, GLint); |
| 590 | |
| 591 | /* Initialize the GLX extension for dpy */ |
| 592 | extern __GLXdisplayPrivate *__glXInitialize(Display*); |
| 593 | |
| 594 | /************************************************************************/ |
| 595 | |
| 596 | extern int __glXDebug; |
| 597 | |
| 598 | /* This is per-thread storage in an MT environment */ |
Ian Romanick | 711555d | 2005-08-03 23:05:25 +0000 | [diff] [blame] | 599 | #if defined( USE_XTHREADS ) || defined( PTHREADS ) |
Ian Romanick | 02986cb | 2005-04-18 16:59:53 +0000 | [diff] [blame] | 600 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 601 | extern void __glXSetCurrentContext(__GLXcontext *c); |
Ian Romanick | 02986cb | 2005-04-18 16:59:53 +0000 | [diff] [blame] | 602 | |
| 603 | # if defined( GLX_USE_TLS ) |
| 604 | |
| 605 | extern __thread void * __glX_tls_Context |
| 606 | __attribute__((tls_model("initial-exec"))); |
| 607 | |
| 608 | # define __glXGetCurrentContext() __glX_tls_Context |
| 609 | |
| 610 | # else |
| 611 | |
| 612 | extern __GLXcontext *__glXGetCurrentContext(void); |
| 613 | |
| 614 | # endif /* defined( GLX_USE_TLS ) */ |
| 615 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 616 | #else |
Ian Romanick | 02986cb | 2005-04-18 16:59:53 +0000 | [diff] [blame] | 617 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 618 | extern __GLXcontext *__glXcurrentContext; |
| 619 | #define __glXGetCurrentContext() __glXcurrentContext |
| 620 | #define __glXSetCurrentContext(gc) __glXcurrentContext = gc |
Ian Romanick | 02986cb | 2005-04-18 16:59:53 +0000 | [diff] [blame] | 621 | |
Ian Romanick | 711555d | 2005-08-03 23:05:25 +0000 | [diff] [blame] | 622 | #endif /* defined( USE_XTHREADS ) || defined( PTHREADS ) */ |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 623 | |
| 624 | |
| 625 | /* |
| 626 | ** Global lock for all threads in this address space using the GLX |
| 627 | ** extension |
| 628 | */ |
Ian Romanick | 711555d | 2005-08-03 23:05:25 +0000 | [diff] [blame] | 629 | #if defined( USE_XTHREADS ) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 630 | extern xmutex_rec __glXmutex; |
| 631 | #define __glXLock() xmutex_lock(&__glXmutex) |
| 632 | #define __glXUnlock() xmutex_unlock(&__glXmutex) |
Ian Romanick | 02986cb | 2005-04-18 16:59:53 +0000 | [diff] [blame] | 633 | #elif defined( PTHREADS ) |
| 634 | extern pthread_mutex_t __glXmutex; |
| 635 | #define __glXLock() pthread_mutex_lock(&__glXmutex) |
| 636 | #define __glXUnlock() pthread_mutex_unlock(&__glXmutex) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 637 | #else |
| 638 | #define __glXLock() |
| 639 | #define __glXUnlock() |
| 640 | #endif |
| 641 | |
| 642 | /* |
| 643 | ** Setup for a command. Initialize the extension for dpy if necessary. |
| 644 | */ |
| 645 | extern CARD8 __glXSetupForCommand(Display *dpy); |
| 646 | |
| 647 | /************************************************************************/ |
| 648 | |
| 649 | /* |
| 650 | ** Data conversion and packing support. |
| 651 | */ |
| 652 | |
Ian Romanick | 5f1f229 | 2005-01-07 02:39:09 +0000 | [diff] [blame] | 653 | extern const GLuint __glXDefaultPixelStore[9]; |
| 654 | |
| 655 | /* Send an image to the server using RenderLarge. */ |
| 656 | extern void __glXSendLargeImage(__GLXcontext *gc, GLint compsize, GLint dim, |
| 657 | GLint width, GLint height, GLint depth, GLenum format, GLenum type, |
| 658 | const GLvoid *src, GLubyte *pc, GLubyte *modes); |
| 659 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 660 | /* Return the size, in bytes, of some pixel data */ |
Ian Romanick | 5f1f229 | 2005-01-07 02:39:09 +0000 | [diff] [blame] | 661 | extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 662 | |
| 663 | /* Return the number of elements per group of a specified format*/ |
| 664 | extern GLint __glElementsPerGroup(GLenum format, GLenum type); |
| 665 | |
| 666 | /* Return the number of bytes per element, based on the element type (other |
| 667 | ** than GL_BITMAP). |
| 668 | */ |
| 669 | extern GLint __glBytesPerElement(GLenum type); |
| 670 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 671 | /* |
| 672 | ** Fill the transport buffer with the data from the users buffer, |
| 673 | ** applying some of the pixel store modes (unpack modes) to the data |
| 674 | ** first. As a side effect of this call, the "modes" field is |
| 675 | ** updated to contain the modes needed by the server to decode the |
| 676 | ** sent data. |
| 677 | */ |
| 678 | extern void __glFillImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum, |
| 679 | GLenum, const GLvoid*, GLubyte*, GLubyte*); |
| 680 | |
| 681 | /* Copy map data with a stride into a packed buffer */ |
| 682 | extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *); |
| 683 | extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *); |
| 684 | extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint, |
| 685 | const GLfloat *, GLfloat *); |
| 686 | extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint, |
| 687 | const GLdouble *, GLdouble *); |
| 688 | |
| 689 | /* |
| 690 | ** Empty an image out of the reply buffer into the clients memory applying |
| 691 | ** the pack modes to pack back into the clients requested format. |
| 692 | */ |
| 693 | extern void __glEmptyImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum, |
| 694 | GLenum, const GLubyte *, GLvoid *); |
| 695 | |
| 696 | |
| 697 | /* |
| 698 | ** Allocate and Initialize Vertex Array client state |
| 699 | */ |
| 700 | extern void __glXInitVertexArrayState(__GLXcontext*); |
| 701 | |
| 702 | /* |
| 703 | ** Inform the Server of the major and minor numbers and of the client |
| 704 | ** libraries extension string. |
| 705 | */ |
| 706 | extern void __glXClientInfo ( Display *dpy, int opcode ); |
| 707 | |
| 708 | /************************************************************************/ |
| 709 | |
| 710 | /* |
| 711 | ** Declarations that should be in Xlib |
| 712 | */ |
| 713 | #ifdef __GL_USE_OUR_PROTOTYPES |
| 714 | extern void _XFlush(Display*); |
| 715 | extern Status _XReply(Display*, xReply*, int, Bool); |
| 716 | extern void _XRead(Display*, void*, long); |
| 717 | extern void _XSend(Display*, const void*, long); |
| 718 | #endif |
| 719 | |
| 720 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 721 | extern void __glXInitializeVisualConfigFromTags( __GLcontextModes *config, |
| 722 | int count, const INT32 *bp, Bool tagged_only, Bool fbconfig_style_tags ); |
| 723 | |
| 724 | extern char * __glXGetStringFromServer( Display * dpy, int opcode, |
| 725 | CARD32 glxCode, CARD32 for_whom, CARD32 name ); |
| 726 | |
| 727 | extern char *__glXstrdup(const char *str); |
| 728 | |
| 729 | |
| 730 | extern const char __glXGLClientVersion[]; |
| 731 | extern const char __glXGLClientExtensions[]; |
| 732 | |
| 733 | /* Determine the internal API version */ |
| 734 | extern int __glXGetInternalVersion(void); |
| 735 | |
| 736 | /* Get the unadjusted system time */ |
| 737 | extern int __glXGetUST( int64_t * ust ); |
| 738 | |
Kristian Høgsberg | aceccda | 2007-05-10 15:52:22 -0400 | [diff] [blame] | 739 | extern GLboolean __glXGetMscRateOML(__DRIdrawable *draw, |
| 740 | int32_t * numerator, int32_t * denominator); |
Ian Romanick | fc5b57b | 2006-08-29 15:38:19 +0000 | [diff] [blame] | 741 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 742 | #endif /* !__GLX_client_h__ */ |