tests:Add ImmutableSamplerOnlyDescriptor test
Bind descriptor set with only an immutable-sampler and verify that no
warning is flagged.
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index ac32f99..04399ac 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -19792,6 +19792,99 @@
}
}
+TEST_F(VkPositiveLayerTest, ImmutableSamplerOnlyDescriptor) {
+ TEST_DESCRIPTION(
+ "Bind a DescriptorSet with only an immutable sampler"
+ "and make sure that we don't warn for no update.");
+
+ ASSERT_NO_FATAL_FAILURE(Init());
+ ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
+
+ VkDescriptorPoolSize ds_type_count = {};
+ ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER;
+ ds_type_count.descriptorCount = 1;
+
+ VkDescriptorPoolCreateInfo ds_pool_ci = {};
+ ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
+ ds_pool_ci.maxSets = 1;
+ ds_pool_ci.poolSizeCount = 1;
+ ds_pool_ci.pPoolSizes = &ds_type_count;
+
+ VkDescriptorPool ds_pool;
+ VkResult err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool);
+ ASSERT_VK_SUCCESS(err);
+
+ VkSamplerCreateInfo sampler_ci = {};
+ sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
+ sampler_ci.pNext = NULL;
+ sampler_ci.magFilter = VK_FILTER_NEAREST;
+ sampler_ci.minFilter = VK_FILTER_NEAREST;
+ sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
+ sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
+ sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
+ sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
+ sampler_ci.mipLodBias = 1.0;
+ sampler_ci.anisotropyEnable = VK_FALSE;
+ sampler_ci.maxAnisotropy = 1;
+ sampler_ci.compareEnable = VK_FALSE;
+ sampler_ci.compareOp = VK_COMPARE_OP_NEVER;
+ sampler_ci.minLod = 1.0;
+ sampler_ci.maxLod = 1.0;
+ sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
+ sampler_ci.unnormalizedCoordinates = VK_FALSE;
+ VkSampler sampler;
+
+ err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler);
+ ASSERT_VK_SUCCESS(err);
+
+ VkDescriptorSetLayoutBinding layout_binding = {};
+ layout_binding.binding = 0;
+ layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
+ layout_binding.descriptorCount = 1;
+ layout_binding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
+ layout_binding.pImmutableSamplers = static_cast<VkSampler *>(&sampler);
+
+ VkDescriptorSetLayoutCreateInfo ds_layout_ci = {};
+ ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
+ ds_layout_ci.bindingCount = 1;
+ ds_layout_ci.pBindings = &layout_binding;
+ VkDescriptorSetLayout ds_layout;
+ err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout);
+ ASSERT_VK_SUCCESS(err);
+
+ 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;
+ VkDescriptorSet descriptor_set;
+ err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptor_set);
+ ASSERT_VK_SUCCESS(err);
+
+ VkPipelineLayoutCreateInfo pipeline_layout_ci = {};
+ pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
+ pipeline_layout_ci.pNext = NULL;
+ pipeline_layout_ci.setLayoutCount = 1;
+ pipeline_layout_ci.pSetLayouts = &ds_layout;
+
+ VkPipelineLayout pipeline_layout;
+ err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout);
+ ASSERT_VK_SUCCESS(err);
+
+ m_errorMonitor->ExpectSuccess();
+ m_commandBuffer->BeginCommandBuffer();
+ m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo);
+
+ vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1,
+ &descriptor_set, 0, nullptr);
+ m_errorMonitor->VerifyNotFound();
+
+ vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL);
+ vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL);
+ vkDestroySampler(m_device->device(), sampler, NULL);
+ vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL);
+}
+
TEST_F(VkLayerTest, DuplicateDescriptorBinding) {
TEST_DESCRIPTION("Create a descriptor set layout with a duplicate binding number.");