From: Mark Lobodzinski Date: Tue, 15 Nov 2016 20:30:38 +0000 (-0700) Subject: tests: Add test for Vtx Attr Format check X-Git-Tag: sdk-1.0.33.0~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d9bb3cbcd8e90d53cff7776e809c5e029a208bb;p=platform%2Fupstream%2FVulkan-LoaderAndValidationLayers.git tests: Add test for Vtx Attr Format check Change-Id: Iee24796050cc87d6f912033ccdf0b18785bb2f60 --- diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp index 3a3f8c3..fdeadb0 100644 --- a/tests/layer_validation_tests.cpp +++ b/tests/layer_validation_tests.cpp @@ -2413,6 +2413,63 @@ TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { #if DRAW_STATE_TESTS +TEST_F(VkLayerTest, CreatePipelineBadVertexAttributeFormat) { + TEST_DESCRIPTION("Test that pipeline validation catches invalid vertex attribute formats"); + + ASSERT_NO_FATAL_FAILURE(InitState()); + ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); + + VkVertexInputBindingDescription input_binding; + memset(&input_binding, 0, sizeof(input_binding)); + + VkVertexInputAttributeDescription input_attribs; + memset(&input_attribs, 0, sizeof(input_attribs)); + + // Pick a really bad format for this purpose and make sure it should fail + input_attribs.format = VK_FORMAT_BC2_UNORM_BLOCK; + VkFormatProperties format_props = m_device->format_properties(input_attribs.format); + if ((format_props.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) != 0) { + printf("Format unsuitable for test; skipped.\n"); + return; + } + + input_attribs.location = 0; + char const *vsSource = "#version 450\n" + "\n" + "out gl_PerVertex {\n" + " vec4 gl_Position;\n" + "};\n" + "void main(){\n" + " gl_Position = vec4(1);\n" + "}\n"; + char const *fsSource = "#version 450\n" + "\n" + "layout(location=0) out vec4 color;\n" + "void main(){\n" + " color = vec4(1);\n" + "}\n"; + + m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_01413); + 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); + + pipe.AddVertexInputBindings(&input_binding, 1); + pipe.AddVertexInputAttribs(&input_attribs, 1); + + VkDescriptorSetObj descriptorSet(m_device); + descriptorSet.AppendDummy(); + descriptorSet.CreateVKDescriptorSet(m_commandBuffer); + + pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); + + m_errorMonitor->VerifyFound(); +} + TEST_F(VkLayerTest, ImageSampleCounts) { TEST_DESCRIPTION("Use bad sample counts in image transfer calls to trigger " @@ -13528,6 +13585,7 @@ TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { #endif // DEVICE_LIMITS_TESTS #if IMAGE_TESTS + TEST_F(VkLayerTest, AttachmentDescriptionUndefinedFormat) { TEST_DESCRIPTION("Create a render pass with an attachment description " "format set to VK_FORMAT_UNDEFINED");