clients/simple-dmabuf-egl: don't add INVALID to modifier list

While this is harmless because gbm_bo_create_with_modifiers will just
fail, it's easy to misunderstand that gbm_bo_create_with_modifiers
accepts MOD_INVALID. Let's just keep modifiers_count to zero instead
and stop even trying to call that function with invalid input.

Stop using modifiers_count to decide whether the compositor supports a
format. Instead use a separate format_supported flag.

Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7601#note_778845
dev
Simon Ser 4 years ago
parent e649c12316
commit 0ccad4b24f
  1. 15
      clients/simple-dmabuf-egl.c

@ -78,6 +78,7 @@ struct display {
struct weston_direct_display_v1 *direct_display; struct weston_direct_display_v1 *direct_display;
struct zwp_linux_explicit_synchronization_v1 *explicit_sync; struct zwp_linux_explicit_synchronization_v1 *explicit_sync;
uint32_t format; uint32_t format;
bool format_supported;
uint64_t *modifiers; uint64_t *modifiers;
int modifiers_count; int modifiers_count;
int req_dmabuf_immediate; int req_dmabuf_immediate;
@ -997,13 +998,19 @@ dmabuf_modifiers(void *data, struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf,
uint32_t format, uint32_t modifier_hi, uint32_t modifier_lo) uint32_t format, uint32_t modifier_hi, uint32_t modifier_lo)
{ {
struct display *d = data; struct display *d = data;
uint64_t modifier = ((uint64_t)modifier_hi << 32) | modifier_lo;
if (format == d->format) { if (format != d->format) {
return;
}
d->format_supported = true;
if (modifier != DRM_FORMAT_MOD_INVALID) {
++d->modifiers_count; ++d->modifiers_count;
d->modifiers = realloc(d->modifiers, d->modifiers = realloc(d->modifiers,
d->modifiers_count * sizeof(*d->modifiers)); d->modifiers_count * sizeof(*d->modifiers));
d->modifiers[d->modifiers_count - 1] = d->modifiers[d->modifiers_count - 1] = modifier;
((uint64_t)modifier_hi << 32) | modifier_lo;
} }
} }
@ -1380,7 +1387,7 @@ create_display(char const *drm_render_node, uint32_t format, int opts)
wl_display_roundtrip(display->display); wl_display_roundtrip(display->display);
if (!display->modifiers_count) { if (!display->format_supported) {
fprintf(stderr, "format 0x%"PRIX32" is not available\n", fprintf(stderr, "format 0x%"PRIX32" is not available\n",
display->format); display->format);
goto error; goto error;

Loading…
Cancel
Save