st/xlib Fix XIMage bytes-per-pixel calculation
[mesa.git] / src / gallium / state_trackers / glx / xlib / xm_api.c
index b758c8eaae74c97ce949f1f86595eccd6a9641d0..7ed401c514ba705e1a899eb0e54c0652333e6206 100644 (file)
@@ -1407,9 +1407,8 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
          return;
       }
 
-      /* The pipe transfer has a pitch rounded up to the nearest 64 pixels.
-         We assume 32 bit pixels. */
-      ximage_stride = w * 4;
+      /* The pipe transfer has a pitch rounded up to the nearest 64 pixels. */
+      ximage_stride = w * ((img->bits_per_pixel + 7) / 8);
 
       for (line = 0; line < h; line++)
          memcpy(&map[line * tex_xfer->stride],