Commit f33f4bc7 by Nicolas Capens

Fix missing luminance and alpha floating-point format selection.

Bug 25351037 Change-Id: I0c758a218d15116fa5593eb9ddb783141ff93146 Reviewed-on: https://swiftshader-review.googlesource.com/4181Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 6ce5c33f
...@@ -37,12 +37,6 @@ namespace ...@@ -37,12 +37,6 @@ namespace
Bytes_4, Bytes_4,
Bytes_8, Bytes_8,
Bytes_16, Bytes_16,
AlphaFloat,
AlphaHalfFloat,
LuminanceFloat,
LuminanceHalfFloat,
LuminanceAlphaFloat,
LuminanceAlphaHalfFloat,
ByteRGB, ByteRGB,
UByteRGB, UByteRGB,
ShortRGB, ShortRGB,
...@@ -104,96 +98,6 @@ namespace ...@@ -104,96 +98,6 @@ namespace
} }
template<> template<>
void LoadImageRow<AlphaFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
{
const float *sourceF = reinterpret_cast<const float*>(source);
float *destF = reinterpret_cast<float*>(dest + (xoffset * 16));
for(int x = 0; x < width; x++)
{
destF[4 * x + 0] = 0;
destF[4 * x + 1] = 0;
destF[4 * x + 2] = 0;
destF[4 * x + 3] = sourceF[x];
}
}
template<>
void LoadImageRow<AlphaHalfFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
{
const unsigned short *sourceH = reinterpret_cast<const unsigned short*>(source);
unsigned short *destH = reinterpret_cast<unsigned short*>(dest + xoffset * 8);
for(int x = 0; x < width; x++)
{
destH[4 * x + 0] = 0;
destH[4 * x + 1] = 0;
destH[4 * x + 2] = 0;
destH[4 * x + 3] = sourceH[x];
}
}
template<>
void LoadImageRow<LuminanceFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
{
const float *sourceF = reinterpret_cast<const float*>(source);
float *destF = reinterpret_cast<float*>(dest + xoffset * 16);
for(int x = 0; x < width; x++)
{
destF[4 * x + 0] = sourceF[x];
destF[4 * x + 1] = sourceF[x];
destF[4 * x + 2] = sourceF[x];
destF[4 * x + 3] = 1.0f;
}
}
template<>
void LoadImageRow<LuminanceHalfFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
{
const unsigned short *sourceH = reinterpret_cast<const unsigned short*>(source);
unsigned short *destH = reinterpret_cast<unsigned short*>(dest + xoffset * 8);
for(int x = 0; x < width; x++)
{
destH[4 * x + 0] = sourceH[x];
destH[4 * x + 1] = sourceH[x];
destH[4 * x + 2] = sourceH[x];
destH[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1
}
}
template<>
void LoadImageRow<LuminanceAlphaFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
{
const float *sourceF = reinterpret_cast<const float*>(source);
float *destF = reinterpret_cast<float*>(dest + xoffset * 16);
for(int x = 0; x < width; x++)
{
destF[4 * x + 0] = sourceF[2 * x + 0];
destF[4 * x + 1] = sourceF[2 * x + 0];
destF[4 * x + 2] = sourceF[2 * x + 0];
destF[4 * x + 3] = sourceF[2 * x + 1];
}
}
template<>
void LoadImageRow<LuminanceAlphaHalfFloat>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
{
const unsigned short *sourceH = reinterpret_cast<const unsigned short*>(source);
unsigned short *destH = reinterpret_cast<unsigned short*>(dest + xoffset * 8);
for(int x = 0; x < width; x++)
{
destH[4 * x + 0] = sourceH[2 * x + 0];
destH[4 * x + 1] = sourceH[2 * x + 0];
destH[4 * x + 2] = sourceH[2 * x + 0];
destH[4 * x + 3] = sourceH[2 * x + 1];
}
}
template<>
void LoadImageRow<ByteRGB>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width) void LoadImageRow<ByteRGB>(const unsigned char *source, unsigned char *dest, GLint xoffset, GLsizei width)
{ {
unsigned char *destB = dest + xoffset * 4; unsigned char *destB = dest + xoffset * 4;
...@@ -704,6 +608,15 @@ namespace egl ...@@ -704,6 +608,15 @@ namespace egl
case GL_FLOAT: case GL_FLOAT:
switch(format) switch(format)
{ {
case GL_ALPHA:
case GL_ALPHA32F_EXT:
return sw::FORMAT_A32F;
case GL_LUMINANCE:
case GL_LUMINANCE32F_EXT:
return sw::FORMAT_L32F;
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE_ALPHA32F_EXT:
return sw::FORMAT_A32L32F;
case GL_RED: case GL_RED:
case GL_R32F: case GL_R32F:
return sw::FORMAT_R32F; return sw::FORMAT_R32F;
...@@ -725,6 +638,15 @@ namespace egl ...@@ -725,6 +638,15 @@ namespace egl
case GL_HALF_FLOAT_OES: case GL_HALF_FLOAT_OES:
switch(format) switch(format)
{ {
case GL_ALPHA:
case GL_ALPHA16F_EXT:
return sw::FORMAT_A16F;
case GL_LUMINANCE:
case GL_LUMINANCE16F_EXT:
return sw::FORMAT_L16F;
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE_ALPHA16F_EXT:
return sw::FORMAT_A16L16F;
case GL_RED: case GL_RED:
case GL_R16F: case GL_R16F:
return sw::FORMAT_R16F; return sw::FORMAT_R16F;
...@@ -1426,15 +1348,15 @@ namespace egl ...@@ -1426,15 +1348,15 @@ namespace egl
// float textures are converted to RGBA, not BGRA // float textures are converted to RGBA, not BGRA
case GL_ALPHA: case GL_ALPHA:
case GL_ALPHA32F_EXT: case GL_ALPHA32F_EXT:
LoadImageData<AlphaFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer); LoadImageData<Bytes_4>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
break; break;
case GL_LUMINANCE: case GL_LUMINANCE:
case GL_LUMINANCE32F_EXT: case GL_LUMINANCE32F_EXT:
LoadImageData<LuminanceFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer); LoadImageData<Bytes_4>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
break; break;
case GL_LUMINANCE_ALPHA: case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE_ALPHA32F_EXT: case GL_LUMINANCE_ALPHA32F_EXT:
LoadImageData<LuminanceAlphaFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer); LoadImageData<Bytes_8>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
break; break;
case GL_RED: case GL_RED:
case GL_R32F: case GL_R32F:
...@@ -1465,15 +1387,15 @@ namespace egl ...@@ -1465,15 +1387,15 @@ namespace egl
{ {
case GL_ALPHA: case GL_ALPHA:
case GL_ALPHA16F_EXT: case GL_ALPHA16F_EXT:
LoadImageData<AlphaHalfFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer); LoadImageData<Bytes_2>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
break; break;
case GL_LUMINANCE: case GL_LUMINANCE:
case GL_LUMINANCE16F_EXT: case GL_LUMINANCE16F_EXT:
LoadImageData<LuminanceHalfFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer); LoadImageData<Bytes_2>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
break; break;
case GL_LUMINANCE_ALPHA: case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE_ALPHA16F_EXT: case GL_LUMINANCE_ALPHA16F_EXT:
LoadImageData<LuminanceAlphaHalfFloat>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer); LoadImageData<Bytes_4>(xoffset, yoffset, zoffset, width, height, depth, inputPitch, inputHeight, getPitch(), getHeight(), input, buffer);
break; break;
case GL_RED: case GL_RED:
case GL_R16F: case GL_R16F:
......
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