Fixes threshold in texture size tests
authorMatthew Netsch <mnetsch@codeaurora.org>
Tue, 19 Dec 2017 20:45:33 +0000 (12:45 -0800)
committerChris Forbes <chrisforbes@google.com>
Mon, 29 Jan 2018 21:22:48 +0000 (13:22 -0800)
Threshold was computed directly from backbuffer format.
This makes the threshold too strict if the texture
sampled from has a lower bit-depth than the backbuffer.

This change takes the minimium bit depth between the
backbuffer and texture to compute the threshold.

Components: OpenGL ES
VK-GL-CTS issue: 163

Affects:
dEQP-GLES2.functional.texture.size.*
dEQP-GLES3.functional.texture.size.*

Change-Id: Id491ff4ef1b958459156fe83d9d5099cf81de81e

modules/gles2/functional/es2fTextureSizeTests.cpp
modules/gles3/functional/es3fTextureSizeTests.cpp

index 4e2988f..f7627b9 100644 (file)
@@ -122,7 +122,10 @@ Texture2DSizeCase::IterateResult Texture2DSizeCase::iterate (void)
        RandomViewport                  viewport                (m_renderCtx.getRenderTarget(), 128, 128, deStringHash(getName()));
        tcu::Surface                    renderedFrame   (viewport.width, viewport.height);
        tcu::Surface                    referenceFrame  (viewport.width, viewport.height);
-       tcu::RGBA                               threshold               = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(7,7,7,7);
+       const tcu::IVec4                texBits                 = tcu::getTextureFormatBitDepth(glu::mapGLTransferFormat(m_format, m_dataType));
+       const tcu::PixelFormat& rtFmt                   = m_renderCtx.getRenderTarget().getPixelFormat();
+       const tcu::PixelFormat  thresholdFormat(std::min(texBits[0], rtFmt.redBits), std::min(texBits[1], rtFmt.greenBits), std::min(texBits[2], rtFmt.blueBits), std::min(texBits[3], rtFmt.alphaBits));
+       tcu::RGBA                               threshold               = thresholdFormat.getColorThreshold() + tcu::RGBA(7,7,7,7);
        deUint32                                wrapS                   = GL_CLAMP_TO_EDGE;
        deUint32                                wrapT                   = GL_CLAMP_TO_EDGE;
        deUint32                                minFilter               = m_useMipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST;
@@ -265,7 +268,10 @@ bool TextureCubeSizeCase::testFace (tcu::CubeFace face)
        RandomViewport                  viewport                (m_renderCtx.getRenderTarget(), 128, 128, deStringHash(getName())+(deUint32)face);
        tcu::Surface                    renderedFrame   (viewport.width, viewport.height);
        tcu::Surface                    referenceFrame  (viewport.width, viewport.height);
-       tcu::RGBA                               threshold               = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(7,7,7,7);
+       const tcu::IVec4                texBits                 = tcu::getTextureFormatBitDepth(glu::mapGLTransferFormat(m_format, m_dataType));
+       const tcu::PixelFormat& rtFmt                   = m_renderCtx.getRenderTarget().getPixelFormat();
+       const tcu::PixelFormat  thresholdFormat(std::min(texBits[0], rtFmt.redBits), std::min(texBits[1], rtFmt.greenBits), std::min(texBits[2], rtFmt.blueBits), std::min(texBits[3], rtFmt.alphaBits));
+       tcu::RGBA                               threshold               = thresholdFormat.getColorThreshold() + tcu::RGBA(7,7,7,7);
        deUint32                                wrapS                   = GL_CLAMP_TO_EDGE;
        deUint32                                wrapT                   = GL_CLAMP_TO_EDGE;
        deUint32                                minFilter               = m_useMipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST;
index a085d64..6eeed5a 100644 (file)
@@ -123,7 +123,10 @@ Texture2DSizeCase::IterateResult Texture2DSizeCase::iterate (void)
        RandomViewport                  viewport                (m_renderCtx.getRenderTarget(), 128, 128, deStringHash(getName()));
        tcu::Surface                    renderedFrame   (viewport.width, viewport.height);
        tcu::Surface                    referenceFrame  (viewport.width, viewport.height);
-       tcu::RGBA                               threshold               = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(7,7,7,7);
+       const tcu::IVec4                texBits                 = tcu::getTextureFormatBitDepth(glu::mapGLTransferFormat(m_format, m_dataType));
+       const tcu::PixelFormat& rtFmt                   = m_renderCtx.getRenderTarget().getPixelFormat();
+       const tcu::PixelFormat  thresholdFormat(std::min(texBits[0], rtFmt.redBits), std::min(texBits[1], rtFmt.greenBits), std::min(texBits[2], rtFmt.blueBits), std::min(texBits[3], rtFmt.alphaBits));
+       tcu::RGBA                               threshold               = thresholdFormat.getColorThreshold() + tcu::RGBA(7,7,7,7);
        deUint32                                wrapS                   = GL_CLAMP_TO_EDGE;
        deUint32                                wrapT                   = GL_CLAMP_TO_EDGE;
        deUint32                                minFilter               = m_useMipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST;
@@ -266,7 +269,10 @@ bool TextureCubeSizeCase::testFace (tcu::CubeFace face)
        RandomViewport                  viewport                (m_renderCtx.getRenderTarget(), 128, 128, deStringHash(getName())+(deUint32)face);
        tcu::Surface                    renderedFrame   (viewport.width, viewport.height);
        tcu::Surface                    referenceFrame  (viewport.width, viewport.height);
-       tcu::RGBA                               threshold               = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(7,7,7,7);
+       const tcu::IVec4                texBits                 = tcu::getTextureFormatBitDepth(glu::mapGLTransferFormat(m_format, m_dataType));
+       const tcu::PixelFormat& rtFmt                   = m_renderCtx.getRenderTarget().getPixelFormat();
+       const tcu::PixelFormat  thresholdFormat(std::min(texBits[0], rtFmt.redBits), std::min(texBits[1], rtFmt.greenBits), std::min(texBits[2], rtFmt.blueBits), std::min(texBits[3], rtFmt.alphaBits));
+       tcu::RGBA                               threshold               = thresholdFormat.getColorThreshold() + tcu::RGBA(7,7,7,7);
        deUint32                                wrapS                   = GL_CLAMP_TO_EDGE;
        deUint32                                wrapT                   = GL_CLAMP_TO_EDGE;
        deUint32                                minFilter               = m_useMipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST;