# HG changeset patch # User reimar # Date 1337023919 0 # Node ID e48338dbd0cb3cedb4fcaee1408621723c6ad15f # Parent ea97bcb28df1ff023d7efd37724b52fe58cbcf66 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). diff -r ea97bcb28df1 -r e48338dbd0cb libvo/vo_gl.c --- 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];