Commit d45d14a5 by Nicolas Capens

Fix using an alpha-less GL format for Android's RGBX.

Bug 19979126 Change-Id: Ic074079cbe3630751a95ffcc2b2b33700063abcf Reviewed-on: https://swiftshader-review.googlesource.com/2782Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarPing-Hao Wu <pinghao@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 36e22dea
...@@ -167,7 +167,7 @@ namespace es1 ...@@ -167,7 +167,7 @@ namespace es1
GLsizei inputPitch = ComputePitch(width, format, type, unpackAlignment); GLsizei inputPitch = ComputePitch(width, format, type, unpackAlignment);
void *buffer = lock(0, 0, sw::LOCK_WRITEONLY); void *buffer = lock(0, 0, sw::LOCK_WRITEONLY);
if(buffer) if(buffer)
{ {
switch(type) switch(type)
...@@ -276,7 +276,7 @@ namespace es1 ...@@ -276,7 +276,7 @@ namespace es1
{ {
const float *source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); const float *source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch);
float *dest = reinterpret_cast<float*>(static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 16); float *dest = reinterpret_cast<float*>(static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 16);
for(int x = 0; x < width; x++) for(int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = 0; dest[4 * x + 0] = 0;
...@@ -304,7 +304,7 @@ namespace es1 ...@@ -304,7 +304,7 @@ namespace es1
{ {
const float *source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); const float *source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch);
float *dest = reinterpret_cast<float*>(static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 16); float *dest = reinterpret_cast<float*>(static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 16);
for(int x = 0; x < width; x++) for(int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x]; dest[4 * x + 0] = source[x];
...@@ -321,7 +321,7 @@ namespace es1 ...@@ -321,7 +321,7 @@ namespace es1
{ {
const unsigned char *source = static_cast<const unsigned char*>(input) + y * inputPitch; const unsigned char *source = static_cast<const unsigned char*>(input) + y * inputPitch;
unsigned char *dest = static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 2; unsigned char *dest = static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 2;
memcpy(dest, source, width * 2); memcpy(dest, source, width * 2);
} }
} }
...@@ -332,7 +332,7 @@ namespace es1 ...@@ -332,7 +332,7 @@ namespace es1
{ {
const float *source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); const float *source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch);
float *dest = reinterpret_cast<float*>(static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 16); float *dest = reinterpret_cast<float*>(static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 16);
for(int x = 0; x < width; x++) for(int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[2*x+0]; dest[4 * x + 0] = source[2*x+0];
...@@ -349,7 +349,7 @@ namespace es1 ...@@ -349,7 +349,7 @@ namespace es1
{ {
const unsigned char *source = static_cast<const unsigned char*>(input) + y * inputPitch; const unsigned char *source = 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 * 4;
for(int x = 0; x < width; x++) for(int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x * 3 + 0]; dest[4 * x + 0] = source[x * 3 + 0];
...@@ -366,7 +366,7 @@ namespace es1 ...@@ -366,7 +366,7 @@ namespace es1
{ {
const unsigned short *source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); 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 * 4;
for(int x = 0; x < width; x++) for(int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -384,7 +384,7 @@ namespace es1 ...@@ -384,7 +384,7 @@ namespace es1
{ {
const float *source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); const float *source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch);
float *dest = reinterpret_cast<float*>(static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 16); float *dest = reinterpret_cast<float*>(static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 16);
for(int x = 0; x < width; x++) for(int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x * 3 + 0]; dest[4 * x + 0] = source[x * 3 + 0];
...@@ -412,7 +412,7 @@ namespace es1 ...@@ -412,7 +412,7 @@ namespace es1
{ {
const unsigned short *source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); 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 * 4;
for(int x = 0; x < width; x++) for(int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -430,7 +430,7 @@ namespace es1 ...@@ -430,7 +430,7 @@ namespace es1
{ {
const unsigned short *source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); 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 * 4;
for(int x = 0; x < width; x++) for(int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -448,7 +448,7 @@ namespace es1 ...@@ -448,7 +448,7 @@ namespace es1
{ {
const float *source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); const float *source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch);
float *dest = reinterpret_cast<float*>(static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 16); float *dest = reinterpret_cast<float*>(static_cast<unsigned char*>(buffer) + (y + yoffset) * getPitch() + xoffset * 16);
memcpy(dest, source, width * 16); memcpy(dest, source, width * 16);
} }
} }
...@@ -538,8 +538,9 @@ namespace es1 ...@@ -538,8 +538,9 @@ namespace es1
switch(format) switch(format)
{ {
case HAL_PIXEL_FORMAT_RGBA_8888: case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_RGBX_8888:
return GL_RGBA; return GL_RGBA;
case HAL_PIXEL_FORMAT_RGBX_8888:
return GL_RGB;
case HAL_PIXEL_FORMAT_RGB_888: case HAL_PIXEL_FORMAT_RGB_888:
return GL_RGB; return GL_RGB;
case HAL_PIXEL_FORMAT_RGB_565: case HAL_PIXEL_FORMAT_RGB_565:
......
...@@ -89,15 +89,15 @@ const GLenum compressedTextureFormats[] = ...@@ -89,15 +89,15 @@ const GLenum compressedTextureFormats[] =
GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,
#endif #endif
#if (GL_ES_VERSION_3_0) #if (GL_ES_VERSION_3_0)
GL_COMPRESSED_R11_EAC, GL_COMPRESSED_R11_EAC,
GL_COMPRESSED_SIGNED_R11_EAC, GL_COMPRESSED_SIGNED_R11_EAC,
GL_COMPRESSED_RG11_EAC, GL_COMPRESSED_RG11_EAC,
GL_COMPRESSED_SIGNED_RG11_EAC, GL_COMPRESSED_SIGNED_RG11_EAC,
GL_COMPRESSED_RGB8_ETC2, GL_COMPRESSED_RGB8_ETC2,
GL_COMPRESSED_SRGB8_ETC2, GL_COMPRESSED_SRGB8_ETC2,
GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
GL_COMPRESSED_RGBA8_ETC2_EAC, GL_COMPRESSED_RGBA8_ETC2_EAC,
GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
#endif #endif
}; };
......
...@@ -515,7 +515,7 @@ namespace es2 ...@@ -515,7 +515,7 @@ namespace es2
{ {
GLsizei inputPitch = ComputePitch(width, format, type, unpackAlignment); GLsizei inputPitch = ComputePitch(width, format, type, unpackAlignment);
void *buffer = lock(0, 0, sw::LOCK_WRITEONLY); void *buffer = lock(0, 0, sw::LOCK_WRITEONLY);
if(buffer) if(buffer)
{ {
switch(type) switch(type)
...@@ -669,8 +669,9 @@ namespace es2 ...@@ -669,8 +669,9 @@ namespace es2
switch(format) switch(format)
{ {
case HAL_PIXEL_FORMAT_RGBA_8888: case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_RGBX_8888:
return GL_RGBA; return GL_RGBA;
case HAL_PIXEL_FORMAT_RGBX_8888:
return GL_RGB;
case HAL_PIXEL_FORMAT_RGB_888: case HAL_PIXEL_FORMAT_RGB_888:
return GL_RGB; return GL_RGB;
case HAL_PIXEL_FORMAT_RGB_565: case HAL_PIXEL_FORMAT_RGB_565:
......
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