From aaab406251540429522c5ef7808ee049c65a06d2 Mon Sep 17 00:00:00 2001 From: Kaido Kert Date: Fri, 29 Nov 2024 04:47:25 +0000 Subject: Implement native visual matching Implement matching GBM buffer format to EGL NATIVE_VISUAL_ID. eglChooseConfig cannot match on NATIVE_VISUAL_ID, but GBM/EGL requires matching formats. Similar logic is implemented in kmscube code in match_config_to_visual. X11, Wayland and Null cube demos remain unchanged. Tested on Raspi-4 and VirtualBox/Ubuntu --- kmscube/cube-gbm.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'kmscube/cube-gbm.cpp') diff --git a/kmscube/cube-gbm.cpp b/kmscube/cube-gbm.cpp index 034ae8a..69930ee 100644 --- a/kmscube/cube-gbm.cpp +++ b/kmscube/cube-gbm.cpp @@ -49,10 +49,10 @@ private: class GbmSurface { public: - GbmSurface(GbmDevice& gdev, int width, int height) + GbmSurface(GbmDevice& gdev, int width, int height, uint32_t format) { m_surface = gbm_surface_create(gdev.handle(), width, height, - GBM_FORMAT_XRGB8888, + format, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); FAIL_IF(!m_surface, "failed to create gbm surface"); } @@ -93,7 +93,7 @@ public: : card(card), egl(egl), m_width(width), m_height(height), bo_prev(0), bo_next(0) { - gsurface = unique_ptr(new GbmSurface(gdev, width, height)); + gsurface = unique_ptr(new GbmSurface(gdev, width, height, egl.native_visual_id())); esurface = eglCreateWindowSurface(egl.display(), egl.config(), gsurface->handle(), NULL); FAIL_IF(esurface == EGL_NO_SURFACE, "failed to create egl surface"); } @@ -319,7 +319,7 @@ void main_gbm() FAIL_IF(!card.has_atomic(), "No atomic modesetting"); GbmDevice gdev(card); - EglState egl(gdev.handle()); + EglState egl(gdev.handle(), GBM_FORMAT_XRGB8888); ResourceManager resman(card); -- cgit v1.2.3