Add UNSIGNED_INT24 channel format.
authorJarkko Pöyry <jpoyry@google.com>
Mon, 20 Apr 2015 20:35:51 +0000 (13:35 -0700)
committerJarkko Pöyry <jpoyry@google.com>
Tue, 21 Apr 2015 20:53:17 +0000 (13:53 -0700)
- Add UINT24 format to tcuTexture.
- Use UINT24 format instead of a combined format in depth-stencil clear
  tests.

Change-Id: Ib1ec54edd0c6ed114130fcfc63436298c4bb70c3

framework/common/tcuTexture.cpp
framework/common/tcuTexture.hpp
framework/common/tcuTextureUtil.cpp
modules/gles2/functional/es2fDepthStencilClearTests.cpp
modules/gles3/functional/es3fDepthStencilClearTests.cpp

index 02e5007..a2d0f45 100644 (file)
@@ -150,7 +150,7 @@ inline deUint32 convertSatRteUint24 (float f)
 int getChannelSize (TextureFormat::ChannelType type)
 {
        // make sure this table is updated if format table is updated
-       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 26);
+       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
 
        switch (type)
        {
@@ -166,6 +166,7 @@ int getChannelSize (TextureFormat::ChannelType type)
                case TextureFormat::SIGNED_INT32:               return 4;
                case TextureFormat::UNSIGNED_INT8:              return 1;
                case TextureFormat::UNSIGNED_INT16:             return 2;
+               case TextureFormat::UNSIGNED_INT24:             return 3;
                case TextureFormat::UNSIGNED_INT32:             return 4;
                case TextureFormat::HALF_FLOAT:                 return 2;
                case TextureFormat::FLOAT:                              return 4;
@@ -209,7 +210,7 @@ int getNumUsedChannels (TextureFormat::ChannelOrder order)
 inline float channelToFloat (const deUint8* value, TextureFormat::ChannelType type)
 {
        // make sure this table is updated if format table is updated
-       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 26);
+       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
 
        switch (type)
        {
@@ -225,6 +226,7 @@ inline float channelToFloat (const deUint8* value, TextureFormat::ChannelType ty
                case TextureFormat::SIGNED_INT32:               return (float)*((const deInt32*)value);
                case TextureFormat::UNSIGNED_INT8:              return (float)*((const deUint8*)value);
                case TextureFormat::UNSIGNED_INT16:             return (float)*((const deUint16*)value);
+               case TextureFormat::UNSIGNED_INT24:             return (float)readUint24(value);
                case TextureFormat::UNSIGNED_INT32:             return (float)*((const deUint32*)value);
                case TextureFormat::HALF_FLOAT:                 return deFloat16To32(*(const deFloat16*)value);
                case TextureFormat::FLOAT:                              return *((const float*)value);
@@ -237,7 +239,7 @@ inline float channelToFloat (const deUint8* value, TextureFormat::ChannelType ty
 inline int channelToInt (const deUint8* value, TextureFormat::ChannelType type)
 {
        // make sure this table is updated if format table is updated
-       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 26);
+       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
 
        switch (type)
        {
@@ -253,6 +255,7 @@ inline int channelToInt (const deUint8* value, TextureFormat::ChannelType type)
                case TextureFormat::SIGNED_INT32:               return (int)*((const deInt32*)value);
                case TextureFormat::UNSIGNED_INT8:              return (int)*((const deUint8*)value);
                case TextureFormat::UNSIGNED_INT16:             return (int)*((const deUint16*)value);
+               case TextureFormat::UNSIGNED_INT24:             return (int)readUint24(value);
                case TextureFormat::UNSIGNED_INT32:             return (int)*((const deUint32*)value);
                case TextureFormat::HALF_FLOAT:                 return (int)deFloat16To32(*(const deFloat16*)value);
                case TextureFormat::FLOAT:                              return (int)*((const float*)value);
@@ -265,7 +268,7 @@ inline int channelToInt (const deUint8* value, TextureFormat::ChannelType type)
 void floatToChannel (deUint8* dst, float src, TextureFormat::ChannelType type)
 {
        // make sure this table is updated if format table is updated
-       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 26);
+       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
 
        switch (type)
        {
@@ -274,13 +277,14 @@ void floatToChannel (deUint8* dst, float src, TextureFormat::ChannelType type)
                case TextureFormat::SNORM_INT32:                *((deInt32*)dst)                = convertSatRte<deInt32>        (src * 2147483647.0f);  break;
                case TextureFormat::UNORM_INT8:                 *((deUint8*)dst)                = convertSatRte<deUint8>        (src * 255.0f);                 break;
                case TextureFormat::UNORM_INT16:                *((deUint16*)dst)               = convertSatRte<deUint16>       (src * 65535.0f);               break;
-               case TextureFormat::UNORM_INT24:                writeUint24(dst, convertSatRteUint24(src * 16777215.0f));                                               break;
+               case TextureFormat::UNORM_INT24:                writeUint24(dst,                  convertSatRteUint24           (src * 16777215.0f));   break;
                case TextureFormat::UNORM_INT32:                *((deUint32*)dst)               = convertSatRte<deUint32>       (src * 4294967295.0f);  break;
                case TextureFormat::SIGNED_INT8:                *((deInt8*)dst)                 = convertSatRte<deInt8>         (src);                                  break;
                case TextureFormat::SIGNED_INT16:               *((deInt16*)dst)                = convertSatRte<deInt16>        (src);                                  break;
                case TextureFormat::SIGNED_INT32:               *((deInt32*)dst)                = convertSatRte<deInt32>        (src);                                  break;
                case TextureFormat::UNSIGNED_INT8:              *((deUint8*)dst)                = convertSatRte<deUint8>        (src);                                  break;
                case TextureFormat::UNSIGNED_INT16:             *((deUint16*)dst)               = convertSatRte<deUint16>       (src);                                  break;
+               case TextureFormat::UNSIGNED_INT24:             writeUint24(dst,                  convertSatRteUint24           (src));                                 break;
                case TextureFormat::UNSIGNED_INT32:             *((deUint32*)dst)               = convertSatRte<deUint32>       (src);                                  break;
                case TextureFormat::HALF_FLOAT:                 *((deFloat16*)dst)              = deFloat32To16                         (src);                                  break;
                case TextureFormat::FLOAT:                              *((float*)dst)                  = src;                                                                                          break;
@@ -320,7 +324,7 @@ static inline deUint32 convertSatUint24 (S src)
 void intToChannel (deUint8* dst, int src, TextureFormat::ChannelType type)
 {
        // make sure this table is updated if format table is updated
-       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 26);
+       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
 
        switch (type)
        {
@@ -328,12 +332,13 @@ void intToChannel (deUint8* dst, int src, TextureFormat::ChannelType type)
                case TextureFormat::SNORM_INT16:                *((deInt16*)dst)                = convertSat<deInt16>   (src);                          break;
                case TextureFormat::UNORM_INT8:                 *((deUint8*)dst)                = convertSat<deUint8>   (src);                          break;
                case TextureFormat::UNORM_INT16:                *((deUint16*)dst)               = convertSat<deUint16>  (src);                          break;
-               case TextureFormat::UNORM_INT24:                writeUint24(dst, convertSatUint24(src));                                                        break;
+               case TextureFormat::UNORM_INT24:                writeUint24(dst,                  convertSatUint24              (src));                         break;
                case TextureFormat::SIGNED_INT8:                *((deInt8*)dst)                 = convertSat<deInt8>    (src);                          break;
                case TextureFormat::SIGNED_INT16:               *((deInt16*)dst)                = convertSat<deInt16>   (src);                          break;
                case TextureFormat::SIGNED_INT32:               *((deInt32*)dst)                = convertSat<deInt32>   (src);                          break;
                case TextureFormat::UNSIGNED_INT8:              *((deUint8*)dst)                = convertSat<deUint8>   ((deUint32)src);        break;
                case TextureFormat::UNSIGNED_INT16:             *((deUint16*)dst)               = convertSat<deUint16>  ((deUint32)src);        break;
+               case TextureFormat::UNSIGNED_INT24:             writeUint24(dst,                  convertSatUint24              ((deUint32)src));       break;
                case TextureFormat::UNSIGNED_INT32:             *((deUint32*)dst)               = convertSat<deUint32>  ((deUint32)src);        break;
                case TextureFormat::HALF_FLOAT:                 *((deFloat16*)dst)              = deFloat32To16((float)src);                            break;
                case TextureFormat::FLOAT:                              *((float*)dst)                  = (float)src;                                                           break;
@@ -3365,6 +3370,7 @@ std::ostream& operator<< (std::ostream& str, TextureFormat::ChannelType type)
                "SIGNED_INT32",
                "UNSIGNED_INT8",
                "UNSIGNED_INT16",
+               "UNSIGNED_INT24",
                "UNSIGNED_INT32",
                "HALF_FLOAT",
                "FLOAT",
index 0d5189c..84a28b9 100644 (file)
@@ -89,6 +89,7 @@ public:
                SIGNED_INT32,
                UNSIGNED_INT8,
                UNSIGNED_INT16,
+               UNSIGNED_INT24,
                UNSIGNED_INT32,
                HALF_FLOAT,
                FLOAT,
index a959ee2..64b31d0 100644 (file)
@@ -81,7 +81,7 @@ bool isSRGB (TextureFormat format)
 bool isCombinedDepthStencilType (TextureFormat::ChannelType type)
 {
        // make sure to update this if type table is updated
-       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 26);
+       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
 
        return  type == TextureFormat::UNSIGNED_INT_24_8 ||
                        type == TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV;
@@ -91,7 +91,7 @@ bool isCombinedDepthStencilType (TextureFormat::ChannelType type)
 TextureChannelClass getTextureChannelClass (TextureFormat::ChannelType channelType)
 {
        // make sure this table is updated if format table is updated
-       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 26);
+       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
 
        switch (channelType)
        {
@@ -117,6 +117,7 @@ TextureChannelClass getTextureChannelClass (TextureFormat::ChannelType channelTy
                case TextureFormat::SIGNED_INT32:                                       return TEXTURECHANNELCLASS_SIGNED_INTEGER;
                case TextureFormat::UNSIGNED_INT8:                                      return TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
                case TextureFormat::UNSIGNED_INT16:                                     return TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
+               case TextureFormat::UNSIGNED_INT24:                                     return TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
                case TextureFormat::UNSIGNED_INT32:                                     return TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
                case TextureFormat::HALF_FLOAT:                                         return TEXTURECHANNELCLASS_FLOATING_POINT;
                case TextureFormat::FLOAT:                                                      return TEXTURECHANNELCLASS_FLOATING_POINT;
@@ -236,7 +237,7 @@ ConstPixelBufferAccess flipYAccess (const ConstPixelBufferAccess& access)
 static Vec2 getChannelValueRange (TextureFormat::ChannelType channelType)
 {
        // make sure this table is updated if format table is updated
-       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 26);
+       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
 
        float cMin = 0.0f;
        float cMax = 0.0f;
@@ -264,6 +265,7 @@ static Vec2 getChannelValueRange (TextureFormat::ChannelType channelType)
                case TextureFormat::SIGNED_INT32:                                       cMin = -2147483648.0f;  cMax = 2147483647.0f;   break;
                case TextureFormat::UNSIGNED_INT8:                                      cMin = 0.0f;                    cMax = 255.0f;                  break;
                case TextureFormat::UNSIGNED_INT16:                                     cMin = 0.0f;                    cMax = 65535.0f;                break;
+               case TextureFormat::UNSIGNED_INT24:                                     cMin = 0.0f;                    cMax = 16777215.0f;             break;
                case TextureFormat::UNSIGNED_INT32:                                     cMin = 0.0f;                    cMax = 4294967295.f;    break;
                case TextureFormat::HALF_FLOAT:                                         cMin = -1e3f;                   cMax = 1e3f;                    break;
                case TextureFormat::FLOAT:                                                      cMin = -1e5f;                   cMax = 1e5f;                    break;
@@ -322,7 +324,7 @@ TextureFormatInfo getTextureFormatInfo (const TextureFormat& format)
 static IVec4 getChannelBitDepth (TextureFormat::ChannelType channelType)
 {
        // make sure this table is updated if format table is updated
-       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 26);
+       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
 
        switch (channelType)
        {
@@ -344,6 +346,7 @@ static IVec4 getChannelBitDepth (TextureFormat::ChannelType channelType)
                case TextureFormat::SIGNED_INT32:                                       return IVec4(32);
                case TextureFormat::UNSIGNED_INT8:                                      return IVec4(8);
                case TextureFormat::UNSIGNED_INT16:                                     return IVec4(16);
+               case TextureFormat::UNSIGNED_INT24:                                     return IVec4(24);
                case TextureFormat::UNSIGNED_INT32:                                     return IVec4(32);
                case TextureFormat::UNSIGNED_INT_1010102_REV:           return IVec4(10,10,10,2);
                case TextureFormat::UNSIGNED_INT_24_8:                          return IVec4(24,8,0,0);
@@ -377,7 +380,7 @@ IVec4 getTextureFormatBitDepth (const TextureFormat& format)
 static IVec4 getChannelMantissaBitDepth (TextureFormat::ChannelType channelType)
 {
        // make sure this table is updated if format table is updated
-       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 26);
+       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
 
        switch (channelType)
        {
@@ -399,6 +402,7 @@ static IVec4 getChannelMantissaBitDepth (TextureFormat::ChannelType channelType)
                case TextureFormat::SIGNED_INT32:
                case TextureFormat::UNSIGNED_INT8:
                case TextureFormat::UNSIGNED_INT16:
+               case TextureFormat::UNSIGNED_INT24:
                case TextureFormat::UNSIGNED_INT32:
                case TextureFormat::UNSIGNED_INT_1010102_REV:
                case TextureFormat::UNSIGNED_INT_24_8:
@@ -1021,7 +1025,7 @@ template <typename AccessType>
 static AccessType toSamplerAccess (const AccessType& baseAccess, Sampler::DepthStencilMode mode)
 {
        // make sure to update this if type table is updated
-       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 26);
+       DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
 
        if (!isCombinedDepthStencilType(baseAccess.getFormat().type))
                return baseAccess;
index d8867af..030a062 100644 (file)
@@ -93,7 +93,7 @@ tcu::TextureFormat getDepthFormat (int depthBits)
        {
                case 8:         return tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNORM_INT8);
                case 16:        return tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNORM_INT16);
-               case 24:        return tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNSIGNED_INT_24_8);
+               case 24:        return tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNORM_INT24);
                case 32:        return tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::FLOAT);
                default:
                        TCU_FAIL("Can't map depth buffer format");
@@ -106,7 +106,7 @@ tcu::TextureFormat getStencilFormat (int stencilBits)
        {
                case 8:         return tcu::TextureFormat(tcu::TextureFormat::S, tcu::TextureFormat::UNSIGNED_INT8);
                case 16:        return tcu::TextureFormat(tcu::TextureFormat::S, tcu::TextureFormat::UNSIGNED_INT16);
-               case 24:        return tcu::TextureFormat(tcu::TextureFormat::S, tcu::TextureFormat::UNSIGNED_INT_24_8);
+               case 24:        return tcu::TextureFormat(tcu::TextureFormat::S, tcu::TextureFormat::UNSIGNED_INT24);
                case 32:        return tcu::TextureFormat(tcu::TextureFormat::S, tcu::TextureFormat::UNSIGNED_INT32);
                default:
                        TCU_FAIL("Can't map depth buffer format");
index d58d48f..a7b773d 100644 (file)
@@ -93,7 +93,7 @@ tcu::TextureFormat getDepthFormat (int depthBits)
        {
                case 8:         return tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNORM_INT8);
                case 16:        return tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNORM_INT16);
-               case 24:        return tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNSIGNED_INT_24_8);
+               case 24:        return tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNORM_INT24);
                case 32:        return tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::FLOAT);
                default:
                        TCU_FAIL("Can't map depth buffer format");
@@ -106,7 +106,7 @@ tcu::TextureFormat getStencilFormat (int stencilBits)
        {
                case 8:         return tcu::TextureFormat(tcu::TextureFormat::S, tcu::TextureFormat::UNSIGNED_INT8);
                case 16:        return tcu::TextureFormat(tcu::TextureFormat::S, tcu::TextureFormat::UNSIGNED_INT16);
-               case 24:        return tcu::TextureFormat(tcu::TextureFormat::S, tcu::TextureFormat::UNSIGNED_INT_24_8);
+               case 24:        return tcu::TextureFormat(tcu::TextureFormat::S, tcu::TextureFormat::UNSIGNED_INT24);
                case 32:        return tcu::TextureFormat(tcu::TextureFormat::S, tcu::TextureFormat::UNSIGNED_INT32);
                default:
                        TCU_FAIL("Can't map depth buffer format");