Skip to content

Commit

Permalink
wayland: rename gpu_formats to planar_formats
Browse files Browse the repository at this point in the history
The old name is misleading. We do want these formats, but it is not
accurate to call them "gpu formats". Call it "planar" instead so it's
more obvious these come from drm primary planes.
  • Loading branch information
Dudemanguy committed Sep 30, 2024
1 parent c5aa7d8 commit 99d4dec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static int spawn_cursor(struct vo_wayland_state *wl);
static void add_feedback(struct vo_wayland_feedback_pool *fback_pool,
struct wp_presentation_feedback *fback);
static void apply_keepaspect(struct vo_wayland_state *wl, int *width, int *height);
static void get_gpu_drm_formats(struct vo_wayland_state *wl);
static void get_planar_drm_formats(struct vo_wayland_state *wl);
static void get_shape_device(struct vo_wayland_state *wl, struct vo_wayland_seat *s);
static void guess_focus(struct vo_wayland_state *wl);
static void handle_key_input(struct vo_wayland_seat *s, uint32_t key, uint32_t state, bool no_emit);
Expand Down Expand Up @@ -1406,7 +1406,7 @@ static void tranche_target_device(void *data,
memcpy(&wl->target_device_id, id, sizeof(dev_t));
break;
}
get_gpu_drm_formats(wl);
get_planar_drm_formats(wl);
}
}

Expand Down Expand Up @@ -1828,7 +1828,7 @@ static char **get_displays_spanned(struct vo_wayland_state *wl)
return names;
}

static void get_gpu_drm_formats(struct vo_wayland_state *wl)
static void get_planar_drm_formats(struct vo_wayland_state *wl)
{
#if HAVE_DRM
drmDevice *device = NULL;
Expand Down Expand Up @@ -1913,15 +1913,15 @@ static void get_gpu_drm_formats(struct vo_wayland_state *wl)
}

plane = drmModeGetPlane(fd, res->planes[index]);
wl->num_gpu_formats = plane->count_formats;
wl->num_planar_formats = plane->count_formats;

if (wl->gpu_formats)
talloc_free(wl->gpu_formats);
if (wl->planar_formats)
talloc_free(wl->planar_formats);

wl->gpu_formats = talloc_zero_array(wl, int, wl->num_gpu_formats);
for (int i = 0; i < wl->num_gpu_formats; ++i) {
wl->planar_formats = talloc_zero_array(wl, int, wl->num_planar_formats);
for (int i = 0; i < wl->num_planar_formats; ++i) {
MP_DBG(wl, "DRM primary plane supports drm format: %s\n", mp_tag_str(plane->formats[i]));
wl->gpu_formats[i] = plane->formats[i];
wl->planar_formats[i] = plane->formats[i];
}

done:
Expand Down
4 changes: 2 additions & 2 deletions video/out/wayland_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ struct vo_wayland_state {
uint32_t compositor_format_size;
struct drm_format *compositor_formats;
int num_compositor_formats;
uint32_t *gpu_formats;
int num_gpu_formats;
uint32_t *planar_formats;
int num_planar_formats;

/* presentation-time */
struct wp_presentation *presentation;
Expand Down
14 changes: 7 additions & 7 deletions video/out/wldmabuf/ra_wldmabuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ bool ra_compatible_format(struct ra *ra, int imgfmt, uint32_t drm_format, uint64
struct drm_format *formats = wl->compositor_formats;


// If we were able to make the DRM query, filter out the GPU formats.
// If we were able to make the DRM query, filter out the planar formats.
// If not, just assume they all work and hope for the best.
if (wl->gpu_formats) {
bool supported_gpu_format = false;
for (int i = 0; i < wl->num_gpu_formats; i++) {
if (drm_format == wl->gpu_formats[i]) {
supported_gpu_format = true;
if (wl->planar_formats) {
bool supported_planar_format = false;
for (int i = 0; i < wl->num_planar_formats; i++) {
if (drm_format == wl->planar_formats[i]) {
supported_planar_format = true;
break;
}
}
if (!supported_gpu_format)
if (!supported_planar_format)
return false;
}

Expand Down

0 comments on commit 99d4dec

Please sign in to comment.