Enable R5G6B5 as an internal format.

Bug 20891368

Change-Id: Iea526eebe65616079578563126a6958d87647eb1
Reviewed-on: https://swiftshader-review.googlesource.com/3255
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/libGL/Image.cpp b/src/OpenGL/libGL/Image.cpp
index b01712a..c444434 100644
--- a/src/OpenGL/libGL/Image.cpp
+++ b/src/OpenGL/libGL/Image.cpp
@@ -214,7 +214,7 @@
 		}
 		else if(type == GL_UNSIGNED_SHORT_5_6_5)
 		{
-			return sw::FORMAT_X8R8G8B8;
+			return sw::FORMAT_R5G6B5;
 		}
         else if(type == GL_UNSIGNED_INT_8_8_8_8_REV)
         {
@@ -504,16 +504,9 @@
 		for(int y = 0; y < height; y++)
 		{
 			const unsigned short *source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch);
-			unsigned char *dest = static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 4;
+			unsigned char *dest = static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 2;
 			
-			for(int x = 0; x < width; x++)
-			{
-				unsigned short rgba = source[x];
-				dest[4 * x + 0] = ((rgba & 0x001F) << 3) | ((rgba & 0x001F) >> 2);
-				dest[4 * x + 1] = ((rgba & 0x07E0) >> 3) | ((rgba & 0x07E0) >> 9);
-				dest[4 * x + 2] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13);
-				dest[4 * x + 3] = 0xFF;
-			}
+			memcpy(dest, source, width * 2);
 		}
 	}