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