changeset 34810:e48338dbd0cb

Align glMapBuffer result. Mesa for some silly reason returns a pointer that is only 8 byte aligned. Fixes -dr and force-pbo crashes (on e.g. x86) and bad output (on e.g. PPC).
author reimar
date Mon, 14 May 2012 19:31:59 +0000
parents ea97bcb28df1
children 57eee2db5fe7
files libvo/vo_gl.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_gl.c	Mon May 14 18:11:24 2012 +0000
+++ b/libvo/vo_gl.c	Mon May 14 19:31:59 2012 +0000
@@ -929,7 +929,7 @@
     mpi->height = texture_height;
   }
   mpi->stride[0] = mpi->width * mpi->bpp / 8;
-  needed_size = mpi->stride[0] * mpi->height;
+  needed_size = mpi->stride[0] * mpi->height + 31;
   if (mesa_buffer) {
 #ifdef CONFIG_GL_X11
     if (mesa_bufferptr && needed_size > mesa_buffersize) {
@@ -952,7 +952,8 @@
     }
     if (!gl_bufferptr)
       gl_bufferptr = mpglMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
-    mpi->planes[0] = gl_bufferptr;
+    mpi->priv = gl_bufferptr;
+    mpi->planes[0] = (uint8_t *)gl_bufferptr + (-(intptr_t)gl_bufferptr & 31);
     mpglBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
   }
   if (!mpi->planes[0]) {
@@ -1052,7 +1053,7 @@
       mpglPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, 1);
       w = texture_width;
     } else {
-      intptr_t base = (intptr_t)planes[0];
+      intptr_t base = (intptr_t)mpi->priv;
       if (ati_hack) { w = texture_width; h = texture_height; }
       if (mpi_flipped)
         base += (mpi->h - 1) * stride[0];