copies_and_blitting: fix ambiguous signed normalized 1.0 value
authorSlawomir Cygan <slawomir.cygan@intel.com>
Thu, 6 Jul 2017 17:24:18 +0000 (19:24 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Sun, 16 Jul 2017 12:52:27 +0000 (08:52 -0400)
Below tests copy floats to signed normalized 8-bit values.
In that process it happens that 1.0 float value is copied to 8_snorm
elements as: {0x00, 0x00, 0x80, 0x3f}

According to spec, on SNORM values:

"Note that while zero is exactly expressible in this representation,
one value (-128 in the example) is outside the representable range,
and must be clamped before use."

The problem occurs when 0x80 == 128 value is copied to buffer:
as it falls outside of <-1,1> range, it may be clamped to 0x81 (both values
represent -1.0 SNORM value).

The change here processes all result and expected data buffers to remove
all ambiguites by converting to float and back to signed normalized format.

Affects:
dEQP-VK.api.copy_and_blit.*.image_to_image.all_formats.color.r32_sfloat.a8b8g8r8_snorm_pack32.*
dEQP-VK.api.copy_and_blit.*.image_to_image.all_formats.color.r32_sfloat.r8g8b8a8_snorm.*

Components: Vulkan

VK-GL-CTS issue: 563

Change-Id: I175665f39811cf6a80862967ad0a9bb8e13527e9

external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp

index 7fc650a..fad5eda 100644 (file)
@@ -1044,6 +1044,31 @@ tcu::TestStatus CopyImageToImage::checkTestResult (tcu::ConstPixelBufferAccess r
                        if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", m_expectedTextureLevel->getAccess(), result, fThreshold, tcu::COMPARE_LOG_RESULT))
                                return tcu::TestStatus::fail("CopiesAndBlitting test");
                }
+               else if (isSnormFormat(mapTextureFormat(result.getFormat())))
+               {
+                       // There may be an ambiguity between two possible binary representations of 1.0.
+                       // Get rid of that by expanding the data to floats and re-normalizing again.
+
+                       tcu::TextureLevel resultSnorm   (result.getFormat(), result.getWidth(), result.getHeight(), result.getDepth());
+                       {
+                               tcu::TextureLevel resultFloat   (tcu::TextureFormat(resultSnorm.getFormat().order, tcu::TextureFormat::FLOAT), resultSnorm.getWidth(), resultSnorm.getHeight(), resultSnorm.getDepth());
+
+                               tcu::copy(resultFloat.getAccess(), result);
+                               tcu::copy(resultSnorm, resultFloat.getAccess());
+                       }
+
+                       tcu::TextureLevel expectedSnorm (m_expectedTextureLevel->getFormat(), m_expectedTextureLevel->getWidth(), m_expectedTextureLevel->getHeight(), m_expectedTextureLevel->getDepth());
+
+                       {
+                               tcu::TextureLevel expectedFloat (tcu::TextureFormat(expectedSnorm.getFormat().order, tcu::TextureFormat::FLOAT), expectedSnorm.getWidth(), expectedSnorm.getHeight(), expectedSnorm.getDepth());
+
+                               tcu::copy(expectedFloat.getAccess(), m_expectedTextureLevel->getAccess());
+                               tcu::copy(expectedSnorm, expectedFloat.getAccess());
+                       }
+
+                       if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", expectedSnorm.getAccess(), resultSnorm.getAccess(), uThreshold, tcu::COMPARE_LOG_RESULT))
+                               return tcu::TestStatus::fail("CopiesAndBlitting test");
+               }
                else
                {
                        if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), "Compare", "Result comparison", m_expectedTextureLevel->getAccess(), result, uThreshold, tcu::COMPARE_LOG_RESULT))