GLX: Implement support for TTM BO based TFP when available.
This commit is contained in:
parent
879515b139
commit
0ffb6a3ad0
|
@ -75,6 +75,7 @@ struct __GLXDRIscreen {
|
|||
|
||||
__DRIcopySubBufferExtension *copySubBuffer;
|
||||
__DRIswapControlExtension *swapControl;
|
||||
__DRItexBufferExtension *texBuffer;
|
||||
|
||||
unsigned char glx_enable_bits[__GLX_EXT_BYTES];
|
||||
};
|
||||
|
@ -213,6 +214,55 @@ __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;
|
||||
}
|
||||
|
||||
static int
|
||||
__glXDRIreleaseTexImage(__GLXcontext *baseContext,
|
||||
int buffer,
|
||||
__GLXdrawable *pixmap)
|
||||
{
|
||||
/* FIXME: Just unbind the texture? */
|
||||
return Success;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int
|
||||
__glXDRIbindTexImage(__GLXcontext *baseContext,
|
||||
int buffer,
|
||||
|
@ -229,6 +279,8 @@ __glXDRIreleaseTexImage(__GLXcontext *baseContext,
|
|||
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 */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,6 +348,14 @@ DRI2Connect(ScreenPtr pScreen, int *fd, const char **driverName,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
DRI2GetPixmapHandle(PixmapPtr pPixmap, unsigned int *flags)
|
||||
{
|
||||
DRI2ScreenPtr ds = DRI2GetScreen(pPixmap->drawable.pScreen);
|
||||
|
||||
return ds->getPixmapHandle(pPixmap, flags);
|
||||
}
|
||||
|
||||
static void *
|
||||
DRI2SetupSAREA(ScreenPtr pScreen, size_t driverSareaSize)
|
||||
{
|
||||
|
|
|
@ -62,6 +62,9 @@ Bool DRI2Connect(ScreenPtr pScreen,
|
|||
int *ddxPatch,
|
||||
unsigned int *sareaHandle);
|
||||
|
||||
unsigned int DRI2GetPixmapHandle(PixmapPtr pPixmap,
|
||||
unsigned int *flags);
|
||||
|
||||
void DRI2Lock(ScreenPtr pScreen);
|
||||
void DRI2Unlock(ScreenPtr pScreen);
|
||||
|
||||
|
|
Loading…
Reference in New Issue