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

Eric Anholt eric at anholt.net
Wed May 16 09:16:20 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.
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
> ---
>  src/mesa/main/framebuffer.c | 73 ++++++++++++++++++++++++++++++++-----
>  1 file changed, 64 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
> index 8e751b453b75..a22c66b349f2 100644
> --- a/src/mesa/main/framebuffer.c
> +++ b/src/mesa/main/framebuffer.c
> @@ -836,15 +836,43 @@ _mesa_get_color_read_format(struct gl_context *ctx,
>        const mesa_format format = fb->_ColorReadBuffer->Format;
>        const GLenum data_type = _mesa_get_format_datatype(format);
>  
> -      if (format == MESA_FORMAT_B8G8R8A8_UNORM)
> +      switch(format) {
> +      case MESA_FORMAT_B8G8R8A8_UNORM:
>           return GL_BGRA;
> -      else if (format == MESA_FORMAT_B5G6R5_UNORM)
> +      case MESA_FORMAT_R10G10B10A2_UINT:
> +         return GL_BGRA_INTEGER;

Surely this should be GL_RGBA_INTEGER?  (maybe just fall back to the
GL_UNSIGNED_INT case below)

Other than that, this patch looks correct and would be an improvement.
However, I'm wondering if we could avoid having so much code by doing
something with _mesa_uncompressed_format_to_type_and_comps() and a bit
of logic on the swizzle of the format to choose between RGB and BGR for
3/4 comps.

Also, could we assert something about
_mesa_format_matches_format_and_type() using the result of this
function, for sanity checking?
-------------- 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/20180516/d922bb24/attachment.sig>


More information about the mesa-dev mailing list