Add support for GL_UNSIGNED_INT_2_10_10_10_REV textures.

TRAC #22956 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2356 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 44a4f98a
...@@ -571,7 +571,7 @@ static InternalFormatInfoMap buildES3InternalFormatInfoMap() ...@@ -571,7 +571,7 @@ static InternalFormatInfoMap buildES3InternalFormatInfoMap()
map.insert(InternalFormatInfoPair(GL_RGB5_A1, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); map.insert(InternalFormatInfoPair(GL_RGB5_A1, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, AlwaysSupported, AlwaysSupported, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_RGBA8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); map.insert(InternalFormatInfoPair(GL_RGBA8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, AlwaysSupported, AlwaysSupported, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_RGBA8_SNORM, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, NeverSupported, AlwaysSupported, UnimplementedSupport))); map.insert(InternalFormatInfoPair(GL_RGBA8_SNORM, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, NeverSupported, AlwaysSupported, UnimplementedSupport)));
map.insert(InternalFormatInfoPair(GL_RGB10_A2, InternalFormatInfo::RGBAFormat(10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, AlwaysSupported, AlwaysSupported, UnimplementedSupport))); map.insert(InternalFormatInfoPair(GL_RGB10_A2, InternalFormatInfo::RGBAFormat(10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, AlwaysSupported, AlwaysSupported, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_RGB10_A2UI, InternalFormatInfo::RGBAFormat(10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, AlwaysSupported, NeverSupported, UnimplementedSupport))); map.insert(InternalFormatInfoPair(GL_RGB10_A2UI, InternalFormatInfo::RGBAFormat(10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, AlwaysSupported, NeverSupported, UnimplementedSupport)));
map.insert(InternalFormatInfoPair(GL_SRGB8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, NeverSupported, AlwaysSupported, AlwaysSupported ))); map.insert(InternalFormatInfoPair(GL_SRGB8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, NeverSupported, AlwaysSupported, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_SRGB8_ALPHA8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); map.insert(InternalFormatInfoPair(GL_SRGB8_ALPHA8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, AlwaysSupported, AlwaysSupported, AlwaysSupported )));
......
...@@ -3660,6 +3660,7 @@ static inline void writePixelColor(const gl::Color &color, GLenum format, GLenum ...@@ -3660,6 +3660,7 @@ static inline void writePixelColor(const gl::Color &color, GLenum format, GLenum
{ {
unsigned char* byteData = reinterpret_cast<unsigned char*>(outData); unsigned char* byteData = reinterpret_cast<unsigned char*>(outData);
unsigned short* shortData = reinterpret_cast<unsigned short*>(outData); unsigned short* shortData = reinterpret_cast<unsigned short*>(outData);
unsigned int* intData = reinterpret_cast<unsigned int*>(outData);
switch (format) switch (format)
{ {
...@@ -3673,6 +3674,13 @@ static inline void writePixelColor(const gl::Color &color, GLenum format, GLenum ...@@ -3673,6 +3674,13 @@ static inline void writePixelColor(const gl::Color &color, GLenum format, GLenum
byteData[4 * x + y * outputPitch + 3] = static_cast<unsigned char>(255 * color.alpha + 0.5f); byteData[4 * x + y * outputPitch + 3] = static_cast<unsigned char>(255 * color.alpha + 0.5f);
break; break;
case GL_UNSIGNED_INT_2_10_10_10_REV:
intData[x + y * outputPitch / sizeof(unsigned int)] = (static_cast<unsigned int>( 3 * color.alpha) << 30) |
(static_cast<unsigned int>(1023 * color.red ) << 20) |
(static_cast<unsigned int>(1023 * color.green) << 10) |
(static_cast<unsigned int>(1023 * color.blue ) << 0);
break;
default: default:
ERR("WritePixelColor not implemented for format GL_RGBA and type 0x%X.", type); ERR("WritePixelColor not implemented for format GL_RGBA and type 0x%X.", type);
UNIMPLEMENTED(); UNIMPLEMENTED();
......
...@@ -54,7 +54,7 @@ static D3D11ES3FormatMap buildD3D11ES3FormatMap() ...@@ -54,7 +54,7 @@ static D3D11ES3FormatMap buildD3D11ES3FormatMap()
map.insert(D3D11ES3FormatPair(GL_RGB5_A1, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); map.insert(D3D11ES3FormatPair(GL_RGB5_A1, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN)));
map.insert(D3D11ES3FormatPair(GL_RGBA8, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN))); map.insert(D3D11ES3FormatPair(GL_RGBA8, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN)));
map.insert(D3D11ES3FormatPair(GL_RGBA8_SNORM, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); map.insert(D3D11ES3FormatPair(GL_RGBA8_SNORM, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
map.insert(D3D11ES3FormatPair(GL_RGB10_A2, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); map.insert(D3D11ES3FormatPair(GL_RGB10_A2, D3D11ES3FormatInfo(DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_UNKNOWN)));
map.insert(D3D11ES3FormatPair(GL_RGB10_A2UI, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); map.insert(D3D11ES3FormatPair(GL_RGB10_A2UI, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
map.insert(D3D11ES3FormatPair(GL_SRGB8, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN))); map.insert(D3D11ES3FormatPair(GL_SRGB8, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
map.insert(D3D11ES3FormatPair(GL_SRGB8_ALPHA8, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_UNKNOWN))); map.insert(D3D11ES3FormatPair(GL_SRGB8_ALPHA8, D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_UNKNOWN)));
...@@ -172,7 +172,8 @@ static bool getD3D11ES3FormatInfo(GLint internalFormat, GLuint clientVersion, D3 ...@@ -172,7 +172,8 @@ static bool getD3D11ES3FormatInfo(GLint internalFormat, GLuint clientVersion, D3
// ES3 image loading functions vary based on the internal format and data type given, // ES3 image loading functions vary based on the internal format and data type given,
// this map type determines the loading function from the internal format and type supplied // this map type determines the loading function from the internal format and type supplied
// to glTex*Image*D // to glTex*Image*D and the destination DXGI_FORMAT. Source formats and types are taken from
// Tables 3.2 and 3.3 of the ES 3 spec.
typedef std::pair<GLint, GLenum> InternalFormatTypePair; typedef std::pair<GLint, GLenum> InternalFormatTypePair;
typedef std::pair<InternalFormatTypePair, LoadImageFunction> D3D11LoadFunctionPair; typedef std::pair<InternalFormatTypePair, LoadImageFunction> D3D11LoadFunctionPair;
typedef std::map<InternalFormatTypePair, LoadImageFunction> D3D11LoadFunctionMap; typedef std::map<InternalFormatTypePair, LoadImageFunction> D3D11LoadFunctionMap;
...@@ -202,9 +203,9 @@ D3D11LoadFunctionMap buildD3D11LoadFunctionMap() ...@@ -202,9 +203,9 @@ D3D11LoadFunctionMap buildD3D11LoadFunctionMap()
insertLoadFunction(&map, GL_SRGB8_ALPHA8, GL_UNSIGNED_BYTE, loadRGBAUByteDataToNative ); insertLoadFunction(&map, GL_SRGB8_ALPHA8, GL_UNSIGNED_BYTE, loadRGBAUByteDataToNative );
insertLoadFunction(&map, GL_RGBA8_SNORM, GL_BYTE, UnimplementedLoadFunction ); insertLoadFunction(&map, GL_RGBA8_SNORM, GL_BYTE, UnimplementedLoadFunction );
insertLoadFunction(&map, GL_RGBA4, GL_UNSIGNED_SHORT_4_4_4_4, loadRGBA4444DataToRGBA ); insertLoadFunction(&map, GL_RGBA4, GL_UNSIGNED_SHORT_4_4_4_4, loadRGBA4444DataToRGBA );
insertLoadFunction(&map, GL_RGB10_A2, GL_UNSIGNED_INT_2_10_10_10_REV, UnimplementedLoadFunction ); insertLoadFunction(&map, GL_RGB10_A2, GL_UNSIGNED_INT_2_10_10_10_REV, loadRGBA2101010ToNative );
insertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_SHORT_5_5_5_1, loadRGBA5551DataToRGBA ); insertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_SHORT_5_5_5_1, loadRGBA5551DataToRGBA );
insertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_INT_2_10_10_10_REV, UnimplementedLoadFunction ); insertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_INT_2_10_10_10_REV, loadRGBA2101010ToRGBA );
insertLoadFunction(&map, GL_RGBA16F, GL_HALF_FLOAT, loadRGBAHalfFloatDataToRGBA ); insertLoadFunction(&map, GL_RGBA16F, GL_HALF_FLOAT, loadRGBAHalfFloatDataToRGBA );
insertLoadFunction(&map, GL_RGBA32F, GL_FLOAT, loadRGBAFloatDataToRGBA ); insertLoadFunction(&map, GL_RGBA32F, GL_FLOAT, loadRGBAFloatDataToRGBA );
insertLoadFunction(&map, GL_RGBA16F, GL_FLOAT, UnimplementedLoadFunction ); insertLoadFunction(&map, GL_RGBA16F, GL_FLOAT, UnimplementedLoadFunction );
...@@ -441,6 +442,8 @@ static FormatMipMap buildFormatMipMap() ...@@ -441,6 +442,8 @@ static FormatMipMap buildFormatMipMap()
map.insert(FormatMipPair(DXGI_FORMAT_R32G32B32_FLOAT, GenerateMip<R32G32B32F> )); map.insert(FormatMipPair(DXGI_FORMAT_R32G32B32_FLOAT, GenerateMip<R32G32B32F> ));
map.insert(FormatMipPair(DXGI_FORMAT_R32G32B32A32_FLOAT, GenerateMip<R32G32B32A32F>)); map.insert(FormatMipPair(DXGI_FORMAT_R32G32B32A32_FLOAT, GenerateMip<R32G32B32A32F>));
map.insert(FormatMipPair(DXGI_FORMAT_R10G10B10A2_UNORM, GenerateMip<R10G10B10A2> ));
return map; return map;
} }
......
...@@ -150,6 +150,22 @@ struct R32G32B32F ...@@ -150,6 +150,22 @@ struct R32G32B32F
typedef A32B32G32R32F R32G32B32A32F; typedef A32B32G32R32F R32G32B32A32F;
struct R10G10B10A2
{
unsigned int R : 10;
unsigned int G : 10;
unsigned int B : 10;
unsigned int A : 2;
static void average(R10G10B10A2 *dst, const R10G10B10A2 *src1, const R10G10B10A2 *src2)
{
dst->R = (src1->R + src2->R) >> 1;
dst->G = (src1->G + src2->G) >> 1;
dst->B = (src1->B + src2->B) >> 1;
dst->A = (src1->A + src2->A) >> 1;
}
};
namespace priv namespace priv
{ {
......
...@@ -678,4 +678,48 @@ void loadBGRADataToBGRA(int width, int height, int depth, ...@@ -678,4 +678,48 @@ void loadBGRADataToBGRA(int width, int height, int depth,
} }
} }
void loadRGBA2101010ToNative(int width, int height, int depth,
const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
{
const unsigned int *source = NULL;
unsigned int *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++)
{
source = offsetDataPointer<unsigned int>(input, y, z, inputRowPitch, inputDepthPitch);
dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
memcpy(dest, source, width * sizeof(unsigned int));
}
}
}
void loadRGBA2101010ToRGBA(int width, int height, int depth,
const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
{
const unsigned int *source = NULL;
unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++)
{
source = offsetDataPointer<unsigned int>(input, y, z, inputRowPitch, inputDepthPitch);
dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++)
{
unsigned int rgba = source[x];
dest[4 * x + 0] = (rgba & 0x000003FF) >> 2;
dest[4 * x + 1] = (rgba & 0x000FFC00) >> 12;
dest[4 * x + 2] = (rgba & 0x3FF00000) >> 22;
dest[4 * x + 3] = ((rgba & 0xC0000000) >> 30) * 0x55;
}
}
}
}
} }
...@@ -136,6 +136,14 @@ void loadBGRADataToBGRA(int width, int height, int depth, ...@@ -136,6 +136,14 @@ void loadBGRADataToBGRA(int width, int height, int depth,
const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch, const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch); void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch);
void loadRGBA2101010ToNative(int width, int height, int depth,
const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch);
void loadRGBA2101010ToRGBA(int width, int height, int depth,
const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch);
template <unsigned int blockWidth, unsigned int blockHeight, unsigned int blockSize> template <unsigned int blockWidth, unsigned int blockHeight, unsigned int blockSize>
void loadCompressedBlockDataToNative(int width, int height, int depth, void loadCompressedBlockDataToNative(int width, int height, int depth,
const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch, const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
......
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