Add getTextureFormatChannelMask.
authorJarkko Pöyry <jpoyry@google.com>
Fri, 10 Apr 2015 01:31:44 +0000 (18:31 -0700)
committerJarkko Pöyry <jpoyry@google.com>
Fri, 17 Apr 2015 02:18:13 +0000 (19:18 -0700)
Change-Id: I282ff43e628c9400a572163baa0e90bde30d460a

framework/common/tcuTextureUtil.cpp
framework/common/tcuTextureUtil.hpp

index cf5475f..c521c49 100644 (file)
@@ -422,6 +422,15 @@ IVec4 getTextureFormatMantissaBitDepth (const TextureFormat& format)
        return select(chnBits.swizzle(chnSwz.x(), chnSwz.y(), chnSwz.z(), chnSwz.w()), IVec4(0), chnMask);
 }
 
+BVec4 getTextureFormatChannelMask (const TextureFormat& format)
+{
+       const TextureSwizzle::Channel* const map = getChannelReadSwizzle(format.order).components;
+       return BVec4(deInRange32(map[0], TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_3) == DE_TRUE,
+                                deInRange32(map[1], TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_3) == DE_TRUE,
+                                deInRange32(map[2], TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_3) == DE_TRUE,
+                                deInRange32(map[3], TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_3) == DE_TRUE);
+}
+
 static inline float linearInterpolate (float t, float minVal, float maxVal)
 {
        return minVal + (maxVal - minVal) * t;
index 643a567..cd67e0f 100644 (file)
@@ -82,6 +82,7 @@ struct TextureFormatInfo
 TextureFormatInfo      getTextureFormatInfo                            (const TextureFormat& format);
 IVec4                          getTextureFormatBitDepth                        (const TextureFormat& format);
 IVec4                          getTextureFormatMantissaBitDepth        (const TextureFormat& format);
+BVec4                          getTextureFormatChannelMask                     (const TextureFormat& format);
 
 // Texture fill.
 void   clear                                                   (const PixelBufferAccess& access, const Vec4& color);