Check dynamic viewports with depth clip control
authorRicardo Garcia <rgarcia@igalia.com>
Wed, 16 Feb 2022 08:51:52 +0000 (09:51 +0100)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Thu, 17 Feb 2022 22:07:05 +0000 (22:07 +0000)
When the view volume depth range changes from [0,1] to [-1,1] there may
be implementations that need to be more careful when emitting
instructions that also take the viewport into account. As the viewport
can be made dynamic despite using depth clip control we need to check
that combination of factors.

Components: Vulkan
VK-GL-CTS issue: 3480

New tests:
dEQP-VK.pipeline.depth.depth_clip_control.*viewport*

Affected tests:
dEQP-VK.pipeline.depth.depth_clip_control.*

Change-Id: I5cf5b7998fd77a0569317f32e480f5a07d5ab969

android/cts/main/vk-master-2021-03-01/pipeline.txt
android/cts/main/vk-master/pipeline.txt
external/vulkancts/modules/vulkan/pipeline/vktPipelineDepthTests.cpp
external/vulkancts/mustpass/main/vk-default/pipeline.txt

index 6571abe..cbe13fd 100644 (file)
@@ -4424,6 +4424,54 @@ dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always
 dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less
 dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always
 dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_after_dynamic
 dEQP-VK.pipeline.dynamic_offset.graphics.multiset.uniform_buffer.numcmdbuffers_1.sameorder.numdescriptorsetbindings_1.numdynamicbindings_1.numnondynamicbindings_0
 dEQP-VK.pipeline.dynamic_offset.graphics.multiset.uniform_buffer.numcmdbuffers_1.sameorder.numdescriptorsetbindings_1.numdynamicbindings_1.numnondynamicbindings_1
 dEQP-VK.pipeline.dynamic_offset.graphics.multiset.uniform_buffer.numcmdbuffers_1.sameorder.numdescriptorsetbindings_1.numdynamicbindings_2.numnondynamicbindings_0
index 24c9514..e1df16f 100644 (file)
@@ -68369,6 +68369,54 @@ dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always
 dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less
 dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always
 dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_after_dynamic
 dEQP-VK.pipeline.dynamic_offset.graphics.single_set.uniform_buffer.numcmdbuffers_1.sameorder.numdescriptorsetbindings_1.numdynamicbindings_1.numnondynamicbindings_0
 dEQP-VK.pipeline.dynamic_offset.graphics.single_set.uniform_buffer.numcmdbuffers_1.sameorder.numdescriptorsetbindings_1.numdynamicbindings_1.numnondynamicbindings_1
 dEQP-VK.pipeline.dynamic_offset.graphics.single_set.uniform_buffer.numcmdbuffers_1.sameorder.numdescriptorsetbindings_1.numdynamicbindings_2.numnondynamicbindings_0
index f782c9b..789da2c 100644 (file)
@@ -56,6 +56,16 @@ using namespace vk;
 namespace
 {
 
+enum class DepthClipControlCase
+{
+       DISABLED                        = 0,    // No depth clip control.
+       NORMAL                          = 1,    // Depth clip control with static viewport.
+       BEFORE_STATIC           = 2,    // Set dynamic viewport state, then bind a static pipeline.
+       BEFORE_DYNAMIC          = 3,    // Set dynamic viewport state, bind dynamic pipeline.
+       BEFORE_TWO_DYNAMICS     = 4,    // Set dynamic viewport state, bind dynamic pipeline with [0,1] view volume, then bind dynamic pipeline with [-1,1] view volume.
+       AFTER_DYNAMIC           = 5,    // Bind dynamic pipeline, then set dynamic viewport state.
+};
+
 bool isSupportedDepthStencilFormat (const InstanceInterface& instanceInterface, VkPhysicalDevice device, VkFormat format)
 {
        VkFormatProperties formatProps;
@@ -115,19 +125,19 @@ public:
        static const float                                      quadDepths[QUAD_COUNT];
        static const float                                      quadDepthsMinusOneToOne[QUAD_COUNT];
 
-                                                                               DepthTest                               (tcu::TestContext&              testContext,
-                                                                                                                                const std::string&             name,
-                                                                                                                                const std::string&             description,
-                                                                                                                                const VkFormat                 depthFormat,
-                                                                                                                                const VkCompareOp              depthCompareOps[QUAD_COUNT],
-                                                                                                                                const bool                             separateDepthStencilLayouts,
-                                                                                                                                const bool                             depthBoundsTestEnable                   = false,
-                                                                                                                                const float                    depthBoundsMin                                  = 0.0f,
-                                                                                                                                const float                    depthBoundsMax                                  = 1.0f,
-                                                                                                                                const bool                             depthTestEnable                                 = true,
-                                                                                                                                const bool                             stencilTestEnable                               = false,
-                                                                                                                                const bool                             colorAttachmentEnable                   = true,
-                                                                                                                                const bool                             depthClipControl                                = false);
+                                                                               DepthTest                               (tcu::TestContext&                      testContext,
+                                                                                                                                const std::string&                     name,
+                                                                                                                                const std::string&                     description,
+                                                                                                                                const VkFormat                         depthFormat,
+                                                                                                                                const VkCompareOp                      depthCompareOps[QUAD_COUNT],
+                                                                                                                                const bool                                     separateDepthStencilLayouts,
+                                                                                                                                const bool                                     depthBoundsTestEnable                   = false,
+                                                                                                                                const float                            depthBoundsMin                                  = 0.0f,
+                                                                                                                                const float                            depthBoundsMax                                  = 1.0f,
+                                                                                                                                const bool                                     depthTestEnable                                 = true,
+                                                                                                                                const bool                                     stencilTestEnable                               = false,
+                                                                                                                                const bool                                     colorAttachmentEnable                   = true,
+                                                                                                                                const DepthClipControlCase     depthClipControl                                = DepthClipControlCase::DISABLED);
        virtual                                                         ~DepthTest                              (void);
        virtual void                                            initPrograms                    (SourceCollections& programCollection) const;
        virtual void                                            checkSupport                    (Context& context) const;
@@ -142,24 +152,24 @@ private:
        const bool                                                      m_depthTestEnable;
        const bool                                                      m_stencilTestEnable;
        const bool                                                      m_colorAttachmentEnable;
-       const bool                                                      m_depthClipControl;
+       const DepthClipControlCase                      m_depthClipControl;
        VkCompareOp                                                     m_depthCompareOps[QUAD_COUNT];
 };
 
 class DepthTestInstance : public vkt::TestInstance
 {
 public:
-                                                                               DepthTestInstance               (Context&                       context,
-                                                                                                                                const VkFormat         depthFormat,
-                                                                                                                                const VkCompareOp      depthCompareOps[DepthTest::QUAD_COUNT],
-                                                                                                                                const bool                     separateDepthStencilLayouts,
-                                                                                                                                const bool                     depthBoundsTestEnable,
-                                                                                                                                const float            depthBoundsMin,
-                                                                                                                                const float            depthBoundsMax,
-                                                                                                                                const bool                     depthTestEnable,
-                                                                                                                                const bool                     stencilTestEnable,
-                                                                                                                                const bool                     colorAttachmentEnable,
-                                                                                                                                const bool                     depthClipControl);
+                                                                               DepthTestInstance               (Context&                                       context,
+                                                                                                                                const VkFormat                         depthFormat,
+                                                                                                                                const VkCompareOp                      depthCompareOps[DepthTest::QUAD_COUNT],
+                                                                                                                                const bool                                     separateDepthStencilLayouts,
+                                                                                                                                const bool                                     depthBoundsTestEnable,
+                                                                                                                                const float                            depthBoundsMin,
+                                                                                                                                const float                            depthBoundsMax,
+                                                                                                                                const bool                                     depthTestEnable,
+                                                                                                                                const bool                                     stencilTestEnable,
+                                                                                                                                const bool                                     colorAttachmentEnable,
+                                                                                                                                const DepthClipControlCase     depthClipControl);
        virtual                                                         ~DepthTestInstance              (void);
        virtual tcu::TestStatus                         iterate                                 (void);
 
@@ -178,7 +188,7 @@ private:
        const bool                                                      m_depthTestEnable;
        const bool                                                      m_stencilTestEnable;
        const bool                                                      m_colorAttachmentEnable;
-       const bool                                                      m_depthClipControl;
+       const DepthClipControlCase                      m_depthClipControl;
        VkImageSubresourceRange                         m_depthImageSubresourceRange;
 
        Move<VkImage>                                           m_colorImage;
@@ -199,6 +209,7 @@ private:
 
        Move<VkPipelineLayout>                          m_pipelineLayout;
        Move<VkPipeline>                                        m_graphicsPipelines[DepthTest::QUAD_COUNT];
+       Move<VkPipeline>                                        m_altGraphicsPipelines[DepthTest::QUAD_COUNT];
 
        Move<VkCommandPool>                                     m_cmdPool;
        Move<VkCommandBuffer>                           m_cmdBuffer;
@@ -221,19 +232,19 @@ const float DepthTest::quadDepthsMinusOneToOne[QUAD_COUNT] =
         0.2f
 };
 
-DepthTest::DepthTest (tcu::TestContext&                testContext,
-                                         const std::string&    name,
-                                         const std::string&    description,
-                                         const VkFormat                depthFormat,
-                                         const VkCompareOp             depthCompareOps[QUAD_COUNT],
-                                         const bool                    separateDepthStencilLayouts,
-                                         const bool                    depthBoundsTestEnable,
-                                         const float                   depthBoundsMin,
-                                         const float                   depthBoundsMax,
-                                         const bool                    depthTestEnable,
-                                         const bool                    stencilTestEnable,
-                                         const bool                    colorAttachmentEnable,
-                                         const bool                    depthClipControl)
+DepthTest::DepthTest (tcu::TestContext&                                testContext,
+                                         const std::string&                    name,
+                                         const std::string&                    description,
+                                         const VkFormat                                depthFormat,
+                                         const VkCompareOp                             depthCompareOps[QUAD_COUNT],
+                                         const bool                                    separateDepthStencilLayouts,
+                                         const bool                                    depthBoundsTestEnable,
+                                         const float                                   depthBoundsMin,
+                                         const float                                   depthBoundsMax,
+                                         const bool                                    depthTestEnable,
+                                         const bool                                    stencilTestEnable,
+                                         const bool                                    colorAttachmentEnable,
+                                         const DepthClipControlCase    depthClipControl)
        : vkt::TestCase (testContext, name, description)
        , m_depthFormat                                 (depthFormat)
        , m_separateDepthStencilLayouts (separateDepthStencilLayouts)
@@ -263,7 +274,7 @@ void DepthTest::checkSupport (Context& context) const
        if (m_separateDepthStencilLayouts && !context.isDeviceFunctionalitySupported("VK_KHR_separate_depth_stencil_layouts"))
                TCU_THROW(NotSupportedError, "VK_KHR_separate_depth_stencil_layouts is not supported");
 
-       if (m_depthClipControl && !context.isDeviceFunctionalitySupported("VK_EXT_depth_clip_control"))
+       if (m_depthClipControl != DepthClipControlCase::DISABLED && !context.isDeviceFunctionalitySupported("VK_EXT_depth_clip_control"))
                TCU_THROW(NotSupportedError, "VK_EXT_depth_clip_control is not supported");
 }
 
@@ -309,17 +320,17 @@ void DepthTest::initPrograms (SourceCollections& programCollection) const
        }
 }
 
-DepthTestInstance::DepthTestInstance (Context&                         context,
-                                                                         const VkFormat                depthFormat,
-                                                                         const VkCompareOp             depthCompareOps[DepthTest::QUAD_COUNT],
-                                                                         const bool                    separateDepthStencilLayouts,
-                                                                         const bool                    depthBoundsTestEnable,
-                                                                         const float                   depthBoundsMin,
-                                                                         const float                   depthBoundsMax,
-                                                                         const bool                    depthTestEnable,
-                                                                         const bool                    stencilTestEnable,
-                                                                         const bool                    colorAttachmentEnable,
-                                                                         const bool                    depthClipControl)
+DepthTestInstance::DepthTestInstance (Context&                                         context,
+                                                                         const VkFormat                                depthFormat,
+                                                                         const VkCompareOp                             depthCompareOps[DepthTest::QUAD_COUNT],
+                                                                         const bool                                    separateDepthStencilLayouts,
+                                                                         const bool                                    depthBoundsTestEnable,
+                                                                         const float                                   depthBoundsMin,
+                                                                         const float                                   depthBoundsMax,
+                                                                         const bool                                    depthTestEnable,
+                                                                         const bool                                    stencilTestEnable,
+                                                                         const bool                                    colorAttachmentEnable,
+                                                                         const DepthClipControlCase    depthClipControl)
        : vkt::TestInstance                             (context)
        , m_renderSize                                  (32, 32)
        , m_colorFormat                                 (colorAttachmentEnable ? VK_FORMAT_R8G8B8A8_UNORM : VK_FORMAT_UNDEFINED)
@@ -338,6 +349,8 @@ DepthTestInstance::DepthTestInstance (Context&                              context,
        const deUint32                          queueFamilyIndex                = context.getUniversalQueueFamilyIndex();
        SimpleAllocator                         memAlloc                                (vk, vkDevice, getPhysicalDeviceMemoryProperties(context.getInstanceInterface(), context.getPhysicalDevice()));
        const VkComponentMapping        componentMappingRGBA    = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
+       const bool                                      hasDepthClipControl             = (m_depthClipControl != DepthClipControlCase::DISABLED);
+       const bool                                      useAltGraphicsPipelines = (m_depthClipControl == DepthClipControlCase::BEFORE_TWO_DYNAMICS);
 
        // Copy depth operators
        deMemcpy(m_depthCompareOps, depthCompareOps, sizeof(VkCompareOp) * DepthTest::QUAD_COUNT);
@@ -488,6 +501,10 @@ DepthTestInstance::DepthTestInstance (Context&                             context,
        if (m_colorAttachmentEnable)
                m_fragmentShaderModule  = createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("color_frag"), 0);
 
+       const VkViewport        viewport                = makeViewport(m_renderSize);
+       const VkViewport        badViewport             = makeViewport(0.0f, 0.0f, static_cast<float>(m_renderSize.x()) / 2.0f, static_cast<float>(m_renderSize.y()) / 2.0f, 1.0f, 0.0f);
+       const bool                      dynamicViewport = (static_cast<int>(m_depthClipControl) > static_cast<int>(DepthClipControlCase::BEFORE_STATIC));
+
        // Create pipeline
        {
                const VkVertexInputBindingDescription                           vertexInputBindingDescription           =
@@ -576,25 +593,54 @@ DepthTestInstance::DepthTestInstance (Context&                            context,
                        1.0f,                                                                                                                   //      float                                                                   lineWidth;
                };
 
-               const VkViewport                                                                                viewport                                                = makeViewport(m_renderSize);
                const VkRect2D                                                                                  scissor                                                 = makeRect2D(m_renderSize);
 
                const VkPipelineViewportDepthClipControlCreateInfoEXT   depthClipControlCreateInfo              =
                {
                        VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT, // VkStructureType      sType;
                        DE_NULL,                                                                                                                                // const void*          pNext;
-                       VK_TRUE,                                                                                                                                // VkBool32             negativeOneToOne;
+                       VK_TRUE,                                                                                                                                // VkBool32                     negativeOneToOne;
+               };
+
+               // Using the range 0,1 in the structure.
+               const VkPipelineViewportDepthClipControlCreateInfoEXT   depthClipControlCreateInfo01    =
+               {
+                       VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT, // VkStructureType      sType;
+                       DE_NULL,                                                                                                                                // const void*          pNext;
+                       VK_FALSE,                                                                                                                               // VkBool32                     negativeOneToOne;
                };
 
                const VkPipelineViewportStateCreateInfo                                 viewportStateCreateInfo                 =
                {
-                       VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,          // VkStructureType                                              sType;
-                       m_depthClipControl ? &depthClipControlCreateInfo : DE_NULL,     // const void*                                                  pNext;
-                       (VkPipelineViewportStateCreateFlags)0,                                          // VkPipelineViewportStateCreateFlags   flags;
-                       1u,                                                                                                                     // deUint32                                                             viewportCount;
-                       &viewport,                                                                                                      // const VkViewport*                                    pViewports;
-                       1u,                                                                                                                     // deUint32                                                             scissorCount;
-                       &scissor                                                                                                        // const VkRect2D*                                              pScissors;
+                       VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,                  // VkStructureType                                              sType;
+                       (hasDepthClipControl ? &depthClipControlCreateInfo : nullptr),  // const void*                                                  pNext;
+                       (VkPipelineViewportStateCreateFlags)0,                                                  // VkPipelineViewportStateCreateFlags   flags;
+                       1u,                                                                                                                             // deUint32                                                             viewportCount;
+                       (dynamicViewport ? &badViewport : &viewport),                                   // const VkViewport*                                    pViewports;
+                       1u,                                                                                                                             // deUint32                                                             scissorCount;
+                       &scissor                                                                                                                // const VkRect2D*                                              pScissors;
+               };
+
+               VkPipelineViewportStateCreateInfo viewportStateCreateInfo01     = viewportStateCreateInfo;
+               viewportStateCreateInfo01.pNext                                                         = &depthClipControlCreateInfo01;
+
+               // Dynamic viewport if needed.
+               std::vector<VkDynamicState> dynamicStates;
+
+               if (m_depthClipControl == DepthClipControlCase::BEFORE_DYNAMIC
+                       || m_depthClipControl == DepthClipControlCase::BEFORE_TWO_DYNAMICS
+                       || m_depthClipControl == DepthClipControlCase::AFTER_DYNAMIC)
+               {
+                       dynamicStates.push_back(VK_DYNAMIC_STATE_VIEWPORT);
+               }
+
+               const VkPipelineDynamicStateCreateInfo                                  dynamicStateCreateInfo                  =
+               {
+                       VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,   //      VkStructureType                                         sType;
+                       nullptr,                                                                                                //      const void*                                                     pNext;
+                       0u,                                                                                                             //      VkPipelineDynamicStateCreateFlags       flags;
+                       static_cast<uint32_t>(dynamicStates.size()),                    //      uint32_t                                                        dynamicStateCount;
+                       de::dataOrNull(dynamicStates),                                                  //      const VkDynamicState*                           pDynamicStates;
                };
 
                for (int quadNdx = 0; quadNdx < DepthTest::QUAD_COUNT; quadNdx++)
@@ -612,12 +658,37 @@ DepthTestInstance::DepthTestInstance (Context&                            context,
                                                                                                                                                   *m_renderPass,                                               // const VkRenderPass                                                           renderPass;
                                                                                                                                                   0u,                                                                  // const deUint32                                                                       subpass;
                                                                                                                                                   &vertexInputStateParams,                             // const VkPipelineVertexInputStateCreateInfo*          vertexInputStateCreateInfo;
-                                                                                                                                                  DE_NULL,                                                             // const VkPipelineInputAssemblyStateCreateInfo*        inputAssemblyStateCreateInfo;
-                                                                                                                                                  DE_NULL,                                                             // const VkPipelineTessellationStateCreateInfo*         tessStateCreateInfo;
+                                                                                                                                                  nullptr,                                                             // const VkPipelineInputAssemblyStateCreateInfo*        inputAssemblyStateCreateInfo;
+                                                                                                                                                  nullptr,                                                             // const VkPipelineTessellationStateCreateInfo*         tessStateCreateInfo;
                                                                                                                                                   &viewportStateCreateInfo,                    // const VkPipelineViewportStateCreateInfo*                     viewportStateCreateInfo;
                                                                                                                                                   &rasterizationStateParams,                   // const VkPipelineRasterizationStateCreateInfo*        rasterizationStateCreateInfo;
-                                                                                                                                                  DE_NULL,                                                             // const VkPipelineMultisampleStateCreateInfo*          multisampleStateCreateInfo;
-                                                                                                                                                  &depthStencilStateParams);                   // const VkPipelineDepthStencilStateCreateInfo*         depthStencilStateCreateInfo;
+                                                                                                                                                  nullptr,                                                             // const VkPipelineMultisampleStateCreateInfo*          multisampleStateCreateInfo;
+                                                                                                                                                  &depthStencilStateParams,                    // const VkPipelineDepthStencilStateCreateInfo*         depthStencilStateCreateInfo;
+                                                                                                                                                  nullptr,                                                             // const VkPipelineColorBlendStateCreateInfo*           colorBlendStateCreateInfo;
+                                                                                                                                                  &dynamicStateCreateInfo);                    // const VkPipelineDynamicStateCreateInfo*                      dynamicStateCreateInfo;
+
+                       if (useAltGraphicsPipelines)
+                       {
+                               m_altGraphicsPipelines[quadNdx]         = makeGraphicsPipeline(vk,                                                                      // const DeviceInterface&                                                       vk;
+                                                                                                                                                  vkDevice,                                                    // const VkDevice                                                                       device;
+                                                                                                                                                  *m_pipelineLayout,                                   // const VkPipelineLayout                                                       pipelineLayout;
+                                                                                                                                                  *m_vertexShaderModule,                               // const VkShaderModule                                                         vertexShaderModule;
+                                                                                                                                                  DE_NULL,                                                             // const VkShaderModule                                                         tessellationControlModule;
+                                                                                                                                                  DE_NULL,                                                             // const VkShaderModule                                                         tessellationEvalModule;
+                                                                                                                                                  DE_NULL,                                                             // const VkShaderModule                                                         geometryShaderModule;
+                                                                                                                                                  *m_fragmentShaderModule,                             // const VkShaderModule                                                         fragmentShaderModule;
+                                                                                                                                                  *m_renderPass,                                               // const VkRenderPass                                                           renderPass;
+                                                                                                                                                  0u,                                                                  // const deUint32                                                                       subpass;
+                                                                                                                                                  &vertexInputStateParams,                             // const VkPipelineVertexInputStateCreateInfo*          vertexInputStateCreateInfo;
+                                                                                                                                                  nullptr,                                                             // const VkPipelineInputAssemblyStateCreateInfo*        inputAssemblyStateCreateInfo;
+                                                                                                                                                  nullptr,                                                             // const VkPipelineTessellationStateCreateInfo*         tessStateCreateInfo;
+                                                                                                                                                  &viewportStateCreateInfo01,                  // const VkPipelineViewportStateCreateInfo*                     viewportStateCreateInfo;
+                                                                                                                                                  &rasterizationStateParams,                   // const VkPipelineRasterizationStateCreateInfo*        rasterizationStateCreateInfo;
+                                                                                                                                                  nullptr,                                                             // const VkPipelineMultisampleStateCreateInfo*          multisampleStateCreateInfo;
+                                                                                                                                                  &depthStencilStateParams,                    // const VkPipelineDepthStencilStateCreateInfo*         depthStencilStateCreateInfo;
+                                                                                                                                                  nullptr,                                                             // const VkPipelineColorBlendStateCreateInfo*           colorBlendStateCreateInfo;
+                                                                                                                                                  &dynamicStateCreateInfo);                    // const VkPipelineDynamicStateCreateInfo*                      dynamicStateCreateInfo;
+                       }
                }
        }
 
@@ -645,7 +716,7 @@ DepthTestInstance::DepthTestInstance (Context&                              context,
                for (int quadNdx = 0; quadNdx < DepthTest::QUAD_COUNT; quadNdx++)
                        for (int vertexNdx = 0; vertexNdx < 6; vertexNdx++)
                        {
-                               m_vertices[quadNdx * 6 + vertexNdx].position.z() = m_depthClipControl ? DepthTest::quadDepthsMinusOneToOne[quadNdx] : DepthTest::quadDepths[quadNdx];
+                               m_vertices[quadNdx * 6 + vertexNdx].position.z() = (hasDepthClipControl ? DepthTest::quadDepthsMinusOneToOne[quadNdx] : DepthTest::quadDepths[quadNdx]);
                        }
 
                // Load vertices into vertex buffer
@@ -724,7 +795,22 @@ DepthTestInstance::DepthTestInstance (Context&                             context,
                {
                        VkDeviceSize vertexBufferOffset = quadOffset * quadNdx;
 
+                       if (m_depthClipControl == DepthClipControlCase::BEFORE_STATIC
+                               || m_depthClipControl == DepthClipControlCase::BEFORE_DYNAMIC
+                               || m_depthClipControl == DepthClipControlCase::BEFORE_TWO_DYNAMICS)
+                       {
+                               vk.cmdSetViewport(*m_cmdBuffer, 0u, 1u, &viewport);
+                       }
+
+                       if (useAltGraphicsPipelines)
+                               vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_altGraphicsPipelines[quadNdx]);
                        vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_graphicsPipelines[quadNdx]);
+
+                       if (m_depthClipControl == DepthClipControlCase::AFTER_DYNAMIC)
+                       {
+                               vk.cmdSetViewport(*m_cmdBuffer, 0u, 1u, &viewport);
+                       }
+
                        vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &m_vertexBuffer.get(), &vertexBufferOffset);
                        vk.cmdDraw(*m_cmdBuffer, (deUint32)(m_vertices.size() / DepthTest::QUAD_COUNT), 1, 0, 0);
                }
@@ -754,7 +840,7 @@ tcu::TestStatus DepthTestInstance::verifyImage (void)
        const tcu::TextureFormat        tcuColorFormat  = mapVkFormat(VK_FORMAT_R8G8B8A8_UNORM);
        const tcu::TextureFormat        tcuDepthFormat  = mapVkFormat(m_depthFormat);
        const ColorVertexShader         vertexShader;
-       const ColorFragmentShader       fragmentShader  (tcuColorFormat, tcuDepthFormat, m_depthClipControl);
+       const ColorFragmentShader       fragmentShader  (tcuColorFormat, tcuDepthFormat, (m_depthClipControl != DepthClipControlCase::DISABLED));
        const rr::Program                       program                 (&vertexShader, &fragmentShader);
        ReferenceRenderer                       refRenderer             (m_renderSize.x(), m_renderSize.y(), 1, tcuColorFormat, tcuDepthFormat, &program);
        bool                                            colorCompareOk  = false;
@@ -1139,15 +1225,29 @@ tcu::TestCaseGroup* createDepthTests (tcu::TestContext& testCtx)
        {
                const VkCompareOp compareOps[] = { VK_COMPARE_OP_ALWAYS, VK_COMPARE_OP_LESS };
 
-               for (const auto& format : depthFormats)
-                       for (const auto& compareOp : compareOps)
-                       {
-                               std::string testName = getFormatCaseName(format) + "_" + de::toLower(std::string(getCompareOpName(compareOp)).substr(14));
+               const struct
+               {
+                       const DepthClipControlCase      viewportCase;
+                       const std::string                       suffix;
+               } kViewportCases[] =
+               {
+                       { DepthClipControlCase::NORMAL,                                 ""                                                              },
+                       { DepthClipControlCase::BEFORE_STATIC,                  "_viewport_before_static"               },
+                       { DepthClipControlCase::BEFORE_DYNAMIC,                 "_viewport_before_dynamic"              },
+                       { DepthClipControlCase::BEFORE_TWO_DYNAMICS,    "_viewport_before_two_dynamic"  },
+                       { DepthClipControlCase::AFTER_DYNAMIC,                  "_viewport_after_dynamic"               },
+               };
 
-                               const VkCompareOp ops[DepthTest::QUAD_COUNT] = { compareOp, compareOp, compareOp, compareOp };
-                               depthClipControlTests->addChild(new DepthTest(testCtx, testName, "", format, ops, false, false,
-                                                                                               0.0f, 1.0f, true, false, true, true));
-                       }
+               for (const auto& viewportCase : kViewportCases)
+                       for (const auto& format : depthFormats)
+                               for (const auto& compareOp : compareOps)
+                               {
+                                       std::string testName = getFormatCaseName(format) + "_" + de::toLower(std::string(getCompareOpName(compareOp)).substr(14)) + viewportCase.suffix;
+
+                                       const VkCompareOp ops[DepthTest::QUAD_COUNT] = { compareOp, compareOp, compareOp, compareOp };
+                                       depthClipControlTests->addChild(new DepthTest(testCtx, testName, "", format, ops, false, false,
+                                                                                                       0.0f, 1.0f, true, false, true, viewportCase.viewportCase));
+                               }
        }
        depthTests->addChild(depthClipControlTests.release());
 
index 8168199..7c137e5 100644 (file)
@@ -68379,6 +68379,54 @@ dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always
 dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less
 dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always
 dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_before_static
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_before_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_before_two_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.x8_d24_unorm_pack32_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d16_unorm_s8_uint_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d24_unorm_s8_uint_less_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_always_viewport_after_dynamic
+dEQP-VK.pipeline.depth.depth_clip_control.d32_sfloat_s8_uint_less_viewport_after_dynamic
 dEQP-VK.pipeline.dynamic_offset.graphics.single_set.uniform_buffer.numcmdbuffers_1.sameorder.numdescriptorsetbindings_1.numdynamicbindings_1.numnondynamicbindings_0
 dEQP-VK.pipeline.dynamic_offset.graphics.single_set.uniform_buffer.numcmdbuffers_1.sameorder.numdescriptorsetbindings_1.numdynamicbindings_1.numnondynamicbindings_1
 dEQP-VK.pipeline.dynamic_offset.graphics.single_set.uniform_buffer.numcmdbuffers_1.sameorder.numdescriptorsetbindings_1.numdynamicbindings_2.numnondynamicbindings_0