blob: 730caf73024b1dccb551b5e494600c9772f841b4 [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 {
Kristian Høgsberg91104252008-03-12 02:18:12 -0400135 void (*destroyDrawable)(__GLXDRIdrawable *drawable);
136
Kristian Høgsberg20b92302008-03-08 21:02:23 -0500137 XID drawable;
138 __GLXscreenConfigs *psc;
139 __DRIdrawable driDrawable;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000140};
141
142/*
143** Function to create and DRI display data and initialize the display
144** dependent methods.
145*/
Kristian Høgsberg425f9ed2008-03-08 19:02:10 -0500146extern __GLXDRIdisplay *driCreateDisplay(Display *dpy);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000147
148extern 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*/
154extern const char *glXGetScreenDriver (Display *dpy, int scrNum);
155
156extern const char *glXGetDriverConfig (const char *driverName);
157
Ian Romanick5f1ba3e2005-07-26 02:44:01 +0000158extern Bool __glXWindowExists(Display *dpy, GLXDrawable draw);
159
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000160#endif
161
162/************************************************************************/
163
164#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16
165
166typedef 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 Jacksoncb3610e2004-10-25 21:09:16 +0000178
179typedef struct __GLXattributeRec {
Ian Romanickfdb07632005-02-22 22:36:31 +0000180 GLuint mask;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000181
Ian Romanickfdb07632005-02-22 22:36:31 +0000182 /**
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 Jacksoncb3610e2004-10-25 21:09:16 +0000188
Ian Romanickfdb07632005-02-22 22:36:31 +0000189 /**
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 Jacksoncb3610e2004-10-25 21:09:16 +0000201} __GLXattribute;
202
203typedef 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 */
212struct __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 Jacksoncb3610e2004-10-25 21:09:16 +0000251 * Screen number.
252 */
253 GLint screen;
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400254 __GLXscreenConfigs *psc;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000255
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 Romanick29206ae2005-07-29 17:30:18 +0000301 * Client side attribs.
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000302 */
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000303 __GLXattributeMachine attributes;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000304
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 Jacksoncb3610e2004-10-25 21:09:16 +0000313 * \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øgsberg286ce272007-11-06 14:34:15 -0500355 /**
356 * Pointer to the mode used to create this context.
357 */
358 const __GLcontextModes * mode;
359
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000360#ifdef GLX_DIRECT_RENDERING
Kristian Høgsberg020c64b2008-03-08 21:57:29 -0500361 __GLXDRIcontext *driContext;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000362#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000363
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 Romanickfdb07632005-02-22 22:36:31 +0000380
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000381 /**
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 Romanickfdb07632005-02-22 22:36:31 +0000397
398 char gl_extension_bits[ __GL_EXT_BYTES ];
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000399};
400
401#define __glXSetError(gc,code) \
402 if (!(gc)->error) { \
403 (gc)->error = code; \
404 }
405
406extern 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øgsbergaceccda2007-05-10 15:52:22 -0400440struct __GLXscreenConfigsRec {
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000441 /**
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000442 * 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øgsberg92d2a782008-03-08 20:34:24 -0500456 __DRIscreen __driScreen;
Kristian Høgsberg4a22ae82007-01-07 08:12:01 -0500457 __glxHashTable *drawHash;
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400458 Display *dpy;
459 int scr;
Kristian Høgsberg0f2723c2008-03-07 01:37:08 -0500460 void *driver;
Kristian Høgsbergac3e8382007-05-15 15:17:30 -0400461
Kristian Høgsberg92d2a782008-03-08 20:34:24 -0500462 __GLXDRIscreen *driScreen;
Kristian Høgsberg53dc8632008-03-08 20:02:22 -0500463
Kristian Høgsbergac3e8382007-05-15 15:17:30 -0400464#ifdef __DRI_COPY_SUB_BUFFER
465 __DRIcopySubBufferExtension *copySubBuffer;
466#endif
467
Kristian Høgsbergefaf90b2007-05-15 16:09:44 -0400468#ifdef __DRI_SWAP_CONTROL
469 __DRIswapControlExtension *swapControl;
470#endif
471
Kristian Høgsberg78a6aa52007-05-16 14:10:29 -0400472#ifdef __DRI_ALLOCATE
473 __DRIallocateExtension *allocate;
474#endif
475
Kristian Høgsberga7a0a2b2007-05-16 15:50:40 -0400476#ifdef __DRI_FRAME_TRACKING
477 __DRIframeTrackingExtension *frameTracking;
478#endif
479
Kristian Høgsberg106a6f22007-05-16 18:13:41 -0400480#ifdef __DRI_MEDIA_STREAM_COUNTER
481 __DRImediaStreamCounterExtension *msc;
482#endif
483
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000484#endif
485
486 /**
Kristian Høgsberg6c533ea2007-10-16 16:07:47 -0400487 * Linked list of glx visuals and fbconfigs for this screen.
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000488 */
Kristian Høgsberg6c533ea2007-10-16 16:07:47 -0400489 __GLcontextModes *visuals, *configs;
Ian Romanickc39bf5e2005-07-24 06:29:14 +0000490
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000491 /**
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øgsbergaceccda2007-05-10 15:52:22 -0400503};
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000504
505/**
506 * Per display private data. One of these records exists for each display
507 * that is using the OpenGL (GLX) extension.
508 */
509struct __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øgsberg425f9ed2008-03-08 19:02:10 -0500552 __GLXDRIdisplay *driDisplay;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000553#endif
554};
555
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400556
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000557void __glXFreeContext(__GLXcontext*);
558
559extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*);
560
561extern void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
562 GLint totalRequests,
563 const GLvoid * data, GLint dataLen);
564
565extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint,
566 const GLvoid *, GLint);
567
568/* Initialize the GLX extension for dpy */
569extern __GLXdisplayPrivate *__glXInitialize(Display*);
570
571/************************************************************************/
572
573extern int __glXDebug;
574
575/* This is per-thread storage in an MT environment */
Ian Romanick711555d2005-08-03 23:05:25 +0000576#if defined( USE_XTHREADS ) || defined( PTHREADS )
Ian Romanick02986cb2005-04-18 16:59:53 +0000577
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000578extern void __glXSetCurrentContext(__GLXcontext *c);
Ian Romanick02986cb2005-04-18 16:59:53 +0000579
580# if defined( GLX_USE_TLS )
581
582extern __thread void * __glX_tls_Context
583 __attribute__((tls_model("initial-exec")));
584
585# define __glXGetCurrentContext() __glX_tls_Context
586
587# else
588
589extern __GLXcontext *__glXGetCurrentContext(void);
590
591# endif /* defined( GLX_USE_TLS ) */
592
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000593#else
Ian Romanick02986cb2005-04-18 16:59:53 +0000594
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000595extern __GLXcontext *__glXcurrentContext;
596#define __glXGetCurrentContext() __glXcurrentContext
597#define __glXSetCurrentContext(gc) __glXcurrentContext = gc
Ian Romanick02986cb2005-04-18 16:59:53 +0000598
Ian Romanick711555d2005-08-03 23:05:25 +0000599#endif /* defined( USE_XTHREADS ) || defined( PTHREADS ) */
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000600
601
602/*
603** Global lock for all threads in this address space using the GLX
604** extension
605*/
Ian Romanick711555d2005-08-03 23:05:25 +0000606#if defined( USE_XTHREADS )
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000607extern xmutex_rec __glXmutex;
608#define __glXLock() xmutex_lock(&__glXmutex)
609#define __glXUnlock() xmutex_unlock(&__glXmutex)
Ian Romanick02986cb2005-04-18 16:59:53 +0000610#elif defined( PTHREADS )
611extern pthread_mutex_t __glXmutex;
612#define __glXLock() pthread_mutex_lock(&__glXmutex)
613#define __glXUnlock() pthread_mutex_unlock(&__glXmutex)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000614#else
615#define __glXLock()
616#define __glXUnlock()
617#endif
618
619/*
620** Setup for a command. Initialize the extension for dpy if necessary.
621*/
622extern CARD8 __glXSetupForCommand(Display *dpy);
623
624/************************************************************************/
625
626/*
627** Data conversion and packing support.
628*/
629
Ian Romanick5f1f2292005-01-07 02:39:09 +0000630extern const GLuint __glXDefaultPixelStore[9];
631
632/* Send an image to the server using RenderLarge. */
633extern 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 Jacksoncb3610e2004-10-25 21:09:16 +0000637/* Return the size, in bytes, of some pixel data */
Ian Romanick5f1f2292005-01-07 02:39:09 +0000638extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000639
640/* Return the number of elements per group of a specified format*/
641extern 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*/
646extern GLint __glBytesPerElement(GLenum type);
647
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000648/*
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*/
655extern 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 */
659extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *);
660extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *);
661extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint,
662 const GLfloat *, GLfloat *);
663extern 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*/
670extern 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*/
677extern void __glXInitVertexArrayState(__GLXcontext*);
678
679/*
680** Inform the Server of the major and minor numbers and of the client
681** libraries extension string.
682*/
683extern void __glXClientInfo ( Display *dpy, int opcode );
684
685/************************************************************************/
686
687/*
688** Declarations that should be in Xlib
689*/
690#ifdef __GL_USE_OUR_PROTOTYPES
691extern void _XFlush(Display*);
692extern Status _XReply(Display*, xReply*, int, Bool);
693extern void _XRead(Display*, void*, long);
694extern void _XSend(Display*, const void*, long);
695#endif
696
697
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000698extern void __glXInitializeVisualConfigFromTags( __GLcontextModes *config,
699 int count, const INT32 *bp, Bool tagged_only, Bool fbconfig_style_tags );
700
701extern char * __glXGetStringFromServer( Display * dpy, int opcode,
702 CARD32 glxCode, CARD32 for_whom, CARD32 name );
703
704extern char *__glXstrdup(const char *str);
705
706
707extern const char __glXGLClientVersion[];
708extern const char __glXGLClientExtensions[];
709
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000710/* Get the unadjusted system time */
711extern int __glXGetUST( int64_t * ust );
712
Kristian Høgsberg286ce272007-11-06 14:34:15 -0500713extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
Kristian Høgsbergaceccda2007-05-10 15:52:22 -0400714 int32_t * numerator, int32_t * denominator);
Ian Romanickfc5b57b2006-08-29 15:38:19 +0000715
Kristian Høgsberg286ce272007-11-06 14:34:15 -0500716#ifdef GLX_DIRECT_RENDERING
717GLboolean
718__driGetMscRateOML(__DRIdrawable *draw, int32_t *numerator, int32_t *denominator);
719#endif
720
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000721#endif /* !__GLX_client_h__ */