From 0f3594cd7b0871c030aff418b4a1611119f789a1 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Wed, 4 Jul 2018 15:19:17 +0200 Subject: [PATCH] gallium/dri: allow create image for formats that only support SV or RT binding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unconditionally requesting both bindings can lead to premature failure to create a valid image. Signed-off-by: Lucas Stach Reviewed-by: Philipp Zabel Reviewed-by: Marek Olšák Part-of: --- src/gallium/frontends/dri/dri2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c index f7a74df60d2..12633277452 100644 --- a/src/gallium/frontends/dri/dri2.c +++ b/src/gallium/frontends/dri/dri2.c @@ -989,14 +989,23 @@ dri2_create_image_common(__DRIscreen *_screen, { const struct dri2_format_mapping *map = dri2_get_mapping_by_format(format); struct dri_screen *screen = dri_screen(_screen); + struct pipe_screen *pscreen = screen->base.screen; __DRIimage *img; struct pipe_resource templ; - unsigned tex_usage; + unsigned tex_usage = 0; if (!map) return NULL; - tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; + if (pscreen->is_format_supported(pscreen, map->pipe_format, screen->target, + 0, 0, PIPE_BIND_RENDER_TARGET)) + tex_usage |= PIPE_BIND_RENDER_TARGET; + if (pscreen->is_format_supported(pscreen, map->pipe_format, screen->target, + 0, 0, PIPE_BIND_SAMPLER_VIEW)) + tex_usage |= PIPE_BIND_SAMPLER_VIEW; + + if (!tex_usage) + return NULL; if (use & __DRI_IMAGE_USE_SCANOUT) tex_usage |= PIPE_BIND_SCANOUT;