[Mesa-dev] [PATCH 4/6] st/dri: handle emulated YUV texture sampling in query_dma_buf_modifiers
Philipp Zabel
p.zabel at pengutronix.de
Mon Apr 15 12:31:26 UTC 2019
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.stach at 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.zabel at pengutronix.de>
regards
Philipp
More information about the mesa-dev
mailing list