Commit 1ded029d authored by Jason Ekstrand's avatar Jason Ekstrand Committed by chadversary

gbm: Use modifiers to create the surface when available

Reviewed-by: chadversary's avatarChad Versace <chad@kiwitree.net>
Closes: #45
parent 8a7ba0f4
......@@ -41,7 +41,8 @@
f(struct gbm_surface *, gbm_surface_create , true, (struct gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, uint32_t flags)) \
f(void , gbm_surface_destroy , true, (struct gbm_surface *surface)) \
f(struct gbm_bo * , gbm_surface_lock_front_buffer , true, (struct gbm_surface *surface)) \
f(void , gbm_surface_release_buffer , true, (struct gbm_surface *surface, struct gbm_bo *bo))
f(void , gbm_surface_release_buffer , true, (struct gbm_surface *surface, struct gbm_bo *bo)) \
f(struct gbm_surface *, gbm_surface_create_with_modifiers, false, (struct gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, const uint64_t *modifiers, const unsigned int count))
struct linux_platform;
......
......@@ -77,12 +77,44 @@ wgbm_window_init(struct wgbm_window *self,
{
struct wgbm_display *dpy = wgbm_display(wc_config->display);
struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));
uint32_t format = wegl_config(wc_config)->visual;
bool ok = true;
self->gbm_surface = plat->gbm_surface_create(dpy->gbm_device,
width, height,
wegl_config(wc_config)->visual,
GBM_BO_USE_RENDERING);
if (dpy->wegl.EXT_image_dma_buf_import_modifiers &&
plat->gbm_surface_create_with_modifiers) {
EGLint num_modifiers = 0;
uint64_t *modifiers;
if (!plat->wegl.eglQueryDmaBufModifiersEXT(dpy->wegl.egl, format,
0, NULL,
NULL, &num_modifiers)) {
wcore_errorf(WAFFLE_ERROR_UNKNOWN,
"eglQueryDmaBufModifiersEXT failed");
return false;
}
modifiers = wcore_calloc(num_modifiers * sizeof(*modifiers));
if (!plat->wegl.eglQueryDmaBufModifiersEXT(dpy->wegl.egl, format,
num_modifiers, modifiers,
NULL, &num_modifiers)) {
wcore_errorf(WAFFLE_ERROR_UNKNOWN,
"eglQueryDmaBufModifiersEXT failed");
free(modifiers);
return false;
}
self->gbm_surface =
plat->gbm_surface_create_with_modifiers(dpy->gbm_device,
width, height, format,
modifiers, num_modifiers);
free(modifiers);
} else {
self->gbm_surface =
plat->gbm_surface_create(dpy->gbm_device,
width, height, format,
GBM_BO_USE_RENDERING);
}
if (!self->gbm_surface) {
wcore_errorf(WAFFLE_ERROR_UNKNOWN,
"gbm_surface_create failed");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment