glxclient.h revision 60fce15447da7d4135ace6f1433896b0a02bcfee
1cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
2dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
5dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Permission is hereby granted, free of charge, to any person obtaining a
6dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * copy of this software and associated documentation files (the "Software"),
7dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * to deal in the Software without restriction, including without limitation
8dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * and/or sell copies of the Software, and to permit persons to whom the
10dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Software is furnished to do so, subject to the following conditions:
11dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
12dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * The above copyright notice including the dates of first publication and
13dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * either this permission notice or a reference to
14dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * http://oss.sgi.com/projects/FreeB/
15dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall be included in all copies or substantial portions of the Software.
16dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
17dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SOFTWARE.
24dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
25dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Except as contained in this notice, the name of Silicon Graphics, Inc.
26dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall not be used in advertising or otherwise to promote the sale, use or
27dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * other dealings in this Software without prior written authorization from
28dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Silicon Graphics, Inc.
29dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson */
30cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
31cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/**
32cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \file glxclient.h
33cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Direct rendering support added by Precision Insight, Inc.
34cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson *
35cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \author Kevin E. Martin <kevin@precisioninsight.com>
36cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */
37cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
38cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifndef _GLX_client_h_
39cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define _GLX_client_h_
40cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include <X11/Xproto.h>
41cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include <X11/Xlibint.h>
4238c51a76533a90cf2c9381c99247cfac45fe70ebKristian Høgsberg#include <X11/Xfuncproto.h>
437a9329ba99fe1242c07fbf4fd04e7a4dbeba2e72Robert Bragg#include <X11/extensions/extutil.h>
44cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define GLX_GLXEXT_PROTOTYPES
45cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include <GL/glx.h>
46cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include <GL/glxext.h>
47cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include <string.h>
48cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include <stdlib.h>
49cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include <stdio.h>
50ad919c30df71bc191be6f107385638b456da6a0fAdam Jackson#ifdef WIN32
51ad919c30df71bc191be6f107385638b456da6a0fAdam Jackson#include <stdint.h>
52ad919c30df71bc191be6f107385638b456da6a0fAdam Jackson#endif
53cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "GL/glxproto.h"
544eb95ce807222bc31019b69156fab44aac72cfe7Brian#include "glapi/glapitable.h"
5565d98e25770487456eb3d7eb8ec3ec8272f170b1Kristian Høgsberg#include "glxconfig.h"
564a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg#include "glxhash.h"
578363dff251fc38b044447bcb173d960b03073974RALOVICH, Kristóf#if defined( PTHREADS )
5802986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick# include <pthread.h>
59cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif
60cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
61ec770150edff9a5955f52e538adc4bac94c92cadJeremy Huddleston#include "glxextensions.h"
62ec770150edff9a5955f52e538adc4bac94c92cadJeremy Huddleston
636ddf66e9230ee862ac341c4767cf6b3b2dd2552bKristian Høgsberg#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
64a25e1aa0aab6bd278eefa7c0748b491c9c6ae62cBrian Paul
650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define GLX_MAJOR_VERSION 1       /* current version numbers */
660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define GLX_MINOR_VERSION 4
67cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
68cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define __GLX_MAX_TEXTURE_UNITS 32
69cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
70c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergstruct glx_display;
71c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergstruct glx_context;
72cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
73cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/************************************************************************/
74cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
75cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef GLX_DIRECT_RENDERING
76cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
77c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern void DRI_glXUseXFont(struct glx_context *ctx,
787b7845a076c933e096ac511b4184141ba194449aKristian Høgsberg			    Font font, int first, int count, int listbase);
7980b280db883edc9550484dba03bd5c124b6a9bf9Jeremy Huddleston
8080b280db883edc9550484dba03bd5c124b6a9bf9Jeremy Huddleston#endif
81cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
8280b280db883edc9550484dba03bd5c124b6a9bf9Jeremy Huddleston#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
83cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
84cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/**
85cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Display dependent methods.  This structure is initialized during the
86cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \c driCreateDisplay call.
87cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */
88425f9ed44e576aef27f7ab98968043f7f180d0fdKristian Høgsbergtypedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
8992d2a78f8d2d56cfadb4cb5323adec32fe73e353Kristian Høgsbergtypedef struct __GLXDRIscreenRec __GLXDRIscreen;
9020b9230ce1b96ca246850a8088caeffc3f391a0cKristian Høgsbergtypedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
9192d2a78f8d2d56cfadb4cb5323adec32fe73e353Kristian Høgsberg
92e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg#include "glxextensions.h"
93e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg
940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstruct __GLXDRIdisplayRec
950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{
96cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
97cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Method to destroy the private DRI display data.
98cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   void (*destroyDisplay) (__GLXDRIdisplay * display);
100a1ea6f6198d80f716936a308cfab235f18a014e1Kristian Høgsberg
101c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   struct glx_screen *(*createScreen)(int screen, struct glx_display * priv);
10292d2a78f8d2d56cfadb4cb5323adec32fe73e353Kristian Høgsberg};
10392d2a78f8d2d56cfadb4cb5323adec32fe73e353Kristian Høgsberg
104daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnesstruct __GLXDRIscreenRec {
105daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes
10666fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian Høgsberg   void (*destroyScreen)(struct glx_screen *psc);
107daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes
108c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   struct glx_context *(*createContext)(struct glx_screen *psc,
109c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg					struct glx_config *config,
110c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg					struct glx_context *shareList,
111c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg					int renderType);
112daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes
11366fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian Høgsberg   __GLXDRIdrawable *(*createDrawable)(struct glx_screen *psc,
114daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes				       XID drawable,
115daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes				       GLXDrawable glxDrawable,
1166ddf66e9230ee862ac341c4767cf6b3b2dd2552bKristian Høgsberg				       struct glx_config *config);
117daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes
118daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes   int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc,
119daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes			  int64_t divisor, int64_t remainder);
120daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes   void (*copySubBuffer)(__GLXDRIdrawable *pdraw,
121daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes			 int x, int y, int width, int height);
12266fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian Høgsberg   int (*getDrawableMSC)(struct glx_screen *psc, __GLXDRIdrawable *pdraw,
123daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes			 int64_t *ust, int64_t *msc, int64_t *sbc);
124daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes   int (*waitForMSC)(__GLXDRIdrawable *pdraw, int64_t target_msc,
125daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes		     int64_t divisor, int64_t remainder, int64_t *ust,
126daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes		     int64_t *msc, int64_t *sbc);
127daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes   int (*waitForSBC)(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
128daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes		     int64_t *msc, int64_t *sbc);
129089fc37c6fa158824279e08e3b378ced94d6f803Kristian Høgsberg   int (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval);
130efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes   int (*getSwapInterval)(__GLXDRIdrawable *pdraw);
13120b9230ce1b96ca246850a8088caeffc3f391a0cKristian Høgsberg};
13220b9230ce1b96ca246850a8088caeffc3f391a0cKristian Høgsberg
1330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstruct __GLXDRIdrawableRec
1340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{
1350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   void (*destroyDrawable) (__GLXDRIdrawable * drawable);
1369110425c72e45f618131b559eba883fd6c5536b4Kristian Høgsberg
1370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   XID xDrawable;
1380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   XID drawable;
13966fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian Høgsberg   struct glx_screen *psc;
1400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLenum textureTarget;
1410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLenum textureFormat;        /* EXT_texture_from_pixmap support */
142f8d81c31cee30821da3aab331a57f484f6a07a5dNick Bowler   unsigned long eventMask;
143cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson};
144cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
145cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
146cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Function to create and DRI display data and initialize the display
147cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** dependent methods.
148cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
1490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern __GLXDRIdisplay *driswCreateDisplay(Display * dpy);
1500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern __GLXDRIdisplay *driCreateDisplay(Display * dpy);
1510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy);
15261d26bc82e7c4100acfb551cbb0ba9d84bbc4ba5Francisco Jerezextern void dri2InvalidateBuffers(Display *dpy, XID drawable);
15361d26bc82e7c4100acfb551cbb0ba9d84bbc4ba5Francisco Jerez
154cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
155cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
156cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Functions to obtain driver configuration information from a direct
157cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** rendering client application
158cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
1590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern const char *glXGetScreenDriver(Display * dpy, int scrNum);
160cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
1610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern const char *glXGetDriverConfig(const char *driverName);
162cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
163cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif
164cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
165cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/************************************************************************/
166cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
167cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16
168cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
1690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóftypedef struct __GLXpixelStoreModeRec
1700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{
1710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLboolean swapEndian;
1720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLboolean lsbFirst;
1730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLuint rowLength;
1740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLuint imageHeight;
1750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLuint imageDepth;
1760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLuint skipRows;
1770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLuint skipPixels;
1780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLuint skipImages;
1790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLuint alignment;
180cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} __GLXpixelStoreMode;
181cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
182cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
1830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóftypedef struct __GLXattributeRec
1840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{
1850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLuint mask;
186cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
187cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
188fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick     * Pixel storage state.  Most of the pixel store mode state is kept
189fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick     * here and used by the client code to manage the packing and
190fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick     * unpacking of data sent to/received from the server.
191cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
1920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   __GLXpixelStoreMode storePack, storeUnpack;
193cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
194cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
195fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick     * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically
196fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick     * disabled?
197cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
1980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLboolean NoDrawArraysProtocol;
1990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf
200cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
201fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick     * Vertex Array storage state.  The vertex array component
202fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick     * state is stored here and is used to manage the packing of
203fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick     * DrawArrays data sent to the server.
204cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
2050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   struct array_state_vector *array_state;
206cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} __GLXattribute;
207cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
2080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóftypedef struct __GLXattributeMachineRec
2090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{
2100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   __GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
2110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   __GLXattribute **stackPointer;
212cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} __GLXattributeMachine;
213cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
214643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsbergstruct glx_context_vtable {
215c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   void (*destroy)(struct glx_context *ctx);
216c491e585e43d48a2aeec96ccc4008da6c443fb42Kristian Høgsberg   int (*bind)(struct glx_context *context, struct glx_context *old,
217c491e585e43d48a2aeec96ccc4008da6c443fb42Kristian Høgsberg	       GLXDrawable draw, GLXDrawable read);
218c491e585e43d48a2aeec96ccc4008da6c443fb42Kristian Høgsberg   void (*unbind)(struct glx_context *context, struct glx_context *new);
219c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   void (*wait_gl)(struct glx_context *ctx);
220c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   void (*wait_x)(struct glx_context *ctx);
221c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   void (*use_x_font)(struct glx_context *ctx,
2227b7845a076c933e096ac511b4184141ba194449aKristian Høgsberg		      Font font, int first, int count, int listBase);
223643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg   void (*bind_tex_image)(Display * dpy,
224643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg			  GLXDrawable drawable,
225643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg			  int buffer, const int *attrib_list);
226643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg   void (*release_tex_image)(Display * dpy, GLXDrawable drawable, int buffer);
227643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg
228643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg};
229643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg
230c796bb0cc3fde409545bff320540ddf5c029e513Kristian Høgsbergextern void
231c796bb0cc3fde409545bff320540ddf5c029e513Kristian Høgsbergglx_send_destroy_context(Display *dpy, XID xid);
232c796bb0cc3fde409545bff320540ddf5c029e513Kristian Høgsberg
233cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/**
234cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * GLX state that needs to be kept on the client.  One of these records
235cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * exist for each context that has been made current by this client.
236cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */
237c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergstruct glx_context
2380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{
239cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
240cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * \name Drawing command buffer.
241cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     *
242cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Drawing commands are packed into this buffer before being sent as a
243cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * single GLX protocol request.  The buffer is sent when it overflows or
244cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * is flushed by \c __glXFlushRenderBuffer.  \c pc is the next location
245cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * in the buffer to be filled.  \c limit is described above in the buffer
246cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * slop discussion.
247cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     *
248cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Commands that require large amounts of data to be transfered will
249cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * also use this buffer to hold a header that describes the large
250cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * command.
251cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     *
252cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * These must be the first 6 fields since they are static initialized
253cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * in the dummy context in glxext.c
254cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
2550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@{ */
2560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLubyte *buf;
2570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLubyte *pc;
2580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLubyte *limit;
2590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLubyte *bufEnd;
2600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLint bufSize;
2610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@} */
262cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
263cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
264cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * The XID of this rendering context.  When the context is created a
265cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * new XID is allocated.  This is set to None when the context is
266cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * destroyed but is still current to some thread. In this case the
267cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * context will be freed on next MakeCurrent.
268cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
2690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   XID xid;
270cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
271cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
272cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * The XID of the \c shareList context.
273cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
2740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   XID share_xid;
275cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
276cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
277cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Screen number.
278cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
2790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLint screen;
28066fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian Høgsberg   struct glx_screen *psc;
281cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
282cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
283cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * \c GL_TRUE if the context was created with ImportContext, which
284cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * means the server-side context was created by another X client.
285cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
2860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLboolean imported;
287cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
288cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
289cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * The context tag returned by MakeCurrent when this context is made
290cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * current. This tag is used to identify the context that a thread has
291cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * current so that proper server context management can be done.  It is
292cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * used for all context specific commands (i.e., \c Render, \c RenderLarge,
293cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old
294cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * context)).
295cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
2960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLXContextTag currentContextTag;
297cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
298cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
299cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * \name Rendering mode
300cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     *
301cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * The rendering mode is kept on the client as well as the server.
302cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * When \c glRenderMode is called, the buffer associated with the
303cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * previous rendering mode (feedback or select) is filled.
304cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
3050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@{ */
3060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLenum renderMode;
3070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLfloat *feedbackBuf;
3080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLuint *selectBuf;
3090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@} */
310cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
311cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
312cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * This is \c GL_TRUE if the pixel unpack modes are such that an image
313cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * can be unpacked from the clients memory by just copying.  It may
314cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * still be true that the server will have to do some work.  This
315cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * just promises that a straight copy will fetch the correct bytes.
316cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
3170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLboolean fastImageUnpack;
318cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
319cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
320cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Fill newImage with the unpacked form of \c oldImage getting it
321cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * ready for transport to the server.
322cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
323c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   void (*fillImage) (struct glx_context *, GLint, GLint, GLint, GLint, GLenum,
3240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                      GLenum, const GLvoid *, GLubyte *, GLubyte *);
325cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
326cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
32729206ae569c4c784ec6884084b4bd8631f66b866Ian Romanick     * Client side attribs.
328cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
3290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   __GLXattributeMachine attributes;
330cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
331cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
332cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Client side error code.  This is set when client side gl API
333cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * routines need to set an error because of a bad enumerant or
334cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * running out of memory, etc.
335cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
3360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLenum error;
337cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
338cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
339ae2c31ed669abab66a8c4b68d8d746e94b9ebf28Xiang, Haihao     * Whether this context does direct rendering.
340ae2c31ed669abab66a8c4b68d8d746e94b9ebf28Xiang, Haihao     */
3410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   Bool isDirect;
342ae2c31ed669abab66a8c4b68d8d746e94b9ebf28Xiang, Haihao
343ae2c31ed669abab66a8c4b68d8d746e94b9ebf28Xiang, Haihao    /**
344cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * \c dpy of current display for this context.  Will be \c NULL if not
345cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * current to any display, or if this is the "dummy context".
346cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
3470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   Display *currentDpy;
348cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
349cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
350cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * The current drawable for this context.  Will be None if this
351cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * context is not current to any drawable.  currentReadable is below.
352cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
3530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLXDrawable currentDrawable;
354cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
355cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
356cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * \name GL Constant Strings
357cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     *
358cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Constant strings that describe the server implementation
359cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * These pertain to GL attributes, not to be confused with
360cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * GLX versioning attributes.
361cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
3620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@{ */
3630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLubyte *vendor;
3640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLubyte *renderer;
3650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLubyte *version;
3660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLubyte *extensions;
3670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@} */
368cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
369cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
370cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Maximum small render command size.  This is the smaller of 64k and
371cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * the size of the above buffer.
372cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
3730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLint maxSmallRenderCommandSize;
374cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
375cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
376cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Major opcode for the extension.  Copied here so a lookup isn't
377cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * needed.
378cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
3790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLint majorOpcode;
380cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
381cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
3826ddf66e9230ee862ac341c4767cf6b3b2dd2552bKristian Høgsberg     * Pointer to the config used to create this context.
383cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
3846ddf66e9230ee862ac341c4767cf6b3b2dd2552bKristian Høgsberg   struct glx_config *config;
3854a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg
386cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
387cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * The current read-drawable for this context.  Will be None if this
388cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * context is not current to any drawable.
389cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     *
390cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * \since Internal API version 20030606.
391cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
3920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLXDrawable currentReadable;
393cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
3940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /**
395cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    * Pointer to client-state data that is private to libGL.  This is only
396cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    * used for indirect rendering contexts.
397cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    *
398cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    * No internal API version change was made for this change.  Client-side
399cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    * drivers should NEVER use this data or even care that it exists.
400cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    */
4010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   void *client_state_private;
402fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick
403cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson   /**
404cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE.
405cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    */
406cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson   int renderType;
4070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf
408cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson   /**
409cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    * \name Raw server GL version
410cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    *
411cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    * True core GL version supported by the server.  This is the raw value
412cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    * returned by the server, and it may not reflect what is actually
413cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    * supported (or reported) by the client-side library.
414cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    */
4150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@{ */
416cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson   int server_major;        /**< Major version number. */
417cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson   int server_minor;        /**< Minor version number. */
4180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@} */
419fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick
42096fd3df59a161957876bfd7a49992e5a2130370cThomas Hellstrom   /**
42196fd3df59a161957876bfd7a49992e5a2130370cThomas Hellstrom    * Thread ID we're currently current in. Zero if none.
42296fd3df59a161957876bfd7a49992e5a2130370cThomas Hellstrom    */
42396fd3df59a161957876bfd7a49992e5a2130370cThomas Hellstrom   unsigned long thread_id;
42496fd3df59a161957876bfd7a49992e5a2130370cThomas Hellstrom
4250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   char gl_extension_bits[__GL_EXT_BYTES];
426643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg
427643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg   const struct glx_context_vtable *vtable;
428cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson};
429cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
43031819830b66a49f1b62e09090cc65aefc657aeb8Kristian Høgsbergextern Bool
431c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergglx_context_init(struct glx_context *gc,
43266fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian Høgsberg		 struct glx_screen *psc, struct glx_config *fbconfig);
43331819830b66a49f1b62e09090cc65aefc657aeb8Kristian Høgsberg
4340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define __glXSetError(gc,code)  \
4350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   if (!(gc)->error) {          \
4360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      (gc)->error = code;       \
4370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   }
438cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
439c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern void __glFreeAttributeState(struct glx_context *);
440cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
441cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/************************************************************************/
442cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
443cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/**
444cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * The size of the largest drawing command known to the implementation
445cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * that will use the GLXRender GLX command.  In this case it is
446cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \c glPolygonStipple.
447cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */
4480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156
449cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
450cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/**
451cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * To keep the implementation fast, the code uses a "limit" pointer
452cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * to determine when the drawing command buffer is too full to hold
453cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * another fixed size command.  This constant defines the amount of
454cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * space that must always be available in the drawing command buffer
455cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * at all times for the implementation to work.  It is important that
456cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * the number be just large enough, but not so large as to reduce the
457cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * efficacy of the buffer.  The "+32" is just to keep the code working
458cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * in case somebody counts wrong.
459cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */
4600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32)
461cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
462cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/**
463cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * This implementation uses a smaller threshold for switching
464cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * to the RenderLarge protocol than the protcol requires so that
465cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * large copies don't occur.
466cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */
4670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define __GLX_RENDER_CMD_SIZE_LIMIT 4096
468cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
469cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/**
470cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * One of these records exists per screen of the display.  It contains
471cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * a pointer to the config data for that screen (if the screen supports GL).
472cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */
4736ec39db726beead21d97bf64ddbe1f0b2d2d6ca1Kristian Høgsbergstruct glx_screen_vtable {
474c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   struct glx_context *(*create_context)(struct glx_screen *psc,
475c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg					 struct glx_config *config,
476c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg					 struct glx_context *shareList,
477c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg					 int renderType);
4786ec39db726beead21d97bf64ddbe1f0b2d2d6ca1Kristian Høgsberg};
4796ec39db726beead21d97bf64ddbe1f0b2d2d6ca1Kristian Høgsberg
48066fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian Høgsbergstruct glx_screen
4810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{
4826ec39db726beead21d97bf64ddbe1f0b2d2d6ca1Kristian Høgsberg   const struct glx_screen_vtable *vtable;
4836ec39db726beead21d97bf64ddbe1f0b2d2d6ca1Kristian Høgsberg
484cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
485cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * GLX extension string reported by the X-server.
486cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
4870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   const char *serverGLXexts;
488cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
489cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
490cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * GLX extension string to be reported to applications.  This is the
491cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * set of extensions that the application can actually use.
492cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
4930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   char *effectiveGLXexts;
494cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
495c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   struct glx_display *display;
496037755122e9011c768e5caa4d4cb83aba783d3e9Kristian Høgsberg
49760fce15447da7d4135ace6f1433896b0a02bcfeeKristian Høgsberg   Display *dpy;
49860fce15447da7d4135ace6f1433896b0a02bcfeeKristian Høgsberg   int scr;
49960fce15447da7d4135ace6f1433896b0a02bcfeeKristian Høgsberg
50080b280db883edc9550484dba03bd5c124b6a9bf9Jeremy Huddleston#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
501cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
502cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Per screen direct rendering interface functions and data.
503cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
5040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   __GLXDRIscreen *driScreen;
505cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif
506cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
507cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
5086c533ea2d1953152f7d95d6c984e0d287edb46c2Kristian Høgsberg     * Linked list of glx visuals and  fbconfigs for this screen.
509cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
5106ddf66e9230ee862ac341c4767cf6b3b2dd2552bKristian Høgsberg   struct glx_config *visuals, *configs;
511c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick
512cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
513cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Per-screen dynamic GLX extension tracking.  The \c direct_support
514cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * field only contains enough bits for 64 extensions.  Should libGL
515cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * ever need to track more than 64 GLX extensions, we can safely grow
51666fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian Høgsberg     * this field.  The \c struct glx_screen structure is not used outside
517cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * libGL.
518cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
5190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@{ */
5200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   unsigned char direct_support[8];
5210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLboolean ext_list_first_time;
5220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@} */
523cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
524aceccda56b08338e217991e54607f1c9f18fc3e6Kristian Høgsberg};
525cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
526cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/**
527cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Per display private data.  One of these records exists for each display
528cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * that is using the OpenGL (GLX) extension.
529cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */
530c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergstruct glx_display
5310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{
532ab434f6b7641a64d30725a9ac24929240362d466Kristian Høgsberg   /* The extension protocol codes */
533ab434f6b7641a64d30725a9ac24929240362d466Kristian Høgsberg   XExtCodes *codes;
534c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   struct glx_display *next;
535ab434f6b7641a64d30725a9ac24929240362d466Kristian Høgsberg
536cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
537cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Back pointer to the display
538cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
5390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   Display *dpy;
540cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
541cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
542cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * The \c majorOpcode is common to all connections to the same server.
543cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * It is also copied into the context structure.
544cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
5450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   int majorOpcode;
546cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
547cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
548cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * \name Server Version
549cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     *
550cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Major and minor version returned by the server during initialization.
551cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
5520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@{ */
5530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   int majorVersion, minorVersion;
5540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@} */
555cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
556cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
557cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * \name Storage for the servers GLX vendor and versions strings.
5580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf     *
559cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * These are the same for all screens on this display. These fields will
560cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * be filled in on demand.
561cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
5620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@{ */
5630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   const char *serverGLXvendor;
5640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   const char *serverGLXversion;
5650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   /*@} */
566cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
567cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
568cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Configurations of visuals for all screens on this display.
569cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Also, per screen data which now includes the server \c GLX_EXTENSION
570cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * string.
571cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
57266fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian Høgsberg   struct glx_screen **screens;
573cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
57480b280db883edc9550484dba03bd5c124b6a9bf9Jeremy Huddleston#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
575e3e8196c025bd344a59b4671e473c395a6ea426bKristian Høgsberg   __glxHashTable *drawHash;
576e3e8196c025bd344a59b4671e473c395a6ea426bKristian Høgsberg
577cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    /**
578cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     * Per display direct rendering interface functions and data.
579cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson     */
5800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   __GLXDRIdisplay *driswDisplay;
5810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   __GLXDRIdisplay *driDisplay;
5820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   __GLXDRIdisplay *dri2Display;
583cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif
584cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson};
585cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
586f972115d33e391499e049b83a1559959f2ca9f72Kristian Høgsbergextern int
58766fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian Høgsbergglx_screen_init(struct glx_screen *psc,
588c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg		int screen, struct glx_display * priv);
589f972115d33e391499e049b83a1559959f2ca9f72Kristian Høgsberg
590c1cbdbfde0a1f016f9d3f23a39cb7bc0b9825e12Kristian Høgsberg#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
5913750ebd540510324ef5ada769537ae05309adadbKristian Høgsbergextern __GLXDRIdrawable *
5923750ebd540510324ef5ada769537ae05309adadbKristian Høgsbergdri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id);
593c1cbdbfde0a1f016f9d3f23a39cb7bc0b9825e12Kristian Høgsberg#endif
594aceccda56b08338e217991e54607f1c9f18fc3e6Kristian Høgsberg
595c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern GLubyte *__glXFlushRenderBuffer(struct glx_context *, GLubyte *);
596cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
597c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern void __glXSendLargeChunk(struct glx_context * gc, GLint requestNumber,
5980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                GLint totalRequests,
5990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                const GLvoid * data, GLint dataLen);
600cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
601c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern void __glXSendLargeCommand(struct glx_context *, const GLvoid *, GLint,
6020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                  const GLvoid *, GLint);
603cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
604cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Initialize the GLX extension for dpy */
605c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern struct glx_display *__glXInitialize(Display *);
606cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
607df2c9424d3b625d6e97528c74051257bc5630a67Brian Paulextern void __glXPreferEGL(int state);
608df2c9424d3b625d6e97528c74051257bc5630a67Brian Paul
609cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/************************************************************************/
610cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
611cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonextern int __glXDebug;
612cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
613cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* This is per-thread storage in an MT environment */
6148363dff251fc38b044447bcb173d960b03073974RALOVICH, Kristóf#if defined( PTHREADS )
61502986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick
616c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern void __glXSetCurrentContext(struct glx_context * c);
61702986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick
61802986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick# if defined( GLX_USE_TLS )
61902986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick
6200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern __thread void *__glX_tls_Context
6210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   __attribute__ ((tls_model("initial-exec")));
62202986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick
6230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#  define __glXGetCurrentContext() __glX_tls_Context
62402986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick
62502986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick# else
62602986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick
627c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern struct glx_context *__glXGetCurrentContext(void);
62802986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick
62902986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick# endif /* defined( GLX_USE_TLS ) */
63002986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick
631cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else
63202986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick
633c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern struct glx_context *__glXcurrentContext;
6340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define __glXGetCurrentContext() __glXcurrentContext
6350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define __glXSetCurrentContext(gc) __glXcurrentContext = gc
63602986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick
6378363dff251fc38b044447bcb173d960b03073974RALOVICH, Kristóf#endif /* defined( PTHREADS ) */
638cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
639df04ffbf025994abd59e26c8439e77bb340ef20bGeorge Sapountzisextern void __glXSetCurrentContextNull(void);
640df04ffbf025994abd59e26c8439e77bb340ef20bGeorge Sapountzis
641cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
642cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
643cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Global lock for all threads in this address space using the GLX
644cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** extension
645cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
6468363dff251fc38b044447bcb173d960b03073974RALOVICH, Kristóf#if defined( PTHREADS )
64702986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanickextern pthread_mutex_t __glXmutex;
64802986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick#define __glXLock()    pthread_mutex_lock(&__glXmutex)
64902986cb2cc1b1d47b26a653e9ae0fa508365f616Ian Romanick#define __glXUnlock()  pthread_mutex_unlock(&__glXmutex)
650cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else
651cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define __glXLock()
652cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define __glXUnlock()
653cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif
654cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
655cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
656cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Setup for a command.  Initialize the extension for dpy if necessary.
657cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
6580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern CARD8 __glXSetupForCommand(Display * dpy);
659cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
660cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/************************************************************************/
661cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
662cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
663cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Data conversion and packing support.
664cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
665cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
6665f1f229f8da255ca9b390da1757ad781978cf619Ian Romanickextern const GLuint __glXDefaultPixelStore[9];
6675f1f229f8da255ca9b390da1757ad781978cf619Ian Romanick
6685f1f229f8da255ca9b390da1757ad781978cf619Ian Romanick/* Send an image to the server using RenderLarge. */
669c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern void __glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim,
6700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                GLint width, GLint height, GLint depth,
6710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                GLenum format, GLenum type,
6720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                const GLvoid * src, GLubyte * pc,
6730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                GLubyte * modes);
6745f1f229f8da255ca9b390da1757ad781978cf619Ian Romanick
675cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Return the size, in bytes, of some pixel data */
6765f1f229f8da255ca9b390da1757ad781978cf619Ian Romanickextern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum);
677cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
678cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Return the number of elements per group of a specified format*/
679cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonextern GLint __glElementsPerGroup(GLenum format, GLenum type);
680cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
681cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Return the number of bytes per element, based on the element type (other
682cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** than GL_BITMAP).
683cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
684cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonextern GLint __glBytesPerElement(GLenum type);
685cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
686cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
687cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Fill the transport buffer with the data from the users buffer,
688cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** applying some of the pixel store modes (unpack modes) to the data
689cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** first.  As a side effect of this call, the "modes" field is
690cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** updated to contain the modes needed by the server to decode the
691cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** sent data.
692cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
693c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern void __glFillImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum,
6940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                          GLenum, const GLvoid *, GLubyte *, GLubyte *);
695cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
696cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Copy map data with a stride into a packed buffer */
697cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonextern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *);
698cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonextern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *);
699cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonextern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint,
7000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                          const GLfloat *, GLfloat *);
701cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonextern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint,
7020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                          const GLdouble *, GLdouble *);
703cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
704cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
705cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Empty an image out of the reply buffer into the clients memory applying
706cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** the pack modes to pack back into the clients requested format.
707cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
708c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern void __glEmptyImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum,
7090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                           GLenum, const GLubyte *, GLvoid *);
710cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
711cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
712cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
713e2060348630b59a446bac7f734fdde40033093abKristof Ralovich** Allocate and Initialize Vertex Array client state, and free.
714cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
715c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern void __glXInitVertexArrayState(struct glx_context *);
716c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergextern void __glXFreeVertexArrayState(struct glx_context *);
717cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
718cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
719cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Inform the Server of the major and minor numbers and of the client
720cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** libraries extension string.
721cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
7220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern void __glXClientInfo(Display * dpy, int opcode);
723cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
724cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/************************************************************************/
725cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
726cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
727cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Declarations that should be in Xlib
728cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
729cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef __GL_USE_OUR_PROTOTYPES
7300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern void _XFlush(Display *);
7310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern Status _XReply(Display *, xReply *, int, Bool);
7320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern void _XRead(Display *, void *, long);
7330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern void _XSend(Display *, const void *, long);
734cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif
735cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
736cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
7376ddf66e9230ee862ac341c4767cf6b3b2dd2552bKristian Høgsbergextern void __glXInitializeVisualConfigFromTags(struct glx_config * config,
7380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                                int count, const INT32 * bp,
7390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                                Bool tagged_only,
7400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                                Bool fbconfig_style_tags);
741cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
7420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern char *__glXQueryServerString(Display * dpy, int opcode,
7430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                    CARD32 screen, CARD32 name);
7440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern char *__glXGetString(Display * dpy, int opcode,
7450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                            CARD32 screen, CARD32 name);
7465444424562781a0a40559db40dfe9b97286dc9daRALOVICH, Kristóf
747cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonextern char *__glXstrdup(const char *str);
748cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
749cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
750cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonextern const char __glXGLClientVersion[];
751cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonextern const char __glXGLClientExtensions[];
752cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
753cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Get the unadjusted system time */
7540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófextern int __glXGetUST(int64_t * ust);
755cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
756286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsbergextern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
7570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                    int32_t * numerator,
7580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                    int32_t * denominator);
759fc5b57b71375ef6c117482be036b442c2cb8ab23Ian Romanick
76080b280db883edc9550484dba03bd5c124b6a9bf9Jeremy Huddleston#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
7617a66e549583a3168f05acc7df1e872d218fd670dKristian Høgsbergextern GLboolean
7627a66e549583a3168f05acc7df1e872d218fd670dKristian Høgsberg__glxGetMscRate(__GLXDRIdrawable *glxDraw,
7637a66e549583a3168f05acc7df1e872d218fd670dKristian Høgsberg		int32_t * numerator, int32_t * denominator);
7647a9329ba99fe1242c07fbf4fd04e7a4dbeba2e72Robert Bragg
7657a9329ba99fe1242c07fbf4fd04e7a4dbeba2e72Robert Bragg/* So that dri2.c:DRI2WireToEvent() can access
7667a9329ba99fe1242c07fbf4fd04e7a4dbeba2e72Robert Bragg * glx_info->codes->first_event */
7677a9329ba99fe1242c07fbf4fd04e7a4dbeba2e72Robert BraggXExtDisplayInfo *__glXFindDisplay (Display *dpy);
76897ec6076f596a3820a9b7c4b7eae18bd98c6676bKristian Høgsberg
769c796bb0cc3fde409545bff320540ddf5c029e513Kristian Høgsbergextern void
77066fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian HøgsbergGarbageCollectDRIDrawables(struct glx_screen *psc);
771c796bb0cc3fde409545bff320540ddf5c029e513Kristian Høgsberg
77297ec6076f596a3820a9b7c4b7eae18bd98c6676bKristian Høgsbergextern __GLXDRIdrawable *
773eeaab2047cfce8a7445fd9f835e737682eb503acKristian HøgsbergGetGLXDRIDrawable(Display *dpy, GLXDrawable drawable);
77497ec6076f596a3820a9b7c4b7eae18bd98c6676bKristian Høgsberg
775286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg#endif
776286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg
777f485ee724d1f1bb57a5c8931f28e7a45ceb5b5d5Kristian Høgsbergextern struct glx_context dummyContext;
778f485ee724d1f1bb57a5c8931f28e7a45ceb5b5d5Kristian Høgsberg
77966fc35cde9ed68a09920ad6a28de794dd1d3aa8cKristian Høgsbergextern struct glx_screen *
780c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergindirect_create_screen(int screen, struct glx_display * priv);
7816849916170c0275c13510251a7b217c20f2b993eKristian Høgsbergextern struct glx_context *
7826849916170c0275c13510251a7b217c20f2b993eKristian Høgsbergindirect_create_context(struct glx_screen *psc,
7836849916170c0275c13510251a7b217c20f2b993eKristian Høgsberg			struct glx_config *mode,
7846849916170c0275c13510251a7b217c20f2b993eKristian Høgsberg			struct glx_context *shareList, int renderType);
7856ec39db726beead21d97bf64ddbe1f0b2d2d6ca1Kristian Høgsberg
786cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif /* !__GLX_client_h__ */
787