Skip to contentSkip to conversation

uxa/dri: Refine the pageflip processing.

PATCH In review [email protected] 2 participants 4 messages Feb 17, 2012 – Feb 21, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 uxa/dri: Refine the pageflip processing.

From: Zhigang Gong <[email protected]>

Add a new element back_name to intel structure to track the back bo's name then avoid flink every time. And at function I830DRI2ExchangeBuffers, after finish the BO exchange between info's front and back pixmap, it set the new front bo to the screen pixmap. But the screen pixmap should be the same as front's pixmap, so this is a duplicate operation and can be removed.

---
 src/intel.h     |    1 +
 src/intel_dri.c |   48 ++++++++++++++++++++++++++++--------------------
 2 files changed, 29 insertions(+), 20 deletions(-)
src/intel.h +1 -0
index 7593731..16055e9 100644
@@ -254,6 +254,7 @@ typedef struct intel_screen_private {
 
 	void *modes;
 	drm_intel_bo *front_buffer, *back_buffer;
+	unsigned int back_name;
 	long front_pitch, front_tiling;
 	void *shadow_buffer;
 	int shadow_stride;
src/intel_dri.c +28 -20

92 lines not on this page · raw message

Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 2/3 uxa/glamor/dri: Enable the pageflip support on glamor.

From: Zhigang Gong <[email protected]>

To support easy buffer exchange at glamor layer, glamor added a new API glamor_egl_exchange_buffers() to exchange two pixmaps' EGL image and fbos and textures without recreating any of them. But this simple method's requirement is that there are two pixmaps. A exceptional case is:
If we are using triple buffer when do page flipping, we will have an extra back_buffer which doesn't have a pixmap attached to it. Then each time we set that buffer to a pixmap, we will have to call the create_egl_textured_pixmap to create the corresponding EGL image and fbo and texture for it. This is not efficient.

To fix this issue, this commit introduces a new back_pixmap to intel structure to hold the back buffer and corresponding glamor resources. Then we will just need to do the light weight buffer exchanging at both DDX and glamor layer.

As the new back pixmap is similar to the screen pixmap and need to be handled carefully when close screen. As the glamor data structure is a per screen data, and will be released at its close screen method. The glamor's close screen method must cleanup the screen pixmap and back pixmap's glamor resources. screen pixmap is easy to get, but there is no good way to store the back pixmap.

So the glamor add a new API glamor_egl_create_textured_screen_ext function to pass the back pixmap's pointer to glamor layer.

This commit make us depend on glamor commit: 4e58c4f. And we increased the required glamor version from 0.3.0 to 0.3.1

---
 configure.ac        |    2 +-
 src/intel.h         |    1 +
 src/intel_display.c |    8 +++++
 src/intel_dri.c     |   73 ++++++++++++++++++++++++++++++++++++++++++++++-----
 src/intel_driver.c  |    5 +++
 src/intel_glamor.c  |   19 ++++++++++---
 src/intel_glamor.h  |    3 +-
 7 files changed, 98 insertions(+), 13 deletions(-)
configure.ac +1 -1
index 785392a..1e77faf 100644
@@ -158,7 +158,7 @@ AC_ARG_ENABLE(glamor,
 AC_MSG_RESULT([$GLAMOR])
 AM_CONDITIONAL(GLAMOR, test x$GLAMOR != xno)
 if test "x$GLAMOR" != "xno"; then
-	PKG_CHECK_MODULES(LIBGLAMOR, [glamor >= 0.3.0])
+	PKG_CHECK_MODULES(LIBGLAMOR, [glamor >= 0.3.1])
 	PKG_CHECK_MODULES(LIBGLAMOR_EGL, [glamor-egl])
 	AC_DEFINE(USE_GLAMOR, 1, [Enable glamor acceleration])
 fi
src/intel.h +1 -0
index 16055e9..444cb6a 100644
@@ -254,6 +254,7 @@ typedef struct intel_screen_private {
 
 	void *modes;
 	drm_intel_bo *front_buffer, *back_buffer;
+	PixmapPtr back_pixmap;
 	unsigned int back_name;
 	long front_pitch, front_tiling;
 	void *shadow_buffer;
src/intel_display.c +8 -0
index d525ffa..868643a 100644
@@ -47,6 +47,7 @@
 #include "xf86DDC.h"
 
 #include "intel_glamor.h"
+#include "uxa.h"
 
 struct intel_mode {
 	int fd;
@@ -1369,6 +1370,7 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 	int	    i, old_width, old_height, old_pitch;
 	unsigned long pitch;
 	uint32_t tiling;
+	ScreenPtr screen;
 
 	if (scrn->virtualX == width && scrn->virtualY == height)
 		return TRUE;
@@ -1382,6 +1384,12 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 	old_fb_id = mode->fb_id;
 	old_front = intel->front_buffer;
 
+	if (intel->back_pixmap) {
+		screen = intel->back_pixmap->drawable.pScreen;
+		screen->DestroyPixmap(intel->back_pixmap);
+		intel->back_pixmap = NULL;
+	}
+
 	if (intel->back_buffer) {
 		drm_intel_bo_unreference(intel->back_buffer);
 		intel->back_buffer = NULL;
src/intel_dri.c +66 -7

122 lines not on this page · raw message

src/intel_driver.c +5 -0
index d66a8fd..b3871f4 100644
@@ -1210,6 +1210,11 @@ static Bool I830CloseScreen(int scrnIndex, ScreenPtr screen)
 		intel->uxa_driver = NULL;
 	}
 
+	if (intel->back_pixmap) {
+		screen->DestroyPixmap(intel->back_pixmap);
+		intel->back_pixmap = NULL;
+	}
+
 	if (intel->back_buffer) {
 		drm_intel_bo_unreference(intel->back_buffer);
 		intel->back_buffer = NULL;
src/intel_glamor.c +15 -4
index c468d34..a868157 100644
@@ -40,6 +40,16 @@
 #include "intel_glamor.h"
 #include "uxa.h"
 
+void
+intel_glamor_exchange_buffers(struct intel_screen_private *intel,
+			      PixmapPtr src,
+			      PixmapPtr dst)
+{
+	if (!(intel->uxa_flags & UXA_USE_GLAMOR))
+		return;
+	glamor_egl_exchange_buffers(src, dst);
+}
+
 Bool
 intel_glamor_create_screen_resources(ScreenPtr screen)
 {
@@ -52,9 +62,10 @@ intel_glamor_create_screen_resources(ScreenPtr screen)
 	if (!glamor_glyphs_init(screen))
 		return FALSE;
 
-	if (!glamor_egl_create_textured_screen(screen,
-					       intel->front_buffer->handle,
-					       intel->front_pitch))
+	if (!glamor_egl_create_textured_screen_ext(screen,
+						   intel->front_buffer->handle,
+						   intel->front_pitch,
+						   &intel->back_pixmap))
 		return FALSE;
 
 	return TRUE;
@@ -70,7 +81,7 @@ intel_glamor_pre_init(ScrnInfoPtr scrn)
 	/* Load glamor module */
 	if ((glamor_module = xf86LoadSubModule(scrn, GLAMOR_EGL_MODULE_NAME))) {
 		version = xf86GetModuleVersion(glamor_module);
-		if (version < MODULE_VERSION_NUMERIC(0,3,0)) {
+		if (version < MODULE_VERSION_NUMERIC(0,3,1)) {
 			xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 			"Incompatible glamor version, required >= 0.3.0.\n");
 		} else {
src/intel_glamor.h +2 -1
index 3065132..46692bc 100644
@@ -44,7 +44,7 @@ Bool intel_glamor_create_textured_pixmap(PixmapPtr pixmap);
 void intel_glamor_destroy_pixmap(PixmapPtr pixmap);
 PixmapPtr intel_glamor_create_pixmap(ScreenPtr screen, int w, int h,
 				     int depth, unsigned int usage);
-
+void intel_glamor_exchange_buffers(struct intel_screen_private *intel, PixmapPtr src, PixmapPtr dst);
 #else
 
 static inline Bool intel_glamor_pre_init(ScrnInfoPtr scrn) { return TRUE; }
@@ -61,6 +61,7 @@ static inline void intel_glamor_destroy_pixmap(PixmapPtr pixmap) { }
 static inline PixmapPtr intel_glamor_create_pixmap(ScreenPtr screen, int w, int h,
 						   int depth, unsigned int usage) { return NULL; }
 
+static inline void intel_glamor_exchange_buffers(struct intel_screen_private *intel, PixmapPtr src, PixmapPtr dst) {}
 #endif
 
 #endif /* INTEL_GLAMOR_H */
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH 3/3 uxa/glamor/dri: Should fixup the drawable pixmap.

In reply to [email protected]

From: Zhigang Gong <[email protected]>

Two fixes in this commit, first we only need to check the front left buffer, for other attachment we don't need to check them. The second is, we should fixup the pixmap's drawable not the original drawable.

---
 src/intel_dri.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)
src/intel_dri.c +16 -6
index 2a0102d..f6f0c86 100644
@@ -280,14 +280,18 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 		pixmap = NULL;
 		if (attachments[i] == DRI2BufferFrontLeft) {
 			pixmap = get_front_buffer(drawable);
+
+			if (pixmap && intel_get_pixmap_private(pixmap) == NULL) {
+				is_glamor_pixmap = TRUE;
+				drawable = &pixmap->drawable;
+				pixmap = NULL;
+			}
 		} else if (attachments[i] == DRI2BufferStencil && pDepthPixmap) {
 			pixmap = pDepthPixmap;
 			pixmap->refcnt++;
 		}
 
-		is_glamor_pixmap = pixmap && (intel_get_pixmap_private(pixmap) == NULL);
-
-		if (pixmap == NULL || is_glamor_pixmap) {
+		if (pixmap == NULL) {
 			unsigned int hint = INTEL_CREATE_PIXMAP_DRI2;
 
 			if (intel->tiling & INTEL_TILING_3D) {
@@ -398,11 +402,17 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 	}
 
 	pixmap = NULL;
-	if (attachment == DRI2BufferFrontLeft)
+	if (attachment == DRI2BufferFrontLeft) {
 		pixmap = get_front_buffer(drawable);
 
-	is_glamor_pixmap = pixmap && (intel_get_pixmap_private(pixmap) == NULL);
-	if (pixmap == NULL || is_glamor_pixmap) {
+		if (pixmap && intel_get_pixmap_private(pixmap) == NULL) {
+			is_glamor_pixmap = TRUE;
+			drawable = &pixmap->drawable;
+			pixmap = NULL;
+		}
+	}
+
+	if (pixmap == NULL) {
 		unsigned int hint = INTEL_CREATE_PIXMAP_DRI2;
 		int pixmap_width = drawable->width;
 		int pixmap_height = drawable->height;
Signature · 1 line
1.7.4.4
#3 lore raw
In reply to [email protected]
Quoted 9 lines · On Fri, 17 Feb 2012 19:50:50 +0800, [email protected] wrote:

From: Zhigang Gong <[email protected]>

Add a new element back_name to intel structure to track the back bo's name then avoid flink every time. And at function I830DRI2ExchangeBuffers, after finish the BO exchange between info's front and back pixmap, it set the new front bo to the screen pixmap. But the screen pixmap should be the same as front's pixmap, so this is a duplicate operation and can be removed.

I couldn't spot anything intrinsically wrong with the series, so pushed. Thanks,
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre