Add a fast path for BGRA to RGBA conversion inside readPixels. Already covered

by existing WebGL conformance tests. 5x speedup observed for reading back a 4096x4096x4 texture on a NVIDIA GeForce 9600M GT (from 1000ms to 200ms). Review URL: https://codereview.appspot.com/7466044 Author: Evan Wallace git-svn-id: https://angleproject.googlecode.com/svn/trunk@1999 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 6416ba45
......@@ -30,3 +30,4 @@ Boying Lu
Aitor Moreno
Yuri O'Donnell
Josh Soref
Evan Wallace
#define MAJOR_VERSION 1
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 1994
#define BUILD_REVISION 1999
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -2679,6 +2679,21 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
(rect.right - rect.left) * fastPixelSize);
continue;
}
else if (desc.Format == D3DFMT_A8R8G8B8 &&
format == GL_RGBA &&
type == GL_UNSIGNED_BYTE)
{
// Fast path for swapping red with blue
for (int i = 0; i < rect.right - rect.left; i++)
{
unsigned int argb = *(unsigned int*)(source + 4 * i + j * inputPitch);
*(unsigned int*)(dest + 4 * i + j * outputPitch) =
(argb & 0xFF00FF00) | // Keep alpha and green
(argb & 0x00FF0000) >> 16 | // Move red to blue
(argb & 0x000000FF) << 16; // Move blue to red
}
continue;
}
for (int i = 0; i < rect.right - rect.left; i++)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment