mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 11:55:59 +01:00
render/egl: improve modifier support detection
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily indicate support for modifiers. For instance, Mesa will advertise EXT_image_dma_buf_import_modifiers for all drivers. This is a trick to allow EGL clients to enumerate supported formats (something EXT_image_dma_buf_import is missing). For more information, see [1]. Add a new wlr_egl.has_modifiers flag which indicates whether modifiers are supported. It's set to true if any eglQueryDmaBufModifiersEXT query returned a non-empty list. Use that flag to figure out whether the buffer modifier should be passed to the EGL implementation on import. [1]: https://github.com/KhronosGroup/EGL-Registry/issues/142
This commit is contained in:
parent
de0bc78319
commit
1bf9676e87
2 changed files with 10 additions and 14 deletions
|
@ -65,6 +65,7 @@ struct wlr_egl {
|
||||||
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT;
|
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT;
|
||||||
} procs;
|
} procs;
|
||||||
|
|
||||||
|
bool has_modifiers;
|
||||||
struct wlr_drm_format_set dmabuf_texture_formats;
|
struct wlr_drm_format_set dmabuf_texture_formats;
|
||||||
struct wlr_drm_format_set dmabuf_render_formats;
|
struct wlr_drm_format_set dmabuf_render_formats;
|
||||||
};
|
};
|
||||||
|
|
19
render/egl.c
19
render/egl.c
|
@ -160,6 +160,8 @@ static void init_dmabuf_formats(struct wlr_egl *egl) {
|
||||||
has_modifiers ? "supported" : "unsupported");
|
has_modifiers ? "supported" : "unsupported");
|
||||||
free(str_formats);
|
free(str_formats);
|
||||||
|
|
||||||
|
egl->has_modifiers = has_modifiers;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free(formats);
|
free(formats);
|
||||||
}
|
}
|
||||||
|
@ -644,20 +646,12 @@ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_modifier = false;
|
|
||||||
|
|
||||||
// we assume the same way we assumed formats without the import_modifiers
|
|
||||||
// extension that mod_linear is supported. The special mod mod_invalid
|
|
||||||
// is sometimes used to signal modifier unawareness which is what we
|
|
||||||
// have here
|
|
||||||
if (attributes->modifier != DRM_FORMAT_MOD_INVALID &&
|
if (attributes->modifier != DRM_FORMAT_MOD_INVALID &&
|
||||||
attributes->modifier != DRM_FORMAT_MOD_LINEAR) {
|
attributes->modifier != DRM_FORMAT_MOD_LINEAR &&
|
||||||
if (!egl->exts.EXT_image_dma_buf_import_modifiers) {
|
!egl->has_modifiers) {
|
||||||
wlr_log(WLR_ERROR, "dmabuf modifiers extension not present");
|
wlr_log(WLR_ERROR, "EGL implementation doesn't support modifiers");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
has_modifier = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int atti = 0;
|
unsigned int atti = 0;
|
||||||
EGLint attribs[50];
|
EGLint attribs[50];
|
||||||
|
@ -709,7 +703,8 @@ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl,
|
||||||
attribs[atti++] = attributes->offset[i];
|
attribs[atti++] = attributes->offset[i];
|
||||||
attribs[atti++] = attr_names[i].pitch;
|
attribs[atti++] = attr_names[i].pitch;
|
||||||
attribs[atti++] = attributes->stride[i];
|
attribs[atti++] = attributes->stride[i];
|
||||||
if (has_modifier) {
|
if (egl->has_modifiers &&
|
||||||
|
attributes->modifier != DRM_FORMAT_MOD_INVALID) {
|
||||||
attribs[atti++] = attr_names[i].mod_lo;
|
attribs[atti++] = attr_names[i].mod_lo;
|
||||||
attribs[atti++] = attributes->modifier & 0xFFFFFFFF;
|
attribs[atti++] = attributes->modifier & 0xFFFFFFFF;
|
||||||
attribs[atti++] = attr_names[i].mod_hi;
|
attribs[atti++] = attr_names[i].mod_hi;
|
||||||
|
|
Loading…
Reference in a new issue