GLX_EXT_texture_from_pixmap: Use client provided texture target when available.
This prevents situations where the server doesn't use the target the client thinks it does, usually resulting in the texture being sampled as all white.
This commit is contained in:
parent
a4197db950
commit
17cb4f64e3
|
@ -1260,13 +1260,15 @@ static int ValidateCreateDrawable(ClientPtr client,
|
||||||
** Create a GLX Pixmap from an X Pixmap.
|
** Create a GLX Pixmap from an X Pixmap.
|
||||||
*/
|
*/
|
||||||
int DoCreateGLXPixmap(__GLXclientState *cl, XID fbconfigId,
|
int DoCreateGLXPixmap(__GLXclientState *cl, XID fbconfigId,
|
||||||
GLuint screenNum, XID pixmapId, XID glxPixmapId)
|
GLuint screenNum, XID pixmapId, XID glxPixmapId,
|
||||||
|
CARD32 *attribs, CARD32 numAttribs)
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
DrawablePtr pDraw;
|
DrawablePtr pDraw;
|
||||||
__GLXpixmap *pGlxPixmap;
|
__GLXpixmap *pGlxPixmap;
|
||||||
__GLcontextModes *modes;
|
__GLcontextModes *modes;
|
||||||
int retval;
|
GLenum target = 0;
|
||||||
|
int retval, i;
|
||||||
|
|
||||||
retval = ValidateCreateDrawable (client, screenNum, fbconfigId,
|
retval = ValidateCreateDrawable (client, screenNum, fbconfigId,
|
||||||
pixmapId, glxPixmapId,
|
pixmapId, glxPixmapId,
|
||||||
|
@ -1292,6 +1294,30 @@ int DoCreateGLXPixmap(__GLXclientState *cl, XID fbconfigId,
|
||||||
|
|
||||||
pGlxPixmap->modes = modes;
|
pGlxPixmap->modes = modes;
|
||||||
|
|
||||||
|
for (i = 0; i < numAttribs; i++) {
|
||||||
|
if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) {
|
||||||
|
switch (attribs[2 * i + 1]) {
|
||||||
|
case GLX_TEXTURE_2D_EXT:
|
||||||
|
target = GL_TEXTURE_2D;
|
||||||
|
break;
|
||||||
|
case GLX_TEXTURE_RECTANGLE_EXT:
|
||||||
|
target = GL_TEXTURE_RECTANGLE_ARB;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target) {
|
||||||
|
int w = pDraw->width, h = pDraw->height;
|
||||||
|
|
||||||
|
if (h & (h - 1) || w & (w - 1))
|
||||||
|
target = GL_TEXTURE_RECTANGLE_ARB;
|
||||||
|
else
|
||||||
|
target = GL_TEXTURE_2D;
|
||||||
|
}
|
||||||
|
|
||||||
|
pGlxPixmap->target = target;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Bump the ref count on the X pixmap so it won't disappear.
|
** Bump the ref count on the X pixmap so it won't disappear.
|
||||||
*/
|
*/
|
||||||
|
@ -1304,14 +1330,16 @@ int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
|
||||||
{
|
{
|
||||||
xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
|
xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
|
||||||
return DoCreateGLXPixmap( cl, req->visual, req->screen,
|
return DoCreateGLXPixmap( cl, req->visual, req->screen,
|
||||||
req->pixmap, req->glxpixmap );
|
req->pixmap, req->glxpixmap, NULL, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc)
|
int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc)
|
||||||
{
|
{
|
||||||
xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
|
xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
|
||||||
return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
|
return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
|
||||||
req->pixmap, req->glxpixmap );
|
req->pixmap, req->glxpixmap,
|
||||||
|
(CARD32*)(req + 1),
|
||||||
|
req->numAttribs );
|
||||||
}
|
}
|
||||||
|
|
||||||
int __glXDisp_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
|
int __glXDisp_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
|
||||||
|
@ -1319,7 +1347,7 @@ int __glXDisp_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
|
||||||
xGLXCreateGLXPixmapWithConfigSGIXReq *req =
|
xGLXCreateGLXPixmapWithConfigSGIXReq *req =
|
||||||
(xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
|
(xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
|
||||||
return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
|
return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
|
||||||
req->pixmap, req->glxpixmap );
|
req->pixmap, req->glxpixmap, NULL, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1681,7 +1709,6 @@ DoGetDrawableAttributes(__GLXclientState *cl, XID drawId)
|
||||||
xGLXGetDrawableAttributesReply reply;
|
xGLXGetDrawableAttributesReply reply;
|
||||||
CARD32 attributes[4];
|
CARD32 attributes[4];
|
||||||
int numAttribs;
|
int numAttribs;
|
||||||
PixmapPtr pixmap;
|
|
||||||
|
|
||||||
glxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes);
|
glxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes);
|
||||||
if (!glxPixmap) {
|
if (!glxPixmap) {
|
||||||
|
@ -1696,19 +1723,11 @@ DoGetDrawableAttributes(__GLXclientState *cl, XID drawId)
|
||||||
reply.numAttribs = numAttribs;
|
reply.numAttribs = numAttribs;
|
||||||
|
|
||||||
attributes[0] = GLX_TEXTURE_TARGET_EXT;
|
attributes[0] = GLX_TEXTURE_TARGET_EXT;
|
||||||
|
attributes[1] = glxPixmap->target == GL_TEXTURE_2D ? GLX_TEXTURE_2D_EXT :
|
||||||
|
GLX_TEXTURE_RECTANGLE_EXT;
|
||||||
attributes[2] = GLX_Y_INVERTED_EXT;
|
attributes[2] = GLX_Y_INVERTED_EXT;
|
||||||
attributes[3] = GL_FALSE;
|
attributes[3] = GL_FALSE;
|
||||||
|
|
||||||
/* XXX this is merely less wrong, see fdo bug #8991 */
|
|
||||||
pixmap = (PixmapPtr) glxPixmap->pDraw;
|
|
||||||
if ((pixmap->drawable.width & (pixmap->drawable.width - 1)) ||
|
|
||||||
(pixmap->drawable.height & (pixmap->drawable.height - 1))
|
|
||||||
/* || strstr(CALL_GetString(GL_EXTENSIONS,
|
|
||||||
"GL_ARB_texture_non_power_of_two")) */)
|
|
||||||
attributes[1] = GLX_TEXTURE_RECTANGLE_EXT;
|
|
||||||
else
|
|
||||||
attributes[1] = GLX_TEXTURE_2D_EXT;
|
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
__glXSwapGetDrawableAttributesReply(client, &reply, attributes);
|
__glXSwapGetDrawableAttributesReply(client, &reply, attributes);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -266,7 +266,7 @@ int __glXDispSwap_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
|
||||||
__GLX_SWAP_INT(&req->glxpixmap);
|
__GLX_SWAP_INT(&req->glxpixmap);
|
||||||
|
|
||||||
return DoCreateGLXPixmap( cl, req->visual, req->screen,
|
return DoCreateGLXPixmap( cl, req->visual, req->screen,
|
||||||
req->pixmap, req->glxpixmap );
|
req->pixmap, req->glxpixmap, NULL, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc)
|
int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc)
|
||||||
|
@ -279,9 +279,12 @@ int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc)
|
||||||
__GLX_SWAP_INT(&req->fbconfig);
|
__GLX_SWAP_INT(&req->fbconfig);
|
||||||
__GLX_SWAP_INT(&req->pixmap);
|
__GLX_SWAP_INT(&req->pixmap);
|
||||||
__GLX_SWAP_INT(&req->glxpixmap);
|
__GLX_SWAP_INT(&req->glxpixmap);
|
||||||
|
__GLX_SWAP_INT(&req->numAttribs);
|
||||||
|
|
||||||
return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
|
return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
|
||||||
req->pixmap, req->glxpixmap );
|
req->pixmap, req->glxpixmap,
|
||||||
|
(CARD32*)(req + 1),
|
||||||
|
req->numAttribs );
|
||||||
}
|
}
|
||||||
|
|
||||||
int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
|
int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
|
||||||
|
@ -297,7 +300,7 @@ int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc
|
||||||
__GLX_SWAP_INT(&req->glxpixmap);
|
__GLX_SWAP_INT(&req->glxpixmap);
|
||||||
|
|
||||||
return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
|
return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
|
||||||
req->pixmap, req->glxpixmap );
|
req->pixmap, req->glxpixmap, NULL, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int __glXDispSwap_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
|
int __glXDispSwap_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
|
||||||
|
|
|
@ -54,6 +54,7 @@ typedef struct {
|
||||||
ScreenPtr pScreen;
|
ScreenPtr pScreen;
|
||||||
Bool idExists;
|
Bool idExists;
|
||||||
int refcnt;
|
int refcnt;
|
||||||
|
GLenum target;
|
||||||
#ifdef XF86DRI
|
#ifdef XF86DRI
|
||||||
DamagePtr pDamage;
|
DamagePtr pDamage;
|
||||||
__DRIcontext *pDRICtx;
|
__DRIcontext *pDRICtx;
|
||||||
|
|
|
@ -375,7 +375,7 @@ __glXDRIbindTexImage(__GLXcontext *baseContext,
|
||||||
RegionPtr pRegion = NULL;
|
RegionPtr pRegion = NULL;
|
||||||
PixmapPtr pixmap;
|
PixmapPtr pixmap;
|
||||||
int w, h, bpp, override = 0;
|
int w, h, bpp, override = 0;
|
||||||
GLenum target, format, type;
|
GLenum format, type;
|
||||||
ScreenPtr pScreen = glxPixmap->pScreen;
|
ScreenPtr pScreen = glxPixmap->pScreen;
|
||||||
__GLXDRIscreen * const screen =
|
__GLXDRIscreen * const screen =
|
||||||
(__GLXDRIscreen *) __glXgetActiveScreen(pScreen->myNum);
|
(__GLXDRIscreen *) __glXgetActiveScreen(pScreen->myNum);
|
||||||
|
@ -384,11 +384,6 @@ __glXDRIbindTexImage(__GLXcontext *baseContext,
|
||||||
w = pixmap->drawable.width;
|
w = pixmap->drawable.width;
|
||||||
h = pixmap->drawable.height;
|
h = pixmap->drawable.height;
|
||||||
|
|
||||||
if (h & (h - 1) || w & (w - 1))
|
|
||||||
target = GL_TEXTURE_RECTANGLE_ARB;
|
|
||||||
else
|
|
||||||
target = GL_TEXTURE_2D;
|
|
||||||
|
|
||||||
if (screen->texOffsetStart && screen->driScreen.setTexOffset) {
|
if (screen->texOffsetStart && screen->driScreen.setTexOffset) {
|
||||||
__GLXpixmap **texOffsetOverride = screen->texOffsetOverride;
|
__GLXpixmap **texOffsetOverride = screen->texOffsetOverride;
|
||||||
int i, firstEmpty = 16, texname;
|
int i, firstEmpty = 16, texname;
|
||||||
|
@ -416,7 +411,7 @@ alreadyin:
|
||||||
|
|
||||||
glxPixmap->pDRICtx = &((__GLXDRIcontext*)baseContext)->driContext;
|
glxPixmap->pDRICtx = &((__GLXDRIcontext*)baseContext)->driContext;
|
||||||
|
|
||||||
CALL_GetIntegerv(GET_DISPATCH(), (target == GL_TEXTURE_2D ?
|
CALL_GetIntegerv(GET_DISPATCH(), (glxPixmap->target == GL_TEXTURE_2D ?
|
||||||
GL_TEXTURE_BINDING_2D :
|
GL_TEXTURE_BINDING_2D :
|
||||||
GL_TEXTURE_BINDING_RECTANGLE_NV,
|
GL_TEXTURE_BINDING_RECTANGLE_NV,
|
||||||
&texname));
|
&texname));
|
||||||
|
@ -481,7 +476,7 @@ nooverride:
|
||||||
pixmap->drawable.y) );
|
pixmap->drawable.y) );
|
||||||
|
|
||||||
CALL_TexImage2D( GET_DISPATCH(),
|
CALL_TexImage2D( GET_DISPATCH(),
|
||||||
(target,
|
(glxPixmap->target,
|
||||||
0,
|
0,
|
||||||
bpp == 4 ? 4 : 3,
|
bpp == 4 ? 4 : 3,
|
||||||
pixmap->drawable.width,
|
pixmap->drawable.width,
|
||||||
|
@ -511,7 +506,7 @@ nooverride:
|
||||||
pixmap->drawable.y + p[i].y1) );
|
pixmap->drawable.y + p[i].y1) );
|
||||||
|
|
||||||
CALL_TexSubImage2D( GET_DISPATCH(),
|
CALL_TexSubImage2D( GET_DISPATCH(),
|
||||||
(target,
|
(glxPixmap->target,
|
||||||
0,
|
0,
|
||||||
p[i].x1, p[i].y1,
|
p[i].x1, p[i].y1,
|
||||||
p[i].x2 - p[i].x1, p[i].y2 - p[i].y1,
|
p[i].x2 - p[i].x1, p[i].y2 - p[i].y1,
|
||||||
|
|
|
@ -80,7 +80,8 @@ extern int DoGetFBConfigs(__GLXclientState *cl, unsigned screen,
|
||||||
extern int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
|
extern int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
|
||||||
GLXContextID shareList, VisualID visual, GLuint screen, GLboolean isDirect);
|
GLXContextID shareList, VisualID visual, GLuint screen, GLboolean isDirect);
|
||||||
extern int DoCreateGLXPixmap(__GLXclientState *cl, XID fbconfigId,
|
extern int DoCreateGLXPixmap(__GLXclientState *cl, XID fbconfigId,
|
||||||
GLuint screenNum, XID pixmapId, XID glxpixmapId);
|
GLuint screenNum, XID pixmapId, XID glxpixmapId, CARD32 *attribs,
|
||||||
|
CARD32 numAttribs);
|
||||||
extern int DoDestroyPixmap(__GLXclientState *cl, XID glxpixmapId);
|
extern int DoDestroyPixmap(__GLXclientState *cl, XID glxpixmapId);
|
||||||
|
|
||||||
extern int DoQueryContext(__GLXclientState *cl, GLXContextID gcId);
|
extern int DoQueryContext(__GLXclientState *cl, GLXContextID gcId);
|
||||||
|
|
Loading…
Reference in New Issue