diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2012-09-20 18:54:29 +0200 |
---|---|---|
committer | Andreas Boll <andreas.boll.dev@gmail.com> | 2013-04-17 13:29:18 +0200 |
commit | b2d7d29a88e16a21b7b30b60b29b92b1d0a997fd (patch) | |
tree | 63a0dff3d3f8beb765af6f1e1b9bf9a0cbba99b9 | |
parent | fc1ce30e3f52dd4d3c535081e3bc473066c7f596 (diff) |
intel: Fix size of temporary etc1 buffer
Fixes valgrind errors in piglit test
oes_compressed_etc1_rgb8_texture-miptree: an invalid write in
_mesa_store_compressed_store_texsubimage() at line 4406 and invalid reads
in texcompress_etc_tmp.h:etc1_parse_block().
The calculation of the size of the temporary etc1 buffer allocated by
intel_miptree_map_etc1() was incorrect. Sometimes the allocated buffer was
too small, sometimes too large. This patch corrects the size to that
expected by _mesa_store_compressed_store_texsubimage().
Note: This is candidate for the 9.0 branch.
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit bb7ecb29fb6358a4c65278c2fe88936c578074cd)
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 556a82fc7f..cd7299e2a3 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -1292,9 +1292,10 @@ intel_miptree_map_etc1(struct intel_context *intel, assert(map->x == 0); assert(map->y == 0); - /* Each ETC1 block contains 4x4 pixels in 8 bytes. */ - map->stride = 2 * map->w; - map->buffer = map->ptr = malloc(map->stride * map->h); + map->stride = _mesa_format_row_stride(MESA_FORMAT_ETC1_RGB8, map->w); + map->buffer = malloc(_mesa_format_image_size(MESA_FORMAT_ETC1_RGB8, + map->w, map->h, 1)); + map->ptr = map->buffer; } static void |