diff options
author | Kristian Høgsberg <[email protected]> | 2010-05-21 10:36:56 -0400 |
---|---|---|
committer | Kristian Høgsberg <[email protected]> | 2010-05-21 23:24:37 -0400 |
commit | 643b2af0203764cb9f0a5b9e082937ab3f243523 (patch) | |
tree | 685afc7329526395fd7865017d05893c9bd3396d /src | |
parent | 4db0c760195c67f1bc114fdfb8464791030a526c (diff) |
glx: Split tfp functions out to context vtable
This introduces a new per-context vtable, which lets us clean up all the
#ifdef's a bit and move the DRI2 specific implementation into dri2_glx.c.
Diffstat (limited to 'src')
-rw-r--r-- | src/glx/dri2_glx.c | 36 | ||||
-rw-r--r-- | src/glx/dri_glx.c | 7 | ||||
-rw-r--r-- | src/glx/glxclient.h | 15 | ||||
-rw-r--r-- | src/glx/glxcmds.c | 81 |
4 files changed, 99 insertions, 40 deletions
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 45959915b4b..ba546a6bc1c 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -563,6 +563,40 @@ dri2InvalidateBuffers(Display *dpy, XID drawable) #endif } +static void +dri2_bind_tex_image(Display * dpy, + GLXDrawable drawable, + int buffer, const int *attrib_list) +{ + GLXContext gc = __glXGetCurrentContext(); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); + + if (pdraw != NULL) { + if (pdraw->psc->texBuffer->base.version >= 2 && + pdraw->psc->texBuffer->setTexBuffer2 != NULL) { + (*pdraw->psc->texBuffer->setTexBuffer2) (gc->__driContext, + pdraw->textureTarget, + pdraw->textureFormat, + pdraw->driDrawable); + } + else { + (*pdraw->psc->texBuffer->setTexBuffer) (gc->__driContext, + pdraw->textureTarget, + pdraw->driDrawable); + } + } +} + +static void +dri2_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer) +{ +} + +static const struct glx_context_vtable dri2_context_vtable = { + dri2_bind_tex_image, + dri2_release_tex_image, +}; + static __GLXDRIscreen * dri2CreateScreen(__GLXscreenConfigs * psc, int screen, __GLXdisplayPrivate * priv) @@ -683,6 +717,8 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen, psp->copySubBuffer = dri2CopySubBuffer; __glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer"); + psc->direct_context_vtable = &dri2_context_vtable; + Xfree(driverName); Xfree(deviceName); diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c index 74afa60301d..12a2cf3af24 100644 --- a/src/glx/dri_glx.c +++ b/src/glx/dri_glx.c @@ -634,6 +634,11 @@ driDestroyScreen(__GLXscreenConfigs * psc) dlclose(psc->driver); } +static const struct glx_context_vtable dri_context_vtable = { + NULL, + NULL, +}; + static __GLXDRIscreen * driCreateScreen(__GLXscreenConfigs * psc, int screen, __GLXdisplayPrivate * priv) @@ -700,6 +705,8 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen, psp->waitX = NULL; psp->waitGL = NULL; + psc->direct_context_vtable = &dri_context_vtable; + return psp; } diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 57d254ea987..78c5f33d4d5 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -249,6 +249,14 @@ typedef struct __GLXattributeMachineRec __GLXattribute **stackPointer; } __GLXattributeMachine; +struct glx_context_vtable { + void (*bind_tex_image)(Display * dpy, + GLXDrawable drawable, + int buffer, const int *attrib_list); + void (*release_tex_image)(Display * dpy, GLXDrawable drawable, int buffer); + +}; + /** * 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. @@ -457,6 +465,8 @@ struct __GLXcontextRec unsigned long thread_id; char gl_extension_bits[__GL_EXT_BYTES]; + + const struct glx_context_vtable *vtable; }; #define __glXSetError(gc,code) \ @@ -511,6 +521,11 @@ struct __GLXscreenConfigsRec */ char *effectiveGLXexts; + /** + * Context vtable to use for direct contexts on this screen + */ + const struct glx_context_vtable *direct_context_vtable; + #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) /** * Per screen direct rendering interface functions and data. diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 34fbecf9563..16c4eef6ba8 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -62,9 +62,7 @@ static const char __glXGLXClientVendorName[] = "Mesa Project and SGI"; static const char __glXGLXClientVersion[] = "1.4"; - - -/****************************************************************************/ +static const struct glx_context_vtable glx_indirect_context_vtable; #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) @@ -378,13 +376,10 @@ CreateContext(Display * dpy, int generic_id, unsigned code, int renderType, int screen) { GLXContext gc; -#ifdef GLX_DIRECT_RENDERING -#ifdef GLX_USE_APPLEGL + __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); +#if defined(GLX_DIRECT_RENDERING) && defined(GLX_USE_APPLEGL) int errorcode; bool x11error; -#else - __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); -#endif #endif if (dpy == NULL) @@ -411,6 +406,11 @@ CreateContext(Display * dpy, int generic_id, } #endif + if (gc->driContext != NULL) + gc->vtable = psc->direct_context_vtable; + else + gc->vtable = &glx_indirect_context_vtable; + LockDisplay(dpy); switch (code) { case X_GLXCreateContext: { @@ -2997,10 +2997,10 @@ __glXCopySubBufferMESA(Display * dpy, GLXDrawable drawable, /** * GLX_EXT_texture_from_pixmap */ -/*@{*/ static void -__glXBindTexImageEXT(Display * dpy, - GLXDrawable drawable, int buffer, const int *attrib_list) +glx_indirect_bind_tex_image(Display * dpy, + GLXDrawable drawable, + int buffer, const int *attrib_list) { xGLXVendorPrivateReq *req; GLXContext gc = __glXGetCurrentContext(); @@ -3011,37 +3011,12 @@ __glXBindTexImageEXT(Display * dpy, CARD8 opcode; unsigned int i; - if (gc == NULL) - return; - i = 0; if (attrib_list) { while (attrib_list[i * 2] != None) i++; } -#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - if (gc->driContext) { - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); - - if (pdraw != NULL) { - if (pdraw->psc->texBuffer->base.version >= 2 && - pdraw->psc->texBuffer->setTexBuffer2 != NULL) { - (*pdraw->psc->texBuffer->setTexBuffer2) (gc->__driContext, - pdraw->textureTarget, - pdraw->textureFormat, - pdraw->driDrawable); - } - else { - (*pdraw->psc->texBuffer->setTexBuffer) (gc->__driContext, - pdraw->textureTarget, - pdraw->driDrawable); - } - } - return; - } -#endif - opcode = __glXSetupForCommand(dpy); if (!opcode) return; @@ -3076,7 +3051,7 @@ __glXBindTexImageEXT(Display * dpy, } static void -__glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer) +glx_indirect_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer) { xGLXVendorPrivateReq *req; GLXContext gc = __glXGetCurrentContext(); @@ -3084,9 +3059,6 @@ __glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer) INT32 *buffer_ptr; CARD8 opcode; - if ((gc == NULL) || GC_IS_DIRECT(gc)) - return; - opcode = __glXSetupForCommand(dpy); if (!opcode) return; @@ -3108,6 +3080,35 @@ __glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer) SyncHandle(); } +static const struct glx_context_vtable glx_indirect_context_vtable = { + glx_indirect_bind_tex_image, + glx_indirect_release_tex_image, +}; + +/*@{*/ +static void +__glXBindTexImageEXT(Display * dpy, + GLXDrawable drawable, int buffer, const int *attrib_list) +{ + GLXContext gc = __glXGetCurrentContext(); + + if (gc == NULL || gc->vtable->bind_tex_image == NULL) + return; + + gc->vtable->bind_tex_image(dpy, drawable, buffer, attrib_list); +} + +static void +__glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer) +{ + GLXContext gc = __glXGetCurrentContext(); + + if (gc == NULL || gc->vtable->release_tex_image == NULL) + return; + + gc->vtable->release_tex_image(dpy, drawable, buffer); +} + /*@}*/ #endif /* GLX_USE_APPLEGL */ |