[Mesa-dev] [PATCH 1/7] egl/dri2: Avoid sign extension when building modifier

Eric Engestrom eric.engestrom at imgtec.com
Tue Jun 6 17:27:07 UTC 2017


On Tuesday, 2017-06-06 18:18:31 +0100, Daniel Stone wrote:
> Since the EGL attributes are signed integers, a straight OR would
> also perform sign extension,
> 
> Fixes: 6f10e7c37a ("egl/dri2: Create EGLImages with dmabuf modifiers")
> Cc: Varad Gautam <varad.gautam at collabora.com>
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index d31a0bf8e0..7175e827c9 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -2278,9 +2278,8 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
>      * will be present in attrs.DMABufPlaneModifiersLo[0] and
>      * attrs.DMABufPlaneModifiersHi[0] */
>     if (attrs.DMABufPlaneModifiersLo[0].IsPresent) {
> -      modifier =
> -         ((uint64_t) attrs.DMABufPlaneModifiersHi[0].Value << 32) |
> -         attrs.DMABufPlaneModifiersLo[0].Value;
> +      modifier = (uint64_t) attrs.DMABufPlaneModifiersHi[0].Value << 32;
> +      modifier |= (uint64_t) (attrs.DMABufPlaneModifiersLo[0].Value & 0xffffffff);

To be clear, the fix is to cast Lo before OR'ing it, right?
The rest is just aesthetic?

Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>

>        has_modifier = true;
>     } else {
>        modifier = DRM_FORMAT_MOD_INVALID;
> -- 
> 2.13.0
> 


More information about the mesa-dev mailing list