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