Apply sRGB conversion to reference in sRGB framebuffer fetch test
authorjames.glanville <james.glanville@imgtec.com>
Thu, 18 May 2017 10:24:06 +0000 (11:24 +0100)
committerMika Isojärvi <misojarvi@google.com>
Tue, 11 Jul 2017 17:30:30 +0000 (10:30 -0700)
Framebuffer fetch returns linear values when the framebuffer format
is sRGB and GL_FRAMEBUFFER_SRGB is enabled (default). This conversion
was not applied when generating reference textures for framebuffer
fetch tests. glReadPixels() does not apply any conversion, so the
final reference value must also be converted back to sRGB.

Affects: dEQP-GLES31.functional.shaders.framebuffer_fetch.
framebuffer_format.srgb8_alpha8

Components: AOSP

modules/gles31/functional/es31fShaderFramebufferFetchTests.cpp

index 8f591aa..9d77831 100644 (file)
@@ -568,11 +568,25 @@ tcu::TextureLevel TextureFormatTestCase::genReferenceTexture (const tcu::Vec4& f
        tcu::TextureChannelClass        textureChannelClass = tcu::getTextureChannelClass(m_texFmt.type);
 
        if (textureChannelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
+       {
                tcu::clear(reference.getAccess(), fbColor.asUint() + uniformColor.asUint());
+       }
        else if (textureChannelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
+       {
                tcu::clear(reference.getAccess(), fbColor.asInt() + uniformColor.asInt());
+       }
        else
-               tcu::clear(reference.getAccess(), fbColor + uniformColor);
+       {
+               if (tcu::isSRGB(m_texFmt))
+               {
+                       const tcu::Vec4 fragmentColor = tcu::sRGBToLinear(fbColor) + uniformColor;
+                       tcu::clear(reference.getAccess(), tcu::linearToSRGB(fragmentColor));
+               }
+               else
+               {
+                       tcu::clear(reference.getAccess(), fbColor + uniformColor);
+               }
+       }
 
        return reference;
 }