xref: /aosp_15_r20/external/mesa3d/src/glx/glxclient.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3  * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * SPDX-License-Identifier: SGI-B-2.0
6  */
7 
8 /**
9  * \file glxclient.h
10  * Direct rendering support added by Precision Insight, Inc.
11  *
12  * \author Kevin E. Martin <[email protected]>
13  */
14 
15 #ifndef _GLX_client_h_
16 #define _GLX_client_h_
17 #include <X11/Xproto.h>
18 #include <X11/Xlibint.h>
19 #include <X11/Xfuncproto.h>
20 #include <X11/extensions/extutil.h>
21 #define GLX_GLXEXT_PROTOTYPES
22 #include <GL/glx.h>
23 #include <GL/glxext.h>
24 #include <string.h>
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <stdint.h>
28 #include <pthread.h>
29 #include "GL/glxproto.h"
30 #include "glxconfig.h"
31 #include "glxhash.h"
32 #include "util/macros.h"
33 #include "util/u_thread.h"
34 #include "util/set.h"
35 #include "loader.h"
36 #include "glxextensions.h"
37 
38 /* bits */
39 enum glx_driver {
40    GLX_DRIVER_NONE = 0,
41    GLX_DRIVER_ZINK_INFER = (1<<0),
42    GLX_DRIVER_SW = (1<<1),
43    GLX_DRIVER_DRI2 = (1<<2),
44    GLX_DRIVER_DRI3 = (1<<3),
45    GLX_DRIVER_WINDOWS = (1<<4),
46    GLX_DRIVER_ZINK_YES = (1<<5),
47 };
48 
49 #if USE_LIBGLVND
50 #define _GLX_PUBLIC _X_HIDDEN
51 #else
52 #define _GLX_PUBLIC _X_EXPORT
53 #endif
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 extern void glx_message(int level, const char *f, ...) PRINTFLIKE(2, 3);
60 
61 #define DebugMessageF(...) glx_message(_LOADER_DEBUG, __VA_ARGS__)
62 #define InfoMessageF(...) glx_message(_LOADER_INFO, __VA_ARGS__)
63 #define ErrorMessageF(...) glx_message(_LOADER_WARNING, __VA_ARGS__)
64 #define CriticalErrorMessageF(...) glx_message(_LOADER_FATAL, __VA_ARGS__)
65 
66 
67 #define GLX_MAJOR_VERSION 1       /* current version numbers */
68 #define GLX_MINOR_VERSION 4
69 
70 struct glx_display;
71 struct glx_context;
72 
73 /************************************************************************/
74 
75 #ifdef GLX_DIRECT_RENDERING
76 
77 extern void DRI_glXUseXFont(struct glx_context *ctx,
78 			    Font font, int first, int count, int listbase);
79 
80 #endif
81 
82 #if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
83 
84 /**
85  * Display dependent methods.  This structure is initialized during the
86  * \c driCreateDisplay call.
87  */
88 typedef struct __GLXDRIdisplay __GLXDRIdisplay;
89 typedef struct __GLXDRIscreenRec __GLXDRIscreen;
90 typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
91 
92 struct __GLXDRIscreenRec {
93 
94    void (*deinitScreen)(struct glx_screen *psc);
95 
96    __GLXDRIdrawable *(*createDrawable)(struct glx_screen *psc,
97 				       XID drawable,
98 				       GLXDrawable glxDrawable,
99 				       int type,
100 				       struct glx_config *config);
101 
102    int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc,
103 			  int64_t divisor, int64_t remainder, Bool flush);
104    void (*copySubBuffer)(__GLXDRIdrawable *pdraw,
105 			 int x, int y, int width, int height, Bool flush);
106    int (*getDrawableMSC)(struct glx_screen *psc, __GLXDRIdrawable *pdraw,
107 			 int64_t *ust, int64_t *msc, int64_t *sbc);
108    int (*waitForMSC)(__GLXDRIdrawable *pdraw, int64_t target_msc,
109 		     int64_t divisor, int64_t remainder, int64_t *ust,
110 		     int64_t *msc, int64_t *sbc);
111    int (*waitForSBC)(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
112 		     int64_t *msc, int64_t *sbc);
113    int (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval);
114    int (*getSwapInterval)(__GLXDRIdrawable *pdraw);
115    void (*bindTexImage)(__GLXDRIdrawable *pdraw, int buffer, const int *attribs);
116 
117    int maxSwapInterval;
118 };
119 
120 struct __GLXDRIdrawableRec
121 {
122    void (*destroyDrawable) (__GLXDRIdrawable * drawable);
123 
124    XID xDrawable;
125    XID drawable;
126    struct glx_screen *psc;
127    GLenum textureTarget;
128    GLenum textureFormat;        /* EXT_texture_from_pixmap support */
129    unsigned long eventMask;
130    int refcount;
131 
132    __DRIdrawable *dri_drawable;
133 };
134 
135 /*
136 ** Function to create and DRI display data and initialize the display
137 ** dependent methods.
138 */
139 extern __GLXDRIdisplay *driswCreateDisplay(Display * dpy, enum glx_driver glx_driver);
140 extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy);
141 extern __GLXDRIdisplay *dri3_create_display(Display * dpy);
142 extern __GLXDRIdisplay *driwindowsCreateDisplay(Display * dpy);
143 
144 
145 #if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
146 #ifdef HAVE_LIBDRM
147 struct glx_screen *dri3_create_screen(int screen, struct glx_display * priv, bool driver_name_is_inferred, bool *return_zink);
148 void dri3_destroy_display(__GLXDRIdisplay * dpy);
149 #endif
150 
151 bool dri2CheckSupport(Display *dpy);
152 struct glx_screen *dri2CreateScreen(int screen, struct glx_display * priv, bool driver_name_is_inferred);
153 void dri2DestroyDisplay(__GLXDRIdisplay * dpy);
154 
155 struct glx_screen *driswCreateScreen(int screen, struct glx_display *priv, enum glx_driver driver, bool driver_name_is_inferred);
156 void driswDestroyDisplay(__GLXDRIdisplay * dpy);
157 #endif
158 
159 #ifdef GLX_USE_WINDOWSGL
160 struct glx_screen *driwindowsCreateScreen(int screen, struct glx_display *priv, bool driver_name_is_inferred);
161 void driwindowsDestroyDisplay(__GLXDRIdisplay * dpy);
162 #endif
163 /*
164 **
165 */
166 extern void dri2InvalidateBuffers(Display *dpy, XID drawable);
167 extern unsigned dri2GetSwapEventType(Display *dpy, XID drawable);
168 
169 /*
170 ** Functions to obtain driver configuration information from a direct
171 ** rendering client application
172 */
173 extern const char *glXGetScreenDriver(Display * dpy, int scrNum);
174 
175 extern const char *glXGetDriverConfig(const char *driverName);
176 
177 #endif
178 
179 /************************************************************************/
180 
181 #define __GL_CLIENT_ATTRIB_STACK_DEPTH 16
182 
183 typedef struct __GLXpixelStoreModeRec
184 {
185    GLboolean swapEndian;
186    GLboolean lsbFirst;
187    GLuint rowLength;
188    GLuint imageHeight;
189    GLuint imageDepth;
190    GLuint skipRows;
191    GLuint skipPixels;
192    GLuint skipImages;
193    GLuint alignment;
194 } __GLXpixelStoreMode;
195 
196 
197 typedef struct __GLXattributeRec
198 {
199    GLuint mask;
200 
201     /**
202      * Pixel storage state.  Most of the pixel store mode state is kept
203      * here and used by the client code to manage the packing and
204      * unpacking of data sent to/received from the server.
205      */
206    __GLXpixelStoreMode storePack, storeUnpack;
207 
208     /**
209      * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically
210      * disabled?
211      */
212    GLboolean NoDrawArraysProtocol;
213 
214     /**
215      * Vertex Array storage state.  The vertex array component
216      * state is stored here and is used to manage the packing of
217      * DrawArrays data sent to the server.
218      */
219    struct array_state_vector *array_state;
220 } __GLXattribute;
221 
222 typedef struct __GLXattributeMachineRec
223 {
224    __GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
225    __GLXattribute **stackPointer;
226 } __GLXattributeMachine;
227 
228 struct mesa_glinterop_device_info;
229 struct mesa_glinterop_export_in;
230 struct mesa_glinterop_export_out;
231 struct mesa_glinterop_flush_out;
232 
233 struct glx_context_vtable {
234    void (*destroy)(struct glx_context *ctx);
235    int (*bind)(struct glx_context *context, GLXDrawable draw, GLXDrawable read);
236    void (*unbind)(struct glx_context *context);
237    void (*wait_gl)(struct glx_context *ctx);
238    void (*wait_x)(struct glx_context *ctx);
239 };
240 
241 /**
242  * GLX state that needs to be kept on the client.  One of these records
243  * exist for each context that has been made current by this client.
244  */
245 struct glx_context
246 {
247     /**
248      * \name Drawing command buffer.
249      *
250      * Drawing commands are packed into this buffer before being sent as a
251      * single GLX protocol request.  The buffer is sent when it overflows or
252      * is flushed by \c __glXFlushRenderBuffer.  \c pc is the next location
253      * in the buffer to be filled.  \c limit is described above in the buffer
254      * slop discussion.
255      *
256      * Commands that require large amounts of data to be transferred will
257      * also use this buffer to hold a header that describes the large
258      * command.
259      *
260      * These must be the first 6 fields since they are static initialized
261      * in the dummy context in glxext.c
262      */
263    /*@{ */
264    GLubyte *buf;
265    GLubyte *pc;
266    GLubyte *limit;
267    GLubyte *bufEnd;
268    GLint bufSize;
269    /*@} */
270 
271    const struct glx_context_vtable *vtable;
272 
273     /**
274      * The XID of this rendering context.  When the context is created a
275      * new XID is allocated.  This is set to None when the context is
276      * destroyed but is still current to some thread. In this case the
277      * context will be freed on next MakeCurrent.
278      */
279    XID xid;
280 
281     /**
282      * The XID of the \c shareList context.
283      */
284    XID share_xid;
285 
286    struct glx_screen *psc;
287 
288     /**
289      * \c GL_TRUE if the context was created with ImportContext, which
290      * means the server-side context was created by another X client.
291      */
292    GLboolean imported;
293 
294     /**
295      * The context tag returned by MakeCurrent when this context is made
296      * current. This tag is used to identify the context that a thread has
297      * current so that proper server context management can be done.  It is
298      * used for all context specific commands (i.e., \c Render, \c RenderLarge,
299      * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old
300      * context)).
301      */
302    GLXContextTag currentContextTag;
303 
304     /**
305      * \name Rendering mode
306      *
307      * The rendering mode is kept on the client as well as the server.
308      * When \c glRenderMode is called, the buffer associated with the
309      * previous rendering mode (feedback or select) is filled.
310      */
311    /*@{ */
312    GLenum renderMode;
313    GLfloat *feedbackBuf;
314    GLuint *selectBuf;
315    /*@} */
316 
317     /**
318      * Client side attribs.
319      */
320    __GLXattributeMachine attributes;
321 
322     /**
323      * Client side error code.  This is set when client side gl API
324      * routines need to set an error because of a bad enumerant or
325      * running out of memory, etc.
326      */
327    GLenum error;
328 
329     /**
330      * Whether this context does direct rendering.
331      */
332    Bool isDirect;
333 
334    /* Backend private state for the context */
335    void *driContext;
336 
337     /**
338      * \c dpy of current display for this context.  Will be \c NULL if not
339      * current to any display, or if this is the "dummy context".
340      */
341    Display *currentDpy;
342 
343     /**
344      * The current drawable for this context.  Will be None if this
345      * context is not current to any drawable.  currentReadable is below.
346      */
347    GLXDrawable currentDrawable;
348 
349     /**
350      * \name GL Constant Strings
351      *
352      * Constant strings that describe the server implementation
353      * These pertain to GL attributes, not to be confused with
354      * GLX versioning attributes.
355      */
356    /*@{ */
357    GLubyte *vendor;
358    GLubyte *renderer;
359    GLubyte *version;
360    GLubyte *extensions;
361    /*@} */
362 
363     /**
364      * Maximum small render command size.  This is the smaller of 64k and
365      * the size of the above buffer.
366      */
367    GLint maxSmallRenderCommandSize;
368 
369     /**
370      * Major opcode for the extension.  Copied here so a lookup isn't
371      * needed.
372      */
373    GLint majorOpcode;
374 
375     /**
376      * Pointer to the config used to create this context.
377      */
378    struct glx_config *config;
379 
380     /**
381      * The current read-drawable for this context.  Will be None if this
382      * context is not current to any drawable.
383      *
384      * \since Internal API version 20030606.
385      */
386    GLXDrawable currentReadable;
387 
388    /**
389     * Pointer to client-state data that is private to libGL.  This is only
390     * used for indirect rendering contexts.
391     *
392     * No internal API version change was made for this change.  Client-side
393     * drivers should NEVER use this data or even care that it exists.
394     */
395    void *client_state_private;
396 
397    /**
398     * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE.
399     */
400    int renderType;
401 
402    /**
403     * \name Raw server GL version
404     *
405     * True core GL version supported by the server.  This is the raw value
406     * returned by the server, and it may not reflect what is actually
407     * supported (or reported) by the client-side library.
408     */
409    /*@{ */
410    int server_major;        /**< Major version number. */
411    int server_minor;        /**< Minor version number. */
412    /*@} */
413 
414    /**
415     * GLX_ARB_create_context_no_error setting for this context.
416     * This needs to be kept here to enforce shared context rules.
417     */
418    Bool noError;
419 
420    char gl_extension_bits[__GL_EXT_BYTES];
421 };
422 
423 extern Bool
424 glx_context_init(struct glx_context *gc,
425 		 struct glx_screen *psc, struct glx_config *fbconfig);
426 
427 #define __glXSetError(gc,code)  \
428    if (!(gc)->error) {          \
429       (gc)->error = code;       \
430    }
431 
432 /************************************************************************/
433 
434 /**
435  * The size of the largest drawing command known to the implementation
436  * that will use the GLXRender GLX command.  In this case it is
437  * \c glPolygonStipple.
438  */
439 #define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156
440 
441 /**
442  * To keep the implementation fast, the code uses a "limit" pointer
443  * to determine when the drawing command buffer is too full to hold
444  * another fixed size command.  This constant defines the amount of
445  * space that must always be available in the drawing command buffer
446  * at all times for the implementation to work.  It is important that
447  * the number be just large enough, but not so large as to reduce the
448  * efficacy of the buffer.  The "+32" is just to keep the code working
449  * in case somebody counts wrong.
450  */
451 #define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32)
452 
453 /**
454  * This implementation uses a smaller threshold for switching
455  * to the RenderLarge protocol than the protocol requires so that
456  * large copies don't occur.
457  */
458 #define __GLX_RENDER_CMD_SIZE_LIMIT 4096
459 
460 /**
461  * One of these records exists per screen of the display.  It contains
462  * a pointer to the config data for that screen (if the screen supports GL).
463  */
464 struct glx_screen_vtable {
465    struct glx_context *(*create_context)(struct glx_screen *psc,
466 					 struct glx_config *config,
467 					 struct glx_context *shareList,
468 					 int renderType);
469 
470    /* The error outparameter abuses the fact that the only possible errors are
471     * GLXBadContext (0), GLXBadFBConfig (9), GLXBadProfileARB (13), BadValue
472     * (2), BadMatch (8), and BadAlloc (11). Since those don't collide we just
473     * use them directly rather than try to offset or use a sign convention.
474     */
475    struct glx_context *(*create_context_attribs)(struct glx_screen *psc,
476 						 struct glx_config *config,
477 						 struct glx_context *shareList,
478 						 unsigned num_attrib,
479 						 const uint32_t *attribs,
480 						 unsigned *error);
481    int (*query_renderer_integer)(struct glx_screen *psc,
482                                  int attribute,
483                                  unsigned int *value);
484    int (*query_renderer_string)(struct glx_screen *psc,
485                                 int attribute,
486                                 const char **value);
487 
488    char *(*get_driver_name)(struct glx_screen *psc);
489 };
490 
491 struct glx_screen
492 {
493    const struct glx_screen_vtable *vtable;
494    const struct glx_context_vtable *context_vtable;
495 
496     /**
497      * \name Storage for the GLX vendor, version, and extension strings
498      */
499    /*@{ */
500    const char *serverGLXexts;
501    const char *serverGLXvendor;
502    const char *serverGLXversion;
503    /*@} */
504 
505     /**
506      * GLX extension string to be reported to applications.  This is the
507      * set of extensions that the application can actually use.
508      */
509    char *effectiveGLXexts;
510 
511    struct glx_display *display;
512 
513    Display *dpy;
514    int scr;
515    bool force_direct_context;
516    bool allow_invalid_glx_destroy_window;
517    bool keep_native_window_glx_drawable;
518    bool can_EXT_texture_from_pixmap;
519 
520    char *driverName;
521 
522 #if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
523     /**
524      * Per screen direct rendering interface functions and data.
525      */
526    __GLXDRIscreen driScreen;
527    __DRIscreen *frontend_screen;
528    const __DRIconfig **driver_configs;
529 #endif
530 
531     /**
532      * Linked list of glx visuals and  fbconfigs for this screen.
533      */
534    struct glx_config *visuals, *configs;
535 
536     /**
537      * Per-screen dynamic GLX extension tracking.  The \c direct_support
538      * field only contains enough bits for 64 extensions.  Should libGL
539      * ever need to track more than 64 GLX extensions, we can safely grow
540      * this field.  The \c struct glx_screen structure is not used outside
541      * libGL.
542      */
543    /*@{ */
544    unsigned char direct_support[__GLX_EXT_BYTES];
545    GLboolean ext_list_first_time;
546 
547    unsigned char glx_force_enabled[__GLX_EXT_BYTES];
548    unsigned char glx_force_disabled[__GLX_EXT_BYTES];
549 
550    unsigned char gl_force_enabled[__GL_EXT_BYTES];
551    unsigned char gl_force_disabled[__GL_EXT_BYTES];
552    /*@} */
553 
554 };
555 
556 /**
557  * Per display private data.  One of these records exists for each display
558  * that is using the OpenGL (GLX) extension.
559  */
560 struct glx_display
561 {
562    struct glx_display *next;
563 
564    enum glx_driver driver;
565 
566    /* The extension protocol codes */
567    XExtCodes codes;
568 
569     /**
570      * Back pointer to the display
571      */
572    Display *dpy;
573 
574     /**
575      * \name Minor Version
576      *
577      * Minor version returned by the server during initialization. The major
578      * version is asserted to be 1 during extension setup.
579      */
580    /*@{ */
581    int minorVersion;
582    /*@} */
583 
584     /**
585      * Configurations of visuals for all screens on this display.
586      * Also, per screen data which now includes the server \c GLX_EXTENSION
587      * string.
588      */
589    struct glx_screen **screens;
590 
591    __glxHashTable *glXDrawHash;
592 
593 #if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
594    __glxHashTable *drawHash;
595 
596    /**
597     * GLXDrawable created from native window and about to be released.
598     */
599    struct set *zombieGLXDrawable;
600 
601    __glxHashTable *dri2Hash;
602    bool has_multibuffer;
603    bool has_explicit_modifiers;
604 #endif
605 #ifdef GLX_USE_WINDOWSGL
606    __GLXDRIdisplay *windowsdriDisplay;
607 #endif
608 };
609 
610 struct glx_drawable {
611    XID xDrawable;
612    XID drawable;
613 
614    uint32_t lastEventSbc;
615    int64_t eventSbcWrap;
616 };
617 
618 extern int
619 glx_screen_init(struct glx_screen *psc,
620 		int screen, struct glx_display * priv);
621 extern void
622 glx_screen_cleanup(struct glx_screen *psc);
623 
624 #if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
625 extern __GLXDRIdrawable *
626 dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id);
627 #endif
628 
629 extern GLubyte *__glXFlushRenderBuffer(struct glx_context *, GLubyte *);
630 
631 extern void __glXSendLargeChunk(struct glx_context * gc, GLint requestNumber,
632                                 GLint totalRequests,
633                                 const GLvoid * data, GLint dataLen);
634 
635 extern void __glXSendLargeCommand(struct glx_context *, const GLvoid *, GLint,
636                                   const GLvoid *, GLint);
637 
638 /* Initialize the GLX extension for dpy */
639 extern struct glx_display *__glXInitialize(Display *);
640 
641 /************************************************************************/
642 
643 extern int __glXDebug;
644 
645 /* This is per-thread storage in an MT environment */
646 
647 extern void __glXSetCurrentContext(struct glx_context * c);
648 
649 extern __THREAD_INITIAL_EXEC void *__glX_tls_Context;
650 
651 #  define __glXGetCurrentContext() __glX_tls_Context
652 
653 extern void __glXSetCurrentContextNull(void);
654 
655 
656 /*
657 ** Global lock for all threads in this address space using the GLX
658 ** extension
659 */
660 extern pthread_mutex_t __glXmutex;
661 #define __glXLock()    pthread_mutex_lock(&__glXmutex)
662 #define __glXUnlock()  pthread_mutex_unlock(&__glXmutex)
663 
664 /*
665 ** Setup for a command.  Initialize the extension for dpy if necessary.
666 */
667 extern CARD8 __glXSetupForCommand(Display * dpy);
668 
669 /************************************************************************/
670 
671 /*
672 ** Data conversion and packing support.
673 */
674 
675 extern const GLuint __glXDefaultPixelStore[9];
676 
677 /* Send an image to the server using RenderLarge. */
678 extern void __glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim,
679                                 GLint width, GLint height, GLint depth,
680                                 GLenum format, GLenum type,
681                                 const GLvoid * src, GLubyte * pc,
682                                 GLubyte * modes);
683 
684 /* Return the size, in bytes, of some pixel data */
685 extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum);
686 
687 /* Return the number of elements per group of a specified format*/
688 extern GLint __glElementsPerGroup(GLenum format, GLenum type);
689 
690 /* Return the number of bytes per element, based on the element type (other
691 ** than GL_BITMAP).
692 */
693 extern GLint __glBytesPerElement(GLenum type);
694 
695 /*
696 ** Fill the transport buffer with the data from the users buffer,
697 ** applying some of the pixel store modes (unpack modes) to the data
698 ** first.  As a side effect of this call, the "modes" field is
699 ** updated to contain the modes needed by the server to decode the
700 ** sent data.
701 */
702 extern void __glFillImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum,
703                           GLenum, const GLvoid *, GLubyte *, GLubyte *);
704 
705 /* Copy map data with a stride into a packed buffer */
706 extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *);
707 extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *);
708 extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint,
709                           const GLfloat *, GLfloat *);
710 extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint,
711                           const GLdouble *, GLdouble *);
712 
713 /*
714 ** Empty an image out of the reply buffer into the clients memory applying
715 ** the pack modes to pack back into the clients requested format.
716 */
717 extern void __glEmptyImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum,
718                            GLenum, const GLubyte *, GLvoid *);
719 
720 
721 /*
722 ** Allocate and Initialize Vertex Array client state, and free.
723 */
724 extern void __glXInitVertexArrayState(struct glx_context *);
725 extern void __glXFreeVertexArrayState(struct glx_context *);
726 
727 extern void glxSendClientInfo(struct glx_display *glx_dpy, int screen);
728 
729 /************************************************************************/
730 
731 extern void __glXInitializeVisualConfigFromTags(struct glx_config * config,
732                                                 int count, const INT32 * bp,
733                                                 Bool tagged_only,
734                                                 Bool fbconfig_style_tags);
735 
736 extern char *__glXQueryServerString(Display *dpy, CARD32 screen, CARD32 name);
737 extern char *__glXGetString(Display *dpy, CARD32 screen, CARD32 name);
738 
739 extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
740                                     int32_t * numerator,
741                                     int32_t * denominator);
742 
743 #if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE))
744 extern GLboolean
745 __glxGetMscRate(struct glx_screen *psc,
746 		int32_t * numerator, int32_t * denominator);
747 
748 /* So that dri2.c:DRI2WireToEvent() can access
749  * glx_info->codes->first_event */
750 XExtDisplayInfo *__glXFindDisplay (Display *dpy);
751 
752 extern __GLXDRIdrawable *
753 GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable);
754 #endif
755 
756 extern struct glx_screen *GetGLXScreenConfigs(Display * dpy, int scrn);
757 
758 #ifdef GLX_USE_APPLEGL
759 extern struct glx_screen *
760 applegl_create_screen(int screen, struct glx_display * priv);
761 
762 extern struct glx_context *
763 applegl_create_context(struct glx_screen *psc,
764 			struct glx_config *mode,
765 			struct glx_context *shareList, int renderType);
766 
767 extern int
768 applegl_create_display(struct glx_display *display);
769 
770 extern void *
771 applegl_get_proc_address(const char *symbol);
772 #endif
773 
774 extern Bool validate_renderType_against_config(const struct glx_config *config,
775                                                int renderType);
776 
777 
778 extern struct glx_drawable *GetGLXDrawable(Display *dpy, GLXDrawable drawable);
779 extern int InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw,
780 			   XID xDrawable, GLXDrawable drawable);
781 extern void DestroyGLXDrawable(Display *dpy, GLXDrawable drawable);
782 
783 extern struct glx_context dummyContext;
784 
785 extern struct glx_screen *
786 indirect_create_screen(int screen, struct glx_display * priv);
787 extern struct glx_context *
788 indirect_create_context(struct glx_screen *psc,
789 			struct glx_config *mode,
790 			struct glx_context *shareList, int renderType);
791 extern struct glx_context *
792 indirect_create_context_attribs(struct glx_screen *base,
793                                 struct glx_config *config_base,
794                                 struct glx_context *shareList,
795                                 unsigned num_attribs,
796                                 const uint32_t *attribs,
797                                 unsigned *error);
798 
799 
800 extern int __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable,
801                                      int attribute, unsigned int *value);
802 
803 #ifdef __cplusplus
804 }
805 #endif
806 
807 #endif /* !__GLX_client_h__ */
808