Skip to content

get_color_read_type: make sure format/type combo is legal for gles

Eric Smith requested to merge ericsmith/mesa:readpix-type-format-gles into main
get_color_read_type: make sure format/type combo is legal for gles

The GLES spec limits the valid combinations of format and type that
may be returned by queries and/or used by ReadPixel. The list of valid
combinations appears in table 8.2 of the GLES 3.2 spec. Our code for
reporting the type and format of the current framebuffer, however,
does not verify that the combination is legal for GLES. For example,
RGBA and UNSIGNED_SHORT_1_5_5_5_REV is not a valid GLES combination,
but it's what we were returning for a panthor 16 bit frame buffer.

We can fix this either by changing the format or type that we return
(internally we can handle any format/type combination). We advertise the
read_format_bgra extension, so we could return GL_BGRA for the format.
However, very few applications (including notably the Khronos CTS for GLES)
cope well with BGRA. So instead we change the type to a non-_REV one
so that the combination appears in the GLES spec table of legal values.

Cc: mesa-stable
Signed-off-by: Eric R. Smith <eric.smith@collabora.com>

Merge request reports