[waffle] [PATCH] gbm: Use EGLConfig to select the correct gbm format
Tom Stellard
thomas.stellard at amd.com
Tue Feb 24 10:43:13 PST 2015
---
I think this is better than my original patch:
http://lists.freedesktop.org/archives/waffle/2015-February/001070.html
However, piglit tests still fail because the alpha channel is always 1.0.
The gbm format being selected by eglGetConfigAttrib() is
GBM_FORMAT_XRGB8888, and I'm not sure if this is a bug in my patch
or something I need to fix in the EGL implementation.
src/waffle/gbm/wgbm_config.c | 29 ++++++++++++++++++-----------
src/waffle/gbm/wgbm_config.h | 4 +++-
src/waffle/gbm/wgbm_window.c | 3 ++-
3 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/src/waffle/gbm/wgbm_config.c b/src/waffle/gbm/wgbm_config.c
index 480c2bf..be1d4e3 100644
--- a/src/waffle/gbm/wgbm_config.c
+++ b/src/waffle/gbm/wgbm_config.c
@@ -25,6 +25,8 @@
#include "wcore_error.h"
+#include "wegl_platform.h"
+
#include "wgbm_config.h"
#include "wgbm_display.h"
@@ -33,7 +35,8 @@ wgbm_config_choose(struct wcore_platform *wc_plat,
struct wcore_display *wc_dpy,
const struct wcore_config_attrs *attrs)
{
- if (wgbm_config_get_gbm_format(attrs) == 0) {
+ struct wcore_config *config = wegl_config_choose(wc_plat, wc_dpy, attrs);
+ if (wgbm_config_get_gbm_format(wc_plat, wc_dpy, config) == 0) {
wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
"requested config is unsupported on GBM");
return NULL;
@@ -43,19 +46,23 @@ wgbm_config_choose(struct wcore_platform *wc_plat,
}
uint32_t
-wgbm_config_get_gbm_format(const struct wcore_config_attrs *attrs)
+wgbm_config_get_gbm_format(struct wcore_platform *wc_plat,
+ struct wcore_display *wc_display,
+ struct wcore_config *wc_config)
{
- if (attrs->red_size > 8 || attrs->blue_size > 8 ||
- attrs->green_size > 8 || attrs->alpha_size > 8) {
+ EGLint gbm_format;
+ struct wgbm_display *dpy = wgbm_display(wc_display);
+ struct wegl_platform *plat = wegl_platform(wc_plat);
+ struct wegl_config *egl_config = wegl_config(wc_config);
+ bool ok = plat->eglGetConfigAttrib(dpy->wegl.egl,
+ egl_config->egl,
+ EGL_NATIVE_VISUAL_ID,
+ &gbm_format);
+
+ if (!ok) {
return 0;
}
-
- if (attrs->alpha_size <= 0)
- return GBM_FORMAT_XRGB8888;
- else if (attrs->alpha_size <= 8)
- return GBM_FORMAT_ABGR8888;
-
- return 0;
+ return gbm_format;
}
union waffle_native_config*
diff --git a/src/waffle/gbm/wgbm_config.h b/src/waffle/gbm/wgbm_config.h
index 8c83270..2c58321 100644
--- a/src/waffle/gbm/wgbm_config.h
+++ b/src/waffle/gbm/wgbm_config.h
@@ -40,7 +40,9 @@ wgbm_config_choose(struct wcore_platform *wc_plat,
const struct wcore_config_attrs *attrs);
uint32_t
-wgbm_config_get_gbm_format(const struct wcore_config_attrs *attrs);
+wgbm_config_get_gbm_format(struct wcore_platform *wc_plat,
+ struct wcore_display *wc_dpy,
+ struct wcore_config *wc_config);
union waffle_native_config*
wgbm_config_get_native(struct wcore_config *wc_config);
diff --git a/src/waffle/gbm/wgbm_window.c b/src/waffle/gbm/wgbm_window.c
index 9fbf1be..b75b5e3 100644
--- a/src/waffle/gbm/wgbm_window.c
+++ b/src/waffle/gbm/wgbm_window.c
@@ -79,7 +79,8 @@ wgbm_window_create(struct wcore_platform *wc_plat,
if (self == NULL)
return NULL;
- gbm_format = wgbm_config_get_gbm_format(&wc_config->attrs);
+ gbm_format = wgbm_config_get_gbm_format(wc_plat, wc_config->display,
+ wc_config);
assert(gbm_format != 0);
self->gbm_surface = plat->gbm_surface_create(dpy->gbm_device,
width, height, gbm_format,
--
1.8.5.5
More information about the waffle
mailing list