mesa/src
Iago Toral Quiroga f2e513b2c0 mesa: Fix element count for byte-swaps in texstore, readpix and texgetimage
Some old format conversion code in pack.c implemented byte-swapping like this:

GLint comps = _mesa_components_in_format(dstFormat);
GLint swapSize = _mesa_sizeof_packed_type(dstType);
if (swapSize == 2)
   _mesa_swap2((GLushort *) dstAddr, n * comps);
else if (swapSize == 4)
   _mesa_swap4((GLuint *) dstAddr, n * comps);

where n is the pixel count. But this is incorrect for packed formats,
where _mesa_sizeof_packed_type is already returning the size of a pixel
instead of the size of a single component, so multiplying this by the
number of components in the format results in a larger element count
for _mesa_swap than we want.

Unfortunately, we followed the same implementation for byte-swapping
in the rewrite of the format conversion code for texstore, readpixels
and texgetimage.

This patch computes the correct element counts for _mesa_swap calls
by computing the bytes per pixel in the image and dividing that by the
swap size to obtain the number of swaps required per pixel. Then multiplies
that by the number of pixels in the image to obtain the swap count that
we need to use.

Also, when handling byte-swapping in texstore_rgba, we were ignoring
the image's depth. This patch fixes this too.

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Cc: "10.5" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit ba426522dd)
2015-02-24 12:20:05 +00:00
..
egl egl: Soften several HAVE_DRM_PLATFORM to HAVE_LIBDRM 2015-02-12 13:29:10 +00:00
gallium nvc0: allow holes in xfb target lists 2015-02-24 12:16:45 +00:00
gbm gbm: Define _DEFAULT_SOURCE to avoid warning 2015-01-16 21:54:54 -08:00
getopt
glsl nir: add missing header to the sources list 2015-02-12 13:29:35 +00:00
glx darwin: build fix 2015-02-11 00:23:48 -08:00
gtest gtest: Add headers to distribution. 2014-12-12 12:11:46 -08:00
hgl hgl: traverse add-on entries 2014-12-10 14:01:01 +00:00
loader loader: Remove NEED_OPENGL_COMMON check. 2015-01-23 14:28:44 -08:00
mapi glapi: add GL_EXT_polygon_offset_clamp 2015-02-02 20:35:36 -05:00
mesa mesa: Fix element count for byte-swaps in texstore, readpix and texgetimage 2015-02-24 12:20:05 +00:00
util util/u_atomic: Provide a _InterlockedCompareExchange8 for older MSVC. 2015-01-30 15:24:34 +00:00
Makefile.am glsl: Build a libglsl_util library. 2015-01-23 14:28:44 -08:00
SConscript egl: Fix non-dri SCons builds re #87657 2014-12-25 10:34:49 -05:00