On Fri, 2019-04-12 at 19:33 +0200, Lucas Stach wrote: > The Mesa state tracker will emulate YUV texture sampling for drivers that > don't support it natively by using multiple R8/RG88 samplers. Teach > dri2_query_dma_buf_modifiers about this special case. > This allows clients like GStreamer glupload or Kodi to properly query > the supported dma-buf import formats, without the need to take a special > code path for the emulated OES_external texture handling. > > Signed-off-by: Lucas Stach <l.st...@pengutronix.de> > --- > src/gallium/state_trackers/dri/dri2.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/src/gallium/state_trackers/dri/dri2.c > b/src/gallium/state_trackers/dri/dri2.c > index f139bd6722b9..4243a00cb38d 100644 > --- a/src/gallium/state_trackers/dri/dri2.c > +++ b/src/gallium/state_trackers/dri/dri2.c > @@ -1358,19 +1358,30 @@ dri2_query_dma_buf_modifiers(__DRIscreen *_screen, > int fourcc, int max, > const struct dri2_format_mapping *map = > dri2_get_mapping_by_fourcc(fourcc); > enum pipe_format format; > > - if (!map) > + if (!map || !pscreen->query_dmabuf_modifiers) > return false; > > format = map->pipe_format; > > - if (pscreen->query_dmabuf_modifiers != NULL && > - (pscreen->is_format_supported(pscreen, format, screen->target, 0, 0, > + if ((pscreen->is_format_supported(pscreen, format, screen->target, 0, 0, > PIPE_BIND_RENDER_TARGET) || > pscreen->is_format_supported(pscreen, format, screen->target, 0, 0, > PIPE_BIND_SAMPLER_VIEW))) { > pscreen->query_dmabuf_modifiers(pscreen, format, max, modifiers, > external_only, count); > return true; > + } else if (util_format_is_yuv(format) && > + pscreen->is_format_supported(pscreen, PIPE_FORMAT_R8_UNORM, > + screen->target, 0, 0, > + PIPE_BIND_SAMPLER_VIEW)) { > + /* YUV format sampling can be emulated by the Mesa state tracker by > + * using multiple R8/RG88 samplers if the driver doesn't support those > + * formats natively, so we need a special case here to give a mostly > + * accurate answer to the modifiers query. > + */
"Mostly accurate" meaning that for IYUV this is correct, but for NV12 we are assuming that the drivers will return the same modifiers for PIPE_FORMAT_R8_UNORM as for PIPE_FORMAT_RG88_UNORM. As far as I can tell, this is currently the case for all drivers that implement query_dmabuf_modifiers. Reviewed-by: Philipp Zabel <p.za...@pengutronix.de> regards Philipp _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev