# Raspberry Pi 4 kmsdrm (no x11) error creating egl\_surface (sdl2 2.0.12)

**URL:** <https://discourse.libsdl.org/t/raspberry-pi-4-kmsdrm-no-x11-error-creating-egl-surface-sdl2-2-0-12/28332>\
**Category:** SDL Development\
**Created:** [November 11, 2020, 4:37pm UTC](https://discourse.libsdl.org/t/raspberry-pi-4-kmsdrm-no-x11-error-creating-egl-surface-sdl2-2-0-12/28332 "2020-11-11T16:37:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gepatto](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/gepatto/32/4289_2.png) [@gepatto](https://discourse.libsdl.org/u/gepatto)\
**Post date:** [November 11, 2020, 4:37pm UTC](https://discourse.libsdl.org/t/raspberry-pi-4-kmsdrm-no-x11-error-creating-egl-surface-sdl2-2-0-12/28332/1 "2020-11-11T16:37:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![vanfanel](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/vanfanel/32/3781_2.png) [@vanfanel](https://discourse.libsdl.org/u/vanfanel)\
**Post date:** [November 12, 2020, 12:36pm UTC](https://discourse.libsdl.org/t/raspberry-pi-4-kmsdrm-no-x11-error-creating-egl-surface-sdl2-2-0-12/28332/2 "2020-11-12T12:36:13Z")

</div>

> [@gepatto](#):
>
> SDL\_EGL\_SetRequiredVisualId

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`

---

<div class="post-metadata">

**Author:** ![gepatto](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/gepatto/32/4289_2.png) [@gepatto](https://discourse.libsdl.org/u/gepatto)\
**Post date:** [November 12, 2020, 4:59pm UTC](https://discourse.libsdl.org/t/raspberry-pi-4-kmsdrm-no-x11-error-creating-egl-surface-sdl2-2-0-12/28332/3 "2020-11-12T16:59:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [November 12, 2020, 5:10pm UTC](https://discourse.libsdl.org/t/raspberry-pi-4-kmsdrm-no-x11-error-creating-egl-surface-sdl2-2-0-12/28332/4 "2020-11-12T17:10:47Z")

</div>

> [@vanfanel](#):
>
> Does it happen only in a program or all SDL2 programs behave the same?

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`

---

<div class="post-metadata">

**Author:** ![gepatto](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/gepatto/32/4289_2.png) [@gepatto](https://discourse.libsdl.org/u/gepatto)\
**Post date:** [November 12, 2020, 7:56pm UTC](https://discourse.libsdl.org/t/raspberry-pi-4-kmsdrm-no-x11-error-creating-egl-surface-sdl2-2-0-12/28332/5 "2020-11-12T19:56:24Z")

</div>

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
