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;
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;
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);
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;
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;
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)
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");
}
}
}
-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)
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);
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 =
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++)
*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;
+ }
}
}
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
{
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);
}
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;
{
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());