From ff3d2c796363ea603ab92995091a967a3f8636d7 Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Sun, 15 Apr 2012 17:09:06 +0800 Subject: [PATCH] Fixed a stride problem for textured_drm pixmap. As a textured_drm pixmap has a drm bo attached to it, and it's the DDX layer to set it stride value. In some case, the stride value is not equal to PixmapBytePad(w, depth) which is used within glamor. Then if it is the case, we have two choice, one is to set the GL_PACK_ROW_LENGTH/GL_UNPACK_ROW_LENGTH when we need to download or upload the pixmap. The other option is to change the pixmap's devKind to match the one glamor is using when downloading the pixmap, and restore it to the drm stride after uploading the pixmap. We choose the 2nd option, as GLES doesn't support the first method. Signed-off-by: Zhigang Gong --- glamor/glamor_core.c | 3 +++ glamor/glamor_pixmap.c | 13 ++++++++++--- glamor/glamor_priv.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c index f9c1db22f..009a0899b 100644 --- a/glamor/glamor_core.c +++ b/glamor/glamor_core.c @@ -344,6 +344,9 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode) free(pixmap->devPrivate.ptr); } + if (pixmap_priv->type == GLAMOR_TEXTURE_DRM) + pixmap->devKind = pixmap_priv->drm_stride; + if (pixmap_priv->gl_fbo == GLAMOR_FBO_DOWNLOADED) pixmap_priv->gl_fbo = GLAMOR_FBO_NORMAL; diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c index fbf159f85..db1b163d5 100644 --- a/glamor/glamor_pixmap.c +++ b/glamor/glamor_pixmap.c @@ -688,6 +688,7 @@ glamor_upload_pixmap_to_texture(PixmapPtr pixmap) glamor_pixmap_private *pixmap_priv; void *data; int pbo; + int ret; pixmap_priv = glamor_get_pixmap_private(pixmap); @@ -706,11 +707,11 @@ glamor_upload_pixmap_to_texture(PixmapPtr pixmap) pixmap->drawable.height, pixmap->devKind, data, pbo)) - return GLAMOR_UPLOAD_DONE; + ret = GLAMOR_UPLOAD_DONE; else - return GLAMOR_UPLOAD_FAILED; + ret = GLAMOR_UPLOAD_FAILED; - return GLAMOR_UPLOAD_DONE; + return ret; } void @@ -1023,6 +1024,12 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access) pbo = pixmap_priv->fbo->pbo; } + if (pixmap_priv->type == GLAMOR_TEXTURE_DRM) { + stride = PixmapBytePad(pixmap->drawable.width, pixmap->drawable.depth); + pixmap_priv->drm_stride = pixmap->devKind; + pixmap->devKind = stride; + } + dst = glamor_download_sub_pixmap_to_cpu(pixmap, 0, 0, pixmap->drawable.width, pixmap->drawable.height, diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 9a153099d..46e4dc54c 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -327,6 +327,7 @@ typedef struct glamor_pixmap_private { PictFormatShort pict_format; glamor_pending_op pending_op; PixmapPtr container; + int drm_stride; glamor_screen_private *glamor_priv; } glamor_pixmap_private;