From: Mika Isojärvi Date: Mon, 17 Aug 2015 22:54:12 +0000 (-0700) Subject: Add texture format range functions with correct types X-Git-Tag: upstream/0.1.0~1446 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4356bb5b4e9a1559ecea41265ee242d37aacaa38;p=platform%2Fupstream%2FVK-GL-CTS.git Add texture format range functions with correct types Change-Id: I1a6891659406d5a4913de3bab6494f858cd68e19 (cherry picked from commit b0efcb495999162fadf75e9630a712ed1643a244) --- diff --git a/framework/common/tcuTextureUtil.cpp b/framework/common/tcuTextureUtil.cpp index 2591f10..3fdfc0b 100644 --- a/framework/common/tcuTextureUtil.cpp +++ b/framework/common/tcuTextureUtil.cpp @@ -234,7 +234,7 @@ ConstPixelBufferAccess flipYAccess (const ConstPixelBufferAccess& access) return ConstPixelBufferAccess(access.getFormat(), access.getSize(), pitch, (deUint8*)access.getDataPtr() + offsetToLast); } -static Vec2 getChannelValueRange (TextureFormat::ChannelType channelType) +static Vec2 getFloatChannelValueRange (TextureFormat::ChannelType channelType) { // make sure this table is updated if format table is updated DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27); @@ -306,7 +306,7 @@ TextureFormatInfo getTextureFormatInfo (const TextureFormat& format) Vec4(1.0f, 1.0f, 1.0f, 1.0f), Vec4(0.0f, 0.0f, 0.0f, 0.0f)); - const Vec2 cRange = getChannelValueRange(format.type); + const Vec2 cRange = getFloatChannelValueRange(format.type); const TextureSwizzle::Channel* map = getChannelReadSwizzle(format.order).components; const BVec4 chnMask = BVec4(deInRange32(map[0], TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_3) == DE_TRUE, deInRange32(map[1], TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_3) == DE_TRUE, @@ -321,6 +321,58 @@ TextureFormatInfo getTextureFormatInfo (const TextureFormat& format) select(bias, 0.0f, chnMask)); } +IVec4 getFormatMinIntValue (const TextureFormat& format) +{ + DE_ASSERT(getTextureChannelClass(format.type) == TEXTURECHANNELCLASS_SIGNED_INTEGER); + + switch (format.type) + { + case TextureFormat::SIGNED_INT8: return IVec4(-128); + case TextureFormat::SIGNED_INT16: return IVec4(-32768); + case TextureFormat::SIGNED_INT32: return IVec4(-2147483648); + + default: + DE_FATAL("Invalid channel type"); + return IVec4(0); + } +} + +IVec4 getFormatMaxIntValue (const TextureFormat& format) +{ + DE_ASSERT(getTextureChannelClass(format.type) == TEXTURECHANNELCLASS_SIGNED_INTEGER); + + switch (format.type) + { + case TextureFormat::SIGNED_INT8: return IVec4(127); + case TextureFormat::SIGNED_INT16: return IVec4(32767); + case TextureFormat::SIGNED_INT32: return IVec4(2147483647); + + default: + DE_FATAL("Invalid channel type"); + return IVec4(0); + } +} + +UVec4 getFormatMaxUintValue (const TextureFormat& format) +{ + DE_ASSERT(getTextureChannelClass(format.type) == TEXTURECHANNELCLASS_UNSIGNED_INTEGER); + + if (format == TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT_1010102_REV)) + return UVec4(1023u, 1023u, 1023u, 3u); + + switch (format.type) + { + case TextureFormat::UNSIGNED_INT8: return UVec4(255u); + case TextureFormat::UNSIGNED_INT16: return UVec4(65535u); + case TextureFormat::UNSIGNED_INT24: return UVec4(16777215u); + case TextureFormat::UNSIGNED_INT32: return UVec4(4294967295u); + + default: + DE_FATAL("Invalid channel type"); + return UVec4(0); + } +} + static IVec4 getChannelBitDepth (TextureFormat::ChannelType channelType) { // make sure this table is updated if format table is updated diff --git a/framework/common/tcuTextureUtil.hpp b/framework/common/tcuTextureUtil.hpp index c51e303..b714a70 100644 --- a/framework/common/tcuTextureUtil.hpp +++ b/framework/common/tcuTextureUtil.hpp @@ -86,6 +86,11 @@ IVec4 getTextureFormatBitDepth (const TextureFormat& format); IVec4 getTextureFormatMantissaBitDepth (const TextureFormat& format); BVec4 getTextureFormatChannelMask (const TextureFormat& format); +IVec4 getFormatMinIntValue (const TextureFormat& format); +IVec4 getFormatMaxIntValue (const TextureFormat& format); + +UVec4 getFormatMaxUintValue (const TextureFormat& format); + // Texture fill. void clear (const PixelBufferAccess& access, const Vec4& color); void clear (const PixelBufferAccess& access, const IVec4& color);