tests: Add DSAspectBitsErrors test
Hits the case when depth/stencil image used in a descriptor set has
both the depth and stencil aspect bits set, which is illegal according
to spec section 11.5 on Image Views.
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index c00e753..46ff1ec 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -7915,6 +7915,138 @@
vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL);
}
+TEST_F(VkLayerTest, DSAspectBitsErrors) {
+ // TODO : Initially only catching case where DEPTH & STENCIL aspect bits
+ // are set, but could expand this test to hit more cases.
+ TEST_DESCRIPTION("Attempt to update descriptor sets for images "
+ "that do not have correct aspect bits sets.");
+ VkResult err;
+
+ ASSERT_NO_FATAL_FAILURE(InitState());
+ VkDescriptorPoolSize ds_type_count = {};
+ ds_type_count.type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT;
+ ds_type_count.descriptorCount = 1;
+
+ VkDescriptorPoolCreateInfo ds_pool_ci = {};
+ ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
+ ds_pool_ci.pNext = NULL;
+ ds_pool_ci.maxSets = 5;
+ ds_pool_ci.poolSizeCount = 1;
+ ds_pool_ci.pPoolSizes = &ds_type_count;
+
+ VkDescriptorPool ds_pool;
+ err =
+ vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool);
+ ASSERT_VK_SUCCESS(err);
+
+ VkDescriptorSetLayoutBinding dsl_binding = {};
+ dsl_binding.binding = 0;
+ dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT;
+ dsl_binding.descriptorCount = 1;
+ dsl_binding.stageFlags = VK_SHADER_STAGE_ALL;
+ dsl_binding.pImmutableSamplers = NULL;
+
+ VkDescriptorSetLayoutCreateInfo ds_layout_ci = {};
+ ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
+ ds_layout_ci.pNext = NULL;
+ ds_layout_ci.bindingCount = 1;
+ ds_layout_ci.pBindings = &dsl_binding;
+ VkDescriptorSetLayout ds_layout;
+ err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL,
+ &ds_layout);
+ ASSERT_VK_SUCCESS(err);
+
+ VkDescriptorSet descriptor_set = {};
+ VkDescriptorSetAllocateInfo alloc_info = {};
+ alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
+ alloc_info.descriptorSetCount = 1;
+ alloc_info.descriptorPool = ds_pool;
+ alloc_info.pSetLayouts = &ds_layout;
+ err = vkAllocateDescriptorSets(m_device->device(), &alloc_info,
+ &descriptor_set);
+ ASSERT_VK_SUCCESS(err);
+
+ // Create an image to be used for invalid updates
+ VkImageCreateInfo image_ci = {};
+ image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
+ image_ci.imageType = VK_IMAGE_TYPE_2D;
+ image_ci.format = VK_FORMAT_D24_UNORM_S8_UINT;
+ image_ci.extent.width = 64;
+ image_ci.extent.height = 64;
+ image_ci.extent.depth = 1;
+ image_ci.mipLevels = 1;
+ image_ci.arrayLayers = 1;
+ image_ci.samples = VK_SAMPLE_COUNT_1_BIT;
+ image_ci.tiling = VK_IMAGE_TILING_LINEAR;
+ image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
+ image_ci.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
+ image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ VkImage image;
+ err = vkCreateImage(m_device->device(), &image_ci, NULL, &image);
+ ASSERT_VK_SUCCESS(err);
+ // Bind memory to image
+ VkMemoryRequirements mem_reqs;
+ VkDeviceMemory image_mem;
+ bool pass;
+ VkMemoryAllocateInfo mem_alloc = {};
+ mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ mem_alloc.pNext = NULL;
+ mem_alloc.allocationSize = 0;
+ mem_alloc.memoryTypeIndex = 0;
+ vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs);
+ mem_alloc.allocationSize = mem_reqs.size;
+ pass =
+ m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0);
+ ASSERT_TRUE(pass);
+ err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem);
+ ASSERT_VK_SUCCESS(err);
+ err = vkBindImageMemory(m_device->device(), image, image_mem, 0);
+ ASSERT_VK_SUCCESS(err);
+ // Now create view for image
+ VkImageViewCreateInfo image_view_ci = {};
+ image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+ image_view_ci.image = image;
+ image_view_ci.format = VK_FORMAT_D24_UNORM_S8_UINT;
+ image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
+ image_view_ci.subresourceRange.layerCount = 1;
+ image_view_ci.subresourceRange.baseArrayLayer = 0;
+ image_view_ci.subresourceRange.levelCount = 1;
+ // Setting both depth & stencil aspect bits is illegal for descriptor
+ image_view_ci.subresourceRange.aspectMask =
+ VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
+
+ VkImageView image_view;
+ err = vkCreateImageView(m_device->device(), &image_view_ci, NULL,
+ &image_view);
+ ASSERT_VK_SUCCESS(err);
+
+ VkDescriptorImageInfo img_info = {};
+ img_info.imageView = image_view;
+ VkWriteDescriptorSet descriptor_write = {};
+ descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ descriptor_write.dstBinding = 0;
+ descriptor_write.descriptorCount = 1;
+ descriptor_write.pTexelBufferView = NULL;
+ descriptor_write.pBufferInfo = NULL;
+ descriptor_write.pImageInfo = &img_info;
+ descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT;
+ descriptor_write.dstSet = descriptor_set;
+ const char *error_msg = " please only set either VK_IMAGE_ASPECT_DEPTH_BIT "
+ "or VK_IMAGE_ASPECT_STENCIL_BIT ";
+ m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+ error_msg);
+
+ vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL);
+
+ m_errorMonitor->VerifyFound();
+ vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL);
+ vkDestroyImage(m_device->device(), image, NULL);
+ vkFreeMemory(m_device->device(), image_mem, NULL);
+ vkDestroyImageView(m_device->device(), image_view, NULL);
+ vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set);
+ vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL);
+}
+
TEST_F(VkLayerTest, DSTypeMismatch) {
// Create DS w/ layout of one type and attempt Update w/ mis-matched type
VkResult err;