Browse Source

Vk: interestingly enough, DescriptorSetLayout can be empty.

I wanted to add asserts for this but seems like it's allowed. Adding
tests for that instead, then.
pull/504/head
Vladimír Vondruš 5 years ago
parent
commit
afb5c9f4a2
  1. 10
      src/Magnum/Vk/DescriptorSetLayoutCreateInfo.h
  2. 30
      src/Magnum/Vk/Test/DescriptorSetLayoutVkTest.cpp

10
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

30
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}}

Loading…
Cancel
Save