diff --git a/src/Magnum/Vk/DescriptorSetLayoutCreateInfo.h b/src/Magnum/Vk/DescriptorSetLayoutCreateInfo.h index 932098d0e..a7cd9ec9b 100644 --- a/src/Magnum/Vk/DescriptorSetLayoutCreateInfo.h +++ b/src/Magnum/Vk/DescriptorSetLayoutCreateInfo.h @@ -134,8 +134,8 @@ class MAGNUM_VK_EXPORT DescriptorSetLayoutBinding { * binding in a shader * @param descriptorType Descriptor type * @param descriptorCount Number of descriptors contained in the - * binding. Has to be at least @cpp 1 @ce. If the shader binding - * is not an array, use @cpp 1 @ce. + * binding. If the shader binding is not an array, use @cpp 1 @ce, + * zero is allowed as well. * @param stages Shader stages that access the binding. * Use @cpp ~Vk::ShaderStages{} @ce to specify that all stages * may access the binding. @@ -163,7 +163,7 @@ class MAGNUM_VK_EXPORT DescriptorSetLayoutBinding { * @param descriptorType Descriptor type. Should be either * @ref DescriptorType::Sampler or * @ref DescriptorType::CombinedImageSampler. - * @param immutableSamplers Immutable samplers + * @param immutableSamplers Immutable samplers. Allowed to be empty. * @param stages Shader stages that access the binding. * Use @cpp ~Vk::ShaderStages{} @ce to specify that all stages * may access the binding. @@ -283,8 +283,8 @@ class MAGNUM_VK_EXPORT DescriptorSetLayoutCreateInfo { /** * @brief Constructor - * @param bindings Descriptor set layout bindings. At least one - * binding has to be present. + * @param bindings Descriptor set layout bindings. Allowed to be + * empty. * @param flags Descriptor set layout creation flags * * The following @type_vk{DescriptorSetLayoutCreateInfo} fields are diff --git a/src/Magnum/Vk/Test/DescriptorSetLayoutVkTest.cpp b/src/Magnum/Vk/Test/DescriptorSetLayoutVkTest.cpp index 3754d2447..23214ec8c 100644 --- a/src/Magnum/Vk/Test/DescriptorSetLayoutVkTest.cpp +++ b/src/Magnum/Vk/Test/DescriptorSetLayoutVkTest.cpp @@ -34,6 +34,8 @@ struct DescriptorSetLayoutVkTest: VulkanTester { explicit DescriptorSetLayoutVkTest(); void construct(); + void constructEmpty(); + void constructEmptyBinding(); void constructMove(); void wrap(); @@ -41,6 +43,8 @@ struct DescriptorSetLayoutVkTest: VulkanTester { DescriptorSetLayoutVkTest::DescriptorSetLayoutVkTest() { addTests({&DescriptorSetLayoutVkTest::construct, + &DescriptorSetLayoutVkTest::constructEmpty, + &DescriptorSetLayoutVkTest::constructEmptyBinding, &DescriptorSetLayoutVkTest::constructMove, &DescriptorSetLayoutVkTest::wrap}); @@ -59,6 +63,32 @@ void DescriptorSetLayoutVkTest::construct() { CORRADE_VERIFY(true); } +void DescriptorSetLayoutVkTest::constructEmpty() { + { + /* Although rather weird, the spec allows this */ + DescriptorSetLayout layout{device(), DescriptorSetLayoutCreateInfo{}}; + CORRADE_VERIFY(layout.handle()); + CORRADE_COMPARE(layout.handleFlags(), HandleFlag::DestroyOnDestruction); + } + + /* Shouldn't crash or anything */ + CORRADE_VERIFY(true); +} + +void DescriptorSetLayoutVkTest::constructEmptyBinding() { + { + /* Also weird, but the spec *also* allows this */ + DescriptorSetLayout layout{device(), DescriptorSetLayoutCreateInfo{ + {{15, DescriptorType::UniformBuffer, 0}} + }}; + CORRADE_VERIFY(layout.handle()); + CORRADE_COMPARE(layout.handleFlags(), HandleFlag::DestroyOnDestruction); + } + + /* Shouldn't crash or anything */ + CORRADE_VERIFY(true); +} + void DescriptorSetLayoutVkTest::constructMove() { DescriptorSetLayout a{device(), DescriptorSetLayoutCreateInfo{ {{15, DescriptorType::UniformBuffer}}