From: Dae Kim Date: Wed, 2 Sep 2015 12:06:53 +0000 (+0100) Subject: Support for FLOAT_UNSIGNED_INT_8 and UNSIGNED_INT_16_8 channel types. X-Git-Tag: upstream/0.1.0~812^2~605^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b574b02e984c815714281c14b25bfec084c472f;p=platform%2Fupstream%2FVK-GL-CTS.git Support for FLOAT_UNSIGNED_INT_8 and UNSIGNED_INT_16_8 channel types. --- diff --git a/framework/common/tcuTexCompareVerifier.cpp b/framework/common/tcuTexCompareVerifier.cpp index 9f10295..a853ce9 100644 --- a/framework/common/tcuTexCompareVerifier.cpp +++ b/framework/common/tcuTexCompareVerifier.cpp @@ -172,7 +172,9 @@ static bool isFixedPointDepthTextureFormat (const tcu::TextureFormat& format) // combined formats have no single channel class, detect format manually switch (format.type) { + case tcu::TextureFormat::FLOAT_UNSIGNED_INT_8: return false; case tcu::TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: return false; + case tcu::TextureFormat::UNSIGNED_INT_16_8: return true; case tcu::TextureFormat::UNSIGNED_INT_24_8: return true; default: diff --git a/framework/common/tcuTexture.cpp b/framework/common/tcuTexture.cpp index 43c7616..21d01b8 100644 --- a/framework/common/tcuTexture.cpp +++ b/framework/common/tcuTexture.cpp @@ -111,6 +111,50 @@ inline deUint32 readUint24 (const deUint8* src) #endif } +inline deUint32 readUint24Low8 (const deUint8* src) +{ +#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN) + const deUint32 uint24ByteOffsetBits0To8 = 0; //!< least significant byte in the lowest address +#else + const deUint32 uint24ByteOffsetBits0To8 = 2; //!< least significant byte in the highest address +#endif + + return src[uint24ByteOffsetBits0To8]; +} + +inline void writeUint24Low8 (deUint8* dst, deUint8 val) +{ +#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN) + const deUint32 uint24ByteOffsetBits0To8 = 0; //!< least significant byte in the lowest address +#else + const deUint32 uint24ByteOffsetBits0To8 = 2; //!< least significant byte in the highest address +#endif + + dst[uint24ByteOffsetBits0To8] = val; +} + +inline deUint32 readUint24High16 (const deUint8* src) +{ +#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN) + return (((deUint32)src[1]) << 0u) | + (((deUint32)src[2]) << 8u); +#else + return (((deUint32)src[0]) << 8u) | + (((deUint32)src[1]) << 0u); +#endif +} + +inline void writeUint24High16 (deUint8* dst, deUint16 val) +{ +#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN) + dst[1] = (deUint8)((val & (deUint16)0x00FFu) >> 0u); + dst[2] = (deUint8)((val & (deUint16)0xFF00u) >> 8u); +#else + dst[0] = (deUint8)((val & (deUint16)0xFF00u) >> 8u); + dst[1] = (deUint8)((val & (deUint16)0x00FFu) >> 0u); +#endif +} + inline deUint8 readUint32Low8 (const deUint8* src) { #if (DE_ENDIANNESS == DE_LITTLE_ENDIAN) @@ -194,7 +238,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 == 27); + DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29); switch (type) { @@ -254,7 +298,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 == 27); + DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29); switch (type) { @@ -283,7 +327,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 == 27); + DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29); switch (type) { @@ -312,7 +356,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 == 27); + DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29); switch (type) { @@ -368,7 +412,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 == 27); + DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29); switch (type) { @@ -568,11 +612,21 @@ int TextureFormat::getPixelSize (void) const DE_ASSERT(order == RGBA); return 4; } + else if (type == UNSIGNED_INT_16_8) + { + DE_ASSERT(order == D || order == DS); + return 3; + } else if (type == UNSIGNED_INT_24_8) { DE_ASSERT(order == D || order == DS); return 4; } + else if (type == FLOAT_UNSIGNED_INT_8) + { + DE_ASSERT(order == DS); + return 5; + } else if (type == FLOAT_UNSIGNED_INT_24_8_REV) { DE_ASSERT(order == DS); @@ -832,22 +886,17 @@ float ConstPixelBufferAccess::getPixDepth (int x, int y, int z) const const deUint8* const pixelPtr = (const deUint8*)getPixelPtr(x, y, z); - DE_ASSERT(m_format.order == TextureFormat::DS || m_format.order == TextureFormat::D); - switch (m_format.type) { - case TextureFormat::UNSIGNED_INT_24_8: - switch (m_format.order) - { - case TextureFormat::D: - case TextureFormat::DS: // \note Fall-through. - return (float)readUint32High24(pixelPtr) / 16777215.0f; + case TextureFormat::UNSIGNED_INT_16_8: + DE_ASSERT(m_format.order == TextureFormat::DS); + return (float)readUint24High16(pixelPtr) / 65535.0f; - default: - DE_ASSERT(false); - return 0.0f; - } + case TextureFormat::UNSIGNED_INT_24_8: + DE_ASSERT(m_format.order == TextureFormat::DS); + return (float)readUint32High24(pixelPtr) / 16777215.0f; + case TextureFormat::FLOAT_UNSIGNED_INT_8: case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: DE_ASSERT(m_format.order == TextureFormat::DS); return *((const float*)pixelPtr); @@ -868,17 +917,17 @@ int ConstPixelBufferAccess::getPixStencil (int x, int y, int z) const switch (m_format.type) { + case TextureFormat::UNSIGNED_INT_16_8: + DE_ASSERT(m_format.order == TextureFormat::DS); + return (int)readUint24Low8(pixelPtr); + case TextureFormat::UNSIGNED_INT_24_8: - switch (m_format.order) - { - case TextureFormat::S: - case TextureFormat::DS: - return (int)readUint32Low8(pixelPtr); + DE_ASSERT(m_format.order == TextureFormat::DS); + return (int)readUint32Low8(pixelPtr); - default: - DE_ASSERT(false); - return 0; - } + case TextureFormat::FLOAT_UNSIGNED_INT_8: + DE_ASSERT(m_format.order == TextureFormat::DS); + return (int)pixelPtr[4]; case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: DE_ASSERT(m_format.order == TextureFormat::DS); @@ -1030,19 +1079,17 @@ void PixelBufferAccess::setPixDepth (float depth, int x, int y, int z) const switch (m_format.type) { - case TextureFormat::UNSIGNED_INT_24_8: - switch (m_format.order) - { - case TextureFormat::D: - case TextureFormat::DS: - writeUint32High24(pixelPtr, convertSatRteUint24(depth * 16777215.0f)); - break; + case TextureFormat::UNSIGNED_INT_16_8: + DE_ASSERT(m_format.order == TextureFormat::DS); + writeUint24High16(pixelPtr, convertSatRte(depth * 65535.0f)); + break; - default: - DE_ASSERT(false); - } + case TextureFormat::UNSIGNED_INT_24_8: + DE_ASSERT(m_format.order == TextureFormat::DS); + writeUint32High24(pixelPtr, convertSatRteUint24(depth * 16777215.0f)); break; + case TextureFormat::FLOAT_UNSIGNED_INT_8: case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: DE_ASSERT(m_format.order == TextureFormat::DS); *((float*)pixelPtr) = depth; @@ -1065,17 +1112,18 @@ void PixelBufferAccess::setPixStencil (int stencil, int x, int y, int z) const switch (m_format.type) { + case TextureFormat::UNSIGNED_INT_16_8: + DE_ASSERT(m_format.order == TextureFormat::DS); + writeUint24Low8(pixelPtr, convertSat((deUint32)stencil)); + break; + case TextureFormat::UNSIGNED_INT_24_8: - switch (m_format.order) - { - case TextureFormat::S: - case TextureFormat::DS: - writeUint32Low8(pixelPtr, convertSat((deUint32)stencil)); - break; + DE_ASSERT(m_format.order == TextureFormat::DS); + writeUint32Low8(pixelPtr, convertSat((deUint32)stencil)); + break; - default: - DE_ASSERT(false); - } + case TextureFormat::FLOAT_UNSIGNED_INT_8: + DE_ASSERT(m_format.order == TextureFormat::DS); break; case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: @@ -3339,6 +3387,7 @@ std::ostream& operator<< (std::ostream& str, TextureFormat::ChannelType type) "UNSIGNED_INT_1010102_REV", "UNSIGNED_INT_11F_11F_10F_REV", "UNSIGNED_INT_999_E5_REV", + "UNSIGNED_INT_16_8", "UNSIGNED_INT_24_8", "SIGNED_INT8", "SIGNED_INT16", @@ -3349,6 +3398,7 @@ std::ostream& operator<< (std::ostream& str, TextureFormat::ChannelType type) "UNSIGNED_INT32", "HALF_FLOAT", "FLOAT", + "FLOAT_UNSIGNED_INT_8", "FLOAT_UNSIGNED_INT_24_8_REV" }; diff --git a/framework/common/tcuTexture.hpp b/framework/common/tcuTexture.hpp index 6ddc1ef..8a6d391 100644 --- a/framework/common/tcuTexture.hpp +++ b/framework/common/tcuTexture.hpp @@ -84,6 +84,7 @@ public: UNSIGNED_INT_1010102_REV, UNSIGNED_INT_11F_11F_10F_REV, UNSIGNED_INT_999_E5_REV, + UNSIGNED_INT_16_8, UNSIGNED_INT_24_8, SIGNED_INT8, SIGNED_INT16, @@ -94,6 +95,7 @@ public: UNSIGNED_INT32, HALF_FLOAT, FLOAT, + FLOAT_UNSIGNED_INT_8, FLOAT_UNSIGNED_INT_24_8_REV, CHANNELTYPE_LAST diff --git a/framework/common/tcuTextureUtil.cpp b/framework/common/tcuTextureUtil.cpp index 2591f10..d878fbb 100644 --- a/framework/common/tcuTextureUtil.cpp +++ b/framework/common/tcuTextureUtil.cpp @@ -81,9 +81,11 @@ 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 == 27); + DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29); - return type == TextureFormat::UNSIGNED_INT_24_8 || + return type == TextureFormat::UNSIGNED_INT_16_8 || + type == TextureFormat::UNSIGNED_INT_24_8 || + type == TextureFormat::FLOAT_UNSIGNED_INT_8 || type == TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV; } @@ -91,7 +93,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 == 27); + DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29); switch (channelType) { @@ -111,6 +113,7 @@ TextureChannelClass getTextureChannelClass (TextureFormat::ChannelType channelTy case TextureFormat::UNSIGNED_INT_1010102_REV: return TEXTURECHANNELCLASS_UNSIGNED_INTEGER; case TextureFormat::UNSIGNED_INT_11F_11F_10F_REV: return TEXTURECHANNELCLASS_FLOATING_POINT; case TextureFormat::UNSIGNED_INT_999_E5_REV: return TEXTURECHANNELCLASS_FLOATING_POINT; + case TextureFormat::UNSIGNED_INT_16_8: return TEXTURECHANNELCLASS_LAST; //!< packed unorm16-uint8 case TextureFormat::UNSIGNED_INT_24_8: return TEXTURECHANNELCLASS_LAST; //!< packed unorm24-uint8 case TextureFormat::SIGNED_INT8: return TEXTURECHANNELCLASS_SIGNED_INTEGER; case TextureFormat::SIGNED_INT16: return TEXTURECHANNELCLASS_SIGNED_INTEGER; @@ -121,6 +124,7 @@ TextureChannelClass getTextureChannelClass (TextureFormat::ChannelType channelTy case TextureFormat::UNSIGNED_INT32: return TEXTURECHANNELCLASS_UNSIGNED_INTEGER; case TextureFormat::HALF_FLOAT: return TEXTURECHANNELCLASS_FLOATING_POINT; case TextureFormat::FLOAT: return TEXTURECHANNELCLASS_FLOATING_POINT; + case TextureFormat::FLOAT_UNSIGNED_INT_8: return TEXTURECHANNELCLASS_LAST; //!< packed float32-uint8 case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: return TEXTURECHANNELCLASS_LAST; //!< packed float32-pad24-uint8 default: return TEXTURECHANNELCLASS_LAST; } @@ -237,7 +241,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 == 27); + DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29); float cMin = 0.0f; float cMax = 0.0f; @@ -324,7 +328,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 == 27); + DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29); switch (channelType) { @@ -349,11 +353,13 @@ static IVec4 getChannelBitDepth (TextureFormat::ChannelType channelType) 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_16_8: return IVec4(16,8,0,0); case TextureFormat::UNSIGNED_INT_24_8: return IVec4(24,8,0,0); case TextureFormat::HALF_FLOAT: return IVec4(16); case TextureFormat::FLOAT: return IVec4(32); case TextureFormat::UNSIGNED_INT_11F_11F_10F_REV: return IVec4(11,11,10,0); case TextureFormat::UNSIGNED_INT_999_E5_REV: return IVec4(9,9,9,0); + case TextureFormat::FLOAT_UNSIGNED_INT_8: return IVec4(32,8,0,0); case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: return IVec4(32,8,0,0); default: DE_ASSERT(false); @@ -380,7 +386,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 == 27); + DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29); switch (channelType) { @@ -405,6 +411,7 @@ static IVec4 getChannelMantissaBitDepth (TextureFormat::ChannelType channelType) case TextureFormat::UNSIGNED_INT24: case TextureFormat::UNSIGNED_INT32: case TextureFormat::UNSIGNED_INT_1010102_REV: + case TextureFormat::UNSIGNED_INT_16_8: case TextureFormat::UNSIGNED_INT_24_8: case TextureFormat::UNSIGNED_INT_999_E5_REV: return getChannelBitDepth(channelType); @@ -412,6 +419,7 @@ static IVec4 getChannelMantissaBitDepth (TextureFormat::ChannelType channelType) case TextureFormat::HALF_FLOAT: return IVec4(10); case TextureFormat::FLOAT: return IVec4(23); case TextureFormat::UNSIGNED_INT_11F_11F_10F_REV: return IVec4(6,6,5,0); + case TextureFormat::FLOAT_UNSIGNED_INT_8: return IVec4(23,8,0,0); case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: return IVec4(23,8,0,0); default: DE_ASSERT(false); @@ -1044,18 +1052,22 @@ template 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 == 27); + DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29); if (!isCombinedDepthStencilType(baseAccess.getFormat().type)) return baseAccess; else { #if (DE_ENDIANNESS == DE_LITTLE_ENDIAN) - const deUint32 uint32ByteOffsetBits0To8 = 0; //!< least significant byte in the lowest address - const deUint32 uint32ByteOffset8To32 = 1; + const deUint32 uint24ByteOffsetBits0To8 = 0; //!< least significant byte in the lowest address + const deUint32 uint24ByteOffsetBits8To24 = 1; + const deUint32 uint32ByteOffsetBits0To8 = 0; + const deUint32 uint32ByteOffsetBits8To32 = 1; #else - const deUint32 uint32ByteOffsetBits0To8 = 3; //!< least significant byte in the highest address - const deUint32 uint32ByteOffset8To32 = 0; + const deUint32 uint24ByteOffsetBits0To8 = 2; //!< least significant byte in the highest address + const deUint32 uint24ByteOffsetBits8To24 = 0; + const deUint32 uint32ByteOffsetBits0To8 = 3; + const deUint32 uint32ByteOffsetBits8To32 = 0; #endif // Sampled channel must exist @@ -1066,6 +1078,32 @@ static AccessType toSamplerAccess (const AccessType& baseAccess, Sampler::DepthS // combined formats have multiple channel classes, detect on sampler settings switch (baseAccess.getFormat().type) { + case TextureFormat::FLOAT_UNSIGNED_INT_8: + { + if (mode == Sampler::MODE_DEPTH) + { + // select the float component + return AccessType(TextureFormat(TextureFormat::D, TextureFormat::FLOAT), + baseAccess.getSize(), + baseAccess.getPitch(), + baseAccess.getDataPtr()); + } + else if (mode == Sampler::MODE_STENCIL) + { + // select the uint 8 component + return AccessType(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), + baseAccess.getSize(), + baseAccess.getPitch(), + addOffset(baseAccess.getDataPtr(), 4)); + } + else + { + // unknown sampler mode + DE_ASSERT(false); + return AccessType(); + } + } + case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: { if (mode == Sampler::MODE_DEPTH) @@ -1092,6 +1130,32 @@ static AccessType toSamplerAccess (const AccessType& baseAccess, Sampler::DepthS } } + case TextureFormat::UNSIGNED_INT_16_8: + { + if (mode == Sampler::MODE_DEPTH) + { + // select the unorm16 component + return AccessType(TextureFormat(TextureFormat::D, TextureFormat::UNORM_INT16), + baseAccess.getSize(), + baseAccess.getPitch(), + addOffset(baseAccess.getDataPtr(), uint24ByteOffsetBits8To24)); + } + else if (mode == Sampler::MODE_STENCIL) + { + // select the uint 8 component + return AccessType(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), + baseAccess.getSize(), + baseAccess.getPitch(), + addOffset(baseAccess.getDataPtr(), uint24ByteOffsetBits0To8)); + } + else + { + // unknown sampler mode + DE_ASSERT(false); + return AccessType(); + } + } + case TextureFormat::UNSIGNED_INT_24_8: { if (mode == Sampler::MODE_DEPTH) @@ -1100,7 +1164,7 @@ static AccessType toSamplerAccess (const AccessType& baseAccess, Sampler::DepthS return AccessType(TextureFormat(TextureFormat::D, TextureFormat::UNORM_INT24), baseAccess.getSize(), baseAccess.getPitch(), - addOffset(baseAccess.getDataPtr(), uint32ByteOffset8To32)); + addOffset(baseAccess.getDataPtr(), uint32ByteOffsetBits8To32)); } else if (mode == Sampler::MODE_STENCIL) {