ETC1 fix for npot textures

Simple fix that replaces width by pitch where needed to avoid misalignment
due to the difference between pitch and width in npot textures.

Change-Id: I7acddc28fae21dddf870a6ef80ac7984cfaf8e0f
Reviewed-on: https://swiftshader-review.googlesource.com/3931
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Renderer/Surface.cpp b/src/Renderer/Surface.cpp
index 3a0530e..8ab1319 100644
--- a/src/Renderer/Surface.cpp
+++ b/src/Renderer/Surface.cpp
@@ -1968,7 +1968,7 @@
 			{
 				for(int x = 0; x < external.width; x += 4)
 				{
-					bgrx8 *color = reinterpret_cast<bgrx8*>(&dest[x + y * internal.width]);
+					bgrx8 *color = reinterpret_cast<bgrx8*>(&dest[x + y * internal.pitchP]);
 
 					int r1, g1, b1;
 					int r2, g2, b2;
@@ -2038,7 +2038,7 @@
 							if((x + 1) < internal.width) color[1] = subblockColors0[source->getIndex(1, j)];
 							if((x + 2) < internal.width) color[2] = subblockColors0[source->getIndex(2, j)];
 							if((x + 3) < internal.width) color[3] = subblockColors0[source->getIndex(3, j)];
-							color += internal.width;
+							color += internal.pitchP;
 						}
 
 						for(int j = 2; j < 4 && (y + j) < internal.height; j++)
@@ -2047,7 +2047,7 @@
 							if((x + 1) < internal.width) color[1] = subblockColors1[source->getIndex(1, j)];
 							if((x + 2) < internal.width) color[2] = subblockColors1[source->getIndex(2, j)];
 							if((x + 3) < internal.width) color[3] = subblockColors1[source->getIndex(3, j)];
-							color += internal.width;
+							color += internal.pitchP;
 						}
 					}
 					else
@@ -2058,7 +2058,7 @@
 							if((x + 1) < internal.width) color[1] = subblockColors0[source->getIndex(1, j)];
 							if((x + 2) < internal.width) color[2] = subblockColors1[source->getIndex(2, j)];
 							if((x + 3) < internal.width) color[3] = subblockColors1[source->getIndex(3, j)];
-							color += internal.width;
+							color += internal.pitchP;
 						}
 					}