tests: Add renderpass tests GH427

Change-Id: Ia86bfa71682613cb98721c0232c94daa6afe3c1a
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index 60aeb2e..feb2f29 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -4148,6 +4148,104 @@
     vkDestroyImageView(m_device->device(), view, nullptr);
 }
 
+TEST_F(VkLayerTest, RenderPassInvalidRenderArea) {
+    TEST_DESCRIPTION("Generate INVALID_RENDER_AREA error by beginning renderpass"
+                     "with extent outside of framebuffer");
+    ASSERT_NO_FATAL_FAILURE(InitState());
+    ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
+
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         "Cannot execute a render pass with renderArea "
+                                         "not within the bound of the framebuffer.");
+
+    // Framebuffer for render target is 256x256, exceed that for INVALID_RENDER_AREA
+    m_renderPassBeginInfo.renderArea.extent.width = 257;
+    m_renderPassBeginInfo.renderArea.extent.height = 257;
+    BeginCommandBuffer();
+    m_errorMonitor->VerifyFound();
+}
+
+TEST_F(VkLayerTest, DisabledIndependentBlend) {
+    TEST_DESCRIPTION("Generate INDEPENDENT_BLEND by disabling independent "
+                     "blend and then specifying different blend states for two "
+                     "attachements");
+    ASSERT_NO_FATAL_FAILURE(InitState());
+
+    m_errorMonitor->SetDesiredFailureMsg(
+        VK_DEBUG_REPORT_ERROR_BIT_EXT,
+        "Invalid Pipeline CreateInfo: If independent blend feature not "
+        "enabled, all elements of pAttachments must be identical");
+    VkPhysicalDeviceFeatures features = {};
+    features.independentBlend = VK_FALSE;
+    std::vector<const char *> extension_names;
+    VkDeviceObj noib_device(0, gpu(), extension_names, &features);
+
+    VkCommandPool cmd_pool;
+    VkCommandPoolCreateInfo pool_create_info{};
+    pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+    pool_create_info.queueFamilyIndex = noib_device.graphics_queue_node_index_;
+    pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
+
+    vkCreateCommandPool(noib_device.device(), &pool_create_info, nullptr,
+                        &cmd_pool);
+    {
+        // Need cmd_buffer's destructor to be called before calling DestroyCommandPool
+        VkCommandBufferObj cmd_buffer(&noib_device, cmd_pool);
+        VkDescriptorSetObj descriptorSet(&noib_device);
+        descriptorSet.AppendDummy();
+        descriptorSet.CreateVKDescriptorSet(&cmd_buffer);
+
+        VkPipelineObj pipeline(&noib_device);
+
+        VkRenderpassObj renderpass(&noib_device);
+
+        VkShaderObj vs(&noib_device, bindStateVertShaderText,
+                       VK_SHADER_STAGE_VERTEX_BIT, this);
+
+        pipeline.AddShader(&vs);
+
+        VkPipelineColorBlendAttachmentState att_state1 = {}, att_state2 = {};
+        att_state1.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR;
+        att_state1.blendEnable = VK_TRUE;
+        att_state2.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR;
+        att_state2.blendEnable = VK_FALSE;
+        pipeline.AddColorAttachment(0, &att_state1);
+        pipeline.AddColorAttachment(1, &att_state2);
+        pipeline.CreateVKPipeline(descriptorSet.GetPipelineLayout(),
+                                  renderpass.handle());
+        m_errorMonitor->VerifyFound();
+    }
+    vkDestroyCommandPool(noib_device.device(), cmd_pool, NULL);
+}
+
+TEST_F(VkLayerTest, RenderPassDepthStencilAttachmentUnused) {
+    TEST_DESCRIPTION("Specify no depth attachement in renderpass then specify "
+                     "depth attachments in subpass");
+
+    m_errorMonitor->SetDesiredFailureMsg(
+        VK_DEBUG_REPORT_ERROR_BIT_EXT,
+        "vkCreateRenderPass has no depth/stencil attachment, yet subpass");
+
+    // Create a renderPass with a single color attachment
+    VkAttachmentReference attach = {};
+    attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+    VkSubpassDescription subpass = {};
+    VkRenderPassCreateInfo rpci = {};
+    rpci.subpassCount = 1;
+    rpci.pSubpasses = &subpass;
+    rpci.attachmentCount = 1;
+    VkAttachmentDescription attach_desc = {};
+    attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM;
+    attach_desc.samples = VK_SAMPLE_COUNT_1_BIT;
+    rpci.pAttachments = &attach_desc;
+    rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
+    VkRenderPass rp;
+    subpass.pDepthStencilAttachment = &attach;
+    subpass.pColorAttachments = NULL;
+    vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp);
+    m_errorMonitor->VerifyFound();
+}
+
 TEST_F(VkLayerTest, RenderPassTransitionsAttachmentUnused) {
     TEST_DESCRIPTION("Ensure that layout transitions work correctly without "
                      "errors, when an attachment reference is "