blob: d19cc04d07797c18fb8b19863ac255e50c4d00cd [file] [log] [blame]
Adam Jacksoncb3610e2004-10-25 21:09:16 +00001/*
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 Jacksonad919c32004-11-15 15:31:32 +000055#ifdef WIN32
56#include <stdint.h>
57#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +000058#include "GL/glxint.h"
59#include "GL/glxproto.h"
60#include "GL/internal/glcore.h"
61#include "glapitable.h"
Kristian Høgsberg4a22ae82007-01-07 08:12:01 -050062#include "glxhash.h"
Ian Romanick711555d2005-08-03 23:05:25 +000063#if defined( USE_XTHREADS )
Ian Romanick7adcedc2005-08-01 16:30:24 +000064# include <X11/Xthreads.h>
Ian Romanick02986cb2005-04-18 16:59:53 +000065#elif defined( PTHREADS )
66# include <pthread.h>
Adam Jacksoncb3610e2004-10-25 21:09:16 +000067#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +000068
69#define GLX_MAJOR_VERSION 1 /* current version numbers */
70#define GLX_MINOR_VERSION 4
71
72#define __GLX_MAX_TEXTURE_UNITS 32
73
Kristian Høgsbergaceccda2007-05-10 15:52:22 -040074typedef struct __GLXscreenConfigsRec __GLXscreenConfigs;
Adam Jacksoncb3610e2004-10-25 21:09:16 +000075typedef struct __GLXcontextRec __GLXcontext;
Kristian Høgsbergaceccda2007-05-10 15:52:22 -040076typedef struct __GLXdrawableRec __GLXdrawable;
Adam Jacksoncb3610e2004-10-25 21:09:16 +000077typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate;
78typedef struct _glapi_table __GLapi;
79
80/************************************************************************/
81
82#ifdef GLX_DIRECT_RENDERING
83
Kristian Høgsbergaceccda2007-05-10 15:52:22 -040084#define containerOf(ptr, type, member) \
85 (type *)( (char *)ptr - offsetof(type,member) )
86
Adam Jacksoncb3610e2004-10-25 21:09:16 +000087#include <GL/internal/dri_interface.h>
88
Adam Jacksoncb3610e2004-10-25 21:09:16 +000089
90/**
91 * Display dependent methods. This structure is initialized during the
92 * \c driCreateDisplay call.
93 */
Kristian Høgsberg425f9ed2008-03-08 19:02:10 -050094typedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
Kristian Høgsberg92d2a782008-03-08 20:34:24 -050095typedef struct __GLXDRIscreenRec __GLXDRIscreen;
Kristian Høgsberg20b92302008-03-08 21:02:23 -050096typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
Kristian Høgsberg020c64b2008-03-08 21:57:29 -050097typedef struct __GLXDRIcontextRec __GLXDRIcontext;
Kristian Høgsberg92d2a782008-03-08 20:34:24 -050098
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -040099#include "glxextensions.h"
100
Kristian Høgsberg425f9ed2008-03-08 19:02:10 -0500101struct __GLXDRIdisplayRec {
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000102 /**
103 * Method to destroy the private DRI display data.
104 */
Kristian Høgsberg425f9ed2008-03-08 19:02:10 -0500105 void (*destroyDisplay)(__GLXDRIdisplay *display);
Kristian Høgsberga1ea6f62008-03-08 19:15:50 -0500106
Kristian Høgsberg92d2a782008-03-08 20:34:24 -0500107 __GLXDRIscreen *(*createScreen)(__GLXscreenConfigs *psc, int screen,
108 __GLXdisplayPrivate *priv);
109};
110
111struct __GLXDRIscreenRec {
112
113 void (*destroyScreen)(__GLXscreenConfigs *psc);
114
Kristian Høgsberg020c64b2008-03-08 21:57:29 -0500115 __GLXDRIcontext *(*createContext)(__GLXscreenConfigs *psc,
116 const __GLcontextModes *mode,
117 GLXContext gc,
118 GLXContext shareList, int renderType);
119
Kristian Høgsberg20b92302008-03-08 21:02:23 -0500120 __GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc,
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400121 XID drawable,
122 GLXDrawable glxDrawable,
123 const __GLcontextModes *modes);
Kristian Høgsberg20b92302008-03-08 21:02:23 -0500124};
125
Kristian Høgsberg020c64b2008-03-08 21:57:29 -0500126struct __GLXDRIcontextRec {
127 void (*destroyContext)(__GLXDRIcontext *context, __GLXscreenConfigs *psc,
128 Display *dpy);
129 Bool (*bindContext)(__GLXDRIcontext *context,
130 __GLXDRIdrawable *pdraw,
131 __GLXDRIdrawable *pread);
132
133 void (*unbindContext)(__GLXDRIcontext *context);
134};
135
Kristian Høgsberg20b92302008-03-08 21:02:23 -0500136struct __GLXDRIdrawableRec {
Kristian Høgsberg91104252008-03-12 02:18:12 -0400137 void (*destroyDrawable)(__GLXDRIdrawable *drawable);
138
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400139 XID xDrawable;
Kristian Høgsberg20b92302008-03-08 21:02:23 -0500140 XID drawable;
141 __GLXscreenConfigs *psc;
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400142 __DRIdrawable *driDrawable;
143 GLenum textureTarget;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000144};
145
146/*
147** Function to create and DRI display data and initialize the display
148** dependent methods.
149*/
Kristian Høgsberg425f9ed2008-03-08 19:02:10 -0500150extern __GLXDRIdisplay *driCreateDisplay(Display *dpy);
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400151extern __GLXDRIdisplay *dri2CreateDisplay(Display *dpy);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000152
153extern void DRI_glXUseXFont( Font font, int first, int count, int listbase );
154
155/*
156** Functions to obtain driver configuration information from a direct
157** rendering client application
158*/
159extern const char *glXGetScreenDriver (Display *dpy, int scrNum);
160
161extern const char *glXGetDriverConfig (const char *driverName);
162
163#endif
164
165/************************************************************************/
166
167#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16
168
169typedef struct __GLXpixelStoreModeRec {
170 GLboolean swapEndian;
171 GLboolean lsbFirst;
172 GLuint rowLength;
173 GLuint imageHeight;
174 GLuint imageDepth;
175 GLuint skipRows;
176 GLuint skipPixels;
177 GLuint skipImages;
178 GLuint alignment;
179} __GLXpixelStoreMode;
180
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000181
182typedef struct __GLXattributeRec {
Ian Romanickfdb07632005-02-22 22:36:31 +0000183 GLuint mask;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000184
Ian Romanickfdb07632005-02-22 22:36:31 +0000185 /**
186 * Pixel storage state. Most of the pixel store mode state is kept
187 * here and used by the client code to manage the packing and
188 * unpacking of data sent to/received from the server.
189 */
190 __GLXpixelStoreMode storePack, storeUnpack;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000191
Ian Romanickfdb07632005-02-22 22:36:31 +0000192 /**
193 * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically
194 * disabled?
195 */
196 GLboolean NoDrawArraysProtocol;
197
198 /**
199 * Vertex Array storage state. The vertex array component
200 * state is stored here and is used to manage the packing of
201 * DrawArrays data sent to the server.
202 */
203 struct array_state_vector * array_state;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000204} __GLXattribute;
205
206typedef struct __GLXattributeMachineRec {
207 __GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
208 __GLXattribute **stackPointer;
209} __GLXattributeMachine;
210
211/**
212 * GLX state that needs to be kept on the client. One of these records
213 * exist for each context that has been made current by this client.
214 */
215struct __GLXcontextRec {
216 /**
217 * \name Drawing command buffer.
218 *
219 * Drawing commands are packed into this buffer before being sent as a
220 * single GLX protocol request. The buffer is sent when it overflows or
221 * is flushed by \c __glXFlushRenderBuffer. \c pc is the next location
222 * in the buffer to be filled. \c limit is described above in the buffer
223 * slop discussion.
224 *
225 * Commands that require large amounts of data to be transfered will
226 * also use this buffer to hold a header that describes the large
227 * command.
228 *
229 * These must be the first 6 fields since they are static initialized
230 * in the dummy context in glxext.c
231 */
232 /*@{*/
233 GLubyte *buf;
234 GLubyte *pc;
235 GLubyte *limit;
236 GLubyte *bufEnd;
237 GLint bufSize;
238 /*@}*/
239
240 /**
241 * The XID of this rendering context. When the context is created a
242 * new XID is allocated. This is set to None when the context is
243 * destroyed but is still current to some thread. In this case the
244 * context will be freed on next MakeCurrent.
245 */
246 XID xid;
247
248 /**
249 * The XID of the \c shareList context.
250 */
251 XID share_xid;
252
253 /**
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000254 * Screen number.
255 */
256 GLint screen;
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400257 __GLXscreenConfigs *psc;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000258
259 /**
260 * \c GL_TRUE if the context was created with ImportContext, which
261 * means the server-side context was created by another X client.
262 */
263 GLboolean imported;
264
265 /**
266 * The context tag returned by MakeCurrent when this context is made
267 * current. This tag is used to identify the context that a thread has
268 * current so that proper server context management can be done. It is
269 * used for all context specific commands (i.e., \c Render, \c RenderLarge,
270 * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old
271 * context)).
272 */
273 GLXContextTag currentContextTag;
274
275 /**
276 * \name Rendering mode
277 *
278 * The rendering mode is kept on the client as well as the server.
279 * When \c glRenderMode is called, the buffer associated with the
280 * previous rendering mode (feedback or select) is filled.
281 */
282 /*@{*/
283 GLenum renderMode;
284 GLfloat *feedbackBuf;
285 GLuint *selectBuf;
286 /*@}*/
287
288 /**
289 * This is \c GL_TRUE if the pixel unpack modes are such that an image
290 * can be unpacked from the clients memory by just copying. It may
291 * still be true that the server will have to do some work. This
292 * just promises that a straight copy will fetch the correct bytes.
293 */
294 GLboolean fastImageUnpack;
295
296 /**
297 * Fill newImage with the unpacked form of \c oldImage getting it
298 * ready for transport to the server.
299 */
300 void (*fillImage)(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
301 GLenum, const GLvoid*, GLubyte*, GLubyte*);
302
303 /**
Ian Romanick29206ae2005-07-29 17:30:18 +0000304 * Client side attribs.
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000305 */
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000306 __GLXattributeMachine attributes;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000307
308 /**
309 * Client side error code. This is set when client side gl API
310 * routines need to set an error because of a bad enumerant or
311 * running out of memory, etc.
312 */
313 GLenum error;
314
315 /**
Xiang, Haihaoae2c31e2008-03-18 15:02:57 +0800316 * Whether this context does direct rendering.
317 */
318 Bool isDirect;
319
320 /**
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000321 * \c dpy of current display for this context. Will be \c NULL if not
322 * current to any display, or if this is the "dummy context".
323 */
324 Display *currentDpy;
325
326 /**
327 * The current drawable for this context. Will be None if this
328 * context is not current to any drawable. currentReadable is below.
329 */
330 GLXDrawable currentDrawable;
331
332 /**
333 * \name GL Constant Strings
334 *
335 * Constant strings that describe the server implementation
336 * These pertain to GL attributes, not to be confused with
337 * GLX versioning attributes.
338 */
339 /*@{*/
340 GLubyte *vendor;
341 GLubyte *renderer;
342 GLubyte *version;
343 GLubyte *extensions;
344 /*@}*/
345
346 /**
347 * Record the dpy this context was created on for later freeing
348 */
349 Display *createDpy;
350
351 /**
352 * Maximum small render command size. This is the smaller of 64k and
353 * the size of the above buffer.
354 */
355 GLint maxSmallRenderCommandSize;
356
357 /**
358 * Major opcode for the extension. Copied here so a lookup isn't
359 * needed.
360 */
361 GLint majorOpcode;
362
Kristian Høgsberg286ce272007-11-06 14:34:15 -0500363 /**
364 * Pointer to the mode used to create this context.
365 */
366 const __GLcontextModes * mode;
367
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000368#ifdef GLX_DIRECT_RENDERING
Kristian Høgsberg020c64b2008-03-08 21:57:29 -0500369 __GLXDRIcontext *driContext;
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400370 __DRIcontext *__driContext;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000371#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000372
373 /**
374 * The current read-drawable for this context. Will be None if this
375 * context is not current to any drawable.
376 *
377 * \since Internal API version 20030606.
378 */
379 GLXDrawable currentReadable;
380
381 /**
382 * Pointer to client-state data that is private to libGL. This is only
383 * used for indirect rendering contexts.
384 *
385 * No internal API version change was made for this change. Client-side
386 * drivers should NEVER use this data or even care that it exists.
387 */
388 void * client_state_private;
Ian Romanickfdb07632005-02-22 22:36:31 +0000389
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000390 /**
391 * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE.
392 */
393 int renderType;
394
395 /**
396 * \name Raw server GL version
397 *
398 * True core GL version supported by the server. This is the raw value
399 * returned by the server, and it may not reflect what is actually
400 * supported (or reported) by the client-side library.
401 */
402 /*@{*/
403 int server_major; /**< Major version number. */
404 int server_minor; /**< Minor version number. */
405 /*@}*/
Ian Romanickfdb07632005-02-22 22:36:31 +0000406
407 char gl_extension_bits[ __GL_EXT_BYTES ];
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000408};
409
410#define __glXSetError(gc,code) \
411 if (!(gc)->error) { \
412 (gc)->error = code; \
413 }
414
415extern void __glFreeAttributeState(__GLXcontext *);
416
417/************************************************************************/
418
419/**
420 * The size of the largest drawing command known to the implementation
421 * that will use the GLXRender GLX command. In this case it is
422 * \c glPolygonStipple.
423 */
424#define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156
425
426/**
427 * To keep the implementation fast, the code uses a "limit" pointer
428 * to determine when the drawing command buffer is too full to hold
429 * another fixed size command. This constant defines the amount of
430 * space that must always be available in the drawing command buffer
431 * at all times for the implementation to work. It is important that
432 * the number be just large enough, but not so large as to reduce the
433 * efficacy of the buffer. The "+32" is just to keep the code working
434 * in case somebody counts wrong.
435 */
436#define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32)
437
438/**
439 * This implementation uses a smaller threshold for switching
440 * to the RenderLarge protocol than the protcol requires so that
441 * large copies don't occur.
442 */
443#define __GLX_RENDER_CMD_SIZE_LIMIT 4096
444
445/**
446 * One of these records exists per screen of the display. It contains
447 * a pointer to the config data for that screen (if the screen supports GL).
448 */
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400449struct __GLXscreenConfigsRec {
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000450 /**
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000451 * GLX extension string reported by the X-server.
452 */
453 const char *serverGLXexts;
454
455 /**
456 * GLX extension string to be reported to applications. This is the
457 * set of extensions that the application can actually use.
458 */
459 char *effectiveGLXexts;
460
461#ifdef GLX_DIRECT_RENDERING
462 /**
463 * Per screen direct rendering interface functions and data.
464 */
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400465 __DRIscreen *__driScreen;
466 const __DRIcoreExtension *core;
467 const __DRIlegacyExtension *legacy;
Kristian Høgsberg4a22ae82007-01-07 08:12:01 -0500468 __glxHashTable *drawHash;
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400469 Display *dpy;
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400470 int scr, fd;
Kristian Høgsberg0f2723c2008-03-07 01:37:08 -0500471 void *driver;
Kristian Høgsbergac3e8382007-05-15 15:17:30 -0400472
Kristian Høgsberg92d2a782008-03-08 20:34:24 -0500473 __GLXDRIscreen *driScreen;
Kristian Høgsberg53dc8632008-03-08 20:02:22 -0500474
Kristian Høgsbergac3e8382007-05-15 15:17:30 -0400475#ifdef __DRI_COPY_SUB_BUFFER
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400476 const __DRIcopySubBufferExtension *copySubBuffer;
Kristian Høgsbergac3e8382007-05-15 15:17:30 -0400477#endif
478
Kristian Høgsbergefaf90b2007-05-15 16:09:44 -0400479#ifdef __DRI_SWAP_CONTROL
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400480 const __DRIswapControlExtension *swapControl;
Kristian Høgsbergefaf90b2007-05-15 16:09:44 -0400481#endif
482
Kristian Høgsberg78a6aa52007-05-16 14:10:29 -0400483#ifdef __DRI_ALLOCATE
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400484 const __DRIallocateExtension *allocate;
Kristian Høgsberg78a6aa52007-05-16 14:10:29 -0400485#endif
486
Kristian Høgsberga7a0a2b2007-05-16 15:50:40 -0400487#ifdef __DRI_FRAME_TRACKING
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400488 const __DRIframeTrackingExtension *frameTracking;
Kristian Høgsberga7a0a2b2007-05-16 15:50:40 -0400489#endif
490
Kristian Høgsberg106a6f22007-05-16 18:13:41 -0400491#ifdef __DRI_MEDIA_STREAM_COUNTER
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400492 const __DRImediaStreamCounterExtension *msc;
493#endif
494
495#ifdef __DRI_TEX_BUFFER
496 const __DRItexBufferExtension *texBuffer;
Kristian Høgsberg106a6f22007-05-16 18:13:41 -0400497#endif
498
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000499#endif
500
501 /**
Kristian Høgsberg6c533ea2007-10-16 16:07:47 -0400502 * Linked list of glx visuals and fbconfigs for this screen.
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000503 */
Kristian Høgsberg6c533ea2007-10-16 16:07:47 -0400504 __GLcontextModes *visuals, *configs;
Ian Romanickc39bf5e2005-07-24 06:29:14 +0000505
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000506 /**
507 * Per-screen dynamic GLX extension tracking. The \c direct_support
508 * field only contains enough bits for 64 extensions. Should libGL
509 * ever need to track more than 64 GLX extensions, we can safely grow
510 * this field. The \c __GLXscreenConfigs structure is not used outside
511 * libGL.
512 */
513 /*@{*/
514 unsigned char direct_support[8];
515 GLboolean ext_list_first_time;
516 /*@}*/
517
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400518};
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000519
520/**
521 * Per display private data. One of these records exists for each display
522 * that is using the OpenGL (GLX) extension.
523 */
524struct __GLXdisplayPrivateRec {
525 /**
526 * Back pointer to the display
527 */
528 Display *dpy;
529
530 /**
531 * The \c majorOpcode is common to all connections to the same server.
532 * It is also copied into the context structure.
533 */
534 int majorOpcode;
535
536 /**
537 * \name Server Version
538 *
539 * Major and minor version returned by the server during initialization.
540 */
541 /*@{*/
542 int majorVersion, minorVersion;
543 /*@}*/
544
545 /**
546 * \name Storage for the servers GLX vendor and versions strings.
547 *
548 * These are the same for all screens on this display. These fields will
549 * be filled in on demand.
550 */
551 /*@{*/
552 const char *serverGLXvendor;
553 const char *serverGLXversion;
554 /*@}*/
555
556 /**
557 * Configurations of visuals for all screens on this display.
558 * Also, per screen data which now includes the server \c GLX_EXTENSION
559 * string.
560 */
561 __GLXscreenConfigs *screenConfigs;
562
563#ifdef GLX_DIRECT_RENDERING
564 /**
565 * Per display direct rendering interface functions and data.
566 */
Kristian Høgsberg425f9ed2008-03-08 19:02:10 -0500567 __GLXDRIdisplay *driDisplay;
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400568 __GLXDRIdisplay *dri2Display;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000569#endif
570};
571
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400572
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000573extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*);
574
575extern void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
576 GLint totalRequests,
577 const GLvoid * data, GLint dataLen);
578
579extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint,
580 const GLvoid *, GLint);
581
582/* Initialize the GLX extension for dpy */
583extern __GLXdisplayPrivate *__glXInitialize(Display*);
584
585/************************************************************************/
586
587extern int __glXDebug;
588
589/* This is per-thread storage in an MT environment */
Ian Romanick711555d2005-08-03 23:05:25 +0000590#if defined( USE_XTHREADS ) || defined( PTHREADS )
Ian Romanick02986cb2005-04-18 16:59:53 +0000591
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000592extern void __glXSetCurrentContext(__GLXcontext *c);
Ian Romanick02986cb2005-04-18 16:59:53 +0000593
594# if defined( GLX_USE_TLS )
595
596extern __thread void * __glX_tls_Context
597 __attribute__((tls_model("initial-exec")));
598
599# define __glXGetCurrentContext() __glX_tls_Context
600
601# else
602
603extern __GLXcontext *__glXGetCurrentContext(void);
604
605# endif /* defined( GLX_USE_TLS ) */
606
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000607#else
Ian Romanick02986cb2005-04-18 16:59:53 +0000608
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000609extern __GLXcontext *__glXcurrentContext;
610#define __glXGetCurrentContext() __glXcurrentContext
611#define __glXSetCurrentContext(gc) __glXcurrentContext = gc
Ian Romanick02986cb2005-04-18 16:59:53 +0000612
Ian Romanick711555d2005-08-03 23:05:25 +0000613#endif /* defined( USE_XTHREADS ) || defined( PTHREADS ) */
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000614
George Sapountzisdf04ffb2008-04-18 17:28:34 +0300615extern void __glXSetCurrentContextNull(void);
616
617extern void __glXFreeContext(__GLXcontext*);
618
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000619
620/*
621** Global lock for all threads in this address space using the GLX
622** extension
623*/
Ian Romanick711555d2005-08-03 23:05:25 +0000624#if defined( USE_XTHREADS )
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000625extern xmutex_rec __glXmutex;
626#define __glXLock() xmutex_lock(&__glXmutex)
627#define __glXUnlock() xmutex_unlock(&__glXmutex)
Ian Romanick02986cb2005-04-18 16:59:53 +0000628#elif defined( PTHREADS )
629extern pthread_mutex_t __glXmutex;
630#define __glXLock() pthread_mutex_lock(&__glXmutex)
631#define __glXUnlock() pthread_mutex_unlock(&__glXmutex)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000632#else
633#define __glXLock()
634#define __glXUnlock()
635#endif
636
637/*
638** Setup for a command. Initialize the extension for dpy if necessary.
639*/
640extern CARD8 __glXSetupForCommand(Display *dpy);
641
642/************************************************************************/
643
644/*
645** Data conversion and packing support.
646*/
647
Ian Romanick5f1f2292005-01-07 02:39:09 +0000648extern const GLuint __glXDefaultPixelStore[9];
649
650/* Send an image to the server using RenderLarge. */
651extern void __glXSendLargeImage(__GLXcontext *gc, GLint compsize, GLint dim,
652 GLint width, GLint height, GLint depth, GLenum format, GLenum type,
653 const GLvoid *src, GLubyte *pc, GLubyte *modes);
654
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000655/* Return the size, in bytes, of some pixel data */
Ian Romanick5f1f2292005-01-07 02:39:09 +0000656extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000657
658/* Return the number of elements per group of a specified format*/
659extern GLint __glElementsPerGroup(GLenum format, GLenum type);
660
661/* Return the number of bytes per element, based on the element type (other
662** than GL_BITMAP).
663*/
664extern GLint __glBytesPerElement(GLenum type);
665
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000666/*
667** Fill the transport buffer with the data from the users buffer,
668** applying some of the pixel store modes (unpack modes) to the data
669** first. As a side effect of this call, the "modes" field is
670** updated to contain the modes needed by the server to decode the
671** sent data.
672*/
673extern void __glFillImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
674 GLenum, const GLvoid*, GLubyte*, GLubyte*);
675
676/* Copy map data with a stride into a packed buffer */
677extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *);
678extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *);
679extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint,
680 const GLfloat *, GLfloat *);
681extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint,
682 const GLdouble *, GLdouble *);
683
684/*
685** Empty an image out of the reply buffer into the clients memory applying
686** the pack modes to pack back into the clients requested format.
687*/
688extern void __glEmptyImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
689 GLenum, const GLubyte *, GLvoid *);
690
691
692/*
693** Allocate and Initialize Vertex Array client state
694*/
695extern void __glXInitVertexArrayState(__GLXcontext*);
696
697/*
698** Inform the Server of the major and minor numbers and of the client
699** libraries extension string.
700*/
701extern void __glXClientInfo ( Display *dpy, int opcode );
702
703/************************************************************************/
704
705/*
706** Declarations that should be in Xlib
707*/
708#ifdef __GL_USE_OUR_PROTOTYPES
709extern void _XFlush(Display*);
710extern Status _XReply(Display*, xReply*, int, Bool);
711extern void _XRead(Display*, void*, long);
712extern void _XSend(Display*, const void*, long);
713#endif
714
715
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000716extern void __glXInitializeVisualConfigFromTags( __GLcontextModes *config,
717 int count, const INT32 *bp, Bool tagged_only, Bool fbconfig_style_tags );
718
719extern char * __glXGetStringFromServer( Display * dpy, int opcode,
720 CARD32 glxCode, CARD32 for_whom, CARD32 name );
721
722extern char *__glXstrdup(const char *str);
723
724
725extern const char __glXGLClientVersion[];
726extern const char __glXGLClientExtensions[];
727
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000728/* Get the unadjusted system time */
729extern int __glXGetUST( int64_t * ust );
730
Kristian Høgsberg286ce272007-11-06 14:34:15 -0500731extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400732 int32_t * numerator, int32_t * denominator);
Ian Romanickfc5b57b2006-08-29 15:38:19 +0000733
Kristian Høgsberg286ce272007-11-06 14:34:15 -0500734#ifdef GLX_DIRECT_RENDERING
735GLboolean
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400736__driGetMscRateOML(__DRIdrawable *draw,
737 int32_t *numerator, int32_t *denominator, void *private);
Kristian Høgsberg286ce272007-11-06 14:34:15 -0500738#endif
739
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000740#endif /* !__GLX_client_h__ */