[Mesa-dev] [PATCH] st: Allow accelerated CopyTexImage from RGBA to RGB.
Brian Paul
brianp at vmware.com
Thu Mar 22 16:40:26 UTC 2018
On 03/21/2018 02:54 PM, Eric Anholt wrote:
> There's nothing to worry about here -- the A channel just gets dropped by
> the blit. This avoids a segfault in the fallback path when copying from a
> RGBA16_SINT renderbuffer to a RGB16_SINT destination represented by an
> RGBA16_SINT texture (the fallback path tries to get/fetch to float
> buffers, but the float pack/unpack functions are NULL for SINT/UINT).
>
> Fixes KHR-GLES3.packed_pixels.pbo_rectangle.rgba16i on VC5.
> ---
> src/mesa/state_tracker/st_cb_texture.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
> index 6345ead6396b..469a82a75390 100644
> --- a/src/mesa/state_tracker/st_cb_texture.c
> +++ b/src/mesa/state_tracker/st_cb_texture.c
> @@ -2327,8 +2327,10 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
> /* The base internal format must match the mesa format, so make sure
> * e.g. an RGB internal format is really allocated as RGB and not as RGBA.
> */
> - if (texImage->_BaseFormat !=
> - _mesa_get_format_base_format(texImage->TexFormat) ||
> + if ((texImage->_BaseFormat !=
> + _mesa_get_format_base_format(texImage->TexFormat) &&
> + (texImage->_BaseFormat != GL_RGB ||
> + _mesa_get_format_base_format(texImage->TexFormat) != GL_RGBA)) ||
> rb->_BaseFormat != _mesa_get_format_base_format(rb->Format)) {
> goto fallback;
> }
When a conditional starts to get complicated like this, I consider
putting it into helper/predicate function. In this case, maybe
st_texture_renderbuffer_formats_compatible().
In any case, the comment should probably be updated to say "But copying
from RGBA to RGB is allowed" so there's no confusion between the comment
and the conditional.
-Brian
More information about the mesa-dev
mailing list