summaryrefslogtreecommitdiff
path: root/GL/glx
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-02-14 22:20:56 -0500
committerKristian Høgsberg <krh@redhat.com>2008-02-14 22:20:56 -0500
commit0ffb6a3ad010e80fe8f973fc228d549f9dd3effd (patch)
treec1a9057f27649a79248de555bc9e8d3d0071832d /GL/glx
parent879515b1399f87a47010532af70f34b9b09e2a9b (diff)
GLX: Implement support for TTM BO based TFP when available.
Diffstat (limited to 'GL/glx')
-rw-r--r--GL/glx/glxdri2.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/GL/glx/glxdri2.c b/GL/glx/glxdri2.c
index d8df604c2..d1c8d417e 100644
--- a/GL/glx/glxdri2.c
+++ b/GL/glx/glxdri2.c
@@ -75,6 +75,7 @@ struct __GLXDRIscreen {
__DRIcopySubBufferExtension *copySubBuffer;
__DRIswapControlExtension *swapControl;
+ __DRItexBufferExtension *texBuffer;
unsigned char glx_enable_bits[__GLX_EXT_BYTES];
};
@@ -213,11 +214,41 @@ __glXDRIcontextForceCurrent(__GLXcontext *baseContext)
&read->driDrawable);
}
+#ifdef __DRI_TEX_BUFFER
+
+#define isPowerOfTwo(n) (((n) & ((n) - 1 )) == 0)
+
static int
__glXDRIbindTexImage(__GLXcontext *baseContext,
int buffer,
__GLXdrawable *glxPixmap)
{
+ ScreenPtr pScreen = glxPixmap->pDraw->pScreen;
+ __GLXDRIscreen * const screen = (__GLXDRIscreen *) glxGetScreen(pScreen);
+ PixmapPtr pixmap;
+ __GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
+ unsigned int flags;
+ int w, h, target;
+
+ if (screen->texBuffer == NULL)
+ return Success;
+
+ pixmap = (PixmapPtr) glxPixmap->pDraw;
+ w = pixmap->drawable.width;
+ h = pixmap->drawable.height;
+
+ if (!isPowerOfTwo(w) || !isPowerOfTwo(h))
+ target = GL_TEXTURE_RECTANGLE_ARB;
+ else
+ target = GL_TEXTURE_2D;
+
+ screen->texBuffer->setTexBuffer(&context->driContext,
+ target,
+ DRI2GetPixmapHandle(pixmap, &flags),
+ pixmap->drawable.depth,
+ pixmap->devKind,
+ h);
+
return Success;
}
@@ -226,9 +257,30 @@ __glXDRIreleaseTexImage(__GLXcontext *baseContext,
int buffer,
__GLXdrawable *pixmap)
{
+ /* FIXME: Just unbind the texture? */
return Success;
}
+#else
+
+static int
+__glXDRIbindTexImage(__GLXcontext *baseContext,
+ int buffer,
+ __GLXdrawable *glxPixmap)
+{
+ return Success;
+}
+
+static int
+__glXDRIreleaseTexImage(__GLXcontext *baseContext,
+ int buffer,
+ __GLXdrawable *pixmap)
+{
+ return Success;
+}
+
+#endif
+
static __GLXtextureFromPixmap __glXDRItextureFromPixmap = {
__glXDRIbindTexImage,
__glXDRIreleaseTexImage
@@ -434,6 +486,14 @@ initializeExtensions(__GLXDRIscreen *screen)
LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control\n");
}
#endif
+
+#ifdef __DRI_TEX_BUFFER
+ if (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0) {
+ screen->texBuffer = (__DRItexBufferExtension *) extensions[i];
+ /* GLX_EXT_texture_from_pixmap is always enabled. */
+ LogMessage(X_INFO, "AIGLX: GLX_EXT_texture_from_pixmap backed by buffer objects\n");
+ }
+#endif
/* Ignore unknown extensions */
}
}