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
GLsizei inputPitch = ComputePitch(width, format, type, unpackAlignment);
void *buffer = lock(0, 0, sw::LOCK_WRITEONLY);
if(buffer)
{
switch(type)
......@@ -276,7 +276,7 @@ namespace es1
{
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);
for(int x = 0; x < width; x++)
{
dest[4 * x + 0] = 0;
......@@ -304,7 +304,7 @@ namespace es1
{
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);
for(int x = 0; x < width; x++)
{
dest[4 * x + 0] = source[x];
......@@ -321,7 +321,7 @@ namespace es1
{
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;
memcpy(dest, source, width * 2);
}
}
......@@ -332,7 +332,7 @@ namespace es1
{
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);
for(int x = 0; x < width; x++)
{
dest[4 * x + 0] = source[2*x+0];
......@@ -349,7 +349,7 @@ namespace es1
{
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;
for(int x = 0; x < width; x++)
{
dest[4 * x + 0] = source[x * 3 + 0];
......@@ -366,7 +366,7 @@ namespace es1
{
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;
for(int x = 0; x < width; x++)
{
unsigned short rgba = source[x];
......@@ -384,7 +384,7 @@ namespace es1
{
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);
for(int x = 0; x < width; x++)
{
dest[4 * x + 0] = source[x * 3 + 0];
......@@ -412,7 +412,7 @@ namespace es1
{
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;
for(int x = 0; x < width; x++)
{
unsigned short rgba = source[x];
......@@ -430,7 +430,7 @@ namespace es1
{
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;
for(int x = 0; x < width; x++)
{
unsigned short rgba = source[x];
......@@ -448,7 +448,7 @@ namespace es1
{
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);
memcpy(dest, source, width * 16);
}
}
......@@ -538,8 +538,9 @@ namespace es1
switch(format)
{
case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_RGBX_8888:
return GL_RGBA;
case HAL_PIXEL_FORMAT_RGBX_8888:
return GL_RGB;
case HAL_PIXEL_FORMAT_RGB_888:
return GL_RGB;
case HAL_PIXEL_FORMAT_RGB_565:
......
......@@ -89,15 +89,15 @@ const GLenum compressedTextureFormats[] =
GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,
#endif
#if (GL_ES_VERSION_3_0)
GL_COMPRESSED_R11_EAC,
GL_COMPRESSED_SIGNED_R11_EAC,
GL_COMPRESSED_RG11_EAC,
GL_COMPRESSED_SIGNED_RG11_EAC,
GL_COMPRESSED_RGB8_ETC2,
GL_COMPRESSED_SRGB8_ETC2,
GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
GL_COMPRESSED_RGBA8_ETC2_EAC,
GL_COMPRESSED_R11_EAC,
GL_COMPRESSED_SIGNED_R11_EAC,
GL_COMPRESSED_RG11_EAC,
GL_COMPRESSED_SIGNED_RG11_EAC,
GL_COMPRESSED_RGB8_ETC2,
GL_COMPRESSED_SRGB8_ETC2,
GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
GL_COMPRESSED_RGBA8_ETC2_EAC,
GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
#endif
};
......
......@@ -515,7 +515,7 @@ namespace es2
{
GLsizei inputPitch = ComputePitch(width, format, type, unpackAlignment);
void *buffer = lock(0, 0, sw::LOCK_WRITEONLY);
if(buffer)
{
switch(type)
......@@ -669,8 +669,9 @@ namespace es2
switch(format)
{
case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_RGBX_8888:
return GL_RGBA;
case HAL_PIXEL_FORMAT_RGBX_8888:
return GL_RGB;
case HAL_PIXEL_FORMAT_RGB_888:
return GL_RGB;
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