egl/dri2: Avoid sign extension when building modifier
authorDaniel Stone <daniels@collabora.com>
Mon, 5 Jun 2017 13:30:02 +0000 (14:30 +0100)
committerDaniel Stone <daniels@collabora.com>
Thu, 8 Jun 2017 21:27:30 +0000 (22:27 +0100)
Since the EGL attributes are signed integers, a straight OR would
also perform sign extension,

Fixes: 6f10e7c37a ("egl/dri2: Create EGLImages with dmabuf modifiers")
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/egl/drivers/dri2/egl_dri2.c

index d31a0bf..7175e82 100644 (file)
@@ -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);
       has_modifier = true;
    } else {
       modifier = DRM_FORMAT_MOD_INVALID;