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