Skip to content

Commit 83be4b2

Browse files
robclarkaleasto
authored andcommitted
gbm: Allow GBM allocation of YUV surfaces
YUV surfaces may potentially not be renderable by the GPU itself, but they can be sampled from the GPU, and exported to other devices such as video decoder which can render into them. This is required by chrome/chromium v4l2 based video decode stack. In the context of ChromeOS, minigbm allows for allocating YUV gbm BOs. This brings parity to minigbm, so that the v4l2 codec stack can also be used on linux. Suggested-by: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7745 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9079 Signed-off-by: Rob Clark <[email protected]>
1 parent 892169c commit 83be4b2

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

src/egl/drivers/dri2/platform_drm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ dri2_drm_config_is_compatible(struct dri2_egl_display *dri2_dpy,
118118
break;
119119
}
120120

121+
if (visual->is_yuv)
122+
return false;
123+
121124
if (i == dri2_dpy->gbm_dri->num_visuals)
122125
return false;
123126

@@ -516,6 +519,9 @@ drm_add_configs_for_visuals(_EGLDisplay *disp)
516519
for (unsigned j = 0; j < num_visuals; j++) {
517520
struct dri2_egl_config *dri2_conf;
518521

522+
if (visuals[j].is_yuv)
523+
continue;
524+
519525
if (visuals[j].rgba_shifts.red != shifts[0] ||
520526
visuals[j].rgba_shifts.green != shifts[1] ||
521527
visuals[j].rgba_shifts.blue != shifts[2] ||

src/gbm/backends/dri/gbm_dri.c

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,82 @@ static const struct gbm_dri_visual gbm_dri_visuals_table[] = {
472472
{ 16, 16, 16, 16 },
473473
true,
474474
},
475+
{
476+
GBM_FORMAT_YUYV, __DRI_IMAGE_FORMAT_NONE,
477+
.is_yuv = true,
478+
},
479+
{
480+
GBM_FORMAT_YVYU, __DRI_IMAGE_FORMAT_NONE,
481+
.is_yuv = true,
482+
},
483+
{
484+
GBM_FORMAT_UYVY, __DRI_IMAGE_FORMAT_NONE,
485+
.is_yuv = true,
486+
},
487+
{
488+
GBM_FORMAT_VYUY, __DRI_IMAGE_FORMAT_NONE,
489+
.is_yuv = true,
490+
},
491+
{
492+
GBM_FORMAT_AYUV, __DRI_IMAGE_FORMAT_NONE,
493+
.is_yuv = true,
494+
},
495+
{
496+
GBM_FORMAT_NV12, __DRI_IMAGE_FORMAT_NONE,
497+
.is_yuv = true,
498+
},
499+
{
500+
GBM_FORMAT_NV21, __DRI_IMAGE_FORMAT_NONE,
501+
.is_yuv = true,
502+
},
503+
{
504+
GBM_FORMAT_NV16, __DRI_IMAGE_FORMAT_NONE,
505+
.is_yuv = true,
506+
},
507+
{
508+
GBM_FORMAT_NV61, __DRI_IMAGE_FORMAT_NONE,
509+
.is_yuv = true,
510+
},
511+
{
512+
GBM_FORMAT_YUV410, __DRI_IMAGE_FORMAT_NONE,
513+
.is_yuv = true,
514+
},
515+
{
516+
GBM_FORMAT_YVU410, __DRI_IMAGE_FORMAT_NONE,
517+
.is_yuv = true,
518+
},
519+
{
520+
GBM_FORMAT_YUV411, __DRI_IMAGE_FORMAT_NONE,
521+
.is_yuv = true,
522+
},
523+
{
524+
GBM_FORMAT_YVU411, __DRI_IMAGE_FORMAT_NONE,
525+
.is_yuv = true,
526+
},
527+
{
528+
GBM_FORMAT_YUV420, __DRI_IMAGE_FORMAT_NONE,
529+
.is_yuv = true,
530+
},
531+
{
532+
GBM_FORMAT_YVU420, __DRI_IMAGE_FORMAT_NONE,
533+
.is_yuv = true,
534+
},
535+
{
536+
GBM_FORMAT_YUV422, __DRI_IMAGE_FORMAT_NONE,
537+
.is_yuv = true,
538+
},
539+
{
540+
GBM_FORMAT_YVU422, __DRI_IMAGE_FORMAT_NONE,
541+
.is_yuv = true,
542+
},
543+
{
544+
GBM_FORMAT_YUV444, __DRI_IMAGE_FORMAT_NONE,
545+
.is_yuv = true,
546+
},
547+
{
548+
GBM_FORMAT_YVU444, __DRI_IMAGE_FORMAT_NONE,
549+
.is_yuv = true,
550+
},
475551
};
476552

477553
static int

src/gbm/backends/dri/gbm_driint.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct gbm_dri_visual {
5858
unsigned int alpha;
5959
} rgba_sizes;
6060
bool is_float;
61+
bool is_yuv;
6162
};
6263

6364
struct gbm_dri_device {

0 commit comments

Comments
 (0)