blob: 259add759587fb178bdeb937a2719831bc642079 [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"
Ian Romanickfdb07632005-02-22 22:36:31 +000062#include "glxextensions.h"
Kristian Høgsberg4a22ae82007-01-07 08:12:01 -050063#include "glxhash.h"
Ian Romanick711555d2005-08-03 23:05:25 +000064#if defined( USE_XTHREADS )
Ian Romanick7adcedc2005-08-01 16:30:24 +000065# include <X11/Xthreads.h>
Ian Romanick02986cb2005-04-18 16:59:53 +000066#elif defined( PTHREADS )
67# include <pthread.h>
Adam Jacksoncb3610e2004-10-25 21:09:16 +000068#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +000069
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øgsbergaceccda2007-05-10 15:52:22 -040075typedef struct __GLXscreenConfigsRec __GLXscreenConfigs;
Adam Jacksoncb3610e2004-10-25 21:09:16 +000076typedef struct __GLXcontextRec __GLXcontext;
Kristian Høgsbergaceccda2007-05-10 15:52:22 -040077typedef struct __GLXdrawableRec __GLXdrawable;
Adam Jacksoncb3610e2004-10-25 21:09:16 +000078typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate;
79typedef struct _glapi_table __GLapi;
80
81/************************************************************************/
82
83#ifdef GLX_DIRECT_RENDERING
84
Kristian Høgsbergaceccda2007-05-10 15:52:22 -040085#define containerOf(ptr, type, member) \
86 (type *)( (char *)ptr - offsetof(type,member) )
87
Adam Jacksoncb3610e2004-10-25 21:09:16 +000088#include <GL/internal/dri_interface.h>
89
Adam Jacksoncb3610e2004-10-25 21:09:16 +000090
91/**
92 * Display dependent methods. This structure is initialized during the
93 * \c driCreateDisplay call.
94 */
Kristian Høgsberg425f9ed2008-03-08 19:02:10 -050095typedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
Kristian Høgsberg92d2a782008-03-08 20:34:24 -050096typedef struct __GLXDRIscreenRec __GLXDRIscreen;
Kristian Høgsberg20b92302008-03-08 21:02:23 -050097typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
Kristian Høgsberg020c64b2008-03-08 21:57:29 -050098typedef struct __GLXDRIcontextRec __GLXDRIcontext;
Kristian Høgsberg92d2a782008-03-08 20:34:24 -050099
Kristian Høgsberg425f9ed2008-03-08 19:02:10 -0500100struct __GLXDRIdisplayRec {
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000101 /**
102 * Method to destroy the private DRI display data.
103 */
Kristian Høgsberg425f9ed2008-03-08 19:02:10 -0500104 void (*destroyDisplay)(__GLXDRIdisplay *display);
Kristian Høgsberga1ea6f62008-03-08 19:15:50 -0500105
Kristian Høgsberg92d2a782008-03-08 20:34:24 -0500106 __GLXDRIscreen *(*createScreen)(__GLXscreenConfigs *psc, int screen,
107 __GLXdisplayPrivate *priv);
108};
109
110struct __GLXDRIscreenRec {
111
112 void (*destroyScreen)(__GLXscreenConfigs *psc);
113
Kristian Høgsberg020c64b2008-03-08 21:57:29 -0500114 __GLXDRIcontext *(*createContext)(__GLXscreenConfigs *psc,
115 const __GLcontextModes *mode,
116 GLXContext gc,
117 GLXContext shareList, int renderType);
118
Kristian Høgsberg20b92302008-03-08 21:02:23 -0500119 __GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc,
120 GLXDrawable drawable,
121 GLXContext gc);
122};
123
Kristian Høgsberg020c64b2008-03-08 21:57:29 -0500124struct __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øgsberg20b92302008-03-08 21:02:23 -0500134struct __GLXDRIdrawableRec {
135 XID drawable;
136 __GLXscreenConfigs *psc;
137 __DRIdrawable driDrawable;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000138};
139
140/*
141** Function to create and DRI display data and initialize the display
142** dependent methods.
143*/
Kristian Høgsberg425f9ed2008-03-08 19:02:10 -0500144extern __GLXDRIdisplay *driCreateDisplay(Display *dpy);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000145
146extern void DRI_glXUseXFont( Font font, int first, int count, int listbase );
147
148/*
149** Functions to obtain driver configuration information from a direct
150** rendering client application
151*/
152extern const char *glXGetScreenDriver (Display *dpy, int scrNum);
153
154extern const char *glXGetDriverConfig (const char *driverName);
155
Ian Romanick5f1ba3e2005-07-26 02:44:01 +0000156extern Bool __glXWindowExists(Display *dpy, GLXDrawable draw);
157
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000158#endif
159
160/************************************************************************/
161
162#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16
163
164typedef struct __GLXpixelStoreModeRec {
165 GLboolean swapEndian;
166 GLboolean lsbFirst;
167 GLuint rowLength;
168 GLuint imageHeight;
169 GLuint imageDepth;
170 GLuint skipRows;
171 GLuint skipPixels;
172 GLuint skipImages;
173 GLuint alignment;
174} __GLXpixelStoreMode;
175
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000176
177typedef struct __GLXattributeRec {
Ian Romanickfdb07632005-02-22 22:36:31 +0000178 GLuint mask;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000179
Ian Romanickfdb07632005-02-22 22:36:31 +0000180 /**
181 * Pixel storage state. Most of the pixel store mode state is kept
182 * here and used by the client code to manage the packing and
183 * unpacking of data sent to/received from the server.
184 */
185 __GLXpixelStoreMode storePack, storeUnpack;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000186
Ian Romanickfdb07632005-02-22 22:36:31 +0000187 /**
188 * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically
189 * disabled?
190 */
191 GLboolean NoDrawArraysProtocol;
192
193 /**
194 * Vertex Array storage state. The vertex array component
195 * state is stored here and is used to manage the packing of
196 * DrawArrays data sent to the server.
197 */
198 struct array_state_vector * array_state;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000199} __GLXattribute;
200
201typedef struct __GLXattributeMachineRec {
202 __GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
203 __GLXattribute **stackPointer;
204} __GLXattributeMachine;
205
206/**
207 * GLX state that needs to be kept on the client. One of these records
208 * exist for each context that has been made current by this client.
209 */
210struct __GLXcontextRec {
211 /**
212 * \name Drawing command buffer.
213 *
214 * Drawing commands are packed into this buffer before being sent as a
215 * single GLX protocol request. The buffer is sent when it overflows or
216 * is flushed by \c __glXFlushRenderBuffer. \c pc is the next location
217 * in the buffer to be filled. \c limit is described above in the buffer
218 * slop discussion.
219 *
220 * Commands that require large amounts of data to be transfered will
221 * also use this buffer to hold a header that describes the large
222 * command.
223 *
224 * These must be the first 6 fields since they are static initialized
225 * in the dummy context in glxext.c
226 */
227 /*@{*/
228 GLubyte *buf;
229 GLubyte *pc;
230 GLubyte *limit;
231 GLubyte *bufEnd;
232 GLint bufSize;
233 /*@}*/
234
235 /**
236 * The XID of this rendering context. When the context is created a
237 * new XID is allocated. This is set to None when the context is
238 * destroyed but is still current to some thread. In this case the
239 * context will be freed on next MakeCurrent.
240 */
241 XID xid;
242
243 /**
244 * The XID of the \c shareList context.
245 */
246 XID share_xid;
247
248 /**
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000249 * Screen number.
250 */
251 GLint screen;
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400252 __GLXscreenConfigs *psc;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000253
254 /**
255 * \c GL_TRUE if the context was created with ImportContext, which
256 * means the server-side context was created by another X client.
257 */
258 GLboolean imported;
259
260 /**
261 * The context tag returned by MakeCurrent when this context is made
262 * current. This tag is used to identify the context that a thread has
263 * current so that proper server context management can be done. It is
264 * used for all context specific commands (i.e., \c Render, \c RenderLarge,
265 * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old
266 * context)).
267 */
268 GLXContextTag currentContextTag;
269
270 /**
271 * \name Rendering mode
272 *
273 * The rendering mode is kept on the client as well as the server.
274 * When \c glRenderMode is called, the buffer associated with the
275 * previous rendering mode (feedback or select) is filled.
276 */
277 /*@{*/
278 GLenum renderMode;
279 GLfloat *feedbackBuf;
280 GLuint *selectBuf;
281 /*@}*/
282
283 /**
284 * This is \c GL_TRUE if the pixel unpack modes are such that an image
285 * can be unpacked from the clients memory by just copying. It may
286 * still be true that the server will have to do some work. This
287 * just promises that a straight copy will fetch the correct bytes.
288 */
289 GLboolean fastImageUnpack;
290
291 /**
292 * Fill newImage with the unpacked form of \c oldImage getting it
293 * ready for transport to the server.
294 */
295 void (*fillImage)(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
296 GLenum, const GLvoid*, GLubyte*, GLubyte*);
297
298 /**
Ian Romanick29206ae2005-07-29 17:30:18 +0000299 * Client side attribs.
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000300 */
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000301 __GLXattributeMachine attributes;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000302
303 /**
304 * Client side error code. This is set when client side gl API
305 * routines need to set an error because of a bad enumerant or
306 * running out of memory, etc.
307 */
308 GLenum error;
309
310 /**
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000311 * \c dpy of current display for this context. Will be \c NULL if not
312 * current to any display, or if this is the "dummy context".
313 */
314 Display *currentDpy;
315
316 /**
317 * The current drawable for this context. Will be None if this
318 * context is not current to any drawable. currentReadable is below.
319 */
320 GLXDrawable currentDrawable;
321
322 /**
323 * \name GL Constant Strings
324 *
325 * Constant strings that describe the server implementation
326 * These pertain to GL attributes, not to be confused with
327 * GLX versioning attributes.
328 */
329 /*@{*/
330 GLubyte *vendor;
331 GLubyte *renderer;
332 GLubyte *version;
333 GLubyte *extensions;
334 /*@}*/
335
336 /**
337 * Record the dpy this context was created on for later freeing
338 */
339 Display *createDpy;
340
341 /**
342 * Maximum small render command size. This is the smaller of 64k and
343 * the size of the above buffer.
344 */
345 GLint maxSmallRenderCommandSize;
346
347 /**
348 * Major opcode for the extension. Copied here so a lookup isn't
349 * needed.
350 */
351 GLint majorOpcode;
352
Kristian Høgsberg286ce272007-11-06 14:34:15 -0500353 /**
354 * Pointer to the mode used to create this context.
355 */
356 const __GLcontextModes * mode;
357
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000358#ifdef GLX_DIRECT_RENDERING
Kristian Høgsberg020c64b2008-03-08 21:57:29 -0500359 __GLXDRIcontext *driContext;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000360#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000361
362 /**
363 * The current read-drawable for this context. Will be None if this
364 * context is not current to any drawable.
365 *
366 * \since Internal API version 20030606.
367 */
368 GLXDrawable currentReadable;
369
370 /**
371 * Pointer to client-state data that is private to libGL. This is only
372 * used for indirect rendering contexts.
373 *
374 * No internal API version change was made for this change. Client-side
375 * drivers should NEVER use this data or even care that it exists.
376 */
377 void * client_state_private;
Ian Romanickfdb07632005-02-22 22:36:31 +0000378
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000379 /**
380 * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE.
381 */
382 int renderType;
383
384 /**
385 * \name Raw server GL version
386 *
387 * True core GL version supported by the server. This is the raw value
388 * returned by the server, and it may not reflect what is actually
389 * supported (or reported) by the client-side library.
390 */
391 /*@{*/
392 int server_major; /**< Major version number. */
393 int server_minor; /**< Minor version number. */
394 /*@}*/
Ian Romanickfdb07632005-02-22 22:36:31 +0000395
396 char gl_extension_bits[ __GL_EXT_BYTES ];
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000397};
398
399#define __glXSetError(gc,code) \
400 if (!(gc)->error) { \
401 (gc)->error = code; \
402 }
403
404extern void __glFreeAttributeState(__GLXcontext *);
405
406/************************************************************************/
407
408/**
409 * The size of the largest drawing command known to the implementation
410 * that will use the GLXRender GLX command. In this case it is
411 * \c glPolygonStipple.
412 */
413#define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156
414
415/**
416 * To keep the implementation fast, the code uses a "limit" pointer
417 * to determine when the drawing command buffer is too full to hold
418 * another fixed size command. This constant defines the amount of
419 * space that must always be available in the drawing command buffer
420 * at all times for the implementation to work. It is important that
421 * the number be just large enough, but not so large as to reduce the
422 * efficacy of the buffer. The "+32" is just to keep the code working
423 * in case somebody counts wrong.
424 */
425#define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32)
426
427/**
428 * This implementation uses a smaller threshold for switching
429 * to the RenderLarge protocol than the protcol requires so that
430 * large copies don't occur.
431 */
432#define __GLX_RENDER_CMD_SIZE_LIMIT 4096
433
434/**
435 * One of these records exists per screen of the display. It contains
436 * a pointer to the config data for that screen (if the screen supports GL).
437 */
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400438struct __GLXscreenConfigsRec {
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000439 /**
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000440 * GLX extension string reported by the X-server.
441 */
442 const char *serverGLXexts;
443
444 /**
445 * GLX extension string to be reported to applications. This is the
446 * set of extensions that the application can actually use.
447 */
448 char *effectiveGLXexts;
449
450#ifdef GLX_DIRECT_RENDERING
451 /**
452 * Per screen direct rendering interface functions and data.
453 */
Kristian Høgsberg92d2a782008-03-08 20:34:24 -0500454 __DRIscreen __driScreen;
Kristian Høgsberg4a22ae82007-01-07 08:12:01 -0500455 __glxHashTable *drawHash;
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400456 Display *dpy;
457 int scr;
Kristian Høgsberg0f2723c2008-03-07 01:37:08 -0500458 void *driver;
Kristian Høgsbergac3e8382007-05-15 15:17:30 -0400459
Kristian Høgsberg92d2a782008-03-08 20:34:24 -0500460 __GLXDRIscreen *driScreen;
Kristian Høgsberg53dc8632008-03-08 20:02:22 -0500461
Kristian Høgsbergac3e8382007-05-15 15:17:30 -0400462#ifdef __DRI_COPY_SUB_BUFFER
463 __DRIcopySubBufferExtension *copySubBuffer;
464#endif
465
Kristian Høgsbergefaf90b2007-05-15 16:09:44 -0400466#ifdef __DRI_SWAP_CONTROL
467 __DRIswapControlExtension *swapControl;
468#endif
469
Kristian Høgsberg78a6aa52007-05-16 14:10:29 -0400470#ifdef __DRI_ALLOCATE
471 __DRIallocateExtension *allocate;
472#endif
473
Kristian Høgsberga7a0a2b2007-05-16 15:50:40 -0400474#ifdef __DRI_FRAME_TRACKING
475 __DRIframeTrackingExtension *frameTracking;
476#endif
477
Kristian Høgsberg106a6f22007-05-16 18:13:41 -0400478#ifdef __DRI_MEDIA_STREAM_COUNTER
479 __DRImediaStreamCounterExtension *msc;
480#endif
481
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000482#endif
483
484 /**
Kristian Høgsberg6c533ea2007-10-16 16:07:47 -0400485 * Linked list of glx visuals and fbconfigs for this screen.
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000486 */
Kristian Høgsberg6c533ea2007-10-16 16:07:47 -0400487 __GLcontextModes *visuals, *configs;
Ian Romanickc39bf5e2005-07-24 06:29:14 +0000488
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000489 /**
490 * Per-screen dynamic GLX extension tracking. The \c direct_support
491 * field only contains enough bits for 64 extensions. Should libGL
492 * ever need to track more than 64 GLX extensions, we can safely grow
493 * this field. The \c __GLXscreenConfigs structure is not used outside
494 * libGL.
495 */
496 /*@{*/
497 unsigned char direct_support[8];
498 GLboolean ext_list_first_time;
499 /*@}*/
500
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400501};
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000502
503/**
504 * Per display private data. One of these records exists for each display
505 * that is using the OpenGL (GLX) extension.
506 */
507struct __GLXdisplayPrivateRec {
508 /**
509 * Back pointer to the display
510 */
511 Display *dpy;
512
513 /**
514 * The \c majorOpcode is common to all connections to the same server.
515 * It is also copied into the context structure.
516 */
517 int majorOpcode;
518
519 /**
520 * \name Server Version
521 *
522 * Major and minor version returned by the server during initialization.
523 */
524 /*@{*/
525 int majorVersion, minorVersion;
526 /*@}*/
527
528 /**
529 * \name Storage for the servers GLX vendor and versions strings.
530 *
531 * These are the same for all screens on this display. These fields will
532 * be filled in on demand.
533 */
534 /*@{*/
535 const char *serverGLXvendor;
536 const char *serverGLXversion;
537 /*@}*/
538
539 /**
540 * Configurations of visuals for all screens on this display.
541 * Also, per screen data which now includes the server \c GLX_EXTENSION
542 * string.
543 */
544 __GLXscreenConfigs *screenConfigs;
545
546#ifdef GLX_DIRECT_RENDERING
547 /**
548 * Per display direct rendering interface functions and data.
549 */
Kristian Høgsberg425f9ed2008-03-08 19:02:10 -0500550 __GLXDRIdisplay *driDisplay;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000551#endif
552};
553
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400554
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000555void __glXFreeContext(__GLXcontext*);
556
557extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*);
558
559extern void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
560 GLint totalRequests,
561 const GLvoid * data, GLint dataLen);
562
563extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint,
564 const GLvoid *, GLint);
565
566/* Initialize the GLX extension for dpy */
567extern __GLXdisplayPrivate *__glXInitialize(Display*);
568
569/************************************************************************/
570
571extern int __glXDebug;
572
573/* This is per-thread storage in an MT environment */
Ian Romanick711555d2005-08-03 23:05:25 +0000574#if defined( USE_XTHREADS ) || defined( PTHREADS )
Ian Romanick02986cb2005-04-18 16:59:53 +0000575
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000576extern void __glXSetCurrentContext(__GLXcontext *c);
Ian Romanick02986cb2005-04-18 16:59:53 +0000577
578# if defined( GLX_USE_TLS )
579
580extern __thread void * __glX_tls_Context
581 __attribute__((tls_model("initial-exec")));
582
583# define __glXGetCurrentContext() __glX_tls_Context
584
585# else
586
587extern __GLXcontext *__glXGetCurrentContext(void);
588
589# endif /* defined( GLX_USE_TLS ) */
590
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000591#else
Ian Romanick02986cb2005-04-18 16:59:53 +0000592
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000593extern __GLXcontext *__glXcurrentContext;
594#define __glXGetCurrentContext() __glXcurrentContext
595#define __glXSetCurrentContext(gc) __glXcurrentContext = gc
Ian Romanick02986cb2005-04-18 16:59:53 +0000596
Ian Romanick711555d2005-08-03 23:05:25 +0000597#endif /* defined( USE_XTHREADS ) || defined( PTHREADS ) */
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000598
599
600/*
601** Global lock for all threads in this address space using the GLX
602** extension
603*/
Ian Romanick711555d2005-08-03 23:05:25 +0000604#if defined( USE_XTHREADS )
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000605extern xmutex_rec __glXmutex;
606#define __glXLock() xmutex_lock(&__glXmutex)
607#define __glXUnlock() xmutex_unlock(&__glXmutex)
Ian Romanick02986cb2005-04-18 16:59:53 +0000608#elif defined( PTHREADS )
609extern pthread_mutex_t __glXmutex;
610#define __glXLock() pthread_mutex_lock(&__glXmutex)
611#define __glXUnlock() pthread_mutex_unlock(&__glXmutex)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000612#else
613#define __glXLock()
614#define __glXUnlock()
615#endif
616
617/*
618** Setup for a command. Initialize the extension for dpy if necessary.
619*/
620extern CARD8 __glXSetupForCommand(Display *dpy);
621
622/************************************************************************/
623
624/*
625** Data conversion and packing support.
626*/
627
Ian Romanick5f1f2292005-01-07 02:39:09 +0000628extern const GLuint __glXDefaultPixelStore[9];
629
630/* Send an image to the server using RenderLarge. */
631extern void __glXSendLargeImage(__GLXcontext *gc, GLint compsize, GLint dim,
632 GLint width, GLint height, GLint depth, GLenum format, GLenum type,
633 const GLvoid *src, GLubyte *pc, GLubyte *modes);
634
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000635/* Return the size, in bytes, of some pixel data */
Ian Romanick5f1f2292005-01-07 02:39:09 +0000636extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000637
638/* Return the number of elements per group of a specified format*/
639extern GLint __glElementsPerGroup(GLenum format, GLenum type);
640
641/* Return the number of bytes per element, based on the element type (other
642** than GL_BITMAP).
643*/
644extern GLint __glBytesPerElement(GLenum type);
645
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000646/*
647** Fill the transport buffer with the data from the users buffer,
648** applying some of the pixel store modes (unpack modes) to the data
649** first. As a side effect of this call, the "modes" field is
650** updated to contain the modes needed by the server to decode the
651** sent data.
652*/
653extern void __glFillImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
654 GLenum, const GLvoid*, GLubyte*, GLubyte*);
655
656/* Copy map data with a stride into a packed buffer */
657extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *);
658extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *);
659extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint,
660 const GLfloat *, GLfloat *);
661extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint,
662 const GLdouble *, GLdouble *);
663
664/*
665** Empty an image out of the reply buffer into the clients memory applying
666** the pack modes to pack back into the clients requested format.
667*/
668extern void __glEmptyImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
669 GLenum, const GLubyte *, GLvoid *);
670
671
672/*
673** Allocate and Initialize Vertex Array client state
674*/
675extern void __glXInitVertexArrayState(__GLXcontext*);
676
677/*
678** Inform the Server of the major and minor numbers and of the client
679** libraries extension string.
680*/
681extern void __glXClientInfo ( Display *dpy, int opcode );
682
683/************************************************************************/
684
685/*
686** Declarations that should be in Xlib
687*/
688#ifdef __GL_USE_OUR_PROTOTYPES
689extern void _XFlush(Display*);
690extern Status _XReply(Display*, xReply*, int, Bool);
691extern void _XRead(Display*, void*, long);
692extern void _XSend(Display*, const void*, long);
693#endif
694
695
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000696extern void __glXInitializeVisualConfigFromTags( __GLcontextModes *config,
697 int count, const INT32 *bp, Bool tagged_only, Bool fbconfig_style_tags );
698
699extern char * __glXGetStringFromServer( Display * dpy, int opcode,
700 CARD32 glxCode, CARD32 for_whom, CARD32 name );
701
702extern char *__glXstrdup(const char *str);
703
704
705extern const char __glXGLClientVersion[];
706extern const char __glXGLClientExtensions[];
707
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000708/* Get the unadjusted system time */
709extern int __glXGetUST( int64_t * ust );
710
Kristian Høgsberg286ce272007-11-06 14:34:15 -0500711extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400712 int32_t * numerator, int32_t * denominator);
Ian Romanickfc5b57b2006-08-29 15:38:19 +0000713
Kristian Høgsberg286ce272007-11-06 14:34:15 -0500714#ifdef GLX_DIRECT_RENDERING
715GLboolean
716__driGetMscRateOML(__DRIdrawable *draw, int32_t *numerator, int32_t *denominator);
717#endif
718
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000719#endif /* !__GLX_client_h__ */