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