Expose isSRGB publicly to avoid duplication.
authorJarkko Pöyry <jpoyry@google.com>
Fri, 6 Mar 2015 02:40:55 +0000 (18:40 -0800)
committerJarkko Pöyry <jpoyry@google.com>
Tue, 10 Mar 2015 20:22:08 +0000 (13:22 -0700)
Change-Id: I4244748cdd043a6c6b395a7b9a2e07200a9c6139

framework/common/tcuTexLookupVerifier.cpp
framework/common/tcuTexture.cpp
framework/common/tcuTextureUtil.cpp
framework/common/tcuTextureUtil.hpp
framework/opengl/simplereference/sglrReferenceContext.cpp
framework/referencerenderer/rrFragmentOperations.cpp
modules/gles3/functional/es3fFboTestUtil.cpp
modules/gles3/functional/es3fFragmentOutputTests.cpp
modules/gles3/functional/es3fFramebufferBlitTests.cpp
modules/gles3/functional/es3fTextureWrapTests.cpp

index de6254a..83af974 100644 (file)
@@ -52,11 +52,6 @@ static inline bool coordsInBounds (const ConstPixelBufferAccess& access, int x,
        return de::inBounds(x, 0, access.getWidth()) && de::inBounds(y, 0, access.getHeight()) && de::inBounds(z, 0, access.getDepth());
 }
 
-static inline bool isSRGB (TextureFormat format)
-{
-       return format.order == TextureFormat::sRGB || format.order == TextureFormat::sRGBA;
-}
-
 template<typename ScalarType>
 inline Vector<ScalarType, 4> lookup (const ConstPixelBufferAccess& access, const Sampler& sampler, int i, int j, int k)
 {
index a8a691f..f4d221f 100644 (file)
@@ -1143,11 +1143,6 @@ static inline float unnormalize (Sampler::WrapMode mode, float c, int size)
        }
 }
 
-static inline bool isSRGB (TextureFormat format)
-{
-       return format.order == TextureFormat::sRGB || format.order == TextureFormat::sRGBA;
-}
-
 static bool isFixedPointDepthTextureFormat (const tcu::TextureFormat& format)
 {
        const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
index 1e10fc9..2f15696 100644 (file)
@@ -70,6 +70,11 @@ Vec4 linearToSRGB (const Vec4& cl)
                                cl[3]);
 }
 
+bool isSRGB (TextureFormat format)
+{
+       return format.order == TextureFormat::sRGB || format.order == TextureFormat::sRGBA;
+}
+
 //! Get texture channel class for format
 TextureChannelClass getTextureChannelClass (TextureFormat::ChannelType channelType)
 {
index a973812..cfba85b 100644 (file)
@@ -42,6 +42,7 @@ ConstPixelBufferAccess        flipYAccess             (const ConstPixelBufferAccess& access);
 // sRGB - linear conversion.
 Vec4                                   sRGBToLinear    (const Vec4& cs);
 Vec4                                   linearToSRGB    (const Vec4& cl);
+bool                                   isSRGB                  (TextureFormat format);
 
 /*--------------------------------------------------------------------*//*!
  * \brief Color channel storage type
index db1eb44..1bead80 100644 (file)
@@ -3004,8 +3004,8 @@ deUint32 ReferenceContext::blitResolveMultisampleFramebuffer (deUint32 mask, con
                bool                                                                    dstIsFloat      = dstClass == tcu::TEXTURECHANNELCLASS_FLOATING_POINT           ||
                                                                                                                          dstClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT     ||
                                                                                                                          dstClass == tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT;
-               bool                                                                    srcIsSRGB       = src.raw().getFormat().order == tcu::TextureFormat::sRGB || src.raw().getFormat().order == tcu::TextureFormat::sRGBA;
-               bool                                                                    dstIsSRGB       = dst.getFormat().order == tcu::TextureFormat::sRGB || dst.getFormat().order == tcu::TextureFormat::sRGBA;
+               bool                                                                    srcIsSRGB       = tcu::isSRGB(src.raw().getFormat());
+               bool                                                                    dstIsSRGB       = tcu::isSRGB(dst.getFormat());
                const bool                                                              convertSRGB     = m_sRGBUpdateEnabled && glu::isContextTypeES(getType());
 
                if (!convertSRGB)
@@ -3156,8 +3156,8 @@ void ReferenceContext::blitFramebuffer (int srcX0, int srcY0, int srcX1, int src
                tcu::Sampler::FilterMode                sFilter         = (scale && filter == GL_LINEAR) ? tcu::Sampler::LINEAR : tcu::Sampler::NEAREST;
                tcu::Sampler                                    sampler         (tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE,
                                                                                                         sFilter, sFilter, 0.0f /* lod threshold */, false /* non-normalized coords */);
-               bool                                                    srcIsSRGB       = src.getFormat().order == tcu::TextureFormat::sRGB || src.getFormat().order == tcu::TextureFormat::sRGBA;
-               bool                                                    dstIsSRGB       = dst.getFormat().order == tcu::TextureFormat::sRGB || dst.getFormat().order == tcu::TextureFormat::sRGBA;
+               bool                                                    srcIsSRGB       = tcu::isSRGB(src.getFormat());
+               bool                                                    dstIsSRGB       = tcu::isSRGB(dst.getFormat());
                const bool                                              convertSRGB     = m_sRGBUpdateEnabled && glu::isContextTypeES(getType());
 
                if (!convertSRGB)
@@ -3350,7 +3350,7 @@ void ReferenceContext::clear (deUint32 buffers)
        {
                IVec4                                                           colorArea       = intersect(baseArea, getBufferRect(colorBuf0));
                rr::MultisamplePixelBufferAccess        access          = rr::getSubregion(colorBuf0, colorArea.x(), colorArea.y(), colorArea.z(), colorArea.w());
-               bool                                                            isSRGB          = colorBuf0.raw().getFormat().order == tcu::TextureFormat::sRGB || colorBuf0.raw().getFormat().order == tcu::TextureFormat::sRGBA;
+               bool                                                            isSRGB          = tcu::isSRGB(colorBuf0.raw().getFormat());
                Vec4                                                            c                       = (isSRGB && m_sRGBUpdateEnabled) ? tcu::linearToSRGB(m_clearColor) : m_clearColor;
                bool                                                            maskUsed        = !m_colorMask[0] || !m_colorMask[1] || !m_colorMask[2] || !m_colorMask[3];
                bool                                                            maskZero        = !m_colorMask[0] && !m_colorMask[1] && !m_colorMask[2] && !m_colorMask[3];
@@ -3499,8 +3499,7 @@ void ReferenceContext::clearBufferfv (deUint32 buffer, int drawbuffer, const flo
                        rr::MultisamplePixelBufferAccess        access          = rr::getSubregion(colorBuf, area.x(), area.y(), area.z(), area.w());
                        Vec4                                                            color           (value[0], value[1], value[2], value[3]);
 
-                       if (m_sRGBUpdateEnabled && (access.raw().getFormat().order == tcu::TextureFormat::sRGB ||
-                                                                               access.raw().getFormat().order == tcu::TextureFormat::sRGBA))
+                       if (m_sRGBUpdateEnabled && tcu::isSRGB(access.raw().getFormat()))
                                color = tcu::linearToSRGB(color);
 
                        if (!maskUsed)
index b8451e6..fa8ad92 100644 (file)
@@ -768,8 +768,7 @@ void FragmentProcessor::render (const rr::MultisamplePixelBufferAccess&             msColor
        const StencilState&             stencilState                            = state.stencilStates[fragmentFacing];
        Vec4                                    colorMaskFactor                         (state.colorMask[0] ? 1.0f : 0.0f, state.colorMask[1] ? 1.0f : 0.0f, state.colorMask[2] ? 1.0f : 0.0f, state.colorMask[3] ? 1.0f : 0.0f);
        Vec4                                    colorMaskNegationFactor         (state.colorMask[0] ? 0.0f : 1.0f, state.colorMask[1] ? 0.0f : 1.0f, state.colorMask[2] ? 0.0f : 1.0f, state.colorMask[3] ? 0.0f : 1.0f);
-       bool                                    sRGBTarget                                      = state.sRGBEnabled && (colorBuffer.getFormat().order == tcu::TextureFormat::sRGBA ||
-                                                                                                                                                               colorBuffer.getFormat().order == tcu::TextureFormat::sRGB);
+       bool                                    sRGBTarget                                      = state.sRGBEnabled && tcu::isSRGB(colorBuffer.getFormat());
 
        DE_ASSERT(SAMPLE_REGISTER_SIZE % numSamplesPerFragment == 0);
 
index 78d2a5a..cd8e7c7 100644 (file)
@@ -1099,7 +1099,7 @@ static int getToSRGB8ConversionError (int srcBits)
 tcu::RGBA getToSRGBConversionThreshold (const tcu::TextureFormat& src, const tcu::TextureFormat& dst)
 {
        // Only SRGB8 and SRGB8_ALPHA8 formats are supported.
-       DE_ASSERT(dst.type == tcu::TextureFormat::UNORM_INT8 && (dst.order == tcu::TextureFormat::sRGB || dst.order == tcu::TextureFormat::sRGBA));
+       DE_ASSERT(dst.type == tcu::TextureFormat::UNORM_INT8 && tcu::isSRGB(dst));
 
        const tcu::IVec4        bits            = tcu::getTextureFormatMantissaBitDepth(src);
        const bool                      dstHasAlpha     = dst.order == tcu::TextureFormat::sRGBA;
index 13de888..71f8422 100644 (file)
@@ -395,7 +395,7 @@ static inline IVec4 readIVec4 (const int* ptr, int numComponents)
 
 static void renderFloatReference (const tcu::PixelBufferAccess& dst, int gridWidth, int gridHeight, int numComponents, const float* vertices)
 {
-       const bool      isSRGB          = dst.getFormat().order == tcu::TextureFormat::sRGB ||dst.getFormat().order == tcu::TextureFormat::sRGBA;
+       const bool      isSRGB          = tcu::isSRGB(dst.getFormat());
        const float     cellW           = (float)dst.getWidth() / (float)(gridWidth-1);
        const float     cellH           = (float)dst.getHeight() / (float)(gridHeight-1);
 
index efcdef3..74e79a7 100644 (file)
@@ -426,8 +426,8 @@ protected:
        {
                const tcu::TextureFormat        srcFormat       = glu::mapGLInternalFormat(m_srcFormat);
                const tcu::TextureFormat        dstFormat       = glu::mapGLInternalFormat(m_dstFormat);
-               const bool                                      srcIsSRGB       = (srcFormat.order == tcu::TextureFormat::sRGBA);
-               const bool                                      dstIsSRGB       = (dstFormat.order == tcu::TextureFormat::sRGBA);
+               const bool                                      srcIsSRGB       = tcu::isSRGB(srcFormat);
+               const bool                                      dstIsSRGB       = tcu::isSRGB(dstFormat);
 
                tcu::RGBA                                       threshold;
 
index 06cd78f..e137304 100644 (file)
@@ -330,7 +330,7 @@ TextureWrapCase::IterateResult TextureWrapCase::iterate (void)
        {
                const tcu::ScopedLogSection             section                 (log, string("Test") + de::toString(m_caseNdx), string("Test ") + de::toString(m_caseNdx));
                const bool                                              isNearestOnly   = m_minFilter == GL_NEAREST && m_magFilter == GL_NEAREST;
-               const bool                                              isSRGB                  = texFormat.order == tcu::TextureFormat::sRGB || texFormat.order == tcu::TextureFormat::sRGBA;
+               const bool                                              isSRGB                  = tcu::isSRGB(texFormat);
                const tcu::PixelFormat                  pixelFormat             = m_renderCtx.getRenderTarget().getPixelFormat();
                const tcu::IVec4                                colorBits               = tcu::max(getBitsVec(pixelFormat) - (isNearestOnly && !isSRGB ? 1 : 2), tcu::IVec4(0));
                tcu::LodPrecision                               lodPrecision;