X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=inline;f=src%2Fglx%2Fglxclient.h;h=f91542661016eb9ff9f8ba0f7a90007a55a44e64;hb=e975e18bebb54b20f00c568e7870932402b79f8f;hp=8e5dc785dd981206a43e2b733fa32ed8813fafdd;hpb=275c4bd3643d773210780cb8d578ca84f2604684;p=mesa.git diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 8e5dc785dd9..f9154266101 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -37,10 +37,9 @@ #ifndef _GLX_client_h_ #define _GLX_client_h_ -#define NEED_REPLIES -#define NEED_EVENTS #include #include +#include #include #define GLX_GLXEXT_PROTOTYPES #include @@ -51,10 +50,9 @@ #ifdef WIN32 #include #endif -#include "GL/glxint.h" #include "GL/glxproto.h" -#include "GL/internal/glcore.h" #include "glapi/glapitable.h" +#include "glxconfig.h" #include "glxhash.h" #if defined( PTHREADS ) # include @@ -62,43 +60,26 @@ #include "glxextensions.h" - -/* If we build the library with gcc's -fvisibility=hidden flag, we'll - * use the PUBLIC macro to mark functions that are to be exported. - * - * We also need to define a USED attribute, so the optimizer doesn't - * inline a static function that we later use in an alias. - ajax - */ -#if defined(__GNUC__) -# define PUBLIC __attribute__((visibility("default"))) -# define USED __attribute__((used)) -#else -# define PUBLIC -# define USED -#endif - - +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) #define GLX_MAJOR_VERSION 1 /* current version numbers */ #define GLX_MINOR_VERSION 4 #define __GLX_MAX_TEXTURE_UNITS 32 -typedef struct __GLXscreenConfigsRec __GLXscreenConfigs; -typedef struct __GLXcontextRec __GLXcontext; -typedef struct __GLXdrawableRec __GLXdrawable; -typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate; -typedef struct _glapi_table __GLapi; +struct glx_display; +struct glx_context; /************************************************************************/ #ifdef GLX_DIRECT_RENDERING -#define containerOf(ptr, type, member) \ - (type *)( (char *)ptr - offsetof(type,member) ) +extern void DRI_glXUseXFont(struct glx_context *ctx, + Font font, int first, int count, int listbase); -#include +#endif +#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) /** * Display dependent methods. This structure is initialized during the @@ -107,9 +88,6 @@ typedef struct _glapi_table __GLapi; typedef struct __GLXDRIdisplayRec __GLXDRIdisplay; typedef struct __GLXDRIscreenRec __GLXDRIscreen; typedef struct __GLXDRIdrawableRec __GLXDRIdrawable; -typedef struct __GLXDRIcontextRec __GLXDRIcontext; - -#include "glxextensions.h" struct __GLXDRIdisplayRec { @@ -118,61 +96,49 @@ struct __GLXDRIdisplayRec */ void (*destroyDisplay) (__GLXDRIdisplay * display); - __GLXDRIscreen *(*createScreen) (__GLXscreenConfigs * psc, int screen, - __GLXdisplayPrivate * priv); + struct glx_screen *(*createScreen)(int screen, struct glx_display * priv); }; struct __GLXDRIscreenRec { - void (*destroyScreen)(__GLXscreenConfigs *psc); + void (*destroyScreen)(struct glx_screen *psc); - __GLXDRIcontext *(*createContext)(__GLXscreenConfigs *psc, - const __GLcontextModes *mode, - GLXContext gc, - GLXContext shareList, int renderType); + struct glx_context *(*createContext)(struct glx_screen *psc, + struct glx_config *config, + struct glx_context *shareList, + int renderType); - __GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc, + __GLXDRIdrawable *(*createDrawable)(struct glx_screen *psc, XID drawable, GLXDrawable glxDrawable, - const __GLcontextModes *modes); + struct glx_config *config); int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, int64_t remainder); void (*copySubBuffer)(__GLXDRIdrawable *pdraw, int x, int y, int width, int height); - void (*waitX)(__GLXDRIdrawable *pdraw); - void (*waitGL)(__GLXDRIdrawable *pdraw); - int (*getDrawableMSC)(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw, + int (*getDrawableMSC)(struct glx_screen *psc, __GLXDRIdrawable *pdraw, int64_t *ust, int64_t *msc, int64_t *sbc); int (*waitForMSC)(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); int (*waitForSBC)(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); - void (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval); + int (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval); int (*getSwapInterval)(__GLXDRIdrawable *pdraw); }; -struct __GLXDRIcontextRec -{ - void (*destroyContext) (__GLXDRIcontext * context, - __GLXscreenConfigs * psc, Display * dpy); - Bool(*bindContext) (__GLXDRIcontext * context, __GLXDRIdrawable * pdraw, - __GLXDRIdrawable * pread); - - void (*unbindContext) (__GLXDRIcontext * context); -}; - struct __GLXDRIdrawableRec { void (*destroyDrawable) (__GLXDRIdrawable * drawable); XID xDrawable; XID drawable; - __GLXscreenConfigs *psc; + struct glx_screen *psc; GLenum textureTarget; - __DRIdrawable *driDrawable; GLenum textureFormat; /* EXT_texture_from_pixmap support */ + unsigned long eventMask; + int refcount; }; /* @@ -183,10 +149,9 @@ extern __GLXDRIdisplay *driswCreateDisplay(Display * dpy); extern __GLXDRIdisplay *driCreateDisplay(Display * dpy); extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy); extern void dri2InvalidateBuffers(Display *dpy, XID drawable); +extern unsigned dri2GetSwapEventType(Display *dpy, XID drawable); -extern void DRI_glXUseXFont(Font font, int first, int count, int listbase); - /* ** Functions to obtain driver configuration information from a direct ** rendering client application @@ -246,11 +211,30 @@ typedef struct __GLXattributeMachineRec __GLXattribute **stackPointer; } __GLXattributeMachine; +struct glx_context_vtable { + void (*destroy)(struct glx_context *ctx); + int (*bind)(struct glx_context *context, struct glx_context *old, + GLXDrawable draw, GLXDrawable read); + void (*unbind)(struct glx_context *context, struct glx_context *new); + void (*wait_gl)(struct glx_context *ctx); + void (*wait_x)(struct glx_context *ctx); + void (*use_x_font)(struct glx_context *ctx, + Font font, int first, int count, int listBase); + void (*bind_tex_image)(Display * dpy, + GLXDrawable drawable, + int buffer, const int *attrib_list); + void (*release_tex_image)(Display * dpy, GLXDrawable drawable, int buffer); + void * (*get_proc_address)(const char *symbol); +}; + +extern void +glx_send_destroy_context(Display *dpy, XID xid); + /** * GLX state that needs to be kept on the client. One of these records * exist for each context that has been made current by this client. */ -struct __GLXcontextRec +struct glx_context { /** * \name Drawing command buffer. @@ -276,6 +260,8 @@ struct __GLXcontextRec GLint bufSize; /*@} */ + const struct glx_context_vtable *vtable; + /** * The XID of this rendering context. When the context is created a * new XID is allocated. This is set to None when the context is @@ -293,7 +279,7 @@ struct __GLXcontextRec * Screen number. */ GLint screen; - __GLXscreenConfigs *psc; + struct glx_screen *psc; /** * \c GL_TRUE if the context was created with ImportContext, which @@ -324,19 +310,11 @@ struct __GLXcontextRec GLuint *selectBuf; /*@} */ - /** - * This is \c GL_TRUE if the pixel unpack modes are such that an image - * can be unpacked from the clients memory by just copying. It may - * still be true that the server will have to do some work. This - * just promises that a straight copy will fetch the correct bytes. - */ - GLboolean fastImageUnpack; - /** * Fill newImage with the unpacked form of \c oldImage getting it * ready for transport to the server. */ - void (*fillImage) (__GLXcontext *, GLint, GLint, GLint, GLint, GLenum, + void (*fillImage) (struct glx_context *, GLint, GLint, GLint, GLint, GLenum, GLenum, const GLvoid *, GLubyte *, GLubyte *); /** @@ -356,6 +334,10 @@ struct __GLXcontextRec */ Bool isDirect; +#if defined(GLX_DIRECT_RENDERING) && defined(GLX_USE_APPLEGL) + void *driContext; +#endif + /** * \c dpy of current display for this context. Will be \c NULL if not * current to any display, or if this is the "dummy context". @@ -382,11 +364,6 @@ struct __GLXcontextRec GLubyte *extensions; /*@} */ - /** - * Record the dpy this context was created on for later freeing - */ - Display *createDpy; - /** * Maximum small render command size. This is the smaller of 64k and * the size of the above buffer. @@ -400,14 +377,9 @@ struct __GLXcontextRec GLint majorOpcode; /** - * Pointer to the mode used to create this context. + * Pointer to the config used to create this context. */ - const __GLcontextModes *mode; - -#ifdef GLX_DIRECT_RENDERING - __GLXDRIcontext *driContext; - __DRIcontext *__driContext; -#endif + struct glx_config *config; /** * The current read-drawable for this context. Will be None if this @@ -444,19 +416,23 @@ struct __GLXcontextRec /*@} */ /** - * Thread ID we're currently current in. Zero if none. + * Number of threads we're currently current in. */ - unsigned long thread_id; + unsigned long thread_refcount; char gl_extension_bits[__GL_EXT_BYTES]; }; +extern Bool +glx_context_init(struct glx_context *gc, + struct glx_screen *psc, struct glx_config *fbconfig); + #define __glXSetError(gc,code) \ if (!(gc)->error) { \ (gc)->error = code; \ } -extern void __glFreeAttributeState(__GLXcontext *); +extern void __glFreeAttributeState(struct glx_context *); /************************************************************************/ @@ -490,8 +466,17 @@ extern void __glFreeAttributeState(__GLXcontext *); * One of these records exists per screen of the display. It contains * a pointer to the config data for that screen (if the screen supports GL). */ -struct __GLXscreenConfigsRec +struct glx_screen_vtable { + struct glx_context *(*create_context)(struct glx_screen *psc, + struct glx_config *config, + struct glx_context *shareList, + int renderType); +}; + +struct glx_screen { + const struct glx_screen_vtable *vtable; + /** * GLX extension string reported by the X-server. */ @@ -503,64 +488,28 @@ struct __GLXscreenConfigsRec */ char *effectiveGLXexts; -#ifdef GLX_DIRECT_RENDERING + struct glx_display *display; + + Display *dpy; + int scr; + +#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) /** * Per screen direct rendering interface functions and data. */ - __DRIscreen *__driScreen; - const __DRIcoreExtension *core; - const __DRIlegacyExtension *legacy; - const __DRIswrastExtension *swrast; - const __DRIdri2Extension *dri2; - __glxHashTable *drawHash; - Display *dpy; - int scr, fd; - void *driver; - __GLXDRIscreen *driScreen; - - const __DRIconfig **driver_configs; - -#ifdef __DRI_COPY_SUB_BUFFER - const __DRIcopySubBufferExtension *driCopySubBuffer; -#endif - -#ifdef __DRI_SWAP_CONTROL - const __DRIswapControlExtension *swapControl; -#endif - -#ifdef __DRI_ALLOCATE - const __DRIallocateExtension *allocate; -#endif - -#ifdef __DRI_FRAME_TRACKING - const __DRIframeTrackingExtension *frameTracking; -#endif - -#ifdef __DRI_MEDIA_STREAM_COUNTER - const __DRImediaStreamCounterExtension *msc; -#endif - -#ifdef __DRI_TEX_BUFFER - const __DRItexBufferExtension *texBuffer; -#endif - -#ifdef __DRI2_FLUSH - const __DRI2flushExtension *f; -#endif - #endif /** * Linked list of glx visuals and fbconfigs for this screen. */ - __GLcontextModes *visuals, *configs; + struct glx_config *visuals, *configs; /** * Per-screen dynamic GLX extension tracking. The \c direct_support * field only contains enough bits for 64 extensions. Should libGL * ever need to track more than 64 GLX extensions, we can safely grow - * this field. The \c __GLXscreenConfigs structure is not used outside + * this field. The \c struct glx_screen structure is not used outside * libGL. */ /*@{ */ @@ -574,8 +523,12 @@ struct __GLXscreenConfigsRec * Per display private data. One of these records exists for each display * that is using the OpenGL (GLX) extension. */ -struct __GLXdisplayPrivateRec +struct glx_display { + /* The extension protocol codes */ + XExtCodes *codes; + struct glx_display *next; + /** * Back pointer to the display */ @@ -612,9 +565,13 @@ struct __GLXdisplayPrivateRec * Also, per screen data which now includes the server \c GLX_EXTENSION * string. */ - __GLXscreenConfigs *screenConfigs; + struct glx_screen **screens; + + __glxHashTable *glXDrawHash; + +#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) + __glxHashTable *drawHash; -#ifdef GLX_DIRECT_RENDERING /** * Per display direct rendering interface functions and data. */ @@ -624,18 +581,36 @@ struct __GLXdisplayPrivateRec #endif }; +struct glx_drawable { + XID xDrawable; + XID drawable; + + uint32_t lastEventSbc; + int64_t eventSbcWrap; +}; + +extern int +glx_screen_init(struct glx_screen *psc, + int screen, struct glx_display * priv); +extern void +glx_screen_cleanup(struct glx_screen *psc); + +#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) +extern __GLXDRIdrawable * +dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id); +#endif -extern GLubyte *__glXFlushRenderBuffer(__GLXcontext *, GLubyte *); +extern GLubyte *__glXFlushRenderBuffer(struct glx_context *, GLubyte *); -extern void __glXSendLargeChunk(__GLXcontext * gc, GLint requestNumber, +extern void __glXSendLargeChunk(struct glx_context * gc, GLint requestNumber, GLint totalRequests, const GLvoid * data, GLint dataLen); -extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint, +extern void __glXSendLargeCommand(struct glx_context *, const GLvoid *, GLint, const GLvoid *, GLint); /* Initialize the GLX extension for dpy */ -extern __GLXdisplayPrivate *__glXInitialize(Display *); +extern struct glx_display *__glXInitialize(Display *); extern void __glXPreferEGL(int state); @@ -646,7 +621,7 @@ extern int __glXDebug; /* This is per-thread storage in an MT environment */ #if defined( PTHREADS ) -extern void __glXSetCurrentContext(__GLXcontext * c); +extern void __glXSetCurrentContext(struct glx_context * c); # if defined( GLX_USE_TLS ) @@ -657,13 +632,13 @@ extern __thread void *__glX_tls_Context # else -extern __GLXcontext *__glXGetCurrentContext(void); +extern struct glx_context *__glXGetCurrentContext(void); # endif /* defined( GLX_USE_TLS ) */ #else -extern __GLXcontext *__glXcurrentContext; +extern struct glx_context *__glXcurrentContext; #define __glXGetCurrentContext() __glXcurrentContext #define __glXSetCurrentContext(gc) __glXcurrentContext = gc @@ -671,8 +646,6 @@ extern __GLXcontext *__glXcurrentContext; extern void __glXSetCurrentContextNull(void); -extern void __glXFreeContext(__GLXcontext *); - /* ** Global lock for all threads in this address space using the GLX @@ -701,7 +674,7 @@ extern CARD8 __glXSetupForCommand(Display * dpy); extern const GLuint __glXDefaultPixelStore[9]; /* Send an image to the server using RenderLarge. */ -extern void __glXSendLargeImage(__GLXcontext * gc, GLint compsize, GLint dim, +extern void __glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim, GLint width, GLint height, GLint depth, GLenum format, GLenum type, const GLvoid * src, GLubyte * pc, @@ -725,7 +698,7 @@ extern GLint __glBytesPerElement(GLenum type); ** updated to contain the modes needed by the server to decode the ** sent data. */ -extern void __glFillImage(__GLXcontext *, GLint, GLint, GLint, GLint, GLenum, +extern void __glFillImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum, GLenum, const GLvoid *, GLubyte *, GLubyte *); /* Copy map data with a stride into a packed buffer */ @@ -740,15 +713,15 @@ extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint, ** Empty an image out of the reply buffer into the clients memory applying ** the pack modes to pack back into the clients requested format. */ -extern void __glEmptyImage(__GLXcontext *, GLint, GLint, GLint, GLint, GLenum, +extern void __glEmptyImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum, GLenum, const GLubyte *, GLvoid *); /* ** Allocate and Initialize Vertex Array client state, and free. */ -extern void __glXInitVertexArrayState(__GLXcontext *); -extern void __glXFreeVertexArrayState(__GLXcontext *); +extern void __glXInitVertexArrayState(struct glx_context *); +extern void __glXFreeVertexArrayState(struct glx_context *); /* ** Inform the Server of the major and minor numbers and of the client @@ -769,7 +742,7 @@ extern void _XSend(Display *, const void *, long); #endif -extern void __glXInitializeVisualConfigFromTags(__GLcontextModes * config, +extern void __glXInitializeVisualConfigFromTags(struct glx_config * config, int count, const INT32 * bp, Bool tagged_only, Bool fbconfig_style_tags); @@ -792,18 +765,48 @@ extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, int32_t * numerator, int32_t * denominator); -#ifdef GLX_DIRECT_RENDERING -GLboolean -__driGetMscRateOML(__DRIdrawable * draw, - int32_t * numerator, int32_t * denominator, void *private); +#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) +extern GLboolean +__glxGetMscRate(__GLXDRIdrawable *glxDraw, + int32_t * numerator, int32_t * denominator); /* So that dri2.c:DRI2WireToEvent() can access * glx_info->codes->first_event */ XExtDisplayInfo *__glXFindDisplay (Display *dpy); +extern void +GarbageCollectDRIDrawables(struct glx_screen *psc); + extern __GLXDRIdrawable * -GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int *const scrn_num); +GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable); +#endif + +#ifdef GLX_USE_APPLEGL +extern struct glx_screen * +applegl_create_screen(int screen, struct glx_display * priv); +extern struct glx_context * +applegl_create_context(struct glx_screen *psc, + struct glx_config *mode, + struct glx_context *shareList, int renderType); + +extern int +applegl_create_display(struct glx_display *display); #endif + +extern struct glx_drawable *GetGLXDrawable(Display *dpy, GLXDrawable drawable); +extern int InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw, + XID xDrawable, GLXDrawable drawable); +extern void DestroyGLXDrawable(Display *dpy, GLXDrawable drawable); + +extern struct glx_context dummyContext; + +extern struct glx_screen * +indirect_create_screen(int screen, struct glx_display * priv); +extern struct glx_context * +indirect_create_context(struct glx_screen *psc, + struct glx_config *mode, + struct glx_context *shareList, int renderType); + #endif /* !__GLX_client_h__ */