From 4bcc8676007d013b7be86c0be6de972d3e9a7745 Mon Sep 17 00:00:00 2001 From: Ryan Neph Date: Thu, 3 Mar 2022 10:07:25 -0800 Subject: [PATCH] vrend: adds vrend_resource_supports_view() helper func using glTextureView() on eglimage-backed bgr* textures has been determined to cause format misinterpretation issues, such as swapping the red/blue channels. This adds a convenience function for detecting these unsupported view uses. It will be used to prevent creating views in the following commits. Signed-off-by: Ryan Neph Reviewed-by: Gert Wollny Part-of: --- src/vrend_renderer.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 1031cf3..2c0e8a5 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -908,6 +908,21 @@ static bool vrend_resource_is_emulated_bgra(struct vrend_resource *res) return false; } +static bool vrend_resource_supports_view(const struct vrend_resource *res, + UNUSED enum virgl_formats view_format) +{ + /* Texture views on eglimage-backed bgr* resources are not supported and + * lead to unexpected format interpretation since internally allocated + * bgr* resources use GL_RGBA8 internal format, while eglimage-backed + * resources use BGRA8, but GL lacks an equivalent internalformat enum. + * + * For views that don't require colorspace conversion, we can add swizzles + * instead. For views that do require colorspace conversion, manual srgb + * decode/encode is required. */ + return !(vrend_format_is_bgra(res->base.format) && + has_bit(res->storage_bits, VREND_STORAGE_EGL_IMAGE)); +} + static bool vrend_resource_has_24bpp_internal_format(struct vrend_resource *res) { /* Some shared resources imported to guest mesa as EGL images occupy 24bpp instead of more common 32bpp. */