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 <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/725>
macos/master
Ryan Neph 3 years ago committed by Marge Bot
parent 61c526177f
commit 4bcc867600
  1. 15
      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. */

Loading…
Cancel
Save