[Mesa-dev] [PATCH kmscube] Fix GBM image formats

Thomas Hellstrom thellstrom at vmware.com
Tue Apr 4 12:49:06 UTC 2017


When the GBM BOs are created, they are created using a bo with a correct
memory requirement but with an incorrect channel layout. This makes
drivers that are picky about matching formats (svga/vmwgfx) complain.

Use the correct GBM formats and require GBM >= 13.0 to make sure they
are available.

Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
---
 configure.ac |  2 +-
 cube-tex.c   | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 242164f..aa0ef36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,7 +36,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 # Obtain compiler/linker options for depedencies
 PKG_CHECK_MODULES(DRM, libdrm)
-PKG_CHECK_MODULES(GBM, gbm)
+PKG_CHECK_MODULES(GBM, gbm >= 13.0)
 PKG_CHECK_MODULES(EGL, egl)
 PKG_CHECK_MODULES(GLES2, glesv2)
 
diff --git a/cube-tex.c b/cube-tex.c
index b11023f..d97ab77 100644
--- a/cube-tex.c
+++ b/cube-tex.c
@@ -223,7 +223,7 @@ static int get_fd_rgba(uint32_t *pstride)
 	int fd;
 
 	/* NOTE: do not actually use GBM_BO_USE_WRITE since that gets us a dumb buffer: */
-	bo = gbm_bo_create(gl.gbm->dev, texw, texh, GBM_FORMAT_ARGB8888, GBM_BO_USE_LINEAR);
+	bo = gbm_bo_create(gl.gbm->dev, texw, texh, GBM_FORMAT_ABGR8888, GBM_BO_USE_LINEAR);
 
 	map = gbm_bo_map(bo, 0, 0, texw, texh, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
 
@@ -254,9 +254,9 @@ static int get_fd_y(uint32_t *pstride)
 
 	/* NOTE: do not actually use GBM_BO_USE_WRITE since that gets us a dumb buffer: */
 	/* hmm, no R8/R8G8 gbm formats?? */
-	bo = gbm_bo_create(gl.gbm->dev, texw/4, texh, GBM_FORMAT_ARGB8888, GBM_BO_USE_LINEAR);
+	bo = gbm_bo_create(gl.gbm->dev, texw, texh, GBM_FORMAT_R8, GBM_BO_USE_LINEAR);
 
-	map = gbm_bo_map(bo, 0, 0, texw/4, texh, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
+	map = gbm_bo_map(bo, 0, 0, texw, texh, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
 
 	for (uint32_t i = 0; i < texh; i++) {
 		memcpy(&map[stride * i], &src[texw * i], texw);
@@ -285,9 +285,9 @@ static int get_fd_uv(uint32_t *pstride)
 
 	/* NOTE: do not actually use GBM_BO_USE_WRITE since that gets us a dumb buffer: */
 	/* hmm, no R8/R8G8 gbm formats?? */
-	bo = gbm_bo_create(gl.gbm->dev, texw/2/2, texh/2, GBM_FORMAT_ARGB8888, GBM_BO_USE_LINEAR);
+	bo = gbm_bo_create(gl.gbm->dev, texw/2, texh/2, GBM_FORMAT_GR88, GBM_BO_USE_LINEAR);
 
-	map = gbm_bo_map(bo, 0, 0, texw/2/2, texh/2, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
+	map = gbm_bo_map(bo, 0, 0, texw/2, texh/2, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
 
 	for (uint32_t i = 0; i < texh/2; i++) {
 		memcpy(&map[stride * i], &src[texw * i], texw);
-- 
2.5.0



More information about the mesa-dev mailing list