Always align rows to pixel size on read pixels tests.
authorMika Isojärvi <misojarvi@google.com>
Tue, 17 Feb 2015 23:21:08 +0000 (15:21 -0800)
committerMika Isojärvi <misojarvi@google.com>
Tue, 17 Feb 2015 23:41:28 +0000 (15:41 -0800)
Fixed read pixels tests to always align pixel data to at least size of the
pixel. Earlier tests had wrong interpretation of specification for packed
renderbuffer formats.

Bug: 19408884
Change-Id: Ic0bf3d309f57bdd52fecf221b8d4f839da85168c

modules/gles2/functional/es2fReadPixelsTests.cpp
modules/gles3/functional/es3fReadPixelsTests.cpp

index cabc6770fc7a57c8da7ddfa5989552453b6f065e..c16630fbb8757c1ce205126b3e33e1046d65b5c7 100644 (file)
@@ -62,7 +62,7 @@ private:
        int                             m_alignment;
        int                             m_seed;
 
-       void                    getFormatInfo   (tcu::TextureFormat& format, GLint& glFormat, GLint& glType, int& pixelSize, bool& align);
+       void                    getFormatInfo   (tcu::TextureFormat& format, GLint& glFormat, GLint& glType, int& pixelSize);
 };
 
 ReadPixelsTest::ReadPixelsTest (Context& context, const char* name, const char* description, bool chooseFormat, int alignment)
@@ -140,7 +140,7 @@ void ReadPixelsTest::render (tcu::Texture2D& reference)
        }
 }
 
-void ReadPixelsTest::getFormatInfo (tcu::TextureFormat& format, GLint& glFormat, GLint& glType, int& pixelSize, bool& align)
+void ReadPixelsTest::getFormatInfo (tcu::TextureFormat& format, GLint& glFormat, GLint& glType, int& pixelSize)
 {
        if (m_chooseFormat)
        {
@@ -149,42 +149,12 @@ void ReadPixelsTest::getFormatInfo (tcu::TextureFormat& format, GLint& glFormat,
 
                format = glu::mapGLTransferFormat(glFormat, glType);
 
-               // Check if aligment is allowed
-               switch (glType)
-               {
-                       case GL_BYTE:
-                       case GL_UNSIGNED_BYTE:
-                       case GL_SHORT:
-                       case GL_UNSIGNED_SHORT:
-                       case GL_INT:
-                       case GL_UNSIGNED_INT:
-                       case GL_FLOAT:
-                       case GL_HALF_FLOAT:
-                               align = true;
-                               break;
-
-                       case GL_UNSIGNED_SHORT_5_6_5:
-                       case GL_UNSIGNED_SHORT_4_4_4_4:
-                       case GL_UNSIGNED_SHORT_5_5_5_1:
-                       case GL_UNSIGNED_INT_2_10_10_10_REV:
-                       case GL_UNSIGNED_INT_10F_11F_11F_REV:
-                       case GL_UNSIGNED_INT_24_8:
-                       case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
-                       case GL_UNSIGNED_INT_5_9_9_9_REV:
-                               align = false;
-                               break;
-
-                       default:
-                               throw tcu::InternalError("Unsupported format", "", __FILE__, __LINE__);
-               }
-
                pixelSize       = format.getPixelSize();
        }
        else
        {
                format          = tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8);
                pixelSize       = 1 * 4;
-               align           = true;
                glFormat        = GL_RGBA;
                glType          = GL_UNSIGNED_BYTE;
        }
@@ -202,9 +172,8 @@ TestCase::IterateResult ReadPixelsTest::iterate (void)
        int                                                     pixelSize;
        GLint                                           glFormat;
        GLint                                           glType;
-       bool                                            align;
 
-       getFormatInfo(format, glFormat, glType, pixelSize, align);
+       getFormatInfo(format, glFormat, glType, pixelSize);
        m_testCtx.getLog() << tcu::TestLog::Message << "Format: " << glu::getPixelFormatStr(glFormat) << ", Type: " << glu::getTypeStr(glType) << tcu::TestLog::EndMessage;
 
        tcu::Texture2D reference(format, width, height);
@@ -234,7 +203,7 @@ TestCase::IterateResult ReadPixelsTest::iterate (void)
        render(reference);
 
        std::vector<deUint8> pixelData;
-       const int rowPitch = (align ? m_alignment * deCeilFloatToInt32(pixelSize * width / (float)m_alignment) : width * pixelSize);
+       const int rowPitch = m_alignment * deCeilFloatToInt32(pixelSize * width / (float)m_alignment);
 
        pixelData.resize(rowPitch * height, 0);
 
index 973bc124aaf09241abdad174ba4e8476859b5ecc..09e987719ccc4085d762493dc87a99de6e632468 100644 (file)
@@ -76,8 +76,8 @@ private:
        const int               m_width;
        const int               m_height;
 
-       void                    getFormatInfo   (tcu::TextureFormat& format, int& pixelSize, bool& align);
-       void                    clearColor              (tcu::Texture2D& reference, vector<deUint8>& pixelData, bool align, int pixelSize);
+       void                    getFormatInfo   (tcu::TextureFormat& format, int& pixelSize);
+       void                    clearColor              (tcu::Texture2D& reference, vector<deUint8>& pixelData, int pixelSize);
 };
 
 ReadPixelsTest::ReadPixelsTest (Context& context, const char* name, const char* description, bool chooseFormat, int alignment, GLint rowLength, GLint skipRows, GLint skipPixels, GLenum format, GLenum type)
@@ -191,7 +191,7 @@ void ReadPixelsTest::render (tcu::Texture2D& reference)
        }
 }
 
-void ReadPixelsTest::getFormatInfo (tcu::TextureFormat& format, int& pixelSize, bool& align)
+void ReadPixelsTest::getFormatInfo (tcu::TextureFormat& format, int& pixelSize)
 {
        if (m_chooseFormat)
        {
@@ -200,39 +200,10 @@ void ReadPixelsTest::getFormatInfo (tcu::TextureFormat& format, int& pixelSize,
        }
 
        format = glu::mapGLTransferFormat(m_format, m_type);
-
-       switch (m_type)
-       {
-               case GL_BYTE:
-               case GL_UNSIGNED_BYTE:
-               case GL_SHORT:
-               case GL_UNSIGNED_SHORT:
-               case GL_INT:
-               case GL_UNSIGNED_INT:
-               case GL_FLOAT:
-               case GL_HALF_FLOAT:
-                       align = true;
-                       break;
-
-               case GL_UNSIGNED_SHORT_5_6_5:
-               case GL_UNSIGNED_SHORT_4_4_4_4:
-               case GL_UNSIGNED_SHORT_5_5_5_1:
-               case GL_UNSIGNED_INT_2_10_10_10_REV:
-               case GL_UNSIGNED_INT_10F_11F_11F_REV:
-               case GL_UNSIGNED_INT_24_8:
-               case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
-               case GL_UNSIGNED_INT_5_9_9_9_REV:
-                       align = false;
-                       break;
-
-               default:
-                       throw tcu::InternalError("Unsupported format", "", __FILE__, __LINE__);
-       }
-
        pixelSize = format.getPixelSize();
 }
 
-void ReadPixelsTest::clearColor (tcu::Texture2D& reference, vector<deUint8>& pixelData, bool align, int pixelSize)
+void ReadPixelsTest::clearColor (tcu::Texture2D& reference, vector<deUint8>& pixelData, int pixelSize)
 {
        de::Random                                      rnd(m_seed);
        GLuint                                          framebuffer = 0;
@@ -334,7 +305,7 @@ void ReadPixelsTest::clearColor (tcu::Texture2D& reference, vector<deUint8>& pix
        render(reference);
 
        const int rowWidth      = (m_rowLength == 0 ? m_width : m_rowLength) + m_skipPixels;
-       const int rowPitch      = (align ? m_alignment * deCeilFloatToInt32(pixelSize * rowWidth / (float)m_alignment) : rowWidth * pixelSize);
+       const int rowPitch      = m_alignment * deCeilFloatToInt32(pixelSize * rowWidth / (float)m_alignment);
 
        pixelData.resize(rowPitch * (m_height + m_skipRows), 0);
 
@@ -351,9 +322,8 @@ TestCase::IterateResult ReadPixelsTest::iterate (void)
 {
        tcu::TextureFormat                      format(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8);
        int                                                     pixelSize;
-       bool                                            align;
 
-       getFormatInfo(format, pixelSize, align);
+       getFormatInfo(format, pixelSize);
        m_testCtx.getLog() << tcu::TestLog::Message << "Format: " << glu::getPixelFormatStr(m_format) << ", Type: " << glu::getTypeStr(m_type) << tcu::TestLog::EndMessage;
 
        tcu::Texture2D reference(format, m_width, m_height);
@@ -374,10 +344,10 @@ TestCase::IterateResult ReadPixelsTest::iterate (void)
        GLU_CHECK_CALL(glViewport(0, 0, m_width, m_height));
 
        vector<deUint8> pixelData;
-       clearColor(reference, pixelData, align, pixelSize);
+       clearColor(reference, pixelData, pixelSize);
 
        const int rowWidth      = (m_rowLength == 0 ? m_width : m_rowLength);
-       const int rowPitch      = (align ? m_alignment * deCeilFloatToInt32(pixelSize * rowWidth / (float)m_alignment) : rowWidth * pixelSize);
+       const int rowPitch      = m_alignment * deCeilFloatToInt32(pixelSize * rowWidth / (float)m_alignment);
 
        // \note GL_RGBA_INTEGER uses always renderbuffers that are never multisampled. Otherwise default framebuffer is used.
        if (m_format != GL_RGBA_INTEGER && m_context.getRenderTarget().getNumSamples() > 1)