glxclient.h revision d8407755
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#include <stdint.h> 5101e04c3fSmrg#include <pthread.h> 52cdc920a0Smrg#include "GL/glxproto.h" 533464ebd5Sriastradh#include "glxconfig.h" 54cdc920a0Smrg#include "glxhash.h" 5501e04c3fSmrg#include "util/macros.h" 56cdc920a0Smrg 57cdc920a0Smrg#include "glxextensions.h" 58cdc920a0Smrg 5901e04c3fSmrg#if defined(USE_LIBGLVND) 6001e04c3fSmrg#define _GLX_PUBLIC _X_HIDDEN 6101e04c3fSmrg#else 6201e04c3fSmrg#define _GLX_PUBLIC _X_EXPORT 6301e04c3fSmrg#endif 6401e04c3fSmrg 6501e04c3fSmrg#ifdef __cplusplus 6601e04c3fSmrgextern "C" { 6701e04c3fSmrg#endif 6801e04c3fSmrg 69cdc920a0Smrg 70cdc920a0Smrg#define GLX_MAJOR_VERSION 1 /* current version numbers */ 71cdc920a0Smrg#define GLX_MINOR_VERSION 4 72cdc920a0Smrg 73cdc920a0Smrg#define __GLX_MAX_TEXTURE_UNITS 32 74cdc920a0Smrg 753464ebd5Sriastradhstruct glx_display; 763464ebd5Sriastradhstruct glx_context; 77cdc920a0Smrg 78cdc920a0Smrg/************************************************************************/ 79cdc920a0Smrg 80cdc920a0Smrg#ifdef GLX_DIRECT_RENDERING 81cdc920a0Smrg 823464ebd5Sriastradhextern void DRI_glXUseXFont(struct glx_context *ctx, 833464ebd5Sriastradh Font font, int first, int count, int listbase); 84cdc920a0Smrg 85cdc920a0Smrg#endif 86cdc920a0Smrg 87cdc920a0Smrg#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) 88cdc920a0Smrg 89cdc920a0Smrg/** 90cdc920a0Smrg * Display dependent methods. This structure is initialized during the 91cdc920a0Smrg * \c driCreateDisplay call. 92cdc920a0Smrg */ 93cdc920a0Smrgtypedef struct __GLXDRIdisplayRec __GLXDRIdisplay; 94cdc920a0Smrgtypedef struct __GLXDRIscreenRec __GLXDRIscreen; 95cdc920a0Smrgtypedef struct __GLXDRIdrawableRec __GLXDRIdrawable; 96cdc920a0Smrg 97cdc920a0Smrgstruct __GLXDRIdisplayRec 98cdc920a0Smrg{ 99cdc920a0Smrg /** 100cdc920a0Smrg * Method to destroy the private DRI display data. 101cdc920a0Smrg */ 102cdc920a0Smrg void (*destroyDisplay) (__GLXDRIdisplay * display); 103cdc920a0Smrg 1043464ebd5Sriastradh struct glx_screen *(*createScreen)(int screen, struct glx_display * priv); 105cdc920a0Smrg}; 106cdc920a0Smrg 107cdc920a0Smrgstruct __GLXDRIscreenRec { 108cdc920a0Smrg 1093464ebd5Sriastradh void (*destroyScreen)(struct glx_screen *psc); 110cdc920a0Smrg 1113464ebd5Sriastradh struct glx_context *(*createContext)(struct glx_screen *psc, 1123464ebd5Sriastradh struct glx_config *config, 1133464ebd5Sriastradh struct glx_context *shareList, 1143464ebd5Sriastradh int renderType); 115cdc920a0Smrg 1163464ebd5Sriastradh __GLXDRIdrawable *(*createDrawable)(struct glx_screen *psc, 117cdc920a0Smrg XID drawable, 118cdc920a0Smrg GLXDrawable glxDrawable, 1193464ebd5Sriastradh struct glx_config *config); 120cdc920a0Smrg 121cdc920a0Smrg int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc, 122af69d88dSmrg int64_t divisor, int64_t remainder, Bool flush); 123cdc920a0Smrg void (*copySubBuffer)(__GLXDRIdrawable *pdraw, 124af69d88dSmrg int x, int y, int width, int height, Bool flush); 1253464ebd5Sriastradh int (*getDrawableMSC)(struct glx_screen *psc, __GLXDRIdrawable *pdraw, 126cdc920a0Smrg int64_t *ust, int64_t *msc, int64_t *sbc); 127cdc920a0Smrg int (*waitForMSC)(__GLXDRIdrawable *pdraw, int64_t target_msc, 128cdc920a0Smrg int64_t divisor, int64_t remainder, int64_t *ust, 129cdc920a0Smrg int64_t *msc, int64_t *sbc); 130cdc920a0Smrg int (*waitForSBC)(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust, 131cdc920a0Smrg int64_t *msc, int64_t *sbc); 1323464ebd5Sriastradh int (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval); 133cdc920a0Smrg int (*getSwapInterval)(__GLXDRIdrawable *pdraw); 134af69d88dSmrg int (*getBufferAge)(__GLXDRIdrawable *pdraw); 135cdc920a0Smrg}; 136cdc920a0Smrg 137cdc920a0Smrgstruct __GLXDRIdrawableRec 138cdc920a0Smrg{ 139cdc920a0Smrg void (*destroyDrawable) (__GLXDRIdrawable * drawable); 140cdc920a0Smrg 141cdc920a0Smrg XID xDrawable; 142cdc920a0Smrg XID drawable; 1433464ebd5Sriastradh struct glx_screen *psc; 144cdc920a0Smrg GLenum textureTarget; 145cdc920a0Smrg GLenum textureFormat; /* EXT_texture_from_pixmap support */ 1463464ebd5Sriastradh unsigned long eventMask; 1473464ebd5Sriastradh int refcount; 148cdc920a0Smrg}; 149cdc920a0Smrg 150cdc920a0Smrg/* 151cdc920a0Smrg** Function to create and DRI display data and initialize the display 152cdc920a0Smrg** dependent methods. 153cdc920a0Smrg*/ 154cdc920a0Smrgextern __GLXDRIdisplay *driswCreateDisplay(Display * dpy); 155cdc920a0Smrgextern __GLXDRIdisplay *driCreateDisplay(Display * dpy); 156cdc920a0Smrgextern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy); 15701e04c3fSmrgextern __GLXDRIdisplay *dri3_create_display(Display * dpy); 15801e04c3fSmrgextern __GLXDRIdisplay *driwindowsCreateDisplay(Display * dpy); 15901e04c3fSmrg 16001e04c3fSmrg/* 16101e04c3fSmrg** 16201e04c3fSmrg*/ 163cdc920a0Smrgextern void dri2InvalidateBuffers(Display *dpy, XID drawable); 1643464ebd5Sriastradhextern unsigned dri2GetSwapEventType(Display *dpy, XID drawable); 165cdc920a0Smrg 166cdc920a0Smrg/* 167cdc920a0Smrg** Functions to obtain driver configuration information from a direct 168cdc920a0Smrg** rendering client application 169cdc920a0Smrg*/ 170cdc920a0Smrgextern const char *glXGetScreenDriver(Display * dpy, int scrNum); 171cdc920a0Smrg 172cdc920a0Smrgextern const char *glXGetDriverConfig(const char *driverName); 173cdc920a0Smrg 174cdc920a0Smrg#endif 175cdc920a0Smrg 176cdc920a0Smrg/************************************************************************/ 177cdc920a0Smrg 178cdc920a0Smrg#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16 179cdc920a0Smrg 180cdc920a0Smrgtypedef struct __GLXpixelStoreModeRec 181cdc920a0Smrg{ 182cdc920a0Smrg GLboolean swapEndian; 183cdc920a0Smrg GLboolean lsbFirst; 184cdc920a0Smrg GLuint rowLength; 185cdc920a0Smrg GLuint imageHeight; 186cdc920a0Smrg GLuint imageDepth; 187cdc920a0Smrg GLuint skipRows; 188cdc920a0Smrg GLuint skipPixels; 189cdc920a0Smrg GLuint skipImages; 190cdc920a0Smrg GLuint alignment; 191cdc920a0Smrg} __GLXpixelStoreMode; 192cdc920a0Smrg 193cdc920a0Smrg 194cdc920a0Smrgtypedef struct __GLXattributeRec 195cdc920a0Smrg{ 196cdc920a0Smrg GLuint mask; 197cdc920a0Smrg 198cdc920a0Smrg /** 199cdc920a0Smrg * Pixel storage state. Most of the pixel store mode state is kept 200cdc920a0Smrg * here and used by the client code to manage the packing and 201cdc920a0Smrg * unpacking of data sent to/received from the server. 202cdc920a0Smrg */ 203cdc920a0Smrg __GLXpixelStoreMode storePack, storeUnpack; 204cdc920a0Smrg 205cdc920a0Smrg /** 206cdc920a0Smrg * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically 207cdc920a0Smrg * disabled? 208cdc920a0Smrg */ 209cdc920a0Smrg GLboolean NoDrawArraysProtocol; 210cdc920a0Smrg 211cdc920a0Smrg /** 212cdc920a0Smrg * Vertex Array storage state. The vertex array component 213cdc920a0Smrg * state is stored here and is used to manage the packing of 214cdc920a0Smrg * DrawArrays data sent to the server. 215cdc920a0Smrg */ 216cdc920a0Smrg struct array_state_vector *array_state; 217cdc920a0Smrg} __GLXattribute; 218cdc920a0Smrg 219cdc920a0Smrgtypedef struct __GLXattributeMachineRec 220cdc920a0Smrg{ 221cdc920a0Smrg __GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; 222cdc920a0Smrg __GLXattribute **stackPointer; 223cdc920a0Smrg} __GLXattributeMachine; 224cdc920a0Smrg 22501e04c3fSmrgstruct mesa_glinterop_device_info; 22601e04c3fSmrgstruct mesa_glinterop_export_in; 22701e04c3fSmrgstruct mesa_glinterop_export_out; 22801e04c3fSmrg 2293464ebd5Sriastradhstruct glx_context_vtable { 2303464ebd5Sriastradh void (*destroy)(struct glx_context *ctx); 2313464ebd5Sriastradh int (*bind)(struct glx_context *context, struct glx_context *old, 2323464ebd5Sriastradh GLXDrawable draw, GLXDrawable read); 233af69d88dSmrg void (*unbind)(struct glx_context *context, struct glx_context *new_ctx); 2343464ebd5Sriastradh void (*wait_gl)(struct glx_context *ctx); 2353464ebd5Sriastradh void (*wait_x)(struct glx_context *ctx); 2363464ebd5Sriastradh void (*use_x_font)(struct glx_context *ctx, 2373464ebd5Sriastradh Font font, int first, int count, int listBase); 2383464ebd5Sriastradh void (*bind_tex_image)(Display * dpy, 2393464ebd5Sriastradh GLXDrawable drawable, 2403464ebd5Sriastradh int buffer, const int *attrib_list); 2413464ebd5Sriastradh void (*release_tex_image)(Display * dpy, GLXDrawable drawable, int buffer); 2423464ebd5Sriastradh void * (*get_proc_address)(const char *symbol); 24301e04c3fSmrg int (*interop_query_device_info)(struct glx_context *ctx, 24401e04c3fSmrg struct mesa_glinterop_device_info *out); 24501e04c3fSmrg int (*interop_export_object)(struct glx_context *ctx, 24601e04c3fSmrg struct mesa_glinterop_export_in *in, 24701e04c3fSmrg struct mesa_glinterop_export_out *out); 2483464ebd5Sriastradh}; 2493464ebd5Sriastradh 250cdc920a0Smrg/** 251cdc920a0Smrg * GLX state that needs to be kept on the client. One of these records 252cdc920a0Smrg * exist for each context that has been made current by this client. 253cdc920a0Smrg */ 2543464ebd5Sriastradhstruct glx_context 255cdc920a0Smrg{ 256cdc920a0Smrg /** 257cdc920a0Smrg * \name Drawing command buffer. 258cdc920a0Smrg * 259cdc920a0Smrg * Drawing commands are packed into this buffer before being sent as a 260cdc920a0Smrg * single GLX protocol request. The buffer is sent when it overflows or 261cdc920a0Smrg * is flushed by \c __glXFlushRenderBuffer. \c pc is the next location 262cdc920a0Smrg * in the buffer to be filled. \c limit is described above in the buffer 263cdc920a0Smrg * slop discussion. 264cdc920a0Smrg * 265cdc920a0Smrg * Commands that require large amounts of data to be transfered will 266cdc920a0Smrg * also use this buffer to hold a header that describes the large 267cdc920a0Smrg * command. 268cdc920a0Smrg * 269cdc920a0Smrg * These must be the first 6 fields since they are static initialized 270cdc920a0Smrg * in the dummy context in glxext.c 271cdc920a0Smrg */ 272cdc920a0Smrg /*@{ */ 273cdc920a0Smrg GLubyte *buf; 274cdc920a0Smrg GLubyte *pc; 275cdc920a0Smrg GLubyte *limit; 276cdc920a0Smrg GLubyte *bufEnd; 277cdc920a0Smrg GLint bufSize; 278cdc920a0Smrg /*@} */ 279cdc920a0Smrg 2803464ebd5Sriastradh const struct glx_context_vtable *vtable; 2813464ebd5Sriastradh 282cdc920a0Smrg /** 283cdc920a0Smrg * The XID of this rendering context. When the context is created a 284cdc920a0Smrg * new XID is allocated. This is set to None when the context is 285cdc920a0Smrg * destroyed but is still current to some thread. In this case the 286cdc920a0Smrg * context will be freed on next MakeCurrent. 287cdc920a0Smrg */ 288cdc920a0Smrg XID xid; 289cdc920a0Smrg 290cdc920a0Smrg /** 291cdc920a0Smrg * The XID of the \c shareList context. 292cdc920a0Smrg */ 293cdc920a0Smrg XID share_xid; 294cdc920a0Smrg 295cdc920a0Smrg /** 296cdc920a0Smrg * Screen number. 297cdc920a0Smrg */ 298cdc920a0Smrg GLint screen; 2993464ebd5Sriastradh struct glx_screen *psc; 300cdc920a0Smrg 301cdc920a0Smrg /** 302cdc920a0Smrg * \c GL_TRUE if the context was created with ImportContext, which 303cdc920a0Smrg * means the server-side context was created by another X client. 304cdc920a0Smrg */ 305cdc920a0Smrg GLboolean imported; 306cdc920a0Smrg 307cdc920a0Smrg /** 308cdc920a0Smrg * The context tag returned by MakeCurrent when this context is made 309cdc920a0Smrg * current. This tag is used to identify the context that a thread has 310cdc920a0Smrg * current so that proper server context management can be done. It is 311cdc920a0Smrg * used for all context specific commands (i.e., \c Render, \c RenderLarge, 312cdc920a0Smrg * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old 313cdc920a0Smrg * context)). 314cdc920a0Smrg */ 315cdc920a0Smrg GLXContextTag currentContextTag; 316cdc920a0Smrg 317cdc920a0Smrg /** 318cdc920a0Smrg * \name Rendering mode 319cdc920a0Smrg * 320cdc920a0Smrg * The rendering mode is kept on the client as well as the server. 321cdc920a0Smrg * When \c glRenderMode is called, the buffer associated with the 322cdc920a0Smrg * previous rendering mode (feedback or select) is filled. 323cdc920a0Smrg */ 324cdc920a0Smrg /*@{ */ 325cdc920a0Smrg GLenum renderMode; 326cdc920a0Smrg GLfloat *feedbackBuf; 327cdc920a0Smrg GLuint *selectBuf; 328cdc920a0Smrg /*@} */ 329cdc920a0Smrg 330cdc920a0Smrg /** 331cdc920a0Smrg * Fill newImage with the unpacked form of \c oldImage getting it 332cdc920a0Smrg * ready for transport to the server. 333cdc920a0Smrg */ 3343464ebd5Sriastradh void (*fillImage) (struct glx_context *, GLint, GLint, GLint, GLint, GLenum, 335cdc920a0Smrg GLenum, const GLvoid *, GLubyte *, GLubyte *); 336cdc920a0Smrg 337cdc920a0Smrg /** 338cdc920a0Smrg * Client side attribs. 339cdc920a0Smrg */ 340cdc920a0Smrg __GLXattributeMachine attributes; 341cdc920a0Smrg 342cdc920a0Smrg /** 343cdc920a0Smrg * Client side error code. This is set when client side gl API 344cdc920a0Smrg * routines need to set an error because of a bad enumerant or 345cdc920a0Smrg * running out of memory, etc. 346cdc920a0Smrg */ 347cdc920a0Smrg GLenum error; 348cdc920a0Smrg 349cdc920a0Smrg /** 350cdc920a0Smrg * Whether this context does direct rendering. 351cdc920a0Smrg */ 352cdc920a0Smrg Bool isDirect; 353cdc920a0Smrg 3543464ebd5Sriastradh#if defined(GLX_DIRECT_RENDERING) && defined(GLX_USE_APPLEGL) 3553464ebd5Sriastradh void *driContext; 3563464ebd5Sriastradh#endif 3573464ebd5Sriastradh 358cdc920a0Smrg /** 359cdc920a0Smrg * \c dpy of current display for this context. Will be \c NULL if not 360cdc920a0Smrg * current to any display, or if this is the "dummy context". 361cdc920a0Smrg */ 362cdc920a0Smrg Display *currentDpy; 363cdc920a0Smrg 364cdc920a0Smrg /** 365cdc920a0Smrg * The current drawable for this context. Will be None if this 366cdc920a0Smrg * context is not current to any drawable. currentReadable is below. 367cdc920a0Smrg */ 368cdc920a0Smrg GLXDrawable currentDrawable; 369cdc920a0Smrg 370cdc920a0Smrg /** 371cdc920a0Smrg * \name GL Constant Strings 372cdc920a0Smrg * 373cdc920a0Smrg * Constant strings that describe the server implementation 374cdc920a0Smrg * These pertain to GL attributes, not to be confused with 375cdc920a0Smrg * GLX versioning attributes. 376cdc920a0Smrg */ 377cdc920a0Smrg /*@{ */ 378cdc920a0Smrg GLubyte *vendor; 379cdc920a0Smrg GLubyte *renderer; 380cdc920a0Smrg GLubyte *version; 381cdc920a0Smrg GLubyte *extensions; 382cdc920a0Smrg /*@} */ 383cdc920a0Smrg 384cdc920a0Smrg /** 385cdc920a0Smrg * Maximum small render command size. This is the smaller of 64k and 386cdc920a0Smrg * the size of the above buffer. 387cdc920a0Smrg */ 388cdc920a0Smrg GLint maxSmallRenderCommandSize; 389cdc920a0Smrg 390cdc920a0Smrg /** 391cdc920a0Smrg * Major opcode for the extension. Copied here so a lookup isn't 392cdc920a0Smrg * needed. 393cdc920a0Smrg */ 394cdc920a0Smrg GLint majorOpcode; 395cdc920a0Smrg 396cdc920a0Smrg /** 3973464ebd5Sriastradh * Pointer to the config used to create this context. 398cdc920a0Smrg */ 3993464ebd5Sriastradh struct glx_config *config; 400cdc920a0Smrg 401cdc920a0Smrg /** 402cdc920a0Smrg * The current read-drawable for this context. Will be None if this 403cdc920a0Smrg * context is not current to any drawable. 404cdc920a0Smrg * 405cdc920a0Smrg * \since Internal API version 20030606. 406cdc920a0Smrg */ 407cdc920a0Smrg GLXDrawable currentReadable; 408cdc920a0Smrg 409cdc920a0Smrg /** 410cdc920a0Smrg * Pointer to client-state data that is private to libGL. This is only 411cdc920a0Smrg * used for indirect rendering contexts. 412cdc920a0Smrg * 413cdc920a0Smrg * No internal API version change was made for this change. Client-side 414cdc920a0Smrg * drivers should NEVER use this data or even care that it exists. 415cdc920a0Smrg */ 416cdc920a0Smrg void *client_state_private; 417cdc920a0Smrg 418cdc920a0Smrg /** 419cdc920a0Smrg * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE. 420cdc920a0Smrg */ 421cdc920a0Smrg int renderType; 422cdc920a0Smrg 423cdc920a0Smrg /** 424cdc920a0Smrg * \name Raw server GL version 425cdc920a0Smrg * 426cdc920a0Smrg * True core GL version supported by the server. This is the raw value 427cdc920a0Smrg * returned by the server, and it may not reflect what is actually 428cdc920a0Smrg * supported (or reported) by the client-side library. 429cdc920a0Smrg */ 430cdc920a0Smrg /*@{ */ 431cdc920a0Smrg int server_major; /**< Major version number. */ 432cdc920a0Smrg int server_minor; /**< Minor version number. */ 433cdc920a0Smrg /*@} */ 434cdc920a0Smrg 435cdc920a0Smrg /** 4363464ebd5Sriastradh * Number of threads we're currently current in. 437cdc920a0Smrg */ 4383464ebd5Sriastradh unsigned long thread_refcount; 439cdc920a0Smrg 440d8407755Smaya /** 441d8407755Smaya * GLX_ARB_create_context_no_error setting for this context. 442d8407755Smaya * This needs to be kept here to enforce shared context rules. 443d8407755Smaya */ 444d8407755Smaya Bool noError; 445d8407755Smaya 446cdc920a0Smrg char gl_extension_bits[__GL_EXT_BYTES]; 447cdc920a0Smrg}; 448cdc920a0Smrg 4493464ebd5Sriastradhextern Bool 4503464ebd5Sriastradhglx_context_init(struct glx_context *gc, 4513464ebd5Sriastradh struct glx_screen *psc, struct glx_config *fbconfig); 4523464ebd5Sriastradh 453cdc920a0Smrg#define __glXSetError(gc,code) \ 454cdc920a0Smrg if (!(gc)->error) { \ 455cdc920a0Smrg (gc)->error = code; \ 456cdc920a0Smrg } 457cdc920a0Smrg 4583464ebd5Sriastradhextern void __glFreeAttributeState(struct glx_context *); 459cdc920a0Smrg 460cdc920a0Smrg/************************************************************************/ 461cdc920a0Smrg 462cdc920a0Smrg/** 463cdc920a0Smrg * The size of the largest drawing command known to the implementation 464cdc920a0Smrg * that will use the GLXRender GLX command. In this case it is 465cdc920a0Smrg * \c glPolygonStipple. 466cdc920a0Smrg */ 467cdc920a0Smrg#define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156 468cdc920a0Smrg 469cdc920a0Smrg/** 470cdc920a0Smrg * To keep the implementation fast, the code uses a "limit" pointer 471cdc920a0Smrg * to determine when the drawing command buffer is too full to hold 472cdc920a0Smrg * another fixed size command. This constant defines the amount of 473cdc920a0Smrg * space that must always be available in the drawing command buffer 474cdc920a0Smrg * at all times for the implementation to work. It is important that 475cdc920a0Smrg * the number be just large enough, but not so large as to reduce the 476cdc920a0Smrg * efficacy of the buffer. The "+32" is just to keep the code working 477cdc920a0Smrg * in case somebody counts wrong. 478cdc920a0Smrg */ 479cdc920a0Smrg#define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32) 480cdc920a0Smrg 481cdc920a0Smrg/** 482cdc920a0Smrg * This implementation uses a smaller threshold for switching 483cdc920a0Smrg * to the RenderLarge protocol than the protcol requires so that 484cdc920a0Smrg * large copies don't occur. 485cdc920a0Smrg */ 486cdc920a0Smrg#define __GLX_RENDER_CMD_SIZE_LIMIT 4096 487cdc920a0Smrg 488cdc920a0Smrg/** 489cdc920a0Smrg * One of these records exists per screen of the display. It contains 490cdc920a0Smrg * a pointer to the config data for that screen (if the screen supports GL). 491cdc920a0Smrg */ 4923464ebd5Sriastradhstruct glx_screen_vtable { 4933464ebd5Sriastradh struct glx_context *(*create_context)(struct glx_screen *psc, 4943464ebd5Sriastradh struct glx_config *config, 4953464ebd5Sriastradh struct glx_context *shareList, 4963464ebd5Sriastradh int renderType); 497af69d88dSmrg 498af69d88dSmrg struct glx_context *(*create_context_attribs)(struct glx_screen *psc, 499af69d88dSmrg struct glx_config *config, 500af69d88dSmrg struct glx_context *shareList, 501af69d88dSmrg unsigned num_attrib, 502af69d88dSmrg const uint32_t *attribs, 503af69d88dSmrg unsigned *error); 504af69d88dSmrg int (*query_renderer_integer)(struct glx_screen *psc, 505af69d88dSmrg int attribute, 506af69d88dSmrg unsigned int *value); 507af69d88dSmrg int (*query_renderer_string)(struct glx_screen *psc, 508af69d88dSmrg int attribute, 509af69d88dSmrg const char **value); 5103464ebd5Sriastradh}; 5113464ebd5Sriastradh 5123464ebd5Sriastradhstruct glx_screen 513cdc920a0Smrg{ 5143464ebd5Sriastradh const struct glx_screen_vtable *vtable; 5153464ebd5Sriastradh 516cdc920a0Smrg /** 517cdc920a0Smrg * GLX extension string reported by the X-server. 518cdc920a0Smrg */ 519cdc920a0Smrg const char *serverGLXexts; 520cdc920a0Smrg 521cdc920a0Smrg /** 522cdc920a0Smrg * GLX extension string to be reported to applications. This is the 523cdc920a0Smrg * set of extensions that the application can actually use. 524cdc920a0Smrg */ 525cdc920a0Smrg char *effectiveGLXexts; 526cdc920a0Smrg 5273464ebd5Sriastradh struct glx_display *display; 5283464ebd5Sriastradh 5293464ebd5Sriastradh Display *dpy; 5303464ebd5Sriastradh int scr; 5313464ebd5Sriastradh 532cdc920a0Smrg#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) 533cdc920a0Smrg /** 534cdc920a0Smrg * Per screen direct rendering interface functions and data. 535cdc920a0Smrg */ 536cdc920a0Smrg __GLXDRIscreen *driScreen; 537cdc920a0Smrg#endif 538cdc920a0Smrg 539cdc920a0Smrg /** 540cdc920a0Smrg * Linked list of glx visuals and fbconfigs for this screen. 541cdc920a0Smrg */ 5423464ebd5Sriastradh struct glx_config *visuals, *configs; 543cdc920a0Smrg 544cdc920a0Smrg /** 545cdc920a0Smrg * Per-screen dynamic GLX extension tracking. The \c direct_support 546cdc920a0Smrg * field only contains enough bits for 64 extensions. Should libGL 547cdc920a0Smrg * ever need to track more than 64 GLX extensions, we can safely grow 5483464ebd5Sriastradh * this field. The \c struct glx_screen structure is not used outside 549cdc920a0Smrg * libGL. 550cdc920a0Smrg */ 551cdc920a0Smrg /*@{ */ 552cdc920a0Smrg unsigned char direct_support[8]; 553cdc920a0Smrg GLboolean ext_list_first_time; 554cdc920a0Smrg /*@} */ 555cdc920a0Smrg 556cdc920a0Smrg}; 557cdc920a0Smrg 558cdc920a0Smrg/** 559cdc920a0Smrg * Per display private data. One of these records exists for each display 560cdc920a0Smrg * that is using the OpenGL (GLX) extension. 561cdc920a0Smrg */ 5623464ebd5Sriastradhstruct glx_display 563cdc920a0Smrg{ 5643464ebd5Sriastradh /* The extension protocol codes */ 5653464ebd5Sriastradh XExtCodes *codes; 5663464ebd5Sriastradh struct glx_display *next; 5673464ebd5Sriastradh 568cdc920a0Smrg /** 569cdc920a0Smrg * Back pointer to the display 570cdc920a0Smrg */ 571cdc920a0Smrg Display *dpy; 572cdc920a0Smrg 573cdc920a0Smrg /** 574cdc920a0Smrg * The \c majorOpcode is common to all connections to the same server. 575cdc920a0Smrg * It is also copied into the context structure. 576cdc920a0Smrg */ 577cdc920a0Smrg int majorOpcode; 578cdc920a0Smrg 579cdc920a0Smrg /** 580cdc920a0Smrg * \name Server Version 581cdc920a0Smrg * 582cdc920a0Smrg * Major and minor version returned by the server during initialization. 583cdc920a0Smrg */ 584cdc920a0Smrg /*@{ */ 585cdc920a0Smrg int majorVersion, minorVersion; 586cdc920a0Smrg /*@} */ 587cdc920a0Smrg 588cdc920a0Smrg /** 589cdc920a0Smrg * \name Storage for the servers GLX vendor and versions strings. 590cdc920a0Smrg * 591cdc920a0Smrg * These are the same for all screens on this display. These fields will 592cdc920a0Smrg * be filled in on demand. 593cdc920a0Smrg */ 594cdc920a0Smrg /*@{ */ 595cdc920a0Smrg const char *serverGLXvendor; 596cdc920a0Smrg const char *serverGLXversion; 597cdc920a0Smrg /*@} */ 598cdc920a0Smrg 599cdc920a0Smrg /** 600cdc920a0Smrg * Configurations of visuals for all screens on this display. 601cdc920a0Smrg * Also, per screen data which now includes the server \c GLX_EXTENSION 602cdc920a0Smrg * string. 603cdc920a0Smrg */ 6043464ebd5Sriastradh struct glx_screen **screens; 605cdc920a0Smrg 606af69d88dSmrg __glxHashTable *glXDrawHash; 607af69d88dSmrg 608cdc920a0Smrg#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) 6093464ebd5Sriastradh __glxHashTable *drawHash; 6103464ebd5Sriastradh 611cdc920a0Smrg /** 612cdc920a0Smrg * Per display direct rendering interface functions and data. 613cdc920a0Smrg */ 614cdc920a0Smrg __GLXDRIdisplay *driswDisplay; 615cdc920a0Smrg __GLXDRIdisplay *driDisplay; 616cdc920a0Smrg __GLXDRIdisplay *dri2Display; 617af69d88dSmrg __GLXDRIdisplay *dri3Display; 618cdc920a0Smrg#endif 61901e04c3fSmrg#ifdef GLX_USE_WINDOWSGL 62001e04c3fSmrg __GLXDRIdisplay *windowsdriDisplay; 62101e04c3fSmrg#endif 622cdc920a0Smrg}; 623cdc920a0Smrg 624af69d88dSmrgstruct glx_drawable { 625af69d88dSmrg XID xDrawable; 626af69d88dSmrg XID drawable; 627af69d88dSmrg 628af69d88dSmrg uint32_t lastEventSbc; 629af69d88dSmrg int64_t eventSbcWrap; 630af69d88dSmrg}; 631af69d88dSmrg 6323464ebd5Sriastradhextern int 6333464ebd5Sriastradhglx_screen_init(struct glx_screen *psc, 6343464ebd5Sriastradh int screen, struct glx_display * priv); 6353464ebd5Sriastradhextern void 6363464ebd5Sriastradhglx_screen_cleanup(struct glx_screen *psc); 637cdc920a0Smrg 6383464ebd5Sriastradh#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) 6393464ebd5Sriastradhextern __GLXDRIdrawable * 6403464ebd5Sriastradhdri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id); 6413464ebd5Sriastradh#endif 642cdc920a0Smrg 6433464ebd5Sriastradhextern GLubyte *__glXFlushRenderBuffer(struct glx_context *, GLubyte *); 6443464ebd5Sriastradh 6453464ebd5Sriastradhextern void __glXSendLargeChunk(struct glx_context * gc, GLint requestNumber, 646cdc920a0Smrg GLint totalRequests, 647cdc920a0Smrg const GLvoid * data, GLint dataLen); 648cdc920a0Smrg 6493464ebd5Sriastradhextern void __glXSendLargeCommand(struct glx_context *, const GLvoid *, GLint, 650cdc920a0Smrg const GLvoid *, GLint); 651cdc920a0Smrg 652cdc920a0Smrg/* Initialize the GLX extension for dpy */ 6533464ebd5Sriastradhextern struct glx_display *__glXInitialize(Display *); 654cdc920a0Smrg 655cdc920a0Smrg/************************************************************************/ 656cdc920a0Smrg 657cdc920a0Smrgextern int __glXDebug; 658cdc920a0Smrg 659cdc920a0Smrg/* This is per-thread storage in an MT environment */ 660cdc920a0Smrg 6613464ebd5Sriastradhextern void __glXSetCurrentContext(struct glx_context * c); 662cdc920a0Smrg 663cdc920a0Smrg# if defined( GLX_USE_TLS ) 664cdc920a0Smrg 665cdc920a0Smrgextern __thread void *__glX_tls_Context 666cdc920a0Smrg __attribute__ ((tls_model("initial-exec"))); 667cdc920a0Smrg 668e81a0f50Smaya#if defined(__NetBSD__) 669e81a0f50Smaya# define __glXGetCurrentContext() (likely(__glX_tls_Context) ? __glX_tls_Context : (void*)&dummyContext) 670e81a0f50Smaya#else 671cdc920a0Smrg# define __glXGetCurrentContext() __glX_tls_Context 672e81a0f50Smaya#endif 673cdc920a0Smrg 674cdc920a0Smrg# else 675cdc920a0Smrg 6763464ebd5Sriastradhextern struct glx_context *__glXGetCurrentContext(void); 677cdc920a0Smrg 678cdc920a0Smrg# endif /* defined( GLX_USE_TLS ) */ 679cdc920a0Smrg 680cdc920a0Smrgextern void __glXSetCurrentContextNull(void); 681cdc920a0Smrg 682cdc920a0Smrg 683cdc920a0Smrg/* 684cdc920a0Smrg** Global lock for all threads in this address space using the GLX 685cdc920a0Smrg** extension 686cdc920a0Smrg*/ 687cdc920a0Smrgextern pthread_mutex_t __glXmutex; 688cdc920a0Smrg#define __glXLock() pthread_mutex_lock(&__glXmutex) 689cdc920a0Smrg#define __glXUnlock() pthread_mutex_unlock(&__glXmutex) 690cdc920a0Smrg 691cdc920a0Smrg/* 692cdc920a0Smrg** Setup for a command. Initialize the extension for dpy if necessary. 693cdc920a0Smrg*/ 694cdc920a0Smrgextern CARD8 __glXSetupForCommand(Display * dpy); 695cdc920a0Smrg 696cdc920a0Smrg/************************************************************************/ 697cdc920a0Smrg 698cdc920a0Smrg/* 699cdc920a0Smrg** Data conversion and packing support. 700cdc920a0Smrg*/ 701cdc920a0Smrg 702cdc920a0Smrgextern const GLuint __glXDefaultPixelStore[9]; 703cdc920a0Smrg 704cdc920a0Smrg/* Send an image to the server using RenderLarge. */ 7053464ebd5Sriastradhextern void __glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim, 706cdc920a0Smrg GLint width, GLint height, GLint depth, 707cdc920a0Smrg GLenum format, GLenum type, 708cdc920a0Smrg const GLvoid * src, GLubyte * pc, 709cdc920a0Smrg GLubyte * modes); 710cdc920a0Smrg 711cdc920a0Smrg/* Return the size, in bytes, of some pixel data */ 712cdc920a0Smrgextern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum); 713cdc920a0Smrg 714cdc920a0Smrg/* Return the number of elements per group of a specified format*/ 715cdc920a0Smrgextern GLint __glElementsPerGroup(GLenum format, GLenum type); 716cdc920a0Smrg 717cdc920a0Smrg/* Return the number of bytes per element, based on the element type (other 718cdc920a0Smrg** than GL_BITMAP). 719cdc920a0Smrg*/ 720cdc920a0Smrgextern GLint __glBytesPerElement(GLenum type); 721cdc920a0Smrg 722cdc920a0Smrg/* 723cdc920a0Smrg** Fill the transport buffer with the data from the users buffer, 724cdc920a0Smrg** applying some of the pixel store modes (unpack modes) to the data 725cdc920a0Smrg** first. As a side effect of this call, the "modes" field is 726cdc920a0Smrg** updated to contain the modes needed by the server to decode the 727cdc920a0Smrg** sent data. 728cdc920a0Smrg*/ 7293464ebd5Sriastradhextern void __glFillImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum, 730cdc920a0Smrg GLenum, const GLvoid *, GLubyte *, GLubyte *); 731cdc920a0Smrg 732cdc920a0Smrg/* Copy map data with a stride into a packed buffer */ 733cdc920a0Smrgextern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *); 734cdc920a0Smrgextern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *); 735cdc920a0Smrgextern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint, 736cdc920a0Smrg const GLfloat *, GLfloat *); 737cdc920a0Smrgextern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint, 738cdc920a0Smrg const GLdouble *, GLdouble *); 739cdc920a0Smrg 740cdc920a0Smrg/* 741cdc920a0Smrg** Empty an image out of the reply buffer into the clients memory applying 742cdc920a0Smrg** the pack modes to pack back into the clients requested format. 743cdc920a0Smrg*/ 7443464ebd5Sriastradhextern void __glEmptyImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum, 745cdc920a0Smrg GLenum, const GLubyte *, GLvoid *); 746cdc920a0Smrg 747cdc920a0Smrg 748cdc920a0Smrg/* 749cdc920a0Smrg** Allocate and Initialize Vertex Array client state, and free. 750cdc920a0Smrg*/ 7513464ebd5Sriastradhextern void __glXInitVertexArrayState(struct glx_context *); 7523464ebd5Sriastradhextern void __glXFreeVertexArrayState(struct glx_context *); 753cdc920a0Smrg 754cdc920a0Smrg/* 755cdc920a0Smrg** Inform the Server of the major and minor numbers and of the client 756cdc920a0Smrg** libraries extension string. 757cdc920a0Smrg*/ 758cdc920a0Smrgextern void __glXClientInfo(Display * dpy, int opcode); 759cdc920a0Smrg 760af69d88dSmrg_X_HIDDEN void 761af69d88dSmrg__glX_send_client_info(struct glx_display *glx_dpy); 762af69d88dSmrg 763cdc920a0Smrg/************************************************************************/ 764cdc920a0Smrg 765cdc920a0Smrg/* 766cdc920a0Smrg** Declarations that should be in Xlib 767cdc920a0Smrg*/ 768cdc920a0Smrg#ifdef __GL_USE_OUR_PROTOTYPES 769cdc920a0Smrgextern void _XFlush(Display *); 770cdc920a0Smrgextern Status _XReply(Display *, xReply *, int, Bool); 771cdc920a0Smrgextern void _XRead(Display *, void *, long); 772cdc920a0Smrgextern void _XSend(Display *, const void *, long); 773cdc920a0Smrg#endif 774cdc920a0Smrg 775cdc920a0Smrg 7763464ebd5Sriastradhextern void __glXInitializeVisualConfigFromTags(struct glx_config * config, 777cdc920a0Smrg int count, const INT32 * bp, 778cdc920a0Smrg Bool tagged_only, 779cdc920a0Smrg Bool fbconfig_style_tags); 780cdc920a0Smrg 781cdc920a0Smrgextern char *__glXQueryServerString(Display * dpy, int opcode, 782cdc920a0Smrg CARD32 screen, CARD32 name); 783cdc920a0Smrgextern char *__glXGetString(Display * dpy, int opcode, 784cdc920a0Smrg CARD32 screen, CARD32 name); 785cdc920a0Smrg 786cdc920a0Smrgextern const char __glXGLClientVersion[]; 787cdc920a0Smrgextern const char __glXGLClientExtensions[]; 788cdc920a0Smrg 789cdc920a0Smrg/* Get the unadjusted system time */ 790cdc920a0Smrgextern int __glXGetUST(int64_t * ust); 791cdc920a0Smrg 792cdc920a0Smrgextern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, 793cdc920a0Smrg int32_t * numerator, 794cdc920a0Smrg int32_t * denominator); 795cdc920a0Smrg 796cdc920a0Smrg#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) 7973464ebd5Sriastradhextern GLboolean 798af69d88dSmrg__glxGetMscRate(struct glx_screen *psc, 7993464ebd5Sriastradh int32_t * numerator, int32_t * denominator); 800cdc920a0Smrg 801cdc920a0Smrg/* So that dri2.c:DRI2WireToEvent() can access 802cdc920a0Smrg * glx_info->codes->first_event */ 803cdc920a0SmrgXExtDisplayInfo *__glXFindDisplay (Display *dpy); 804cdc920a0Smrg 8053464ebd5Sriastradhextern void 8063464ebd5SriastradhGarbageCollectDRIDrawables(struct glx_screen *psc); 8073464ebd5Sriastradh 808cdc920a0Smrgextern __GLXDRIdrawable * 8093464ebd5SriastradhGetGLXDRIDrawable(Display *dpy, GLXDrawable drawable); 8103464ebd5Sriastradh#endif 811cdc920a0Smrg 812af69d88dSmrgextern struct glx_screen *GetGLXScreenConfigs(Display * dpy, int scrn); 813af69d88dSmrg 8143464ebd5Sriastradh#ifdef GLX_USE_APPLEGL 8153464ebd5Sriastradhextern struct glx_screen * 8163464ebd5Sriastradhapplegl_create_screen(int screen, struct glx_display * priv); 8173464ebd5Sriastradh 8183464ebd5Sriastradhextern struct glx_context * 8193464ebd5Sriastradhapplegl_create_context(struct glx_screen *psc, 8203464ebd5Sriastradh struct glx_config *mode, 8213464ebd5Sriastradh struct glx_context *shareList, int renderType); 8223464ebd5Sriastradh 8233464ebd5Sriastradhextern int 8243464ebd5Sriastradhapplegl_create_display(struct glx_display *display); 825cdc920a0Smrg#endif 826cdc920a0Smrg 827af69d88dSmrgextern Bool validate_renderType_against_config(const struct glx_config *config, 828af69d88dSmrg int renderType); 829af69d88dSmrg 830af69d88dSmrg 831af69d88dSmrgextern struct glx_drawable *GetGLXDrawable(Display *dpy, GLXDrawable drawable); 832af69d88dSmrgextern int InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw, 833af69d88dSmrg XID xDrawable, GLXDrawable drawable); 834af69d88dSmrgextern void DestroyGLXDrawable(Display *dpy, GLXDrawable drawable); 835af69d88dSmrg 8363464ebd5Sriastradhextern struct glx_context dummyContext; 8373464ebd5Sriastradh 8383464ebd5Sriastradhextern struct glx_screen * 8393464ebd5Sriastradhindirect_create_screen(int screen, struct glx_display * priv); 8403464ebd5Sriastradhextern struct glx_context * 8413464ebd5Sriastradhindirect_create_context(struct glx_screen *psc, 8423464ebd5Sriastradh struct glx_config *mode, 8433464ebd5Sriastradh struct glx_context *shareList, int renderType); 844af69d88dSmrgextern struct glx_context * 845af69d88dSmrgindirect_create_context_attribs(struct glx_screen *base, 846af69d88dSmrg struct glx_config *config_base, 847af69d88dSmrg struct glx_context *shareList, 848af69d88dSmrg unsigned num_attribs, 849af69d88dSmrg const uint32_t *attribs, 850af69d88dSmrg unsigned *error); 8513464ebd5Sriastradh 85201e04c3fSmrg 85301e04c3fSmrgextern int __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable, 85401e04c3fSmrg int attribute, unsigned int *value); 85501e04c3fSmrg 85601e04c3fSmrg#ifdef __cplusplus 85701e04c3fSmrg} 85801e04c3fSmrg#endif 85901e04c3fSmrg 860cdc920a0Smrg#endif /* !__GLX_client_h__ */ 861