[Glamor] [PATCH 1/3] prepare_access: Don't use fbo after it was downloaded.

zhigang.gong at linux.intel.com zhigang.gong at linux.intel.com
Thu Feb 2 20:00:16 PST 2012


From: Zhigang Gong <zhigang.gong at linux.intel.com>

We add a new gl_fbo status GLAMOR_FBO_DOWNLOADED to indicate
the fbo was already downloaded to CPU. Then latter the access
to this pixmap will be treated as pure CPU access. In glamor,
if we fallback to DDX/fbXXX, then we fallback everything
currently. We don't support to jump into glamor acceleration
layer between a prepare_access/finish_access. Actually, fbCopyPlane
is such a function which may call to acceleration function within
it. Then we must mark the downloaded pixmap to another state
rather than a normal fbo textured pixmap, and then stick to use
it as a in-memory pixmap.

Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 src/glamor_core.c   |    7 ++++---
 src/glamor_pixmap.c |    3 ++-
 src/glamor_priv.h   |   39 ++++++++++++++++++++++++++++-----------
 src/glamor_utils.h  |    3 ++-
 4 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/src/glamor_core.c b/src/glamor_core.c
index 395e912..01c9aea 100644
--- a/src/glamor_core.c
+++ b/src/glamor_core.c
@@ -263,8 +263,6 @@ glamor_fini_finish_access_shaders(ScreenPtr screen)
 	dispatch->glDeleteProgram(glamor_priv->finish_access_prog[1]);
 }
 
-
-
 void
 glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
 {
@@ -275,7 +273,7 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
 	    glamor_get_screen_private(drawable->pScreen);
 	glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
 
-	if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+	if (!GLAMOR_PIXMAP_PRIV_HAS_FBO_DOWNLOADED(pixmap_priv))
 		return;
 
 	if (access_mode != GLAMOR_ACCESS_RO) {
@@ -293,6 +291,9 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
 		free(pixmap->devPrivate.ptr);
 	}
 
+	if (pixmap_priv->gl_fbo == GLAMOR_FBO_DOWNLOADED)
+		pixmap_priv->gl_fbo = GLAMOR_FBO_NORMAL;
+
 	pixmap->devPrivate.ptr = NULL;
 }
 
diff --git a/src/glamor_pixmap.c b/src/glamor_pixmap.c
index e154273..6563e94 100644
--- a/src/glamor_pixmap.c
+++ b/src/glamor_pixmap.c
@@ -641,7 +641,6 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum * format,
  * 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)
 {
@@ -794,6 +793,8 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
 
 	dispatch->glBindFramebuffer(GL_FRAMEBUFFER, 0);
       done:
+
+	pixmap_priv->gl_fbo = GLAMOR_FBO_DOWNLOADED;
 	pixmap->devPrivate.ptr = data;
 
 	if (temp_pixmap)
diff --git a/src/glamor_priv.h b/src/glamor_priv.h
index 0b75588..b19a304 100644
--- a/src/glamor_priv.h
+++ b/src/glamor_priv.h
@@ -243,19 +243,23 @@ typedef union _glamor_pending_op {
 	glamor_pending_fill fill;
 } glamor_pending_op;
 
-/*
- * 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.
+#define GLAMOR_FBO_NORMAL     1
+#define GLAMOR_FBO_DOWNLOADED 2
+/* glamor_pixmap_fbo:
+ * @list:    to be used to link to the cache pool list.
+ * @expire:  when push to cache pool list, set a expire count.
+ * 	     will be freed when glamor_priv->tick is equal or
+ * 	     larger than this expire count in block handler.
  * @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.
- * @pict_format: the corresponding picture's format.
- * #pending_op: currently only support pending filling.
- * @container: The corresponding pixmap's pointer.
- **/
+ * @width:   width of this fbo.
+ * @height:  height of this fbo.
+ * @format:  internal format of this fbo's texture.
+ * @type:    internal type of this fbo's texture.
+ * @glamor_priv: point to glamor private data.
+ */
 typedef struct glamor_pixmap_fbo {
 	struct list list;
 	unsigned int expire;
@@ -270,9 +274,22 @@ typedef struct glamor_pixmap_fbo {
 	glamor_screen_private *glamor_priv;
 } glamor_pixmap_fbo;
 
-
+/*
+ * glamor_pixmap_private - glamor pixmap's private structure.
+ * @gl_fbo:
+ * 	0 		  	- The pixmap doesn't has a fbo attached to it.
+ * 	GLAMOR_FBO_NORMAL 	- The pixmap has a fbo and can be accessed normally.
+ * 	GLAMOR_FBO_DOWNLOADED 	- The pixmap has a fbo and already downloaded to
+ * 				  CPU, so it can only be treated as a in-memory pixmap
+ * 				  if this bit is set.
+ * @gl_tex:  The pixmap is in a gl texture originally.
+ * @is_picture: The drawable is attached to a picture.
+ * @pict_format: the corresponding picture's format.
+ * #pending_op: currently only support pending filling.
+ * @container: The corresponding pixmap's pointer.
+ **/
 typedef struct glamor_pixmap_private {
-	unsigned char gl_fbo:1;
+	unsigned char gl_fbo:2;
 	unsigned char is_picture:1;
 	unsigned char gl_tex:1;
 	glamor_pixmap_type_t type;
diff --git a/src/glamor_utils.h b/src/glamor_utils.h
index b292928..a60b146 100644
--- a/src/glamor_utils.h
+++ b/src/glamor_utils.h
@@ -175,7 +175,8 @@ glamor_transform_boxes(BoxPtr boxes, int nbox, int dx, int dy)
 
 
 #define GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) (pixmap_priv && pixmap_priv->is_picture == 1)
-#define GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)    (pixmap_priv && pixmap_priv->gl_fbo == 1)
+#define GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)    (pixmap_priv && pixmap_priv->gl_fbo == GLAMOR_FBO_NORMAL)
+#define GLAMOR_PIXMAP_PRIV_HAS_FBO_DOWNLOADED(pixmap_priv)    (pixmap_priv && (pixmap_priv->gl_fbo == GLAMOR_FBO_DOWNLOADED))
 
 #define GLAMOR_PIXMAP_PRIV_NEED_VALIDATE(pixmap_priv)  \
 	(GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv) \
-- 
1.7.4.4



More information about the Glamor mailing list