glamor: Resolved merge conflictions with Kristian's glamor-ddx patch.

This commit is contained in:
Zhigang Gong 2011-05-11 15:54:50 +08:00
parent 49bf0e301e
commit 26ff612171
4 changed files with 41 additions and 22 deletions

View File

@ -2185,6 +2185,7 @@ hw/xfree86/utils/Makefile
hw/xfree86/utils/man/Makefile hw/xfree86/utils/man/Makefile
hw/xfree86/utils/cvt/Makefile hw/xfree86/utils/cvt/Makefile
hw/xfree86/utils/gtf/Makefile hw/xfree86/utils/gtf/Makefile
hw/xfree86/glamor/Makefile
hw/dmx/config/Makefile hw/dmx/config/Makefile
hw/dmx/config/man/Makefile hw/dmx/config/man/Makefile
hw/dmx/doc/Makefile hw/dmx/doc/Makefile

View File

@ -59,25 +59,54 @@ glamor_get_drawable_pixmap(DrawablePtr drawable)
return (PixmapPtr)drawable; return (PixmapPtr)drawable;
} }
void
glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
{
ScreenPtr screen = pixmap->drawable.pScreen;
glamor_pixmap_private *pixmap_priv;
pixmap_priv = glamor_get_pixmap_private(pixmap);
pixmap_priv->tex = tex;
/* Create a framebuffer object wrapping the texture so that we can render
* to it.
*/
glGenFramebuffersEXT(1, &pixmap_priv->fb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D,
pixmap_priv->tex,
0);
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0,
(((w * pixmap->drawable.bitsPerPixel +
7) / 8) + 3) & ~3,
NULL);
}
static PixmapPtr static PixmapPtr
glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
unsigned int usage) unsigned int usage)
{ {
PixmapPtr pixmap; PixmapPtr pixmap;
glamor_pixmap_private *pixmap_priv, *newpixmap_priv;
GLenum format; GLenum format;
GLuint tex;
if (w > 32767 || h > 32767) if (w > 32767 || h > 32767)
return NullPixmap; return NullPixmap;
pixmap = fbCreatePixmap (screen, 0, 0, depth, usage); pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
if (dixAllocatePrivates(pixmap->devPrivates, PRIVATE_PIXMAP) != TRUE) { if (dixAllocatePrivates(pixmap->devPrivates, PRIVATE_PIXMAP) != TRUE) {
fbDestroyPixmap(pixmap); fbDestroyPixmap(pixmap);
ErrorF("Fail to allocate privates for PIXMAP.\n"); ErrorF("Fail to allocate privates for PIXMAP.\n");
return NullPixmap; return NullPixmap;
} }
pixmap_priv = glamor_get_pixmap_private(pixmap);
assert(pixmap_priv != NULL);
if (w == 0 || h == 0) if (w == 0 || h == 0)
return pixmap; return pixmap;
@ -95,28 +124,15 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
/* Create the texture used to store the pixmap's data. */ /* Create the texture used to store the pixmap's data. */
glGenTextures(1, &pixmap_priv->tex); glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, pixmap_priv->tex); glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
format, GL_UNSIGNED_BYTE, NULL); format, GL_UNSIGNED_BYTE, NULL);
/* Create a framebuffer object wrapping the texture so that we can render glamor_set_pixmap_texture(pixmap, w, h, tex);
** to it.
**/
glGenFramebuffersEXT(1, &pixmap_priv->fb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D,
pixmap_priv->tex,
0);
screen->ModifyPixmapHeader(pixmap, w, h, depth, 0,
(((w * pixmap->drawable.bitsPerPixel +
7) / 8) + 3) & ~3,
NULL);
return pixmap; return pixmap;
} }
@ -149,6 +165,7 @@ Bool
glamor_init(ScreenPtr screen) glamor_init(ScreenPtr screen)
{ {
glamor_screen_private *glamor_priv; glamor_screen_private *glamor_priv;
#ifdef RENDER #ifdef RENDER
PictureScreenPtr ps = GetPictureScreenIfSet(screen); PictureScreenPtr ps = GetPictureScreenIfSet(screen);
#endif #endif
@ -173,7 +190,6 @@ glamor_init(ScreenPtr screen)
screen->myNum); screen->myNum);
} }
glewInit(); glewInit();
if (!GLEW_EXT_framebuffer_object) { if (!GLEW_EXT_framebuffer_object) {
@ -196,13 +212,13 @@ glamor_init(ScreenPtr screen)
ErrorF("GL_EXT_bgra required\n"); ErrorF("GL_EXT_bgra required\n");
goto fail; goto fail;
} }
if (!RegisterBlockAndWakeupHandlers(glamor_block_handler, if (!RegisterBlockAndWakeupHandlers(glamor_block_handler,
glamor_wakeup_handler, glamor_wakeup_handler,
NULL)) { NULL)) {
goto fail; goto fail;
} }
glamor_priv->saved_close_screen = screen->CloseScreen; glamor_priv->saved_close_screen = screen->CloseScreen;
screen->CloseScreen = glamor_close_screen; screen->CloseScreen = glamor_close_screen;

View File

@ -37,5 +37,7 @@
#endif /* GLAMOR_H */ #endif /* GLAMOR_H */
Bool glamor_init(ScreenPtr screen); Bool glamor_init(ScreenPtr screen);
void glamor_fini(ScreenPtr screen); void glamor_fini(ScreenPtr screen);
void glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex);

View File

@ -1118,7 +1118,7 @@ videoPtrToDriverList(struct pci_device *dev,
} else if (dev->device_id == 0x8108) { } else if (dev->device_id == 0x8108) {
break; /* "hooray" for poulsbo */ break; /* "hooray" for poulsbo */
} else { } else {
driverList[0] = "intel"; driverList[0] = "glamor";
} }
break; break;
case 0x102b: driverList[0] = "mga"; break; case 0x102b: driverList[0] = "mga"; break;