[Mesa-dev] [PATCH 4/6] st/dri: handle emulated YUV texture sampling in query_dma_buf_modifiers
Lucas Stach
l.stach at pengutronix.de
Fri Apr 12 17:33:33 UTC 2019
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.
+ */
+ pscreen->query_dmabuf_modifiers(pscreen, PIPE_FORMAT_R8_UNORM, max,
+ modifiers, external_only, count);
+ return true;
}
return false;
}
--
2.20.1
More information about the mesa-dev
mailing list