libweston: rename get_supported_formats to get_supported_dmabuf_formats

Let's be more more specific and rename the renderer interface function
that returns the supported dma-buf formats. I.e. if we pass a dma-buf
with one of these formats for the renderer, it should be able to import
it.

Next we'll introduce a function to query the rendering formats from
the renderer, so this distinction is important.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
Leandro Ribeiro 2024-09-30 17:01:53 -03:00
parent fba356e44d
commit dd5e1f5047
6 changed files with 22 additions and 21 deletions

View file

@ -2351,8 +2351,8 @@ get_scanout_formats(struct drm_device *device)
/* If we got here it means that dma-buf feedback is supported and that /* If we got here it means that dma-buf feedback is supported and that
* the renderer has formats/modifiers to expose. */ * the renderer has formats/modifiers to expose. */
assert(ec->renderer->get_supported_formats != NULL); assert(ec->renderer->get_supported_dmabuf_formats != NULL);
renderer_formats = ec->renderer->get_supported_formats(ec); renderer_formats = ec->renderer->get_supported_dmabuf_formats(ec);
scanout_formats = zalloc(sizeof(*scanout_formats)); scanout_formats = zalloc(sizeof(*scanout_formats));
if (!scanout_formats) { if (!scanout_formats) {

View file

@ -115,7 +115,7 @@ struct weston_renderer {
struct linux_dmabuf_buffer *buffer); struct linux_dmabuf_buffer *buffer);
const struct weston_drm_format_array * const struct weston_drm_format_array *
(*get_supported_formats)(struct weston_compositor *ec); (*get_supported_dmabuf_formats)(struct weston_compositor *ec);
bool (*fill_buffer_info)(struct weston_compositor *ec, bool (*fill_buffer_info)(struct weston_compositor *ec,
struct weston_buffer *buffer); struct weston_buffer *buffer);

View file

@ -1057,9 +1057,11 @@ bind_linux_dmabuf(struct wl_client *client,
return; return;
/* If we got here, it means that the renderer is able to import dma-buf /* If we got here, it means that the renderer is able to import dma-buf
* buffers, and so it must have get_supported_formats() set. */ * buffers, and so it must have get_supported_dmabuf_formats() set. */
weston_assert_ptr_not_null(compositor, compositor->renderer->get_supported_formats); weston_assert_ptr_not_null(compositor,
supported_formats = compositor->renderer->get_supported_formats(compositor); compositor->renderer->get_supported_dmabuf_formats);
supported_formats =
compositor->renderer->get_supported_dmabuf_formats(compositor);
wl_array_for_each(fmt, &supported_formats->arr) { wl_array_for_each(fmt, &supported_formats->arr) {
modifiers = weston_drm_format_get_modifiers(fmt, &num_modifiers); modifiers = weston_drm_format_get_modifiers(fmt, &num_modifiers);

View file

@ -403,7 +403,7 @@ struct gl_renderer {
EGLDeviceEXT egl_device; EGLDeviceEXT egl_device;
const char *drm_device; const char *drm_device;
struct weston_drm_format_array supported_formats; struct weston_drm_format_array supported_dmabuf_formats;
uint64_t egl_client_extensions; uint64_t egl_client_extensions;
uint64_t egl_device_extensions; uint64_t egl_device_extensions;

View file

@ -3702,15 +3702,15 @@ gl_renderer_attach_buffer(struct weston_surface *surface,
} }
static const struct weston_drm_format_array * static const struct weston_drm_format_array *
gl_renderer_get_supported_formats(struct weston_compositor *ec) gl_renderer_get_supported_dmabuf_formats(struct weston_compositor *ec)
{ {
struct gl_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(ec);
return &gr->supported_formats; return &gr->supported_dmabuf_formats;
} }
static int static int
populate_supported_formats(struct weston_compositor *ec, populate_supported_dmabuf_formats(struct weston_compositor *ec,
struct weston_drm_format_array *supported_formats) struct weston_drm_format_array *supported_formats)
{ {
struct weston_drm_format *fmt; struct weston_drm_format *fmt;
@ -4545,7 +4545,7 @@ gl_renderer_destroy(struct weston_compositor *ec)
wl_list_for_each_safe(format, next_format, &gr->dmabuf_formats, link) wl_list_for_each_safe(format, next_format, &gr->dmabuf_formats, link)
dmabuf_format_destroy(format); dmabuf_format_destroy(format);
weston_drm_format_array_fini(&gr->supported_formats); weston_drm_format_array_fini(&gr->supported_dmabuf_formats);
gl_renderer_allocator_destroy(gr->allocator); gl_renderer_allocator_destroy(gr->allocator);
@ -4642,7 +4642,7 @@ gl_renderer_display_create(struct weston_compositor *ec,
if (!gr->allocator) if (!gr->allocator)
weston_log("failed to initialize allocator\n"); weston_log("failed to initialize allocator\n");
weston_drm_format_array_init(&gr->supported_formats); weston_drm_format_array_init(&gr->supported_dmabuf_formats);
log_egl_info(gr, gr->egl_display); log_egl_info(gr, gr->egl_display);
@ -4693,17 +4693,16 @@ gl_renderer_display_create(struct weston_compositor *ec,
if (egl_display_has(gr, EXTENSION_EXT_IMAGE_DMA_BUF_IMPORT) && if (egl_display_has(gr, EXTENSION_EXT_IMAGE_DMA_BUF_IMPORT) &&
gl_extensions_has(gr, EXTENSION_OES_EGL_IMAGE)) { gl_extensions_has(gr, EXTENSION_OES_EGL_IMAGE)) {
gr->base.import_dmabuf = gl_renderer_import_dmabuf; gr->base.import_dmabuf = gl_renderer_import_dmabuf;
gr->base.get_supported_formats = gl_renderer_get_supported_formats; gr->base.get_supported_dmabuf_formats = gl_renderer_get_supported_dmabuf_formats;
gr->base.create_renderbuffer_dmabuf = gr->base.create_renderbuffer_dmabuf = gl_renderer_create_renderbuffer_dmabuf;
gl_renderer_create_renderbuffer_dmabuf; ret = populate_supported_dmabuf_formats(ec, &gr->supported_dmabuf_formats);
ret = populate_supported_formats(ec, &gr->supported_formats);
if (ret < 0) if (ret < 0)
goto fail_terminate; goto fail_terminate;
if (gr->drm_device) { if (gr->drm_device) {
/* We support dma-buf feedback only when the renderer /* We support dma-buf feedback only when the renderer
* exposes a DRM-device */ * exposes a DRM-device */
ec->dmabuf_feedback_format_table = ec->dmabuf_feedback_format_table =
weston_dmabuf_feedback_format_table_create(&gr->supported_formats); weston_dmabuf_feedback_format_table_create(&gr->supported_dmabuf_formats);
if (!ec->dmabuf_feedback_format_table) if (!ec->dmabuf_feedback_format_table)
goto fail_terminate; goto fail_terminate;
ret = create_default_dmabuf_feedback(ec, gr); ret = create_default_dmabuf_feedback(ec, gr);
@ -4765,7 +4764,7 @@ fail_feedback:
ec->dmabuf_feedback_format_table = NULL; ec->dmabuf_feedback_format_table = NULL;
} }
fail_terminate: fail_terminate:
weston_drm_format_array_fini(&gr->supported_formats); weston_drm_format_array_fini(&gr->supported_dmabuf_formats);
eglTerminate(gr->egl_display); eglTerminate(gr->egl_display);
fail: fail:
weston_log_scope_destroy(gr->shader_scope); weston_log_scope_destroy(gr->shader_scope);

View file

@ -3926,7 +3926,7 @@ vulkan_renderer_import_dmabuf(struct weston_compositor *ec,
} }
static const struct weston_drm_format_array * static const struct weston_drm_format_array *
vulkan_renderer_get_supported_formats(struct weston_compositor *ec) vulkan_renderer_get_supported_dmabuf_formats(struct weston_compositor *ec)
{ {
struct vulkan_renderer *vr = get_renderer(ec); struct vulkan_renderer *vr = get_renderer(ec);
@ -4352,7 +4352,7 @@ vulkan_renderer_display_create(struct weston_compositor *ec,
if (vr->has_external_memory_dma_buf) { if (vr->has_external_memory_dma_buf) {
int ret; int ret;
vr->base.import_dmabuf = vulkan_renderer_import_dmabuf; vr->base.import_dmabuf = vulkan_renderer_import_dmabuf;
vr->base.get_supported_formats = vulkan_renderer_get_supported_formats; vr->base.get_supported_dmabuf_formats = vulkan_renderer_get_supported_dmabuf_formats;
vr->base.create_renderbuffer_dmabuf = vr->base.create_renderbuffer_dmabuf =
vulkan_renderer_create_renderbuffer_dmabuf; vulkan_renderer_create_renderbuffer_dmabuf;