Raspberry Pi 4 kmsdrm (no x11) error creating egl_surface (sdl2 2.0.12)

I am in the process of providing Raspberry Pi4 support for Lime:
a crossplatform haxe library that uses sdl2.

It uses the sdl2 2.0.12 source files to compile a dynamic library for the platform you want to compile to.
For Raspberry Pi 4 the X11 video driver works just fine.
But when I use SDL with KMSDRM support, my program segfaults in SDL_kmsdrmvideo.c.
the visual_id that is set with SDL_EGL_SetRequiredVisualId:
GBM_FORMAT_XRGB8888 ( 875713112)
will not return a valid eglConfig because no config matches the visual_id
egl returns EGL_NATIVE_VISUALID 875713089
and ALL other ATTRIBUTES return that same value 875713089 ( via dumpconfig)

When I comment out the line SDL_EGL_SetRequiredVisualId(_this, surface_fmt);
It does work! SDL_EGL_ChooseConfig finds a working config and the eglconfig attributes return sensible values.

This is on A Raspberry Pi 4, with Raspberry Pi OS 2020-08-20 (formerly known as buster).
with libgles2-mesa-dev libdrm-dev and libgbm-dev installed and using the fkms driver.
All config vars and paths are copied from a regular configure of sdl2 2.0.12.

Any Ideas if this is a bug, or that I’m missing a configuration var?

Hello there.
Can you please try building from latest sources in hg?
hg clone http://hg.libsdl.org/SDL

The kmsdrm backend was rewritten since 2.0.12.
Also, take into account that Raspberry Pi OS ships with horribly outdated MESA versions. So maybe updating would fix it.

All in all, never saw that happening. Does it happen only in a program or all SDL2 programs behave the same?

Aaaand another note: please don’t use fkms, but full KMS instead:
dtoverlay=vc4-kms-v3d-pi4

I will go ahead an build from sources in hg.
And I will try an sdl only gles2 example to see what happens there.

I found that the number egl_config returned for visual_id is the value of GBM_FORMAT_ARGB8888
instead of GBM_FORMAT_XRGB8888

Problem with full-kms is that that option is not given (in raspi-config) on a fresh latest version op Raspberry Pi OS, only fkms.
For me that’s not a problem but for a non-advanced Pi-user it might be a bit hard.

I install SDL2 from the Raspbian Buster repository (which I don’t think is 2.0.12 yet) and that ‘just works’: sudo apt-get install libsdl2-2.0-0

Ah I see that in SDL from hg ,
in KMSDRM_CreateSurfaces: SDL_EGL_SetRequiredVisualId(_this, surface_fmt) is now called with
surface_fmt = GBM_FORMAT_ARGB8888;
this is exactly what I did to get it working, but thought was probably wrong.

I’ll have a look and see if I can integrate the new kms_backend,

Thnx