From 4d092efb3f115ba17b286b9557910f95d2f2164e Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 13 Sep 2016 16:32:57 +1200 Subject: [PATCH] tests: Add test for depth/stencil state required in pipeline Signed-off-by: Chris Forbes --- tests/layer_validation_tests.cpp | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp index 795919d..424e892 100644 --- a/tests/layer_validation_tests.cpp +++ b/tests/layer_validation_tests.cpp @@ -14142,6 +14142,72 @@ TEST_F(VkLayerTest, CreatePipelineSimplePositive) { m_errorMonitor->VerifyNotFound(); } +TEST_F(VkLayerTest, CreatePipelineDepthStencilRequired) { + m_errorMonitor->SetDesiredFailureMsg( + VK_DEBUG_REPORT_ERROR_BIT_EXT, + "pDepthStencilState is NULL when rasterization is enabled and subpass " + "uses a depth/stencil attachment"); + + ASSERT_NO_FATAL_FAILURE(InitState()); + ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); + + char const *vsSource = "#version 450\n" + "void main(){ gl_Position = vec4(0); }\n"; + char const *fsSource = "#version 450\n" + "\n" + "layout(location=0) out vec4 color;\n" + "void main(){\n" + " color = vec4(1);\n" + "}\n"; + + VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); + VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); + + VkPipelineObj pipe(m_device); + pipe.AddColorAttachment(); + pipe.AddShader(&vs); + pipe.AddShader(&fs); + + VkDescriptorSetObj descriptorSet(m_device); + descriptorSet.AppendDummy(); + descriptorSet.CreateVKDescriptorSet(m_commandBuffer); + + VkAttachmentDescription attachments[] = { + { 0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, + VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, + VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, + VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, + }, + { 0, VK_FORMAT_D16_UNORM, VK_SAMPLE_COUNT_1_BIT, + VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, + VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, + VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, + }, + }; + VkAttachmentReference refs[] = { + { 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }, + { 1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }, + }; + VkSubpassDescription subpass = { + 0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, + 1, &refs[0], nullptr, &refs[1], + 0, nullptr + }; + VkRenderPassCreateInfo rpci = { + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, + 0, 2, attachments, 1, &subpass, 0, nullptr + }; + VkRenderPass rp; + VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); + ASSERT_VK_SUCCESS(err); + + pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), rp); + + m_errorMonitor->VerifyFound(); + + vkDestroyRenderPass(m_device->device(), rp, nullptr); +} + TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) { TEST_DESCRIPTION("Test that pipeline validation accepts the relaxed type matching rules " "set out in 14.1.3: fundamental type must match, and producer side must " -- 2.7.4