Fix issues with non-tightly packed images.
authorJarkko Pöyry <jpoyry@google.com>
Mon, 11 May 2015 23:42:02 +0000 (16:42 -0700)
committerJarkko Pöyry <jpoyry@google.com>
Tue, 12 May 2015 00:02:06 +0000 (17:02 -0700)
- Add logging fast-path pixel pitch check.
- Fix MultisamplePixelBufferAccess with non-tightly packed images.
- Add estimatePixelValueRange() fast-paths for all normalized formats.

Change-Id: If5b334de2658b7c714fe56bb561892b5a736e3b0

framework/common/tcuTestLog.cpp
framework/common/tcuTextureUtil.cpp
framework/referencerenderer/rrMultisamplePixelBufferAccess.cpp

index fc1ea0f..5870f10 100644 (file)
@@ -174,9 +174,10 @@ void TestLog::writeImage (const char* name, const char* description, const Const
        if ((qpTestLog_getLogFlags(m_log) & QP_TEST_LOG_EXCLUDE_IMAGES) != 0)
                return;
 
-       if (depth == 1 && format.type == TextureFormat::UNORM_INT8 &&
-               width <= MAX_IMAGE_SIZE_2D && height <= MAX_IMAGE_SIZE_2D &&
-               (format.order == TextureFormat::RGB || format.order == TextureFormat::RGBA)
+       if (depth == 1 && format.type == TextureFormat::UNORM_INT8
+               && width <= MAX_IMAGE_SIZE_2D && height <= MAX_IMAGE_SIZE_2D
+               && (format.order == TextureFormat::RGB || format.order == TextureFormat::RGBA)
+               && access.getPixelPitch() == access.getFormat().getPixelSize()
                && pixelBias[0] == 0.0f && pixelBias[1] == 0.0f && pixelBias[2] == 0.0f && pixelBias[3] == 0.0f
                && pixelScale[0] == 1.0f && pixelScale[1] == 1.0f && pixelScale[2] == 1.0f && pixelScale[3] == 1.0f)
        {
index 0de34c6..99f8dbd 100644 (file)
@@ -916,17 +916,15 @@ void estimatePixelValueRange (const ConstPixelBufferAccess& access, Vec4& minVal
 {
        const TextureFormat& format = access.getFormat();
 
-       switch (format.type)
+       switch (getTextureChannelClass(format.type))
        {
-               case TextureFormat::UNORM_INT8:
-               case TextureFormat::UNORM_INT16:
+               case TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
                        // Normalized unsigned formats.
                        minVal = Vec4(0.0f);
                        maxVal = Vec4(1.0f);
                        break;
 
-               case TextureFormat::SNORM_INT8:
-               case TextureFormat::SNORM_INT16:
+               case TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
                        // Normalized signed formats.
                        minVal = Vec4(-1.0f);
                        maxVal = Vec4(+1.0f);
index f7effbd..e7ab014 100644 (file)
@@ -42,11 +42,8 @@ const tcu::PixelBufferAccess MultisamplePixelBufferAccess::toSinglesampleAccess
        DE_ASSERT(getNumSamples() == 1);
 
        return tcu::PixelBufferAccess(m_access.getFormat(),
-                                                                 m_access.getHeight(),
-                                                                 m_access.getDepth(),
-                                                                 1,
-                                                                 m_access.getSlicePitch(),
-                                                                 m_access.getSlicePitch() * m_access.getDepth(),
+                                                                 tcu::IVec3(m_access.getHeight(), m_access.getDepth(), 1),
+                                                                 tcu::IVec3(m_access.getRowPitch(), m_access.getSlicePitch(), m_access.getSlicePitch() * m_access.getDepth()),
                                                                  m_access.getDataPtr());
 }
 
@@ -55,11 +52,8 @@ MultisamplePixelBufferAccess MultisamplePixelBufferAccess::fromSinglesampleAcces
        return MultisamplePixelBufferAccess(
                                tcu::PixelBufferAccess(
                                                                original.getFormat(),
-                                                               1,
-                                                               original.getWidth(),
-                                                               original.getHeight(),
-                                                               original.getFormat().getPixelSize(),
-                                                               original.getRowPitch(),
+                                                               tcu::IVec3(1, original.getWidth(), original.getHeight()),
+                                                               tcu::IVec3(original.getPixelPitch(), original.getPixelPitch(), original.getRowPitch()),
                                                                original.getDataPtr()));
 }
 
@@ -88,11 +82,8 @@ const tcu::ConstPixelBufferAccess MultisampleConstPixelBufferAccess::toSinglesam
        DE_ASSERT(getNumSamples() == 1);
 
        return tcu::ConstPixelBufferAccess(m_access.getFormat(),
-                                                                          m_access.getHeight(),
-                                                                          m_access.getDepth(),
-                                                                          1,
-                                                                          m_access.getSlicePitch(),
-                                                                          m_access.getSlicePitch() * m_access.getDepth(),
+                                                                          tcu::IVec3(m_access.getHeight(), m_access.getDepth(), 1),
+                                                                          tcu::IVec3(m_access.getRowPitch(), m_access.getSlicePitch(), m_access.getSlicePitch() * m_access.getDepth()),
                                                                           m_access.getDataPtr());
 }
 
@@ -101,11 +92,8 @@ MultisampleConstPixelBufferAccess MultisampleConstPixelBufferAccess::fromSingles
        return MultisampleConstPixelBufferAccess(
                                tcu::ConstPixelBufferAccess(
                                                                original.getFormat(),
-                                                               1,
-                                                               original.getWidth(),
-                                                               original.getHeight(),
-                                                               original.getFormat().getPixelSize(),
-                                                               original.getRowPitch(),
+                                                               tcu::IVec3(1, original.getWidth(), original.getHeight()),
+                                                               tcu::IVec3(original.getPixelPitch(), original.getPixelPitch(), original.getRowPitch()),
                                                                original.getDataPtr()));
 }