Fix tolerance values when VK_COMPONENT_SWIZZLE_ONE is in use
authorJoe Withers <joe.withers@imgtec.com>
Mon, 30 Jan 2023 17:32:24 +0000 (17:32 +0000)
committerPiotr Byszewski <piotr.byszewski@mobica.com>
Thu, 2 Feb 2023 18:16:09 +0000 (18:16 +0000)
Tolerance values were being increased unnecessarily for tests using
VK_COMPONENT_SWIZZLE_ONE.

This change overwrites any SWIZZLE_ONE with SWIZZLE_ZERO when applying
a swizzle to the threshold values, to maintain a strict tolerance.

Affects: dEQP-VK.pipeline.sampler.border_swizzle.*

Components: Vulkan
Change-Id: Ie72e4a97e502bdbb74ea412951f5a9481434d489

external/vulkancts/modules/vulkan/pipeline/vktPipelineSamplerBorderSwizzleTests.cpp

index aa15eaf..89b73e7 100644 (file)
@@ -452,6 +452,15 @@ bool comparePixelToColorClearValue (const TestParams&                                      params,
        const auto      channelClass    = getTextureChannelClass(textureFormat.type);
        // We must compare all available channels in the color buffer to check RGBA conversion.
        const auto      channelMask             = getTextureFormatChannelMask(bufferFormat);
+       // If the component mapping contains a SWIZZLE_ONE, overwrite this with a SWIZZLE_ZERO to ensure
+       // a strict tolerance when applying a swizzle of SWIZZLE_ONE to the threshold.
+       const VkComponentMapping thresholdComponentMapping =
+       {
+               (params.componentMapping.r == VK_COMPONENT_SWIZZLE_ONE ? VK_COMPONENT_SWIZZLE_ZERO : params.componentMapping.r),
+               (params.componentMapping.g == VK_COMPONENT_SWIZZLE_ONE ? VK_COMPONENT_SWIZZLE_ZERO : params.componentMapping.g),
+               (params.componentMapping.b == VK_COMPONENT_SWIZZLE_ONE ? VK_COMPONENT_SWIZZLE_ZERO : params.componentMapping.b),
+               (params.componentMapping.a == VK_COMPONENT_SWIZZLE_ONE ? VK_COMPONENT_SWIZZLE_ZERO : params.componentMapping.a),
+       };
 
        switch (channelClass)
        {
@@ -484,7 +493,7 @@ bool comparePixelToColorClearValue (const TestParams&                                       params,
                        }
 
                        // Apply swizzle and gather to thresholds.
-                       threshold = applySwizzle(threshold, params.componentMapping);
+                       threshold = applySwizzle(threshold, thresholdComponentMapping);
 
                        if (params.componentGather)
                                threshold = applyGather(threshold, *params.componentGather);
@@ -530,7 +539,7 @@ bool comparePixelToColorClearValue (const TestParams&                                       params,
                        }
 
                        // Apply swizzle and gather to thresholds.
-                       threshold = applySwizzle(threshold, params.componentMapping);
+                       threshold = applySwizzle(threshold, thresholdComponentMapping);
 
                        if (params.componentGather)
                                threshold = applyGather(threshold, *params.componentGather);
@@ -576,7 +585,7 @@ bool comparePixelToColorClearValue (const TestParams&                                       params,
                        }
 
                        // Apply swizzle and gather to thresholds.
-                       threshold = applySwizzle(threshold, params.componentMapping);
+                       threshold = applySwizzle(threshold, thresholdComponentMapping);
 
                        if (params.componentGather)
                                threshold = applyGather(threshold, *params.componentGather);
@@ -625,7 +634,7 @@ bool comparePixelToColorClearValue (const TestParams&                                       params,
                        }
 
                        // Apply swizzle and gather to thresholds.
-                       threshold = applySwizzle(threshold, params.componentMapping);
+                       threshold = applySwizzle(threshold, thresholdComponentMapping);
 
                        if (params.componentGather)
                                threshold = applyGather(threshold, *params.componentGather);