Fixed bug 3792 - [KMS/DRM] Wrong GBM format
authorSam Lantinga <slouken@libsdl.org>
Fri, 01 Sep 2017 12:54:38 -0700
changeset 1144211413fa29401
parent 11441 f9cf3fb0b2f7
child 11443 a15af5a487a1
Fixed bug 3792 - [KMS/DRM] Wrong GBM format

Romain Tisserand

Using KMS/DRM driver from WIP SDL2.0.6 on Linux/ARM SoC RockChip RK3328 (ARM Mali 450 MP2 GPU).

The current code is using GBM_BO_FORMAT_XRGB8888 as GBM buffer format specifier.

The Mali driver (it has been confirmed some other vendor implementations too) expects GBM_FORMAT_XRGB8888.

The Mesa implementation is actually handling both values as the same, but it's not implemented like this into every gbm.h vendor header.

https://github.com/ideak/mesa/blob/master/src/gbm/backends/dri/gbm_dri.c

So with stock SDL2 on my card (Mali vendor implementation), it does not work, eglCreateWindowSurface fails, and gbm_is_format_supported fails too (with the BO variant).
It runs fine with GBM_FORMAT_XRGB8888.

Here is a link of the gbm.h from Mali user-space driver :

https://github.com/rockchip-linux/libmali/blob/rockchip/include/gbm.h
src/video/kmsdrm/SDL_kmsdrmvideo.c
     1.1 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c	Fri Sep 01 14:08:09 2017 -0400
     1.2 +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c	Fri Sep 01 12:54:38 2017 -0700
     1.3 @@ -500,7 +500,7 @@
     1.4      /* Maybe you didn't ask for a fullscreen OpenGL window, but that's what you get */
     1.5      window->flags |= (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL);
     1.6  
     1.7 -    surface_fmt = GBM_BO_FORMAT_XRGB8888;
     1.8 +    surface_fmt = GBM_FORMAT_XRGB8888;
     1.9      surface_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
    1.10  
    1.11      if (!KMSDRM_gbm_device_is_format_supported(vdata->gbm, surface_fmt, surface_flags)) {