glamor : Add dynamic texture uploading feature.

Major refactoring.
1. Rewrite the pixmap texture uploading and downloading functions.
   Add some new functions for both the prepare/finish access and
   the new performance feature dynamic texture uploading, which
   could download and upload the current image to/from a private
   texture/fbo. In the uploading or downloading phase, we need to
   handle two things:
   The first is the yInverted option, If it set, then we don't need
   to flip y. If not set, if it is from a dynamic texture uploading
   then we don't need to flip either if the current drawing process
   will flip it latter. If it is from finish_access, then we must
   flip the y axis.

   The second thing is the alpha channel hanlding, if the pixmap's
   format is something like x8a8r8g8, x1r5g5b5 which means it doesn't
   has alpha channel, but it do has those extra bits. Then we need to
   wire those bits to 1.

2. Add almost all the required picture format support.
   This is not as trivial as it looks like. The previous implementation
   only support GL_a8,GL_a8r8g8b8,GL_x8r8g8b8. All the other format,
   we have to fallback to cpu. The reason why we can't simply add those
   other color format is because the exists of picture. one drawable
   pixmap may has one or even more container pictures. The drawable pixmap's
   depth can't map to a specified color format, for example depth 16 can
   mapped to r5g6b5, x1r5g5b5, a1r5g5b5, or even b5g6r5. So we can't get
   get the color format just from the depth value. But the pixmap do not
   has a pict_format element. We have to make a new one in the pixmap
   private data structure. Reroute the CreatePicture to glamor_create_picture
   and then store the picture's format to the pixmap's private structure.

   This is not an ideal solution, as there may be more than one pictures
   refer to the same pixmap. Then we will have trouble. There is an example
   in glamor_composite_with_shader. The source and mask often share the
   same pixmap, but use different picture format. Our current solution is to
   combine those two different picture formats to one which will not lose any
   data. Then change the source's format to this new format and then upload
   the pixmap to texture once. It works. If we fail to find a matched new
   format then we fallback.

   There still is a potential problem, if two pictures refer to the same
   pixmap, and one of them destroy the picture, but the other still remained
   to be used latter. We don't handle that situation currently. To be fixed.

3. Dynamic texture uploading.
   This is a performance feature. Although we don't like the client to hold
   a pixmap data to shared memory and we can't accelerate it. And even worse,
   we may need to fallback all the required pixmaps to cpu memory and then
   process them on CPU. This feature is to mitigate this penalty. When the
   target pixmap has a valid gl fbo attached to it. But the other pixmaps are
   not. Then it will be more efficient to upload the other pixmaps to GPU and
   then do the blitting or rendering on GPU than fallback all the pixmaps to CPU.
   To enable this feature, I experienced a significant performance improvement
   in the Game "Mines" :).

4. Debug facility.
   Modify the debug output mechanism. Now add a new macro:
   glamor_debug_output(_level_, _format_,...) to conditional output some messages
   according to the environment variable GLAMOR_DEBUG. We have the following
   levels currently.
    exports GLAMOR_DEBUG to 3 will enable all the above messages.

5. Changes in pixmap private data structure.
   Add some for the full color format supports and relate it to the pictures which
   already described. Also Add the following new elements:
   gl_fbo - to indicates whether this pixmap is on gpu only.
   gl_tex - to indicates whether the tex is valid and is containing the pixmap's
            image originally.
   As we bring the dynamic pixmap uploading feature, so a cpu memory pixmap may
   also has a valid fbo or tex attached to it. So we will have to use the above
   new element to check it true type.

After this commit, we can pass the rendercheck testing for all the picture formats.
And is much much fater than fallback to cpu when doing rendercheck testing.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
Zhigang Gong 2011-06-21 18:31:11 +08:00
parent ba6dd8aa49
commit 355334fcd9
21 changed files with 2676 additions and 1964 deletions

View File

@ -31,6 +31,8 @@ libglamor_la_SOURCES = \
glamor_render.c \
glamor_tile.c \
glamor_triangles.c\
glamor_pixmap.c\
glamor_picture.c\
glamor.h
libglamor_la_LIBADD = \
glu3/libglu3.la

View File

@ -59,8 +59,7 @@ glamor_get_drawable_pixmap(DrawablePtr drawable)
return (PixmapPtr)drawable;
}
void
static void
glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
{
ScreenPtr screen = pixmap->drawable.pScreen;
@ -73,6 +72,8 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
/* Create a framebuffer object wrapping the texture so that we can render
* to it.
*/
pixmap_priv->gl_fbo = 1;
pixmap_priv->gl_tex = 1;
glGenFramebuffersEXT(1, &pixmap_priv->fb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
@ -87,13 +88,24 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
NULL);
}
/* Set screen pixmap. If tex equal to 0, means it is called from ephyr. */
void
glamor_set_screen_pixmap_texture(ScreenPtr screen, int w, int h, unsigned int tex)
{
PixmapPtr pixmap = screen->GetScreenPixmap(screen);
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
glamor_set_pixmap_texture(pixmap, w, h, tex);
glamor_priv->screen_fbo = pixmap_priv->fb;
}
#define GLAMOR_PIXMAP_MEMORY 0
#define GLAMOR_PIXMAP_TEXTURE 1
/* XXX For the screen pixmap, the w and h maybe 0,0 too, but it should
* be GLAMOR_GL pixmap. Now, all the pixmap will have a valid pixmap_priv.
* This is not good enough. After we can identify which is the screen
* pixmap and which is not, then we can split the pixmap to exclusive
* two types GLAMOR_GL and GLAMOR_FB, and for those GLAMOR_FB pixmaps,
* we don't need to allocate pixmap_priv. */
static PixmapPtr
glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
@ -102,22 +114,24 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
PixmapPtr pixmap;
GLenum format;
GLuint tex;
enum glamor_pixmap_type type = GLAMOR_GL;
int type = GLAMOR_PIXMAP_TEXTURE;
glamor_pixmap_private *pixmap_priv;
if (w > 32767 || h > 32767)
return NullPixmap;
if (w > MAX_WIDTH || h > MAX_HEIGHT || ( depth == 1 && w != 0 && h != 0)) {
if (!glamor_check_fbo_width_height(w,h) || !glamor_check_fbo_depth(depth)) {
/* MESA can only support upto MAX_WIDTH*MAX_HEIGHT fbo.
If we exceed such limitation, we have to use framebuffer.*/
type = GLAMOR_FB;
type = GLAMOR_PIXMAP_MEMORY;
pixmap = fbCreatePixmap (screen, w, h, depth, usage);
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0,
(((w * pixmap->drawable.bitsPerPixel +
7) / 8) + 3) & ~3,
NULL);
glamor_fallback("fallback to software fb for pixmap %p , %d x %d depth %d\n", pixmap, w, h, depth);
glamor_fallback("choose cpu memory for pixmap %p ,"
" %d x %d depth %d\n", pixmap, w, h, depth);
} else
pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
@ -127,7 +141,10 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
return NullPixmap;
}
if (w == 0 || h == 0 || type == GLAMOR_FB)
pixmap_priv = glamor_get_pixmap_private(pixmap);
pixmap_priv->container = pixmap;
if (w == 0 || h == 0 || type == GLAMOR_PIXMAP_MEMORY)
return pixmap;
/* We should probably take advantage of ARB_fbo's allowance of GL_ALPHA.
@ -136,7 +153,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
switch (depth) {
case 24:
format = GL_RGB;
break;
break;
default:
format = GL_RGBA;
break;
@ -154,13 +171,51 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
return pixmap;
}
/**
* For Xephyr use only. set up the screen pixmap to correct state.
**/
static PixmapPtr
glamor_create_screen_pixmap(ScreenPtr screen, int w, int h, int depth,
unsigned int usage)
{
PixmapPtr pixmap;
glamor_pixmap_private *pixmap_priv;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
assert(w ==0 && h == 0);
glamor_priv->screen_fbo = 0;
pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
if (dixAllocatePrivates(&pixmap->devPrivates, PRIVATE_PIXMAP) != TRUE) {
fbDestroyPixmap(pixmap);
ErrorF("Fail to allocate privates for PIXMAP.\n");
return NullPixmap;
}
pixmap_priv = glamor_get_pixmap_private(pixmap);
pixmap_priv->tex = 0;
pixmap_priv->gl_fbo = 1;
pixmap_priv->gl_tex = 1;
screen->CreatePixmap = glamor_create_pixmap;
return pixmap;
}
static Bool
glamor_destroy_pixmap(PixmapPtr pixmap)
{
if (pixmap->refcnt == 1) {
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
glDeleteFramebuffersEXT(1, &pixmap_priv->fb);
glDeleteTextures(1, &pixmap_priv->tex);
if (pixmap_priv->fb)
glDeleteFramebuffersEXT(1, &pixmap_priv->fb);
if (pixmap_priv->tex)
glDeleteTextures(1, &pixmap_priv->tex);
if (pixmap_priv->pbo)
glDeleteBuffersARB(1, &pixmap_priv->pbo);
}
return fbDestroyPixmap(pixmap);
@ -177,6 +232,18 @@ glamor_wakeup_handler(void *data, int result, void *last_select_mask)
{
}
static void
glamor_set_debug_level(int *debug_level)
{
char *debug_level_string;
debug_level_string = getenv("GLAMOR_DEBUG");
if (debug_level_string && sscanf(debug_level_string, "%d", debug_level) == 1)
return;
*debug_level = 0;
}
int glamor_debug_level;
/** Set up glamor for an already-configured GL context. */
Bool
glamor_init(ScreenPtr screen, unsigned int flags)
@ -186,7 +253,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
#ifdef RENDER
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
#endif
if (flags & ~GLAMOR_VALID_FLAGS) {
ErrorF("glamor_init: Invalid flags %x\n", flags);
return FALSE;
@ -205,7 +271,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
LogMessage(X_WARNING,
"glamor%d: Failed to allocate screen private\n",
screen->myNum);
return FALSE;
}
dixSetPrivate(&screen->devPrivates, glamor_screen_private_key, glamor_priv);
if (!dixRegisterPrivateKey(glamor_pixmap_private_key,PRIVATE_PIXMAP,
@ -213,6 +281,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
LogMessage(X_WARNING,
"glamor%d: Failed to allocate pixmap private\n",
screen->myNum);
return FALSE;
}
glewInit();
@ -243,7 +312,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
goto fail;
}
glamor_set_debug_level(&glamor_debug_level);
glamor_priv->saved_close_screen = screen->CloseScreen;
screen->CloseScreen = glamor_close_screen;
@ -251,7 +320,11 @@ glamor_init(ScreenPtr screen, unsigned int flags)
screen->CreateGC = glamor_create_gc;
glamor_priv->saved_create_pixmap = screen->CreatePixmap;
screen->CreatePixmap = glamor_create_pixmap;
if (flags & GLAMOR_HOSTX)
screen->CreatePixmap = glamor_create_screen_pixmap;
else
screen->CreatePixmap = glamor_create_pixmap;
glamor_priv->saved_destroy_pixmap = screen->DestroyPixmap;
screen->DestroyPixmap = glamor_destroy_pixmap;
@ -281,6 +354,10 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_priv->saved_triangles = ps->Triangles;
ps->Triangles = glamor_triangles;
glamor_init_composite_shaders(screen);
glamor_priv->saved_create_picture = ps->CreatePicture;
ps->CreatePicture = glamor_create_picture;
glamor_priv->saved_destroy_picture = ps->DestroyPicture;
ps->DestroyPicture = glamor_destroy_picture;
#endif
glamor_init_solid_shader(screen);
glamor_init_tile_shader(screen);
@ -288,7 +365,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_init_finish_access_shaders(screen);
glamor_glyphs_init(screen);
return TRUE;
fail:
@ -319,6 +395,7 @@ glamor_close_screen(int idx, ScreenPtr screen)
ps->Trapezoids = glamor_priv->saved_trapezoids;
ps->Glyphs = glamor_priv->saved_glyphs;
ps->Triangles = glamor_priv->saved_triangles;
ps->CreatePicture = glamor_priv->saved_create_picture;
}
#endif
free(glamor_priv);

View File

@ -39,9 +39,10 @@
#endif /* GLAMOR_H */
#define GLAMOR_INVERTED_Y_AXIS 0x1
#define GLAMOR_VALID_FLAGS (GLAMOR_INVERTED_Y_AXIS)
#define GLAMOR_INVERTED_Y_AXIS 1
#define GLAMOR_HOSTX 2
#define GLAMOR_VALID_FLAGS (GLAMOR_INVERTED_Y_AXIS | GLAMOR_HOSTX)
Bool glamor_init(ScreenPtr screen, unsigned int flags);
void glamor_fini(ScreenPtr screen);
void glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex);
void glamor_set_screen_pixmap_texture(ScreenPtr screen, int w, int h, unsigned int tex);

View File

@ -31,7 +31,6 @@
*
* GC CopyArea implementation
*/
static Bool
glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
DrawablePtr dst,
@ -49,45 +48,36 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
int dst_x_off, dst_y_off, src_x_off, src_y_off, i;
if (src == dst) {
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_fbo_blit(): "
"src == dest\n");
glamor_delayed_fallback(screen,"src == dest\n");
return FALSE;
}
if (!GLEW_EXT_framebuffer_blit) {
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_fbo_blit(): "
"no EXT_framebuffer_blit\n");
glamor_delayed_fallback(screen,"no EXT_framebuffer_blit\n");
return FALSE;
}
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
if (src_pixmap_priv->fb == 0) {
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
if (src_pixmap != screen_pixmap) {
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_fbo_blit(): "
"no src fbo\n");
return FALSE;
}
}
if (gc) {
if (gc->alu != GXcopy) {
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_fbo_blit(): "
"non-copy ALU\n");
glamor_delayed_fallback(screen, "non-copy ALU\n");
return FALSE;
}
if (!glamor_pm_is_solid(dst, gc->planemask)) {
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_fbo_blit(): "
"non-solid planemask\n");
glamor_delayed_fallback(screen, "non-solid planemask\n");
return FALSE;
}
}
if (!glamor_set_destination_pixmap(dst_pixmap))
return FALSE;
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)) {
glamor_delayed_fallback(screen, "no src fbo\n");
return FALSE;
}
if (glamor_set_destination_pixmap(dst_pixmap)) {
return FALSE;
}
glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, src_pixmap_priv->fb);
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
@ -124,7 +114,6 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
GL_NEAREST);
}
}
return TRUE;
}
@ -142,29 +131,26 @@ glamor_copy_n_to_n_copypixels(DrawablePtr src,
glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen);
int x_off, y_off, i;
if (src != dst) {
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_copypixels(): "
"src != dest\n");
glamor_delayed_fallback(screen, "src != dest\n");
return FALSE;
}
if (gc) {
if (gc->alu != GXcopy) {
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_copypixels(): "
"non-copy ALU\n");
glamor_delayed_fallback(screen,"non-copy ALU\n");
return FALSE;
}
if (!glamor_pm_is_solid(dst, gc->planemask)) {
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_copypixels(): "
"non-solid planemask\n");
glamor_delayed_fallback(screen,"non-solid planemask\n");
return FALSE;
}
}
if (!glamor_set_destination_pixmap(dst_pixmap))
if (glamor_set_destination_pixmap(dst_pixmap)) {
glamor_delayed_fallback(screen, "dst has no fbo.\n");
return FALSE;
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glOrtho(0, dst_pixmap->drawable.width,
@ -196,7 +182,6 @@ glamor_copy_n_to_n_copypixels(DrawablePtr src,
GL_COLOR);
}
}
return TRUE;
}
@ -216,29 +201,43 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
int i;
float vertices[4][2], texcoords[4][2];
glamor_pixmap_private *src_pixmap_priv;
glamor_pixmap_private *dst_pixmap_priv;
int src_x_off, src_y_off, dst_x_off, dst_y_off;
enum glamor_pixmap_status src_status = GLAMOR_NONE;
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
if (src == dst) {
glamor_fallback("glamor_copy_n_to_n with same src/dst\n");
glamor_delayed_fallback(dst->pScreen, "same src/dst\n");
goto fail;
}
if (!src_pixmap_priv || !src_pixmap_priv->tex) {
glamor_fallback("glamor_copy_n_to_n with non-texture src\n");
goto fail;
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv)) {
glamor_delayed_fallback(dst->pScreen, "dst has no fbo.\n");
goto fail;
}
if (!glamor_set_destination_pixmap(dst_pixmap))
if (!src_pixmap_priv->gl_tex) {
#ifndef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
glamor_delayed_fallback(dst->pScreen, "src has no fbo.\n");
goto fail;
#else
/* XXX in yInverted mode we have bug here.*/
if (!glamor_priv->yInverted) goto fail;
src_status = glamor_upload_pixmap_to_texture(src_pixmap);
if (src_status != GLAMOR_UPLOAD_DONE)
goto fail;
#endif
}
if (gc) {
glamor_set_alu(gc->alu);
if (!glamor_set_planemask(dst_pixmap, gc->planemask))
goto fail;
goto fail;
}
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
dx += src_x_off;
@ -258,7 +257,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
assert(GLEW_ARB_fragment_shader);
glUseProgramObjectARB(glamor_priv->finish_access_prog);
glUseProgramObjectARB(glamor_priv->finish_access_prog[0]);
for (i = 0; i < nbox; i++) {
@ -324,23 +323,23 @@ glamor_copy_n_to_n(DrawablePtr src,
void *closure)
{
if (glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, dy)) {
glamor_clear_delayed_fallbacks(dst->pScreen);
goto done;
return;
}
if (glamor_copy_n_to_n_copypixels(src, dst, gc, box, nbox, dx, dy)) {
glamor_clear_delayed_fallbacks(dst->pScreen);
if (glamor_copy_n_to_n_copypixels(src, dst, gc, box, nbox, dx, dy)){
goto done;
return;
}
}
if (glamor_copy_n_to_n_textured(src, dst, gc, box, nbox, dx, dy)) {
glamor_clear_delayed_fallbacks(dst->pScreen);
goto done;
return;
}
glamor_report_delayed_fallbacks(src->pScreen);
glamor_report_delayed_fallbacks(dst->pScreen);
glamor_fallback("glamor_copy_area() from %p to %p (%c,%c)\n", src, dst,
glamor_fallback("from %p to %p (%c,%c)\n", src, dst,
glamor_get_drawable_location(src),
glamor_get_drawable_location(dst));
if (glamor_prepare_access(dst, GLAMOR_ACCESS_RW)) {
@ -352,6 +351,11 @@ glamor_copy_n_to_n(DrawablePtr src,
}
glamor_finish_access(dst);
}
return;
done:
glamor_clear_delayed_fallbacks(src->pScreen);
glamor_clear_delayed_fallbacks(dst->pScreen);
}
RegionPtr

View File

@ -42,144 +42,27 @@
const Bool
glamor_get_drawable_location(const DrawablePtr drawable)
{
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
if (pixmap_priv == NULL)
return 'm';
if (pixmap_priv->fb == 0)
return 's';
else
return 'f';
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
glamor_screen_private *glamor_priv =
glamor_get_screen_private(drawable->pScreen);
if (pixmap_priv == NULL || pixmap_priv->gl_fbo == 0)
return 'm';
if (pixmap_priv->fb == glamor_priv->screen_fbo)
return 's';
else
return 'f';
}
/**
* Sets the offsets to add to coordinates to make them address the same bits in
* the backing drawable. These coordinates are nonzero only for redirected
* windows.
*/
void
glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
int *x, int *y)
{
#ifdef COMPOSITE
if (drawable->type == DRAWABLE_WINDOW) {
*x = -pixmap->screen_x;
*y = -pixmap->screen_y;
return;
}
#endif
*x = 0;
*y = 0;
}
Bool
glamor_set_destination_pixmap(PixmapPtr pixmap)
{
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
if (pixmap_priv == NULL) {
glamor_fallback("glamor_set_destination_pixmap(): no pixmap priv");
return FALSE;
}
if (pixmap_priv->fb == 0) {
ScreenPtr screen = pixmap->drawable.pScreen;
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
if (pixmap != screen_pixmap) {
glamor_fallback("glamor_set_destination_pixmap(): no fbo");
return FALSE;
}
}
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
glViewport(0, 0,
pixmap->drawable.width,
pixmap->drawable.height);
return TRUE;
}
Bool
glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask)
{
if (glamor_pm_is_solid(&pixmap->drawable, planemask)) {
return GL_TRUE;
}
ErrorF("unsupported planemask\n");
return GL_FALSE;
}
void
glamor_set_alu(unsigned char alu)
{
if (alu == GXcopy) {
glDisable(GL_COLOR_LOGIC_OP);
return;
}
glEnable(GL_COLOR_LOGIC_OP);
switch (alu) {
case GXclear:
glLogicOp(GL_CLEAR);
break;
case GXand:
glLogicOp(GL_AND);
break;
case GXandReverse:
glLogicOp(GL_AND_REVERSE);
break;
case GXandInverted:
glLogicOp(GL_AND_INVERTED);
break;
case GXnoop:
glLogicOp(GL_NOOP);
break;
case GXxor:
glLogicOp(GL_XOR);
break;
case GXor:
glLogicOp(GL_OR);
break;
case GXnor:
glLogicOp(GL_NOR);
break;
case GXequiv:
glLogicOp(GL_EQUIV);
break;
case GXinvert:
glLogicOp(GL_INVERT);
break;
case GXorReverse:
glLogicOp(GL_OR_REVERSE);
break;
case GXcopyInverted:
glLogicOp(GL_COPY_INVERTED);
break;
case GXorInverted:
glLogicOp(GL_OR_INVERTED);
break;
case GXnand:
glLogicOp(GL_NAND);
break;
case GXset:
glLogicOp(GL_SET);
break;
default:
FatalError("unknown logic op\n");
}
}
void
glamor_get_transform_uniform_locations(GLint prog,
glamor_transform_uniforms *uniform_locations)
{
uniform_locations->x_bias = glGetUniformLocationARB(prog, "x_bias");
uniform_locations->x_scale = glGetUniformLocationARB(prog, "x_scale");
uniform_locations->y_bias = glGetUniformLocationARB(prog, "y_bias");
uniform_locations->y_scale = glGetUniformLocationARB(prog, "y_scale");
uniform_locations->x_bias = glGetUniformLocationARB(prog, "x_bias");
uniform_locations->x_scale = glGetUniformLocationARB(prog, "x_scale");
uniform_locations->y_bias = glGetUniformLocationARB(prog, "y_bias");
uniform_locations->y_scale = glGetUniformLocationARB(prog, "y_scale");
}
/* We don't use a full matrix for our transformations because it's
@ -190,400 +73,163 @@ void
glamor_set_transform_for_pixmap(PixmapPtr pixmap,
glamor_transform_uniforms *uniform_locations)
{
glUniform1fARB(uniform_locations->x_bias, -pixmap->drawable.width / 2.0f);
glUniform1fARB(uniform_locations->x_scale, 2.0f / pixmap->drawable.width);
glUniform1fARB(uniform_locations->y_bias, -pixmap->drawable.height / 2.0f);
glUniform1fARB(uniform_locations->y_scale, -2.0f / pixmap->drawable.height);
glUniform1fARB(uniform_locations->x_bias, -pixmap->drawable.width / 2.0f);
glUniform1fARB(uniform_locations->x_scale, 2.0f / pixmap->drawable.width);
glUniform1fARB(uniform_locations->y_bias, -pixmap->drawable.height / 2.0f);
glUniform1fARB(uniform_locations->y_scale, -2.0f / pixmap->drawable.height);
}
GLint
glamor_compile_glsl_prog(GLenum type, const char *source)
{
GLint ok;
GLint prog;
GLint ok;
GLint prog;
prog = glCreateShaderObjectARB(type);
glShaderSourceARB(prog, 1, (const GLchar **)&source, NULL);
glCompileShaderARB(prog);
glGetObjectParameterivARB(prog, GL_OBJECT_COMPILE_STATUS_ARB, &ok);
if (!ok) {
GLchar *info;
GLint size;
prog = glCreateShaderObjectARB(type);
glShaderSourceARB(prog, 1, (const GLchar **)&source, NULL);
glCompileShaderARB(prog);
glGetObjectParameterivARB(prog, GL_OBJECT_COMPILE_STATUS_ARB, &ok);
if (!ok) {
GLchar *info;
GLint size;
glGetObjectParameterivARB(prog, GL_OBJECT_INFO_LOG_LENGTH_ARB, &size);
info = malloc(size);
glGetObjectParameterivARB(prog, GL_OBJECT_INFO_LOG_LENGTH_ARB, &size);
info = malloc(size);
glGetInfoLogARB(prog, size, NULL, info);
ErrorF("Failed to compile %s: %s\n",
type == GL_FRAGMENT_SHADER ? "FS" : "VS",
info);
ErrorF("Program source:\n%s", source);
FatalError("GLSL compile failure\n");
}
glGetInfoLogARB(prog, size, NULL, info);
ErrorF("Failed to compile %s: %s\n",
type == GL_FRAGMENT_SHADER ? "FS" : "VS",
info);
ErrorF("Program source:\n%s", source);
FatalError("GLSL compile failure\n");
}
return prog;
return prog;
}
void
glamor_link_glsl_prog(GLint prog)
{
GLint ok;
GLint ok;
glLinkProgram(prog);
glGetObjectParameterivARB(prog, GL_OBJECT_LINK_STATUS_ARB, &ok);
if (!ok) {
GLchar *info;
GLint size;
glLinkProgram(prog);
glGetObjectParameterivARB(prog, GL_OBJECT_LINK_STATUS_ARB, &ok);
if (!ok) {
GLchar *info;
GLint size;
glGetObjectParameterivARB(prog, GL_OBJECT_INFO_LOG_LENGTH_ARB, &size);
info = malloc(size);
glGetObjectParameterivARB(prog, GL_OBJECT_INFO_LOG_LENGTH_ARB, &size);
info = malloc(size);
glGetInfoLogARB(prog, size, NULL, info);
ErrorF("Failed to link: %s\n",
info);
FatalError("GLSL link failure\n");
}
glGetInfoLogARB(prog, size, NULL, info);
ErrorF("Failed to link: %s\n",
info);
FatalError("GLSL link failure\n");
}
}
static float ubyte_to_float(uint8_t b)
{
return b / 255.0f;
}
void
glamor_get_color_4f_from_pixel(PixmapPtr pixmap, unsigned long fg_pixel,
GLfloat *color)
{
switch (pixmap->drawable.depth) {
case 1:
color[0] = 0.0;
color[1] = 0.0;
color[2] = 0.0;
color[3] = fg_pixel & 0x01;
break;
case 8:
color[0] = 0.0;
color[1] = 0.0;
color[2] = 0.0;
color[3] = (fg_pixel & 0xff) / 255.0;
break;
case 24:
case 32:
color[0] = ubyte_to_float((fg_pixel >> 16) & 0xFF);
color[1] = ubyte_to_float((fg_pixel >> 8) & 0xFF);
color[2] = ubyte_to_float((fg_pixel >> 0) & 0xFF);
color[3] = ubyte_to_float((fg_pixel >> 24) & 0xFF);
break;
default:
ErrorF("pixmap with bad depth: %d\n", pixmap->drawable.depth);
color[0] = 1.0;
color[1] = 0.0;
color[2] = 1.0;
color[3] = 1.0;
break;
}
}
Bool
glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
{
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
unsigned int stride, row_length, y;
GLenum format, type;
uint8_t *data, *read;
glamor_screen_private *glamor_priv =
glamor_get_screen_private(drawable->pScreen);
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
if (!pixmap_priv)
return TRUE;
if (pixmap_priv->fb == 0) {
ScreenPtr screen = pixmap->drawable.pScreen;
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
if (pixmap != screen_pixmap)
return TRUE;
}
stride = pixmap->devKind;
row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
assert(drawable->depth != 1);
switch (drawable->depth) {
case 8:
format = GL_ALPHA;
type = GL_UNSIGNED_BYTE;
break;
case 24:
assert(drawable->bitsPerPixel == 32);
/* FALLTHROUGH */
case 32:
format = GL_BGRA;
type = GL_UNSIGNED_INT_8_8_8_8_REV;
break;
default:
ErrorF("Unknown prepareaccess depth %d\n", drawable->depth);
return FALSE;
}
pixmap_priv->access_mode = access;
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ROW_LENGTH, row_length);
if (GLEW_MESA_pack_invert || glamor_priv->yInverted) {
if (!glamor_priv->yInverted)
glPixelStorei(GL_PACK_INVERT_MESA, 1);
glGenBuffersARB (1, &pixmap_priv->pbo);
glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, pixmap_priv->pbo);
glBufferDataARB (GL_PIXEL_PACK_BUFFER_EXT,
stride * pixmap->drawable.height,
NULL, GL_DYNAMIC_DRAW_ARB);
glReadPixels (0, 0,
row_length, pixmap->drawable.height,
format, type, 0);
data = glMapBufferARB (GL_PIXEL_PACK_BUFFER_EXT, GL_READ_WRITE_ARB);
if (!glamor_priv->yInverted)
glPixelStorei(GL_PACK_INVERT_MESA, 0);
} else {
data = malloc(stride * pixmap->drawable.height);
glGenBuffersARB(1, &pixmap_priv->pbo);
glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, pixmap_priv->pbo);
glBufferDataARB(GL_PIXEL_PACK_BUFFER_EXT,
stride * pixmap->drawable.height,
NULL, GL_STREAM_READ_ARB);
glReadPixels (0, 0, row_length, pixmap->drawable.height,
format, type, 0);
read = glMapBufferARB(GL_PIXEL_PACK_BUFFER_EXT, GL_READ_ONLY_ARB);
for (y = 0; y < pixmap->drawable.height; y++)
memcpy(data + y * stride,
read + (pixmap->drawable.height - y - 1) * stride, stride);
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_EXT);
glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, 0);
glDeleteBuffersARB(1, &pixmap_priv->pbo);
pixmap_priv->pbo = 0;
}
pixmap->devPrivate.ptr = data;
return TRUE;
return glamor_download_pixmap_to_cpu(pixmap, access);
}
void
glamor_init_finish_access_shaders(ScreenPtr screen)
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
const char *vs_source =
"void main()\n"
"{\n"
" gl_Position = gl_Vertex;\n"
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
"}\n";
const char *fs_source =
"varying vec2 texcoords;\n"
"uniform sampler2D sampler;\n"
"void main()\n"
"{\n"
" gl_FragColor = texture2D(sampler, gl_TexCoord[0].xy);\n"
"}\n";
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
const char *vs_source =
"void main()\n"
"{\n"
" gl_Position = gl_Vertex;\n"
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
"}\n";
const char *fs_source =
"varying vec2 texcoords;\n"
"uniform sampler2D sampler;\n"
"void main()\n"
"{\n"
" gl_FragColor = texture2D(sampler, gl_TexCoord[0].xy);\n"
"}\n";
const char *aswizzle_source =
"varying vec2 texcoords;\n"
"uniform sampler2D sampler;\n"
"void main()\n"
"{\n"
" gl_FragColor = vec4(texture2D(sampler, gl_TexCoord[0].xy).rgb, 1);\n"
"}\n";
const char *aswizzle_source =
"varying vec2 texcoords;\n"
"uniform sampler2D sampler;\n"
"void main()\n"
"{\n"
" gl_FragColor = vec4(texture2D(sampler, gl_TexCoord[0].xy).rgb, 1);\n"
"}\n";
GLint fs_prog, vs_prog, avs_prog, aswizzle_prog;
GLint fs_prog, vs_prog, avs_prog, aswizzle_prog;
glamor_priv->finish_access_prog = glCreateProgramObjectARB();
glamor_priv->aswizzle_prog = glCreateProgramObjectARB();
glamor_priv->finish_access_prog[0] = glCreateProgramObjectARB();
glamor_priv->finish_access_prog[1] = glCreateProgramObjectARB();
if (GLEW_ARB_fragment_shader) {
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER_ARB, vs_source);
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER_ARB, fs_source);
glAttachObjectARB(glamor_priv->finish_access_prog, vs_prog);
glAttachObjectARB(glamor_priv->finish_access_prog, fs_prog);
if (GLEW_ARB_fragment_shader) {
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER_ARB, vs_source);
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER_ARB, fs_source);
glAttachObjectARB(glamor_priv->finish_access_prog[0], vs_prog);
glAttachObjectARB(glamor_priv->finish_access_prog[0], fs_prog);
avs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER_ARB, vs_source);
aswizzle_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER_ARB, aswizzle_source);
glAttachObjectARB(glamor_priv->aswizzle_prog, avs_prog);
glAttachObjectARB(glamor_priv->aswizzle_prog, aswizzle_prog);
} else {
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER_ARB, vs_source);
glAttachObjectARB(glamor_priv->finish_access_prog, vs_prog);
ErrorF("Lack of framgment shader support.\n");
}
avs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER_ARB, vs_source);
aswizzle_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER_ARB, aswizzle_source);
glAttachObjectARB(glamor_priv->finish_access_prog[1], avs_prog);
glAttachObjectARB(glamor_priv->finish_access_prog[1], aswizzle_prog);
} else {
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER_ARB, vs_source);
glAttachObjectARB(glamor_priv->finish_access_prog[0], vs_prog);
ErrorF("Lack of framgment shader support.\n");
}
glamor_link_glsl_prog(glamor_priv->finish_access_prog);
glamor_link_glsl_prog(glamor_priv->aswizzle_prog);
glamor_link_glsl_prog(glamor_priv->finish_access_prog[0]);
glamor_link_glsl_prog(glamor_priv->finish_access_prog[1]);
if (GLEW_ARB_fragment_shader) {
GLint sampler_uniform_location;
if (GLEW_ARB_fragment_shader) {
GLint sampler_uniform_location;
sampler_uniform_location =
glGetUniformLocationARB(glamor_priv->finish_access_prog, "sampler");
glUseProgramObjectARB(glamor_priv->finish_access_prog);
glUniform1iARB(sampler_uniform_location, 0);
glUseProgramObjectARB(0);
sampler_uniform_location =
glGetUniformLocationARB(glamor_priv->aswizzle_prog, "sampler");
glUseProgramObjectARB(glamor_priv->aswizzle_prog);
glUniform1iARB(sampler_uniform_location, 0);
glUseProgramObjectARB(0);
}
}
/*
* Load texture from the pixmap's data pointer and then
* draw the texture to the fbo, and flip the y axis.
* */
static void
glamor_load_texture_pixmap(PixmapPtr pixmap)
{
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
glamor_screen_private *glamor_priv =
glamor_get_screen_private(pixmap->drawable.pScreen);
unsigned int stride, row_length;
GLenum format, type;
static float vertices[8] = {-1, -1,
1, -1,
1, 1,
-1, 1};
static float texcoords[8] = {0, 1,
1, 1,
1, 0,
0, 0};
static float texcoords_inverted[8] = {0, 0,
1, 0,
1, 1,
0, 1};
float *ptexcoords;
void * texel;
GLuint tex;
int alfa_mode = 0;
if (glamor_priv->yInverted)
ptexcoords = texcoords_inverted;
else
ptexcoords = texcoords;
assert(pixmap->drawable.depth != 1);
stride = pixmap->devKind;
row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
switch (pixmap->drawable.depth) {
case 8:
format = GL_ALPHA;
type = GL_UNSIGNED_BYTE;
break;
case 24:
assert(pixmap->drawable.bitsPerPixel == 32);
/* FALLTHROUGH */
alfa_mode = 1;
case 32:
format = GL_BGRA;
type = GL_UNSIGNED_INT_8_8_8_8_REV;
break;
default:
ErrorF("Unknown finishaccess depth %d\n", pixmap->drawable.depth);
return;
}
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glClientActiveTexture(GL_TEXTURE0);
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, ptexcoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
glViewport(0, 0, pixmap->drawable.width, pixmap->drawable.height);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
glGenTextures(1, &tex);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
if (glamor_priv->yInverted || GLEW_MESA_pack_invert) {
texel = NULL;
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, pixmap_priv->pbo);
}
else
texel = pixmap->devPrivate.ptr;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
pixmap->drawable.width, pixmap->drawable.height, 0,
format, type, texel);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D);
assert(GLEW_ARB_fragment_shader);
if (alfa_mode == 0)
glUseProgramObjectARB(glamor_priv->finish_access_prog);
else
glUseProgramObjectARB(glamor_priv->aswizzle_prog);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisable(GL_TEXTURE_2D);
sampler_uniform_location =
glGetUniformLocationARB(glamor_priv->finish_access_prog[0], "sampler");
glUseProgramObjectARB(glamor_priv->finish_access_prog[0]);
glUniform1iARB(sampler_uniform_location, 0);
glUseProgramObjectARB(0);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDeleteTextures(1, &tex);
sampler_uniform_location =
glGetUniformLocationARB(glamor_priv->finish_access_prog[1], "sampler");
glUseProgramObjectARB(glamor_priv->finish_access_prog[1]);
glUniform1iARB(sampler_uniform_location, 0);
glUseProgramObjectARB(0);
}
}
void
glamor_finish_access(DrawablePtr drawable)
{
glamor_screen_private *glamor_priv =
glamor_get_screen_private(drawable->pScreen);
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
/* Check if finish_access was already called once on this */
if (pixmap->devPrivate.ptr == NULL)
return;
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
return;
if (!pixmap_priv)
return;
if ( pixmap_priv->access_mode != GLAMOR_ACCESS_RO) {
glamor_restore_pixmap_to_texture(pixmap);
}
if (pixmap_priv->fb == 0) {
ScreenPtr screen = pixmap->drawable.pScreen;
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
if (pixmap_priv->pbo != 0 && pixmap_priv->pbo_valid) {
glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, 0);
glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_EXT, 0);
pixmap_priv->pbo_valid = FALSE;
glDeleteBuffersARB(1, &pixmap_priv->pbo);
pixmap_priv->pbo = 0;
} else
free(pixmap->devPrivate.ptr);
if (pixmap != screen_pixmap)
return;
}
if ( pixmap_priv->access_mode != GLAMOR_ACCESS_RO) {
glamor_load_texture_pixmap(pixmap);
}
if (GLEW_MESA_pack_invert || glamor_priv->yInverted) {
glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, pixmap_priv->pbo);
glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, 0);
glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_EXT, 0);
glDeleteBuffersARB (1, &pixmap_priv->pbo);
pixmap_priv->pbo = 0;
} else
free(pixmap->devPrivate.ptr);
pixmap->devPrivate.ptr = NULL;
pixmap->devPrivate.ptr = NULL;
}
/**
* Calls uxa_prepare_access with UXA_PREPARE_SRC for the tile, if that is the
* current fill style.
@ -595,18 +241,18 @@ glamor_finish_access(DrawablePtr drawable)
Bool
glamor_prepare_access_gc(GCPtr gc)
{
if (gc->stipple)
if (!glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO))
return FALSE;
if (gc->fillStyle == FillTiled) {
if (!glamor_prepare_access (&gc->tile.pixmap->drawable,
GLAMOR_ACCESS_RO)) {
if (gc->stipple)
glamor_finish_access(&gc->stipple->drawable);
return FALSE;
}
if (gc->stipple)
if (!glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO))
return FALSE;
if (gc->fillStyle == FillTiled) {
if (!glamor_prepare_access (&gc->tile.pixmap->drawable,
GLAMOR_ACCESS_RO)) {
if (gc->stipple)
glamor_finish_access(&gc->stipple->drawable);
return FALSE;
}
return TRUE;
}
return TRUE;
}
/**
@ -615,10 +261,10 @@ glamor_prepare_access_gc(GCPtr gc)
void
glamor_finish_access_gc(GCPtr gc)
{
if (gc->fillStyle == FillTiled)
glamor_finish_access(&gc->tile.pixmap->drawable);
if (gc->stipple)
glamor_finish_access(&gc->stipple->drawable);
if (gc->fillStyle == FillTiled)
glamor_finish_access(&gc->tile.pixmap->drawable);
if (gc->stipple)
glamor_finish_access(&gc->stipple->drawable);
}
Bool
@ -628,33 +274,31 @@ glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
unsigned long fg_pixel, unsigned long bg_pixel,
int stipple_x, int stipple_y)
{
glamor_fallback("stubbed out stipple depth %d\n", pixmap->drawable.depth);
return FALSE;
// ErrorF("stubbed out stipple depth %d\n", pixmap->drawable.depth);
// glamor_solid_fail_region(pixmap, x, y, width, height);
glamor_fallback("stubbed out stipple depth %d\n", pixmap->drawable.depth);
return FALSE;
}
GCOps glamor_gc_ops = {
.FillSpans = glamor_fill_spans,
.SetSpans = glamor_set_spans,
.PutImage = glamor_put_image,
.CopyArea = glamor_copy_area,
.CopyPlane = miCopyPlane,
.PolyPoint = miPolyPoint,
.Polylines = glamor_poly_lines,
.PolySegment = miPolySegment,
.PolyRectangle = miPolyRectangle,
.PolyArc = miPolyArc,
.FillPolygon = miFillPolygon,
.PolyFillRect = glamor_poly_fill_rect,
.PolyFillArc = miPolyFillArc,
.PolyText8 = miPolyText8,
.PolyText16 = miPolyText16,
.ImageText8 = miImageText8,
.ImageText16 = miImageText16,
.ImageGlyphBlt = miImageGlyphBlt,
.PolyGlyphBlt = miPolyGlyphBlt,
.PushPixels = miPushPixels,
.FillSpans = glamor_fill_spans,
.SetSpans = glamor_set_spans,
.PutImage = glamor_put_image,
.CopyArea = glamor_copy_area,
.CopyPlane = miCopyPlane,
.PolyPoint = miPolyPoint,
.Polylines = glamor_poly_lines,
.PolySegment = miPolySegment,
.PolyRectangle = miPolyRectangle,
.PolyArc = miPolyArc,
.FillPolygon = miFillPolygon,
.PolyFillRect = glamor_poly_fill_rect,
.PolyFillArc = miPolyFillArc,
.PolyText8 = miPolyText8,
.PolyText16 = miPolyText16,
.ImageText8 = miImageText8,
.ImageText16 = miImageText16,
.ImageGlyphBlt = miImageGlyphBlt,
.PolyGlyphBlt = miPolyGlyphBlt,
.PushPixels = miPushPixels,
};
/**
@ -664,84 +308,84 @@ GCOps glamor_gc_ops = {
static void
glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
{
/* fbValidateGC will do direct access to pixmaps if the tiling has changed.
* Preempt fbValidateGC by doing its work and masking the change out, so
* that we can do the Prepare/finish_access.
*/
/* fbValidateGC will do direct access to pixmaps if the tiling has changed.
* Preempt fbValidateGC by doing its work and masking the change out, so
* that we can do the Prepare/finish_access.
*/
#ifdef FB_24_32BIT
if ((changes & GCTile) && fbGetRotatedPixmap(gc)) {
gc->pScreen->DestroyPixmap(fbGetRotatedPixmap(gc));
fbGetRotatedPixmap(gc) = 0;
}
if ((changes & GCTile) && fbGetRotatedPixmap(gc)) {
gc->pScreen->DestroyPixmap(fbGetRotatedPixmap(gc));
fbGetRotatedPixmap(gc) = 0;
}
if (gc->fillStyle == FillTiled) {
PixmapPtr old_tile, new_tile;
if (gc->fillStyle == FillTiled) {
PixmapPtr old_tile, new_tile;
old_tile = gc->tile.pixmap;
if (old_tile->drawable.bitsPerPixel != drawable->bitsPerPixel) {
new_tile = fbGetRotatedPixmap(gc);
if (!new_tile ||
new_tile ->drawable.bitsPerPixel != drawable->bitsPerPixel)
{
if (new_tile)
gc->pScreen->DestroyPixmap(new_tile);
/* fb24_32ReformatTile will do direct access of a newly-
* allocated pixmap.
*/
if (glamor_prepare_access(&old_tile->drawable,
GLAMOR_ACCESS_RO)) {
new_tile = fb24_32ReformatTile(old_tile,
drawable->bitsPerPixel);
glamor_finish_access(&old_tile->drawable);
}
}
if (new_tile) {
fbGetRotatedPixmap(gc) = old_tile;
gc->tile.pixmap = new_tile;
changes |= GCTile;
}
}
}
#endif
if (changes & GCTile) {
if (!gc->tileIsPixel && FbEvenTile(gc->tile.pixmap->drawable.width *
drawable->bitsPerPixel))
old_tile = gc->tile.pixmap;
if (old_tile->drawable.bitsPerPixel != drawable->bitsPerPixel) {
new_tile = fbGetRotatedPixmap(gc);
if (!new_tile ||
new_tile ->drawable.bitsPerPixel != drawable->bitsPerPixel)
{
if (glamor_prepare_access(&gc->tile.pixmap->drawable,
GLAMOR_ACCESS_RW)) {
fbPadPixmap(gc->tile.pixmap);
glamor_finish_access(&gc->tile.pixmap->drawable);
}
if (new_tile)
gc->pScreen->DestroyPixmap(new_tile);
/* fb24_32ReformatTile will do direct access of a newly-
* allocated pixmap.
*/
if (glamor_prepare_access(&old_tile->drawable,
GLAMOR_ACCESS_RO)) {
new_tile = fb24_32ReformatTile(old_tile,
drawable->bitsPerPixel);
glamor_finish_access(&old_tile->drawable);
}
}
/* Mask out the GCTile change notification, now that we've done FB's
* job for it.
*/
changes &= ~GCTile;
if (new_tile) {
fbGetRotatedPixmap(gc) = old_tile;
gc->tile.pixmap = new_tile;
changes |= GCTile;
}
}
if (changes & GCStipple && gc->stipple) {
/* We can't inline stipple handling like we do for GCTile because
* it sets fbgc privates.
*/
if (glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
fbValidateGC(gc, changes, drawable);
glamor_finish_access(&gc->stipple->drawable);
}
#endif
if (changes & GCTile) {
if (!gc->tileIsPixel && FbEvenTile(gc->tile.pixmap->drawable.width *
drawable->bitsPerPixel))
{
if (glamor_prepare_access(&gc->tile.pixmap->drawable,
GLAMOR_ACCESS_RW)) {
fbPadPixmap(gc->tile.pixmap);
glamor_finish_access(&gc->tile.pixmap->drawable);
}
} else {
fbValidateGC(gc, changes, drawable);
}
}
/* Mask out the GCTile change notification, now that we've done FB's
* job for it.
*/
changes &= ~GCTile;
}
gc->ops = &glamor_gc_ops;
if (changes & GCStipple && gc->stipple) {
/* We can't inline stipple handling like we do for GCTile because
* it sets fbgc privates.
*/
if (glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
fbValidateGC(gc, changes, drawable);
glamor_finish_access(&gc->stipple->drawable);
}
} else {
fbValidateGC(gc, changes, drawable);
}
gc->ops = &glamor_gc_ops;
}
static GCFuncs glamor_gc_funcs = {
glamor_validate_gc,
miChangeGC,
miCopyGC,
miDestroyGC,
miChangeClip,
miDestroyClip,
miCopyClip
glamor_validate_gc,
miChangeGC,
miCopyGC,
miDestroyGC,
miChangeClip,
miDestroyClip,
miCopyClip
};
/**
@ -751,54 +395,54 @@ static GCFuncs glamor_gc_funcs = {
int
glamor_create_gc(GCPtr gc)
{
if (!fbCreateGC(gc))
return FALSE;
if (!fbCreateGC(gc))
return FALSE;
gc->funcs = &glamor_gc_funcs;
gc->funcs = &glamor_gc_funcs;
return TRUE;
return TRUE;
}
Bool
glamor_prepare_access_window(WindowPtr window)
{
if (window->backgroundState == BackgroundPixmap) {
if (!glamor_prepare_access(&window->background.pixmap->drawable,
GLAMOR_ACCESS_RO))
return FALSE;
}
if (window->backgroundState == BackgroundPixmap) {
if (!glamor_prepare_access(&window->background.pixmap->drawable,
GLAMOR_ACCESS_RO))
return FALSE;
}
if (window->borderIsPixel == FALSE) {
if (!glamor_prepare_access(&window->border.pixmap->drawable,
GLAMOR_ACCESS_RO)) {
if (window->backgroundState == BackgroundPixmap)
glamor_finish_access(&window->background.pixmap->drawable);
return FALSE;
}
if (window->borderIsPixel == FALSE) {
if (!glamor_prepare_access(&window->border.pixmap->drawable,
GLAMOR_ACCESS_RO)) {
if (window->backgroundState == BackgroundPixmap)
glamor_finish_access(&window->background.pixmap->drawable);
return FALSE;
}
return TRUE;
}
return TRUE;
}
void
glamor_finish_access_window(WindowPtr window)
{
if (window->backgroundState == BackgroundPixmap)
glamor_finish_access(&window->background.pixmap->drawable);
if (window->backgroundState == BackgroundPixmap)
glamor_finish_access(&window->background.pixmap->drawable);
if (window->borderIsPixel == FALSE)
glamor_finish_access(&window->border.pixmap->drawable);
if (window->borderIsPixel == FALSE)
glamor_finish_access(&window->border.pixmap->drawable);
}
Bool
glamor_change_window_attributes(WindowPtr window, unsigned long mask)
{
Bool ret;
Bool ret;
if (!glamor_prepare_access_window(window))
return FALSE;
ret = fbChangeWindowAttributes(window, mask);
glamor_finish_access_window(window);
return ret;
if (!glamor_prepare_access_window(window))
return FALSE;
ret = fbChangeWindowAttributes(window, mask);
glamor_finish_access_window(window);
return ret;
}
RegionPtr

67
glamor/glamor_debug.h Normal file
View File

@ -0,0 +1,67 @@
#ifndef __GLAMOR_DEBUG_H__
#define __GLAMOR_DEBUG_H__
#define GLAMOR_DELAYED_STRING_MAX 64
#define GLAMOR_DEBUG_NONE 0
#define GLAMOR_DEBUG_FALLBACK 1
#define GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD 2
#define GLAMOR_DEBUG_TEXTURE_DOWNLOAD 3
#define __debug_output_message(_format_, _prefix_, ...) \
LogMessageVerb(X_NONE, 0, \
"%32s:\t" _format_ , \
/*_prefix_,*/ \
__FUNCTION__, \
##__VA_ARGS__)
#define glamor_debug_output(_level_, _format_,...) \
do { \
if (glamor_debug_level >= _level_) \
__debug_output_message(_format_, \
"Glamor debug", \
##__VA_ARGS__); \
} while(0)
#define glamor_fallback(_format_,...) \
do { \
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) \
__debug_output_message(_format_, \
"Glamor fallback", \
##__VA_ARGS__);} while(0)
#define glamor_delayed_fallback(_screen_, _format_,...) \
do { \
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
glamor_screen_private *_glamor_priv_; \
_glamor_priv_ = glamor_get_screen_private(_screen_); \
_glamor_priv_->delayed_fallback_pending = 1; \
snprintf(_glamor_priv_->delayed_fallback_string, \
GLAMOR_DELAYED_STRING_MAX, \
"glamor delayed fallback: \t%s " _format_ , \
__FUNCTION__, ##__VA_ARGS__); } } while(0)
#define glamor_clear_delayed_fallbacks(_screen_) \
do { \
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
glamor_screen_private *_glamor_priv_; \
_glamor_priv_ = glamor_get_screen_private(_screen_); \
_glamor_priv_->delayed_fallback_pending = 0; } } while(0)
#define glamor_report_delayed_fallbacks(_screen_) \
do { \
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
glamor_screen_private *_glamor_priv_; \
_glamor_priv_ = glamor_get_screen_private(_screen_); \
LogMessageVerb(X_INFO, 0, "%s", \
_glamor_priv_->delayed_fallback_string); \
_glamor_priv_->delayed_fallback_pending = 0; } } while(0)
#endif

View File

@ -89,7 +89,6 @@ glamor_fill(DrawablePtr drawable,
}
return;
fail:
glamor_fallback("glamor_fill()");
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_gc(gc)) {
fbFill(drawable, gc, x, y, width, height);
@ -154,16 +153,22 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
GLfloat color[4];
float vertices[4][2];
if (!glamor_set_destination_pixmap(pixmap))
if (glamor_set_destination_pixmap(pixmap)) {
glamor_fallback("dest has no fbo.\n");
goto fail;
}
glamor_set_alu(alu);
if (!glamor_set_planemask(pixmap, planemask)) {
ErrorF("Failedto set planemask in glamor_solid.\n");
glamor_fallback("Failedto set planemask in glamor_solid.\n");
goto fail;
}
glUseProgramObjectARB(glamor_priv->solid_prog);
glamor_get_color_4f_from_pixel(pixmap, fg_pixel, color);
glamor_get_rgba_from_pixel(fg_pixel,
&color[0],
&color[1],
&color[2],
&color[3],
format_for_pixmap(pixmap));
glUniform4fvARB(glamor_priv->solid_color_uniform_location, 1, color);
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
@ -196,22 +201,4 @@ fail:
return FALSE;
}
/* Highlight places where we're doing it wrong. */
void
glamor_solid_fail_region(PixmapPtr pixmap, int x, int y, int width, int height)
{
unsigned long pixel;
switch (pixmap->drawable.depth) {
case 24:
case 32:
pixel = 0x00ff00ff; /* our favorite color */
break;
default:
case 8:
pixel = 0xd0d0d0d0;
break;
}
glamor_solid(pixmap, x, y, width, height, GXcopy, ~0, pixel);
}

View File

@ -47,10 +47,9 @@ glamor_fill_spans(DrawablePtr drawable,
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
goto fail;
glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
ppt = points;
while (n--) {
@ -82,7 +81,7 @@ glamor_fill_spans(DrawablePtr drawable,
}
return;
fail:
glamor_fallback("glamor_fillspans(): to %p (%c)\n", drawable,
glamor_fallback("to %p (%c)\n", drawable,
glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_gc(gc)) {

View File

@ -31,18 +31,6 @@
#include "glamor_priv.h"
static void
set_bit(uint8_t *bitfield, unsigned int index, unsigned int val)
{
int i = index / 8;
int mask = 1 << (index % 8);
if (val)
bitfield[i] |= mask;
else
bitfield[i] &= ~mask;
}
void
glamor_get_spans(DrawablePtr drawable,
int wmax,
@ -53,39 +41,27 @@ glamor_get_spans(DrawablePtr drawable,
{
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
GLenum format, type;
int ax;
glamor_screen_private *glamor_priv =
glamor_get_screen_private(drawable->pScreen);
int i, j;
uint8_t *temp_dst = NULL, *readpixels_dst = (uint8_t *)dst;
int i;
uint8_t *readpixels_dst = (uint8_t *)dst;
int x_off, y_off;
switch (drawable->depth) {
case 1:
temp_dst = malloc(wmax);
format = GL_ALPHA;
type = GL_UNSIGNED_BYTE;
readpixels_dst = temp_dst;
break;
case 8:
format = GL_ALPHA;
type = GL_UNSIGNED_BYTE;
break;
case 24:
case 32:
format = GL_BGRA;
type = GL_UNSIGNED_INT_8_8_8_8_REV;
break;
default:
glamor_fallback("glamor_get_spans(): "
"Unknown getspans depth %d\n", drawable->depth);
goto fail;
if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format,
&type,
&ax
)) {
glamor_fallback("unknown depth. %d \n",
drawable->depth);
goto fail;
}
if (!glamor_set_destination_pixmap(pixmap))
if (glamor_set_destination_pixmap(pixmap)) {
glamor_fallback("pixmap has no fbo.\n");
goto fail;
}
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
for (i = 0; i < count; i++) {
if (glamor_priv->yInverted) {
glReadPixels(points[i].x + x_off,
@ -102,21 +78,12 @@ glamor_get_spans(DrawablePtr drawable,
format, type,
readpixels_dst);
}
if (temp_dst) {
for (j = 0; j < widths[i]; j++) {
set_bit((uint8_t *)dst, j, temp_dst[j] & 0x1);
}
dst += PixmapBytePad(widths[i], drawable->depth);
} else {
readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
}
readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
}
free(temp_dst);
return;
fail:
free(temp_dst);
glamor_fallback("glamor_get_spans() from %p (%c)\n", drawable,
glamor_fallback("from %p (%c)\n", drawable,
glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
fbGetSpans(drawable, wmax, points, widths, count, dst);

View File

@ -67,6 +67,7 @@
*/
#define GLYPH_BUFFER_SIZE 256
typedef struct {
PicturePtr source;
glamor_composite_rect_t rects[GLYPH_BUFFER_SIZE];
@ -573,6 +574,7 @@ static void glamor_glyphs_to_mask(PicturePtr mask,
glamor_glyph_buffer_t *buffer)
{
#ifdef RENDER
glamor_composite_rects(PictOpAdd, buffer->source, mask,
buffer->count, buffer->rects);
#endif

93
glamor/glamor_picture.c Normal file
View File

@ -0,0 +1,93 @@
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <stdlib.h>
#include "glamor_priv.h"
/* Upload picture to texture. We may need to flip the y axis or
* wire alpha to 1. So we may conditional create fbo for the picture.
* */
enum glamor_pixmap_status
glamor_upload_picture_to_texture(PicturePtr picture)
{
PixmapPtr pixmap;
glamor_pixmap_private *pixmap_priv;
assert(picture->pDrawable);
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
pixmap_priv = glamor_get_pixmap_private(pixmap);
assert(GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) == 1);
return glamor_upload_pixmap_to_texture(pixmap);
}
Bool
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access)
{
if (!picture || !picture->pDrawable)
return TRUE;
return glamor_prepare_access(picture->pDrawable, access);
}
void
glamor_finish_access_picture(PicturePtr picture)
{
if (!picture || !picture->pDrawable)
return;
glamor_finish_access(picture->pDrawable);
}
/*
* We should already has drawable attached to it, if it has one.
* Then set the attached pixmap to is_picture format, and set
* the pict format.
* */
int
glamor_create_picture(PicturePtr picture)
{
PixmapPtr pixmap;
glamor_pixmap_private *pixmap_priv;
glamor_screen_private *glamor_priv;
if (!picture || !picture->pDrawable)
return 0;
glamor_priv = glamor_get_screen_private(picture->pDrawable->pScreen);
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
pixmap_priv = glamor_get_pixmap_private(pixmap);
assert(pixmap_priv);
pixmap_priv->is_picture = 1;
pixmap_priv->pict_format = picture->format;
return glamor_priv->saved_create_picture(picture);
}
void
glamor_destroy_picture(PicturePtr picture)
{
PixmapPtr pixmap;
glamor_pixmap_private *pixmap_priv;
glamor_screen_private *glamor_priv;
if (!picture || !picture->pDrawable)
return;
glamor_priv = glamor_get_screen_private(picture->pDrawable->pScreen);
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
pixmap_priv = glamor_get_pixmap_private(pixmap);
assert(pixmap_priv);
pixmap_priv->is_picture = 0;
pixmap_priv->pict_format = 0;
glamor_priv->saved_destroy_picture(picture);
}
void glamor_picture_format_fixup(PicturePtr picture, glamor_pixmap_private *pixmap_priv)
{
pixmap_priv->pict_format = picture->format;
}

483
glamor/glamor_pixmap.c Normal file
View File

@ -0,0 +1,483 @@
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <stdlib.h>
#include "glamor_priv.h"
/**
* Sets the offsets to add to coordinates to make them address the same bits in
* the backing drawable. These coordinates are nonzero only for redirected
* windows.
*/
void
glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
int *x, int *y)
{
#ifdef COMPOSITE
if (drawable->type == DRAWABLE_WINDOW) {
*x = -pixmap->screen_x;
*y = -pixmap->screen_y;
return;
}
#endif
*x = 0;
*y = 0;
}
void
glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *pixmap_priv)
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
glViewport(0, 0,
pixmap_priv->container->drawable.width,
pixmap_priv->container->drawable.height);
}
int
glamor_set_destination_pixmap_priv(glamor_pixmap_private *pixmap_priv)
{
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
return -1;
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
return 0;
}
int
glamor_set_destination_pixmap(PixmapPtr pixmap)
{
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
return glamor_set_destination_pixmap_priv(pixmap_priv);
}
Bool
glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask)
{
if (glamor_pm_is_solid(&pixmap->drawable, planemask)) {
return GL_TRUE;
}
glamor_fallback("unsupported planemask %lx\n", planemask);
return GL_FALSE;
}
void
glamor_set_alu(unsigned char alu)
{
if (alu == GXcopy) {
glDisable(GL_COLOR_LOGIC_OP);
return;
}
glEnable(GL_COLOR_LOGIC_OP);
switch (alu) {
case GXclear:
glLogicOp(GL_CLEAR);
break;
case GXand:
glLogicOp(GL_AND);
break;
case GXandReverse:
glLogicOp(GL_AND_REVERSE);
break;
case GXandInverted:
glLogicOp(GL_AND_INVERTED);
break;
case GXnoop:
glLogicOp(GL_NOOP);
break;
case GXxor:
glLogicOp(GL_XOR);
break;
case GXor:
glLogicOp(GL_OR);
break;
case GXnor:
glLogicOp(GL_NOR);
break;
case GXequiv:
glLogicOp(GL_EQUIV);
break;
case GXinvert:
glLogicOp(GL_INVERT);
break;
case GXorReverse:
glLogicOp(GL_OR_REVERSE);
break;
case GXcopyInverted:
glLogicOp(GL_COPY_INVERTED);
break;
case GXorInverted:
glLogicOp(GL_OR_INVERTED);
break;
case GXnand:
glLogicOp(GL_NAND);
break;
case GXset:
glLogicOp(GL_SET);
break;
default:
FatalError("unknown logic op\n");
}
}
/**
* Upload pixmap to a specified texture.
* This texture may not be the one attached to it.
**/
static void
__glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type, GLuint tex)
{
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
unsigned int stride, row_length;
void *texels;
GLenum iformat = GL_RGBA;
stride = pixmap->devKind;
row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
glBindTexture(GL_TEXTURE_2D, tex);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
if (pixmap_priv->pbo && pixmap_priv->pbo_valid) {
texels = NULL;
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, pixmap_priv->pbo);
}
else
texels = pixmap->devPrivate.ptr;
glTexImage2D(GL_TEXTURE_2D,
0,
iformat,
pixmap->drawable.width,
pixmap->drawable.height, 0,
format, type, texels);
}
/*
* Load texture from the pixmap's data pointer and then
* draw the texture to the fbo, and flip the y axis.
* */
static void
_glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type, int ax, int flip)
{
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
glamor_screen_private *glamor_priv =
glamor_get_screen_private(pixmap->drawable.pScreen);
static float vertices[8] = {-1, -1,
1, -1,
1, 1,
-1, 1};
static float texcoords[8] = {0, 1,
1, 1,
1, 0,
0, 0};
static float texcoords_inv[8] = {0, 0,
1, 0,
1, 1,
0, 1};
float *ptexcoords;
GLuint tex;
int need_flip;
need_flip = (flip && !glamor_priv->yInverted);
/* Try fast path firstly, upload the pixmap to the texture attached
* to the fbo directly. */
if (ax == 0 && !need_flip) {
__glamor_upload_pixmap_to_texture(pixmap, format, type, pixmap_priv->tex);
return;
}
if (need_flip)
ptexcoords = texcoords;
else
ptexcoords = texcoords_inv;
/* Slow path, we need to flip y or wire alpha to 1. */
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glClientActiveTexture(GL_TEXTURE0);
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, ptexcoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
glViewport(0, 0, pixmap->drawable.width, pixmap->drawable.height);
glGenTextures(1, &tex);
__glamor_upload_pixmap_to_texture(pixmap, format, type, tex);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D);
glUseProgramObjectARB(glamor_priv->finish_access_prog[ax]);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisable(GL_TEXTURE_2D);
glUseProgramObjectARB(0);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDeleteTextures(1, &tex);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
/* */
static int
glamor_pixmap_upload_prepare(PixmapPtr pixmap, int need_fbo)
{
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
if (!glamor_check_fbo_width_height(pixmap->drawable.width , pixmap->drawable.height)
|| !glamor_check_fbo_depth(pixmap->drawable.depth)) {
glamor_fallback("upload failed reason: bad size or depth %d x %d @depth %d \n",
pixmap->drawable.width, pixmap->drawable.height, pixmap->drawable.depth);
return -1;
}
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
return 0;
if (pixmap_priv->tex == 0) {
/* Create a framebuffer object wrapping the texture so that we can render
* to it.
*/
glGenTextures(1, &pixmap_priv->tex);
glBindTexture(GL_TEXTURE_2D, pixmap_priv->tex);
}
if (need_fbo && pixmap_priv->fb == 0) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixmap->drawable.width,
pixmap->drawable.height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
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);
}
return 0;
}
enum glamor_pixmap_status
glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
{
GLenum format, type;
int ax;
if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format,
&type,
&ax)) {
glamor_fallback("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
return GLAMOR_UPLOAD_FAILED;
}
if (glamor_pixmap_upload_prepare(pixmap, ax))
return GLAMOR_UPLOAD_FAILED;
glamor_debug_output(GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD,
"Uploading pixmap %p %dx%d depth%d.\n",
pixmap,
pixmap->drawable.width,
pixmap->drawable.height,
pixmap->drawable.depth);
_glamor_upload_pixmap_to_texture(pixmap, format, type, ax, 0);
return GLAMOR_UPLOAD_DONE;
}
#if 0
enum glamor_pixmap_status
glamor_upload_pixmap_to_texure_from_data(PixmapPtr pixmap, void *data)
{
enum glamor_pixmap_status upload_status;
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
assert(pixmap_priv->pbo_valid == 0);
assert(pixmap->devPrivate.ptr == NULL);
pixmap->devPrivate.ptr = data;
upload_status = glamor_upload_pixmap_to_texture(pixmap);
pixmap->devPrivate.ptr = NULL;
return upload_status;
}
#endif
void
glamor_restore_pixmap_to_texture(PixmapPtr pixmap)
{
GLenum format, type;
int ax;
if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format,
&type,
&ax)) {
ErrorF("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
assert(0);
}
_glamor_upload_pixmap_to_texture(pixmap, format, type, ax, 1);
}
/**
* Move a pixmap to CPU memory.
* The input data is the pixmap's fbo.
* The output data is at pixmap->devPrivate.ptr. We always use pbo
* to read the fbo and then map it to va. If possible, we will use
* it directly as devPrivate.ptr.
* If successfully download a fbo to cpu then return TRUE.
* Otherwise return FALSE.
**/
Bool
glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
{
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
unsigned int stride, row_length, y;
GLenum format, type, gl_access, gl_usage;
int ax;
uint8_t *data, *read;
glamor_screen_private *glamor_priv =
glamor_get_screen_private(pixmap->drawable.pScreen);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
return TRUE;
if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format,
&type,
&ax)) {
ErrorF("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
assert(0); // Should never happen.
return FALSE;
}
pixmap_priv->access_mode = access;
switch (access) {
case GLAMOR_ACCESS_RO:
gl_access = GL_READ_ONLY_ARB;
gl_usage = GL_STREAM_READ_ARB;
break;
case GLAMOR_ACCESS_WO:
gl_access = GL_WRITE_ONLY_ARB;
gl_usage = GL_STREAM_DRAW_ARB;
break;
case GLAMOR_ACCESS_RW:
gl_access = GL_READ_WRITE_ARB;
gl_usage = GL_DYNAMIC_DRAW_ARB;
break;
default:
ErrorF("Glamor: Invalid access code. %d\n", access);
assert(0);
}
glamor_debug_output(GLAMOR_DEBUG_TEXTURE_DOWNLOAD,
"Downloading pixmap %p %dx%d depth%d\n",
pixmap,
pixmap->drawable.width,
pixmap->drawable.height,
pixmap->drawable.depth);
stride = pixmap->devKind;
row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ROW_LENGTH, row_length);
if (GLEW_MESA_pack_invert || glamor_priv->yInverted) {
if (!glamor_priv->yInverted)
glPixelStorei(GL_PACK_INVERT_MESA, 1);
if (pixmap_priv->pbo == 0)
glGenBuffersARB (1, &pixmap_priv->pbo);
glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, pixmap_priv->pbo);
glBufferDataARB (GL_PIXEL_PACK_BUFFER_EXT,
stride * pixmap->drawable.height,
NULL, gl_usage);
if (access != GLAMOR_ACCESS_WO)
glReadPixels (0, 0,
row_length, pixmap->drawable.height,
format, type, 0);
data = glMapBufferARB (GL_PIXEL_PACK_BUFFER_EXT, gl_access);
pixmap_priv->pbo_valid = TRUE;
if (!glamor_priv->yInverted)
glPixelStorei(GL_PACK_INVERT_MESA, 0);
} else {
data = malloc(stride * pixmap->drawable.height);
assert(data);
if (access != GLAMOR_ACCESS_WO) {
if (pixmap_priv->pbo == 0)
glGenBuffersARB(1, &pixmap_priv->pbo);
glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, pixmap_priv->pbo);
glBufferDataARB(GL_PIXEL_PACK_BUFFER_EXT,
stride * pixmap->drawable.height,
NULL, GL_STREAM_READ_ARB);
glReadPixels (0, 0, row_length, pixmap->drawable.height,
format, type, 0);
read = glMapBufferARB(GL_PIXEL_PACK_BUFFER_EXT, GL_READ_ONLY_ARB);
for (y = 0; y < pixmap->drawable.height; y++)
memcpy(data + y * stride,
read + (pixmap->drawable.height - y - 1) * stride, stride);
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_EXT);
glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, 0);
pixmap_priv->pbo_valid = FALSE;
glDeleteBuffersARB(1, &pixmap_priv->pbo);
pixmap_priv->pbo = 0;
}
}
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
pixmap->devPrivate.ptr = data;
return TRUE;
}
static void
_glamor_destroy_upload_pixmap(PixmapPtr pixmap)
{
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
assert(pixmap_priv->gl_fbo == 0);
if (pixmap_priv->fb)
glDeleteFramebuffersEXT(1, &pixmap_priv->fb);
if (pixmap_priv->tex)
glDeleteTextures(1, &pixmap_priv->tex);
if (pixmap_priv->pbo)
glDeleteBuffersARB(1, &pixmap_priv->pbo);
pixmap_priv->fb = pixmap_priv->tex = pixmap_priv->pbo = 0;
}
void glamor_destroy_upload_pixmap(PixmapPtr pixmap)
{
_glamor_destroy_upload_pixmap(pixmap);
}

View File

@ -50,9 +50,9 @@ glamor_poly_fill_rect(DrawablePtr drawable,
int off_x, off_y;
RegionPtr pClip = fbGetCompositeClip(gc);
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled) {
goto fail;
}
xorg = drawable->x;
yorg = drawable->y;
@ -101,9 +101,8 @@ glamor_poly_fill_rect(DrawablePtr drawable,
return;
fail:
glamor_fallback("glamor_poly_fill_rect() to %p (%c)\n",
glamor_fallback(" to %p (%c)\n",
drawable, glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_gc(gc)) {
fbPolyFillRect(drawable, gc, nrect, prect );

View File

@ -49,18 +49,17 @@ glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
xRectangle *rects;
int x1, x2, y1, y2;
int i;
/* Don't try to do wide lines or non-solid fill style. */
if (gc->lineWidth != 0) {
/* This ends up in miSetSpans, which is accelerated as well as we
* can hope X wide lines will be.
*/
/*glamor_fallback("glamor_poly_lines(): wide lines\n");*/
goto fail;
}
if (gc->lineStyle != LineSolid ||
gc->fillStyle != FillSolid) {
glamor_fallback("glamor_poly_lines(): non-solid fill\n");
glamor_fallback("non-solid fill line style %d, fill style %d\n",
gc->lineStyle, gc->fillStyle);
goto fail;
}
@ -77,11 +76,9 @@ glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
y2 = points[i + 1].y;
}
if (x1 != x2 && y1 != y2) {
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
free(rects);
glamor_fallback("stub diagonal poly_line\n");
goto fail;
return;
}
if (x1 < x2) {
rects[i].x = x1;

View File

@ -39,6 +39,7 @@
#include "glyphstr.h"
#endif
#ifndef MAX_WIDTH
#define MAX_WIDTH 4096
#endif
@ -47,175 +48,450 @@
#define MAX_HEIGHT 4096
#endif
typedef enum glamor_access {
GLAMOR_ACCESS_RO,
GLAMOR_ACCESS_RW,
} glamor_access_t;
#include "glamor_debug.h"
#define glamor_check_fbo_width_height(_w_, _h_) (_w_ > 0 && _h_ > 0 \
&& _w_ < MAX_WIDTH \
&& _h_ < MAX_HEIGHT)
#define glamor_check_fbo_depth(_depth_) ( \
_depth_ == 8 \
|| _depth_ == 15 \
|| _depth_ == 16 \
|| _depth_ == 24 \
|| _depth_ == 30 \
|| _depth_ == 32)
#define GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) (pixmap_priv->is_picture == 1)
#define GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv) (pixmap_priv->gl_fbo == 1)
typedef struct glamor_transform_uniforms {
GLint x_bias;
GLint x_scale;
GLint y_bias;
GLint y_scale;
GLint x_bias;
GLint x_scale;
GLint y_bias;
GLint y_scale;
} glamor_transform_uniforms;
typedef struct glamor_composite_shader {
GLuint prog;
GLint dest_to_dest_uniform_location;
GLint dest_to_source_uniform_location;
GLint dest_to_mask_uniform_location;
GLint source_uniform_location;
GLint mask_uniform_location;
GLuint prog;
GLint dest_to_dest_uniform_location;
GLint dest_to_source_uniform_location;
GLint dest_to_mask_uniform_location;
GLint source_uniform_location;
GLint mask_uniform_location;
} glamor_composite_shader;
typedef struct {
INT16 x_src;
INT16 y_src;
INT16 x_mask;
INT16 y_mask;
INT16 x_dst;
INT16 y_dst;
INT16 width;
INT16 height;
INT16 x_src;
INT16 y_src;
INT16 x_mask;
INT16 y_mask;
INT16 x_dst;
INT16 y_dst;
INT16 width;
INT16 height;
} glamor_composite_rect_t;
typedef struct {
unsigned char sha1[20];
unsigned char sha1[20];
} glamor_cached_glyph_t;
typedef struct {
/* The identity of the cache, statically configured at initialization */
unsigned int format;
int glyph_width;
int glyph_height;
/* The identity of the cache, statically configured at initialization */
unsigned int format;
int glyph_width;
int glyph_height;
/* Size of cache; eventually this should be dynamically determined */
int size;
/* Size of cache; eventually this should be dynamically determined */
int size;
/* Hash table mapping from glyph sha1 to position in the glyph; we use
* open addressing with a hash table size determined based on size and large
* enough so that we always have a good amount of free space, so we can
* use linear probing. (Linear probing is preferrable to double hashing
* here because it allows us to easily remove entries.)
*/
int *hash_entries;
int hash_size;
/* Hash table mapping from glyph sha1 to position in the glyph; we use
* open addressing with a hash table size determined based on size and large
* enough so that we always have a good amount of free space, so we can
* use linear probing. (Linear probing is preferrable to double hashing
* here because it allows us to easily remove entries.)
*/
int *hash_entries;
int hash_size;
glamor_cached_glyph_t *glyphs;
int glyph_count; /* Current number of glyphs */
glamor_cached_glyph_t *glyphs;
int glyph_count; /* Current number of glyphs */
PicturePtr picture; /* Where the glyphs of the cache are stored */
int y_offset; /* y location within the picture where the cache starts */
int columns; /* Number of columns the glyphs are layed out in */
int eviction_position; /* Next random position to evict a glyph */
PicturePtr picture; /* Where the glyphs of the cache are stored */
int y_offset; /* y location within the picture where the cache starts */
int columns; /* Number of columns the glyphs are layed out in */
int eviction_position; /* Next random position to evict a glyph */
} glamor_glyph_cache_t;
#define GLAMOR_NUM_GLYPH_CACHES 4
enum shader_source {
SHADER_SOURCE_SOLID,
SHADER_SOURCE_TEXTURE,
SHADER_SOURCE_TEXTURE_ALPHA,
SHADER_SOURCE_COUNT,
SHADER_SOURCE_SOLID,
SHADER_SOURCE_TEXTURE,
SHADER_SOURCE_TEXTURE_ALPHA,
SHADER_SOURCE_COUNT,
};
enum shader_mask {
SHADER_MASK_NONE,
SHADER_MASK_SOLID,
SHADER_MASK_TEXTURE,
SHADER_MASK_TEXTURE_ALPHA,
SHADER_MASK_COUNT,
SHADER_MASK_NONE,
SHADER_MASK_SOLID,
SHADER_MASK_TEXTURE,
SHADER_MASK_TEXTURE_ALPHA,
SHADER_MASK_COUNT,
};
enum shader_in {
SHADER_IN_SOURCE_ONLY,
SHADER_IN_NORMAL,
SHADER_IN_CA_SOURCE,
SHADER_IN_CA_ALPHA,
SHADER_IN_COUNT,
SHADER_IN_SOURCE_ONLY,
SHADER_IN_NORMAL,
SHADER_IN_CA_SOURCE,
SHADER_IN_CA_ALPHA,
SHADER_IN_COUNT,
};
typedef struct glamor_screen_private {
CloseScreenProcPtr saved_close_screen;
CreateGCProcPtr saved_create_gc;
CreatePixmapProcPtr saved_create_pixmap;
DestroyPixmapProcPtr saved_destroy_pixmap;
GetSpansProcPtr saved_get_spans;
GetImageProcPtr saved_get_image;
CompositeProcPtr saved_composite;
TrapezoidsProcPtr saved_trapezoids;
GlyphsProcPtr saved_glyphs;
ChangeWindowAttributesProcPtr saved_change_window_attributes;
CopyWindowProcPtr saved_copy_window;
BitmapToRegionProcPtr saved_bitmap_to_region;
TrianglesProcPtr saved_triangles;
CloseScreenProcPtr saved_close_screen;
CreateGCProcPtr saved_create_gc;
CreatePixmapProcPtr saved_create_pixmap;
DestroyPixmapProcPtr saved_destroy_pixmap;
GetSpansProcPtr saved_get_spans;
GetImageProcPtr saved_get_image;
CompositeProcPtr saved_composite;
TrapezoidsProcPtr saved_trapezoids;
GlyphsProcPtr saved_glyphs;
ChangeWindowAttributesProcPtr saved_change_window_attributes;
CopyWindowProcPtr saved_copy_window;
BitmapToRegionProcPtr saved_bitmap_to_region;
TrianglesProcPtr saved_triangles;
CreatePictureProcPtr saved_create_picture;
DestroyPictureProcPtr saved_destroy_picture;
char *delayed_fallback_string;
int yInverted;
GLuint vbo;
int vbo_offset;
int vbo_size;
char *vb;
int vb_stride;
int yInverted;
int screen_fbo;
GLuint vbo;
int vbo_offset;
int vbo_size;
char *vb;
int vb_stride;
/* glamor_finishaccess */
GLint finish_access_prog;
GLint aswizzle_prog;
/* glamor_finishaccess */
GLint finish_access_prog[2];
/* glamor_solid */
GLint solid_prog;
GLint solid_color_uniform_location;
/* glamor_solid */
GLint solid_prog;
GLint solid_color_uniform_location;
/* glamor_tile */
GLint tile_prog;
/* glamor_tile */
GLint tile_prog;
/* glamor_putimage */
GLint put_image_xybitmap_prog;
glamor_transform_uniforms put_image_xybitmap_transform;
GLint put_image_xybitmap_fg_uniform_location;
GLint put_image_xybitmap_bg_uniform_location;
/* glamor_putimage */
GLint put_image_xybitmap_prog;
glamor_transform_uniforms put_image_xybitmap_transform;
GLint put_image_xybitmap_fg_uniform_location;
GLint put_image_xybitmap_bg_uniform_location;
/* glamor_composite */
glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT]
[SHADER_MASK_COUNT]
[SHADER_IN_COUNT];
Bool has_source_coords, has_mask_coords;
int render_nr_verts;
/* glamor_composite */
glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT]
[SHADER_MASK_COUNT]
[SHADER_IN_COUNT];
Bool has_source_coords, has_mask_coords;
int render_nr_verts;
glamor_glyph_cache_t glyph_caches[GLAMOR_NUM_GLYPH_CACHES];
glamor_glyph_cache_t glyph_caches[GLAMOR_NUM_GLYPH_CACHES];
char delayed_fallback_string[GLAMOR_DELAYED_STRING_MAX + 1];
int delayed_fallback_pending;
} glamor_screen_private;
enum glamor_pixmap_type {
GLAMOR_GL,
GLAMOR_FB
};
typedef enum glamor_access {
GLAMOR_ACCESS_RO,
GLAMOR_ACCESS_RW,
GLAMOR_ACCESS_WO,
} glamor_access_t;
/*
* glamor_pixmap_private - glamor pixmap's private structure.
* @gl_fbo: The pixmap is attached to a fbo originally.
* @gl_tex: The pixmap is in a gl texture originally.
* @pbo_valid: The pbo has a valid copy of the pixmap's data.
* @is_picture: The drawable is attached to a picture.
* @tex: attached texture.
* @fb: attached fbo.
* @pbo: attached pbo.
* @access_mode: access mode during the prepare/finish pair.
* @pict_format: the corresponding picture's format.
* @container: The corresponding pixmap's pointer.
**/
typedef struct glamor_pixmap_private {
GLuint tex;
GLuint fb;
GLuint pbo;
enum glamor_pixmap_type type;
glamor_access_t access_mode;
unsigned char gl_fbo:1;
unsigned char gl_tex:1;
unsigned char pbo_valid:1;
unsigned char is_picture:1;
GLuint tex;
GLuint fb;
GLuint pbo;
glamor_access_t access_mode;
PictFormatShort pict_format;
PixmapPtr container;
} glamor_pixmap_private;
/*
* Pixmap dynamic status, used by dynamic upload feature.
*
* GLAMOR_NONE: initial status, don't need to do anything.
* GLAMOR_UPLOAD_PENDING: marked as need to be uploaded to gl texture.
* GLAMOR_UPLOAD_DONE: the pixmap has been uploaded successfully.
* GLAMOR_UPLOAD_FAILED: fail to upload the pixmap.
*
* */
typedef enum glamor_pixmap_status {
GLAMOR_NONE,
GLAMOR_UPLOAD_PENDING,
GLAMOR_UPLOAD_DONE,
GLAMOR_UPLOAD_FAILED
} glamor_pixmap_status_t;
extern DevPrivateKey glamor_screen_private_key;
extern DevPrivateKey glamor_pixmap_private_key;
static inline glamor_screen_private *
glamor_get_screen_private(ScreenPtr screen)
{
return (glamor_screen_private *)dixLookupPrivate(&screen->devPrivates,
glamor_screen_private_key);
return (glamor_screen_private *)dixLookupPrivate(&screen->devPrivates,
glamor_screen_private_key);
}
static inline glamor_pixmap_private *
glamor_get_pixmap_private(PixmapPtr pixmap)
{
return dixLookupPrivate(&pixmap->devPrivates, glamor_pixmap_private_key);
return dixLookupPrivate(&pixmap->devPrivates, glamor_pixmap_private_key);
}
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
/**
* Borrow from uxa.
*/
static inline CARD32
format_for_depth(int depth)
{
switch (depth) {
case 1: return PICT_a1;
case 4: return PICT_a4;
case 8: return PICT_a8;
case 15: return PICT_x1r5g5b5;
case 16: return PICT_r5g6b5;
default:
case 24: return PICT_x8r8g8b8;
#if XORG_VERSION_CURRENT >= 10699900
case 30: return PICT_x2r10g10b10;
#endif
case 32: return PICT_a8r8g8b8;
}
}
static inline CARD32
format_for_pixmap(PixmapPtr pixmap)
{
glamor_pixmap_private *pixmap_priv;
PictFormatShort pict_format;
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
pict_format = pixmap_priv->pict_format;
else
pict_format = format_for_depth(pixmap->drawable.depth);
return pict_format;
}
/*
* Map picture's format to the correct gl texture format and type.
* xa is used to indicate whehter we need to wire alpha to 1.
*
* Return 0 if find a matched texture type. Otherwise return -1.
**/
static inline int
glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
GLenum *tex_format,
GLenum *tex_type,
int *xa)
{
*xa = 0;
switch (format) {
case PICT_a1:
*tex_format = GL_COLOR_INDEX;
*tex_type = GL_BITMAP;
break;
case PICT_b8g8r8x8:
*xa = 1;
case PICT_b8g8r8a8:
*tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_INT_8_8_8_8;
break;
case PICT_x8r8g8b8:
*xa = 1;
case PICT_a8r8g8b8:
*tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
break;
case PICT_x8b8g8r8:
*xa = 1;
case PICT_a8b8g8r8:
*tex_format = GL_RGBA;
*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
break;
case PICT_x2r10g10b10:
*xa = 1;
case PICT_a2r10g10b10:
*tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
break;
case PICT_x2b10g10r10:
*xa = 1;
case PICT_a2b10g10r10:
*tex_format = GL_RGBA;
*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
break;
case PICT_r5g6b5:
*tex_format = GL_RGB;
*tex_type = GL_UNSIGNED_SHORT_5_6_5;
break;
case PICT_b5g6r5:
*tex_format = GL_RGB;
*tex_type = GL_UNSIGNED_SHORT_5_6_5_REV;
break;
case PICT_x1b5g5r5:
*xa = 1;
case PICT_a1b5g5r5:
*tex_format = GL_RGBA;
*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
break;
case PICT_x1r5g5b5:
*xa = 1;
case PICT_a1r5g5b5:
*tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
break;
case PICT_a8:
*tex_format = GL_ALPHA;
*tex_type = GL_UNSIGNED_BYTE;
break;
case PICT_x4r4g4b4:
*xa = 1;
case PICT_a4r4g4b4:
*tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
break;
case PICT_x4b4g4r4:
*xa = 1;
case PICT_a4b4g4r4:
*tex_format = GL_RGBA;
*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
break;
default:
LogMessageVerb(X_INFO, 0, "fail to get matched format for %x \n", format);
return -1;
}
return 0;
}
static inline int
glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
GLenum *format,
GLenum *type,
int *ax)
{
glamor_pixmap_private *pixmap_priv;
PictFormatShort pict_format;
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
pict_format = pixmap_priv->pict_format;
else
pict_format = format_for_depth(pixmap->drawable.depth);
return glamor_get_tex_format_type_from_pictformat(pict_format,
format, type, ax);
}
/* borrowed from uxa */
static inline Bool
glamor_get_rgba_from_pixel(CARD32 pixel,
float * red,
float * green,
float * blue,
float * alpha,
CARD32 format)
{
int rbits, bbits, gbits, abits;
int rshift, bshift, gshift, ashift;
rbits = PICT_FORMAT_R(format);
gbits = PICT_FORMAT_G(format);
bbits = PICT_FORMAT_B(format);
abits = PICT_FORMAT_A(format);
if (PICT_FORMAT_TYPE(format) == PICT_TYPE_A) {
rshift = gshift = bshift = ashift = 0;
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
bshift = 0;
gshift = bbits;
rshift = gshift + gbits;
ashift = rshift + rbits;
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
rshift = 0;
gshift = rbits;
bshift = gshift + gbits;
ashift = bshift + bbits;
#if XORG_VERSION_CURRENT >= 10699900
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
ashift = 0;
rshift = abits;
if (abits == 0)
rshift = PICT_FORMAT_BPP(format) - (rbits+gbits+bbits);
gshift = rshift + rbits;
bshift = gshift + gbits;
#endif
} else {
return FALSE;
}
#define COLOR_INT_TO_FLOAT(_fc_, _p_, _s_, _bits_) \
*_fc_ = (((_p_) >> (_s_)) & (( 1 << (_bits_)) - 1)) \
/ (float)((1<<(_bits_)) - 1)
if (rbits)
COLOR_INT_TO_FLOAT(red, pixel, rshift, rbits);
else
*red = 0;
if (gbits)
COLOR_INT_TO_FLOAT(green, pixel, gshift, gbits);
else
*green = 0;
if (bbits)
COLOR_INT_TO_FLOAT(blue, pixel, bshift, bbits);
else
*blue = 0;
if (abits)
COLOR_INT_TO_FLOAT(alpha, pixel, ashift, abits);
else
*alpha = 1;
return TRUE;
}
/**
* Returns TRUE if the given planemask covers all the significant bits in the
* pixel values for pDrawable.
@ -223,91 +499,47 @@ glamor_get_pixmap_private(PixmapPtr pixmap)
static inline Bool
glamor_pm_is_solid(DrawablePtr drawable, unsigned long planemask)
{
return (planemask & FbFullMask(drawable->depth)) ==
FbFullMask(drawable->depth);
return (planemask & FbFullMask(drawable->depth)) ==
FbFullMask(drawable->depth);
}
static inline void
glamor_fallback(char *format, ...)
{
va_list ap;
va_start(ap, format);
//LogMessageVerb(X_INFO, 3, "fallback: ");
//LogMessageVerb(X_NONE, 3, format, ap);
va_end(ap);
}
static inline void
glamor_delayed_fallback(ScreenPtr screen, char *format, ...)
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
va_list ap;
if (glamor_priv->delayed_fallback_string != NULL)
return;
va_start(ap, format);
XNFvasprintf(&glamor_priv->delayed_fallback_string, format, ap);
va_end(ap);
}
static inline void
glamor_clear_delayed_fallbacks(ScreenPtr screen)
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
free(glamor_priv->delayed_fallback_string);
glamor_priv->delayed_fallback_string = NULL;
}
static inline void
glamor_report_delayed_fallbacks(ScreenPtr screen)
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
if (glamor_priv->delayed_fallback_string) {
//LogMessageVerb(X_INFO, 3, "fallback: %s",
// glamor_priv->delayed_fallback_string);
glamor_clear_delayed_fallbacks(screen);
}
}
extern int glamor_debug_level;
static inline float
v_from_x_coord_x(PixmapPtr pixmap, int x)
{
return (float)x / pixmap->drawable.width * 2.0 - 1.0;
return (float)x / pixmap->drawable.width * 2.0 - 1.0;
}
static inline float
v_from_x_coord_y(PixmapPtr pixmap, int y)
{
return (float)y / pixmap->drawable.height * -2.0 + 1.0;
return (float)y / pixmap->drawable.height * -2.0 + 1.0;
}
static inline float
v_from_x_coord_y_inverted(PixmapPtr pixmap, int y)
{
return (float)y / pixmap->drawable.height * 2.0 - 1.0;
return (float)y / pixmap->drawable.height * 2.0 - 1.0;
}
static inline float
t_from_x_coord_x(PixmapPtr pixmap, int x)
{
return (float)x / pixmap->drawable.width;
return (float)x / pixmap->drawable.width;
}
static inline float
t_from_x_coord_y(PixmapPtr pixmap, int y)
{
return 1.0 - (float)y / pixmap->drawable.height;
return 1.0 - (float)y / pixmap->drawable.height;
}
static inline float
t_from_x_coord_y_inverted(PixmapPtr pixmap, int y)
{
return (float)y / pixmap->drawable.height;
return (float)y / pixmap->drawable.height;
}
@ -359,7 +591,15 @@ GLint glamor_compile_glsl_prog(GLenum type, const char *source);
void glamor_link_glsl_prog(GLint prog);
void glamor_get_color_4f_from_pixel(PixmapPtr pixmap, unsigned long fg_pixel,
GLfloat *color);
Bool glamor_set_destination_pixmap(PixmapPtr pixmap);
int glamor_set_destination_pixmap(PixmapPtr pixmap);
int glamor_set_destination_pixmap_priv(glamor_pixmap_private *pixmap_priv);
/* nc means no check. caller must ensure this pixmap has valid fbo.
* usually use the GLAMOR_PIXMAP_PRIV_HAS_FBO firstly.
* */
void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *pixmap_priv);
void glamor_set_alu(unsigned char alu);
Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
void glamor_get_transform_uniform_locations(GLint prog,
@ -462,15 +702,93 @@ Bool glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
int tile_x, int tile_y);
void glamor_init_tile_shader(ScreenPtr screen);
/* glamor_triangles */
/* glamor_triangles.c */
void
glamor_triangles (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntris,
xTriangle *tris);
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntris,
xTriangle *tris);
/* glamor_pixmap.c */
/**
* Download a pixmap's texture to cpu memory. If success,
* One copy of current pixmap's texture will be put into
* the pixmap->devPrivate.ptr. Will use pbo to map to
* the pointer if possible.
* The pixmap must be a gl texture pixmap. gl_fbo and
* gl_tex must be 1. Used by glamor_prepare_access.
*
*/
Bool
glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access);
/**
* Restore a pixmap's data which is downloaded by
* glamor_download_pixmap_to_cpu to its original
* gl texture. Used by glamor_finish_access.
*
* The pixmap must be
* in texture originally. In other word, the gl_fbo
* must be 1.
**/
void
glamor_restore_pixmap_to_texture(PixmapPtr pixmap);
/**
* Upload a pixmap to gl texture. Used by dynamic pixmap
* uploading feature. The pixmap must be a software pixmap.
* This function will change current FBO and current shaders.
*/
enum glamor_pixmap_status
glamor_upload_pixmap_to_texture(PixmapPtr pixmap);
/**
* Upload a picture to gl texture. Similar to the
* glamor_upload_pixmap_to_texture. Used in rendering.
**/
enum glamor_pixmap_status
glamor_upload_picture_to_texture(PicturePtr picture);
/**
* Destroy all the resources allocated on the uploading
* phase, includs the tex and fbo.
**/
void
glamor_destroy_upload_pixmap(PixmapPtr pixmap);
int
glamor_create_picture(PicturePtr picture);
Bool
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access);
void
glamor_finish_access_picture(PicturePtr picture);
void
glamor_destroy_picture(PicturePtr picture);
enum glamor_pixmap_status
glamor_upload_picture_to_texture(PicturePtr picture);
void
glamor_picture_format_fixup(PicturePtr picture, glamor_pixmap_private *pixmap_priv);
/* Dynamic pixmap upload to texture if needed.
* Sometimes, the target is a gl texture pixmap/picture,
* but the source or mask is in cpu memory. In that case,
* upload the source/mask to gl texture and then avoid
* fallback the whole process to cpu. Most of the time,
* this will increase performance obviously. */
#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
#endif /* GLAMOR_PRIV_H */

View File

@ -132,6 +132,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
0.0, 1.0,
};
dest_coords[0][0] = v_from_x_coord_x(pixmap, x);
dest_coords[0][1] = v_from_x_coord_y(pixmap, y);
dest_coords[1][0] = v_from_x_coord_x(pixmap, x + w);
@ -226,13 +227,11 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
return;
fail:
glamor_set_alu(GXcopy);
glamor_set_planemask(pixmap, ~0);
glamor_fallback("glamor_put_image(): to %p (%c)\n",
glamor_fallback(": to %p (%c)\n",
drawable, glamor_get_drawable_location(drawable));
fail:
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap, bits);
glamor_finish_access(drawable);
@ -251,12 +250,11 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
RegionPtr clip;
BoxPtr pbox;
int nbox;
int bpp = drawable->bitsPerPixel;
int src_stride = PixmapBytePad(w, drawable->depth);
int x_off, y_off;
float vertices[4][2], texcoords[4][2];
GLuint tex;
int alfa_mode = 0;
int ax = 0;
if (image_format == XYBitmap) {
assert(depth == 1);
glamor_put_image_xybitmap(drawable, gc, x, y, w, h,
@ -264,56 +262,32 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
return;
}
if (pixmap_priv == NULL) {
glamor_fallback("glamor_put_image: system memory pixmap\n");
goto fail;
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
glamor_fallback("has no fbo.\n");
goto fail;
}
if (pixmap_priv->fb == 0) {
ScreenPtr screen = pixmap->drawable.pScreen;
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
if (pixmap != screen_pixmap) {
glamor_fallback("glamor_put_image: no fbo\n");
goto fail;
}
}
if (bpp == 1 && image_format == XYPixmap)
image_format = ZPixmap;
if (image_format != ZPixmap) {
glamor_fallback("glamor_put_image: non-ZPixmap\n");
glamor_fallback("non-ZPixmap\n");
goto fail;
}
switch (drawable->depth) {
case 1:
format = GL_COLOR_INDEX;
type = GL_BITMAP;
break;
case 8:
format = GL_ALPHA;
type = GL_UNSIGNED_BYTE;
break;
case 24:
assert(drawable->bitsPerPixel == 32);
/* FALLTHROUGH */
alfa_mode = 1;
case 32:
format = GL_BGRA;
type = GL_UNSIGNED_INT_8_8_8_8_REV;
break;
default:
glamor_fallback("glamor_putimage: bad depth %d\n", drawable->depth);
if (!glamor_set_planemask(pixmap, gc->planemask)) {
goto fail;
}
if (!glamor_set_planemask(pixmap, gc->planemask))
goto fail;
glamor_set_alu(gc->alu);
if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format,
&type,
&ax
)) {
glamor_fallback("unknown depth. %d \n",
drawable->depth);
goto fail;
}
/* XXX consider to reuse a function to do the following work. */
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
@ -321,15 +295,13 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, texcoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
glViewport(0, 0, pixmap->drawable.width, pixmap->drawable.height);
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ROW_LENGTH, src_stride * 8 /
pixmap->drawable.bitsPerPixel);
if (bpp == 1)
glPixelStorei(GL_UNPACK_SKIP_PIXELS, left_pad);
glGenTextures(1, &tex);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
@ -341,10 +313,7 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
glEnable(GL_TEXTURE_2D);
assert(GLEW_ARB_fragment_shader);
if (alfa_mode == 0)
glUseProgramObjectARB(glamor_priv->finish_access_prog);
else
glUseProgramObjectARB(glamor_priv->aswizzle_prog);
glUseProgramObjectARB(glamor_priv->finish_access_prog[ax]);
x += drawable->x;
y += drawable->y;
@ -425,7 +394,7 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
fail:
glamor_set_planemask(pixmap, ~0);
glamor_fallback("glamor_put_image(): to %p (%c)\n",
glamor_fallback("to %p (%c)\n",
drawable, glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
fbPutImage(drawable, gc, depth, x, y, w, h, left_pad, image_format,

File diff suppressed because it is too large Load Diff

View File

@ -37,46 +37,23 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
{
PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
GLenum format, type;
uint8_t *temp_src = NULL, *drawpixels_src = (uint8_t *)src;
int i, j;
int wmax = 0;
int ax, i;
uint8_t *drawpixels_src = (uint8_t *)src;
RegionPtr clip = fbGetCompositeClip(gc);
BoxRec *pbox;
int x_off, y_off;
goto fail;
for (i = 0 ; i < n; i++) {
if (wmax < widths[i])
wmax = widths[i];
if (glamor_get_tex_format_type_from_pixmap(dest_pixmap,
&format,
&type,
&ax
)) {
glamor_fallback("unknown depth. %d \n",
drawable->depth);
goto fail;
}
switch (drawable->depth) {
case 1:
temp_src = malloc(wmax);
format = GL_ALPHA;
type = GL_UNSIGNED_BYTE;
drawpixels_src = temp_src;
break;
case 8:
format = GL_ALPHA;
type = GL_UNSIGNED_BYTE;
break;
case 24:
format = GL_RGB;
type = GL_UNSIGNED_BYTE;
break;
case 32:
format = GL_BGRA;
type = GL_UNSIGNED_INT_8_8_8_8_REV;
break;
default:
glamor_fallback("glamor_set_spans()Unknown depth %d\n",
drawable->depth);
goto fail;
}
if (!glamor_set_destination_pixmap(dest_pixmap))
if (glamor_set_destination_pixmap(dest_pixmap))
goto fail;
if (!glamor_set_planemask(dest_pixmap, gc->planemask))
goto fail;
@ -87,14 +64,6 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
glamor_get_drawable_deltas(drawable, dest_pixmap, &x_off, &y_off);
for (i = 0; i < n; i++) {
if (temp_src) {
for (j = 0; j < widths[i]; j++) {
if (src[j / 8] & (1 << (j % 8)))
temp_src[j] = 0xff;
else
temp_src[j] = 0;
}
}
n = REGION_NUM_RECTS(clip);
pbox = REGION_RECTS(clip);
@ -113,19 +82,14 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
format, type,
drawpixels_src);
}
if (temp_src) {
src += PixmapBytePad(widths[i], drawable->depth);
} else {
drawpixels_src += PixmapBytePad(widths[i], drawable->depth);
}
}
fail:
glDisable(GL_SCISSOR_TEST);
glamor_set_planemask(dest_pixmap, ~0);
glamor_set_alu(GXcopy);
free(temp_src);
glamor_fallback("glamor_set_spans(): to %p (%c)\n",
glamor_fallback("to %p (%c)\n",
drawable, glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
fbSetSpans(drawable, gc, src, points, widths, n, sorted);

View File

@ -91,24 +91,26 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
glamor_pixmap_private *tile_priv = glamor_get_pixmap_private(tile);
float vertices[4][2];
float source_texcoords[4][2];
if (glamor_priv->tile_prog == 0) {
glamor_fallback("Tiling unsupported\n");
goto fail;
}
if (!glamor_set_destination_pixmap(pixmap))
if (glamor_set_destination_pixmap(pixmap)) {
glamor_fallback("dest has no fbo.");
goto fail;
}
if (tile_priv->tex == 0) {
if (tile_priv->gl_tex == 0) {
glamor_fallback("Non-texture tile pixmap\n");
goto fail;
}
if (!glamor_set_planemask(pixmap, planemask))
if (!glamor_set_planemask(pixmap, planemask)) {
glamor_fallback("unsupported planemask %lx\n", planemask);
goto fail;
}
glamor_set_alu(alu);
glUseProgramObjectARB(glamor_priv->tile_prog);
glActiveTexture(GL_TEXTURE0);

View File

@ -45,7 +45,7 @@ ephyr_glamor_init(ScreenPtr screen)
ephyr_glamor_host_create_context(kd_screen);
glamor_init(screen, 0);
glamor_init(screen, GLAMOR_HOSTX);
return TRUE;
}

View File

@ -113,8 +113,7 @@ glamor_resize(ScrnInfoPtr scrn, int width, int height)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
glamor_set_pixmap_texture(screen->GetScreenPixmap(screen),
width, height, texture);
glamor_set_screen_pixmap_texture(screen, width, height, texture);
glamor->root = image;
scrn->virtualX = width;
scrn->virtualY = height;