Avoid out-of-range depth values
authorPiers Daniell <pdaniell@nvidia.com>
Tue, 8 Aug 2017 22:03:35 +0000 (16:03 -0600)
committerDaniel Koch <dkoch@nvidia.com>
Tue, 16 Jan 2018 23:47:15 +0000 (18:47 -0500)
The "d32_sfloat_large_depth" variants of the
dEQP-VK.glsl.builtin_var.fragdepth.* tests rely on undefined behavior
because it uses an out-of-range depth value. The unextended Vulkan spec
requires depth values to be in the range of 0.0..1.0. The test was using
a depth value of 20.0..21.0 and expecting the implementation to clamp.

Instead of disabling this part of the test entirely, only run it if the
implementation exposes the VK_EXT_depth_range_unrestricted device
extension, which does have defined behavior with depth values outside
the range of 0.0..1.0.

Affects:

dEQP-VK.glsl.builtin_var.fragdepth.*d32_sfloat_large_depth

Components: Vulkan

VK-GL-CTS issue: 623

Change-Id: I436b8b98bebe3ef37bd306d93da2bf8c40eee6c8

external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.cpp

index a96602e..602d162 100644 (file)
@@ -314,6 +314,9 @@ BuiltinFragDepthCaseInstance::BuiltinFragDepthCaseInstance (Context& context, Vk
 
                if ((formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) == 0)
                        throw tcu::NotSupportedError("MarkerImage format not supported as storage image");
+
+               if (m_largeDepthEnable && !de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), "VK_EXT_depth_range_unrestricted"))
+                       throw tcu::NotSupportedError("large_depth test variants require the VK_EXT_depth_range_unrestricted extension");
        }
        catch (const vk::Error& e)
        {
@@ -1185,12 +1188,6 @@ bool BuiltinFragDepthCaseInstance::validateDepthBuffer (const tcu::ConstPixelBuf
                        if (m_largeDepthEnable)
                                expectedValue += m_largeDepthBase;
 
-                       if (expectedValue > 1.0f)
-                               expectedValue = 1.0f;
-
-                       if (expectedValue < 0.0f)
-                               expectedValue = 0.0f;
-
                        for (deUint32 sampleNdx = 0; sampleNdx < (deUint32)m_samples; sampleNdx++)
                        {
                                const float     actualValue             = validationBuffer.getPixel(sampleNdx + m_samples * colNdx, rowNdx).x();