Browse Source

Added alignment warning for imageSwizzleBgra8.

bkaradzic 12 years ago
parent
commit
a68969875e
2 changed files with 8 additions and 2 deletions
  1. 1 0
      src/bgfx_p.h
  2. 7 2
      src/image.cpp

+ 1 - 0
src/bgfx_p.h

@@ -68,6 +68,7 @@ namespace bgfx
 #include <bx/ringbuffer.h>
 #include <bx/uint32_t.h>
 #include <bx/readerwriter.h>
+#include <bx/allocator.h>
 #include <bx/string.h>
 #include <bx/os.h>
 

+ 7 - 2
src/image.cpp

@@ -185,9 +185,14 @@ namespace bgfx
 	{
 		// Test can we do four 4-byte pixels at the time.
 		if (0 != (_width&0x3)
-		||  _width < 4)
+		||  _width < 4
+		||  !bx::isPtrAligned(_src, 16)
+		||  !bx::isPtrAligned(_dst, 16) )
 		{
-			BX_WARN(_width < 4, "Image swizzle is taking slow path. Image width must be multiple of 4 (width %d).", _width);
+			BX_WARN(false, "Image swizzle is taking slow path.");
+			BX_WARN(bx::isPtrAligned(_src, 16), "Source %p is not 16-byte aligned.", _src);
+			BX_WARN(bx::isPtrAligned(_dst, 16), "Destination %p is not 16-byte aligned.", _dst);
+			BX_WARN(_width < 4, "Image width must be multiple of 4 (width %d).", _width);
 			imageSwizzleBgra8Ref(_width, _height, _src, _dst);
 			return;
 		}