From 750ddf323954d8b005665d1dacd85208837c6ec7 Mon Sep 17 00:00:00 2001 From: Erico Nunes Date: Wed, 14 Apr 2021 00:59:46 +0200 Subject: [PATCH] gallium/hud: extend check for has_srgb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gallium hud checks for the PIPE_FORMAT_B8G8R8A8_SRGB format to set has_srgb, but can then receive a different format such as PIPE_FORMAT_B8G8R8X8 in hud_run. If the driver supports PIPE_FORMAT_B8G8R8A8_SRGB but does not support the other formats such as PIPE_FORMAT_B8G8R8X8_SRGB, that will break rendering as gallium hud assumes srgb is also supported for that format. Extend the check to set has_srgb to prevent that from happening. Signed-off-by: Erico Nunes Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/hud/hud_context.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index ff077950773..5d6b5690b79 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -1891,10 +1891,19 @@ hud_create(struct cso_context *cso, struct st_context_iface *st, } hud->refcount = 1; - hud->has_srgb = screen->is_format_supported(screen, - PIPE_FORMAT_B8G8R8A8_SRGB, - PIPE_TEXTURE_2D, 0, 0, - PIPE_BIND_RENDER_TARGET) != 0; + + static const enum pipe_format srgb_formats[] = { + PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_FORMAT_B8G8R8X8_SRGB + }; + for (i = 0; i < ARRAY_SIZE(srgb_formats); i++) { + if (!screen->is_format_supported(screen, srgb_formats[i], + PIPE_TEXTURE_2D, 0, 0, + PIPE_BIND_RENDER_TARGET)) + break; + } + + hud->has_srgb = (i == ARRAY_SIZE(srgb_formats)); /* blend state */ hud->no_blend.rt[0].colormask = PIPE_MASK_RGBA;