[PATCH] trace: Fix alignment bug in computing image sizes.

Carl Worth cworth at cworth.org
Mon Sep 10 15:17:01 PDT 2012


Previously, the code would not properly align the row stride in some
conditions. This would result in less data being captured than
necessary when capturing a texture-data blob (such as for
glTexImage2D).

This would cause the resulting trace to be invalid. Some textures
would be initialized with an insufficiently-sized buffer. Some texture
contents would be initialized from whatever resides in memory above
the texture data. This would then cause incorrect rendering when
retracing compared to the original application.
---
 helpers/glsize.hpp |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/helpers/glsize.hpp b/helpers/glsize.hpp
index a589199..6736613 100644
--- a/helpers/glsize.hpp
+++ b/helpers/glsize.hpp
@@ -683,9 +683,7 @@ _gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsize
 
     size_t row_stride = (row_length*bits_per_pixel + 7)/8;
 
-    if ((GLint)bits_per_pixel < alignment*8 &&
-        (bits_per_pixel & 7) == 0 &&
-        _is_pot(bits_per_pixel)) {
+    if ((GLint)bits_per_pixel < alignment*8) {
         row_stride = _align(row_stride, alignment);
     }
 
-- 
1.7.10



More information about the apitrace mailing list