Add color output check to early fragment sample count tests
authorJuha Heiskanen <juha.heiskanen@siru.fi>
Mon, 17 Jan 2022 14:36:23 +0000 (16:36 +0200)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Sat, 29 Jan 2022 17:19:44 +0000 (17:19 +0000)
Additional check for the edge cases, where the sample count value
is correct, but the color output value is wrong.

Components: Vulkan

VK-GL-CTS Issue: 3452

Affects: dEQP-VK.fragment_operations.early_fragment.sample_*

Change-Id: I19bfdd4f007a75580418fb61720ba06e82610291

external/vulkancts/modules/vulkan/fragment_ops/vktFragmentOperationsEarlyFragmentTests.cpp

index 3a91202..e2adfbb 100644 (file)
@@ -1664,6 +1664,8 @@ public:
        tcu::TestStatus         iterate                                                                 (void);
 
 private:
+       tcu::TextureLevel       generateReferenceColorImage                             (const tcu::TextureFormat format, const tcu::IVec2& renderSize);
+
        Move<VkRenderPass>      makeRenderPass                                                  (const DeviceInterface&         vk,
                                                                                                                                 const VkDevice                         device,
                                                                                                                                 const VkFormat                         colorFormat,
@@ -1847,6 +1849,16 @@ Move<VkRenderPass> EarlyFragmentSampleCountTestInstance::makeRenderPass  (const D
        return createRenderPass(vk, device, &renderPassInfo, DE_NULL);
 }
 
+tcu::TextureLevel EarlyFragmentSampleCountTestInstance::generateReferenceColorImage(const tcu::TextureFormat format, const tcu::IVec2 &renderSize)
+{
+       tcu::TextureLevel       image           (format, renderSize.x(), renderSize.y());
+       const tcu::Vec4         clearColor      = tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f);
+
+       tcu::clear(image.getAccess(), clearColor);
+
+       return image;
+}
+
 tcu::TestStatus EarlyFragmentSampleCountTestInstance::iterate (void)
 {
        const DeviceInterface&                          vk                                                      = m_context.getDeviceInterface();
@@ -2058,6 +2070,17 @@ tcu::TestStatus EarlyFragmentSampleCountTestInstance::iterate (void)
                submitCommandsAndWait(vk, device, queue, *cmdBuffer);
        }
 
+       // When early fragment test is enabled, all samples are killed in fragment shader. The result color should be black.
+       {
+               invalidateAlloc(vk, device, *colorBufferAllocEarly);
+
+               const tcu::ConstPixelBufferAccess       imagePixelAccess(mapVkFormat(colorFormat), renderSize.x(), renderSize.y(), 1, colorBufferAllocEarly->getHostPtr());
+               const tcu::TextureLevel                         referenceImage = generateReferenceColorImage(mapVkFormat(colorFormat), renderSize);
+
+               if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Compare color output", "Early fragment image result comparison", referenceImage.getAccess(), imagePixelAccess, tcu::Vec4(0.02f), tcu::COMPARE_LOG_RESULT))
+                       return tcu::TestStatus::fail("Rendered color image is not correct");
+       }
+
        // The image has 32x32 pixels and each pixel has m_sampleCount samples. Half of these samples are discarded before sample counting.
        // This means the reference value for passed samples is ((32 x 32) / 2 / 2) * sampleCount.
        {