[Mesa-dev] [PATCH v4] mesa: handle a bunch of formats in IMPLEMENTATION_COLOR_READ_*

Eric Anholt eric at anholt.net
Tue Jul 17 19:35:13 UTC 2018


Tomeu Vizoso <tomeu.vizoso at collabora.com> writes:

> Virgl could save a lot of work converting buffers in the host side
> between formats if Mesa supported a bunch of other formats when reading
> pixels.
>
> This commit adds cases to handle specific formats so that the values
> reported by the two calls match more closely the underlying native
> formats.
>
> In GLES is important that IMPLEMENTATION_COLOR_READ_* return the native
> format and data type because the spec only allows reading with those,
> besides GL_RGBA or GL_RGBA_INTEGER.
>
> Additionally, because virgl currently doesn't implement such
> conversions, this commit fixes several tests in
> dEQP-GLES3.functional.fbo.color.clear.*, when using virgl in the guest
> side.
>
> The logic is based on knowledge that is shared with
> _mesa_format_matches_format_and_type() but we cannot assert that the
> results match as we don't have all the starting information at both
> points. So leave the assert out and hope CI comes soon to save us all.
>
> v2: * Let R10G10B10A2_UINT fall back to GL_RGBA_INTEGER (Eric Anholt)
>     * Assert with _mesa_format_matches_format_and_type (Eric Anholt)
>
> v3: * Remove the assert, as it won't be reliable (Eric Anholt)
>
> v4: * Use _mesa_is_format_integer in the fallback (Eric Anholt)
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
> Reviewed-by: Gurchetan Singh <gurchetansingh at chromium.org>
> ---
>  src/mesa/main/framebuffer.c | 79 ++++++++++++++++++++++---------------
>  1 file changed, 47 insertions(+), 32 deletions(-)
>
> diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
> index 3ec8b91eaa2c..8e09620966cf 100644
> --- a/src/mesa/main/framebuffer.c
> +++ b/src/mesa/main/framebuffer.c
> @@ -844,22 +844,53 @@ _mesa_get_color_read_format(struct gl_context *ctx,
>     }
>     else {
>        const mesa_format format = fb->_ColorReadBuffer->Format;
> -      const GLenum data_type = _mesa_get_format_datatype(format);
> +      GLenum data_type;
> +      GLuint comps;
>  
> -      if (format == MESA_FORMAT_B8G8R8A8_UNORM)
> +      _mesa_uncompressed_format_to_type_and_comps(format, &data_type, &comps);

This should move down below the format switch, it looks like.

Other than that, I think this gets things right.

Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180717/7ec77417/attachment.sig>


More information about the mesa-dev mailing list