Re: [Mesa-dev] [PATCH 2/2] gbm: Use libkms to work around missing cursor support in dri drivers
*snip* Reviewed-by: Kristian Høgsberg k...@bitplanet.net I briefly tested these patches on RV350 and it fixes the problem here https://bugs.freedesktop.org/show_bug.cgi?id=52267 I did notice that the last frame of the last instance of weston is 'flashed' during the fade-in when running the next instance of weston. Since Jakob added gbm_bo_write support now, I think you're now (for the first time) using hw cursor instead of gl cursor. The flicker could be the RV350 flickering when we enable the hw cursor after the fade finishes. You can try adding return NULL; early in drm_output_prepare_cursor_surface() to disable hw cursor and see if that's the case. Kristian This does not seem to be the case. When weston starts, the last frame from the last instance of weston is shown, then during fade-in, it is all black. Specifically, it's black for about a half second and then weston appears when the fade-in is nearly complete and you can tell damage from the fade animation is still happening because the cursor is slower. Subsequent fades work fine. If switched to X and back to tty, it then shows garbage from the pixels of whatever X was showing. Scott ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] gbm: Use libkms to work around missing cursor support in dri drivers
Uses libkms to work around missing dri image cursor support. One could take this patch one step futher and removing cursor surfaces entirely from the DRI interface and as a consequence also from the Gallium interface. Tho to make everybody happy with this it would probably require adding a kms_bo_write function, but that is probably wise in anyways. The only downside is that it adds a dependancy on libkms, this could how ever be replaced with the dumb_bo drm ioctl interface. Signed-off-by: Jakob Bornecrantz ja...@vmware.com --- configure.ac |2 ++ src/egl/drivers/dri2/Makefile.am |1 + src/gbm/Makefile.am |3 +- src/gbm/backends/dri/gbm_dri.c| 56 + src/gbm/backends/dri/gbm_driint.h |8 ++ 5 files changed, 63 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 2ecedaf..f5836d6 100644 --- a/configure.ac +++ b/configure.ac @@ -1355,6 +1355,8 @@ if test x$enable_gbm = xyes; then if test $SHARED_GLAPI -eq 0; then AC_MSG_ERROR([gbm_dri requires --enable-shared-glapi]) fi +PKG_CHECK_MODULES([LIBKMS], [libkms], [], + AC_MSG_ERROR([gbm needs libkms])) fi fi GBM_PC_REQ_PRIV=libudev diff --git a/src/egl/drivers/dri2/Makefile.am b/src/egl/drivers/dri2/Makefile.am index 49ec06b..45f7dfa 100644 --- a/src/egl/drivers/dri2/Makefile.am +++ b/src/egl/drivers/dri2/Makefile.am @@ -30,6 +30,7 @@ AM_CFLAGS = \ $(DEFINES) \ $(LIBDRM_CFLAGS) \ $(LIBUDEV_CFLAGS) \ + $(LIBKMS_CFLAGS) \ -DDEFAULT_DRIVER_DIR=\$(DRI_DRIVER_SEARCH_DIR)\ noinst_LTLIBRARIES = libegl_dri2.la diff --git a/src/gbm/Makefile.am b/src/gbm/Makefile.am index f079da1..e22c55c 100644 --- a/src/gbm/Makefile.am +++ b/src/gbm/Makefile.am @@ -7,6 +7,7 @@ AM_CFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src/gbm/main \ $(LIBUDEV_CFLAGS) \ + $(LIBKMS_CFLAGS) \ $(DLOPEN_CFLAGS) \ $(DEFINES) @@ -18,7 +19,7 @@ libgbm_la_SOURCES = \ main/backend.c \ main/common.c libgbm_la_LDFLAGS = -version-info 1:0 -libgbm_la_LIBADD = $(LIBUDEV_LIBS) $(DLOPEN_LIBS) +libgbm_la_LIBADD = $(LIBUDEV_LIBS) $(LIBKMS_LIBS) $(DLOPEN_LIBS) if HAVE_EGL_PLATFORM_WAYLAND AM_CPPFLAGS = -DHAVE_WAYLAND_PLATFORM diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index f09f6ef..784bb93 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -301,11 +301,24 @@ gbm_dri_bo_write(struct gbm_bo *_bo, const void *buf, size_t count) { struct gbm_dri_device *dri = gbm_dri_device(_bo-gbm); struct gbm_dri_bo *bo = gbm_dri_bo(_bo); + void *ptr; + int ret; + + /* This should be safe as write is guarded in create. */ + if (bo-image != NULL) + return dri-image-write(bo-image, buf, count); + + if (bo-bo == NULL) + return -1; - if (dri-image-base.version 4) + ret = kms_bo_map(bo-bo, ptr); + if (ret 0) return -1; - return dri-image-write(bo-image, buf, count); + memcpy(ptr, buf, count); + + kms_bo_unmap(bo-bo); + return 0; } static void @@ -314,7 +327,10 @@ gbm_dri_bo_destroy(struct gbm_bo *_bo) struct gbm_dri_device *dri = gbm_dri_device(_bo-gbm); struct gbm_dri_bo *bo = gbm_dri_bo(_bo); - dri-image-destroyImage(bo-image); + if (bo-image != NULL) + dri-image-destroyImage(bo-image); + if (bo-bo != NULL) + kms_bo_destroy(bo-bo); free(bo); } @@ -446,9 +462,6 @@ gbm_dri_bo_create(struct gbm_device *gbm, int dri_format; unsigned dri_use = 0; - if (dri-image-base.version 4 (usage GBM_BO_USE_WRITE)) - return NULL; - bo = calloc(1, sizeof *bo); if (bo == NULL) return NULL; @@ -457,6 +470,33 @@ gbm_dri_bo_create(struct gbm_device *gbm, bo-base.base.width = width; bo-base.base.height = height; + if (dri-image-base.version 4 (usage GBM_BO_USE_WRITE)) { + int ret; + unsigned attrs[7] = { + KMS_WIDTH, 64, + KMS_HEIGHT, 64, + KMS_BO_TYPE, KMS_BO_TYPE_SCANOUT_X8R8G8B8, + KMS_TERMINATE_PROP_LIST, + }; + + if (!(usage GBM_BO_USE_CURSOR_64X64)) + return NULL; + + if (dri-kms == NULL) + return NULL; + + ret = kms_bo_create(dri-kms, attrs, bo-bo); + if (ret 0) { + free(bo); + return NULL; + } + + kms_bo_get_prop(bo-bo, KMS_PITCH, bo-base.base.stride); + kms_bo_get_prop(bo-bo, KMS_HANDLE, (unsigned*)bo-base.base.handle); + + return bo-base.base; + } + switch (format) { case GBM_FORMAT_RGB565: dri_format =__DRI_IMAGE_FORMAT_RGB565; @@ -567,6 +607,10 @@ dri_device_create(int fd) return NULL; } + if (dri-image-base.version 4) { + kms_create(fd, dri-kms); + } + return dri-base.base; } diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h index
Re: [Mesa-dev] [PATCH 2/2] gbm: Use libkms to work around missing cursor support in dri drivers
On Mon, Aug 13, 2012 at 10:16 AM, Jakob Bornecrantz ja...@vmware.com wrote: Uses libkms to work around missing dri image cursor support. One could take this patch one step futher and removing cursor surfaces entirely from the DRI interface and as a consequence also from the Gallium interface. Tho to make everybody happy with this it would probably require adding a kms_bo_write function, but that is probably wise in anyways. The only downside is that it adds a dependancy on libkms, this could how ever be replaced with the dumb_bo drm ioctl interface. Signed-off-by: Jakob Bornecrantz ja...@vmware.com That looks good, using libkms is a fine way to handle this as long as it doesn't leak through the gbm API. Using libkms or dumb_bo ioctl entirely for cursor gbm bo's would be fine too. Reviewed-by: Kristian Høgsberg k...@bitplanet.net --- configure.ac |2 ++ src/egl/drivers/dri2/Makefile.am |1 + src/gbm/Makefile.am |3 +- src/gbm/backends/dri/gbm_dri.c| 56 + src/gbm/backends/dri/gbm_driint.h |8 ++ 5 files changed, 63 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 2ecedaf..f5836d6 100644 --- a/configure.ac +++ b/configure.ac @@ -1355,6 +1355,8 @@ if test x$enable_gbm = xyes; then if test $SHARED_GLAPI -eq 0; then AC_MSG_ERROR([gbm_dri requires --enable-shared-glapi]) fi +PKG_CHECK_MODULES([LIBKMS], [libkms], [], + AC_MSG_ERROR([gbm needs libkms])) fi fi GBM_PC_REQ_PRIV=libudev diff --git a/src/egl/drivers/dri2/Makefile.am b/src/egl/drivers/dri2/Makefile.am index 49ec06b..45f7dfa 100644 --- a/src/egl/drivers/dri2/Makefile.am +++ b/src/egl/drivers/dri2/Makefile.am @@ -30,6 +30,7 @@ AM_CFLAGS = \ $(DEFINES) \ $(LIBDRM_CFLAGS) \ $(LIBUDEV_CFLAGS) \ + $(LIBKMS_CFLAGS) \ -DDEFAULT_DRIVER_DIR=\$(DRI_DRIVER_SEARCH_DIR)\ noinst_LTLIBRARIES = libegl_dri2.la diff --git a/src/gbm/Makefile.am b/src/gbm/Makefile.am index f079da1..e22c55c 100644 --- a/src/gbm/Makefile.am +++ b/src/gbm/Makefile.am @@ -7,6 +7,7 @@ AM_CFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src/gbm/main \ $(LIBUDEV_CFLAGS) \ + $(LIBKMS_CFLAGS) \ $(DLOPEN_CFLAGS) \ $(DEFINES) @@ -18,7 +19,7 @@ libgbm_la_SOURCES = \ main/backend.c \ main/common.c libgbm_la_LDFLAGS = -version-info 1:0 -libgbm_la_LIBADD = $(LIBUDEV_LIBS) $(DLOPEN_LIBS) +libgbm_la_LIBADD = $(LIBUDEV_LIBS) $(LIBKMS_LIBS) $(DLOPEN_LIBS) if HAVE_EGL_PLATFORM_WAYLAND AM_CPPFLAGS = -DHAVE_WAYLAND_PLATFORM diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index f09f6ef..784bb93 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -301,11 +301,24 @@ gbm_dri_bo_write(struct gbm_bo *_bo, const void *buf, size_t count) { struct gbm_dri_device *dri = gbm_dri_device(_bo-gbm); struct gbm_dri_bo *bo = gbm_dri_bo(_bo); + void *ptr; + int ret; + + /* This should be safe as write is guarded in create. */ + if (bo-image != NULL) + return dri-image-write(bo-image, buf, count); + + if (bo-bo == NULL) + return -1; - if (dri-image-base.version 4) + ret = kms_bo_map(bo-bo, ptr); + if (ret 0) return -1; - return dri-image-write(bo-image, buf, count); + memcpy(ptr, buf, count); + + kms_bo_unmap(bo-bo); + return 0; } static void @@ -314,7 +327,10 @@ gbm_dri_bo_destroy(struct gbm_bo *_bo) struct gbm_dri_device *dri = gbm_dri_device(_bo-gbm); struct gbm_dri_bo *bo = gbm_dri_bo(_bo); - dri-image-destroyImage(bo-image); + if (bo-image != NULL) + dri-image-destroyImage(bo-image); + if (bo-bo != NULL) + kms_bo_destroy(bo-bo); free(bo); } @@ -446,9 +462,6 @@ gbm_dri_bo_create(struct gbm_device *gbm, int dri_format; unsigned dri_use = 0; - if (dri-image-base.version 4 (usage GBM_BO_USE_WRITE)) - return NULL; - bo = calloc(1, sizeof *bo); if (bo == NULL) return NULL; @@ -457,6 +470,33 @@ gbm_dri_bo_create(struct gbm_device *gbm, bo-base.base.width = width; bo-base.base.height = height; + if (dri-image-base.version 4 (usage GBM_BO_USE_WRITE)) { + int ret; + unsigned attrs[7] = { + KMS_WIDTH, 64, + KMS_HEIGHT, 64, + KMS_BO_TYPE, KMS_BO_TYPE_SCANOUT_X8R8G8B8, + KMS_TERMINATE_PROP_LIST, + }; + + if (!(usage GBM_BO_USE_CURSOR_64X64)) + return NULL; + + if (dri-kms == NULL) + return NULL; + + ret = kms_bo_create(dri-kms, attrs, bo-bo); + if (ret 0) { + free(bo); + return NULL; + } + + kms_bo_get_prop(bo-bo, KMS_PITCH, bo-base.base.stride); + kms_bo_get_prop(bo-bo, KMS_HANDLE,
Re: [Mesa-dev] [PATCH 2/2] gbm: Use libkms to work around missing cursor support in dri drivers
On Mon, Aug 13, 2012 at 1:00 PM, Scott Moreau ore...@gmail.com wrote: On Mon, Aug 13, 2012 at 10:51 AM, Kristian Høgsberg k...@bitplanet.net wrote: On Mon, Aug 13, 2012 at 10:16 AM, Jakob Bornecrantz ja...@vmware.com wrote: Uses libkms to work around missing dri image cursor support. One could take this patch one step futher and removing cursor surfaces entirely from the DRI interface and as a consequence also from the Gallium interface. Tho to make everybody happy with this it would probably require adding a kms_bo_write function, but that is probably wise in anyways. The only downside is that it adds a dependancy on libkms, this could how ever be replaced with the dumb_bo drm ioctl interface. Signed-off-by: Jakob Bornecrantz ja...@vmware.com That looks good, using libkms is a fine way to handle this as long as it doesn't leak through the gbm API. Using libkms or dumb_bo ioctl entirely for cursor gbm bo's would be fine too. Reviewed-by: Kristian Høgsberg k...@bitplanet.net I briefly tested these patches on RV350 and it fixes the problem here https://bugs.freedesktop.org/show_bug.cgi?id=52267 I did notice that the last frame of the last instance of weston is 'flashed' during the fade-in when running the next instance of weston. Since Jakob added gbm_bo_write support now, I think you're now (for the first time) using hw cursor instead of gl cursor. The flicker could be the RV350 flickering when we enable the hw cursor after the fade finishes. You can try adding return NULL; early in drm_output_prepare_cursor_surface() to disable hw cursor and see if that's the case. Kristian ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev