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 * binding in a shader
* @param descriptorType Descriptor type * @param descriptorType Descriptor type
* @param descriptorCount Number of descriptors contained in the * @param descriptorCount Number of descriptors contained in the
* binding. Has to be at least @cpp 1 @ce. If the shader binding * binding. If the shader binding is not an array, use @cpp 1 @ce,
* is not an array, use @cpp 1 @ce. * zero is allowed as well.
* @param stages Shader stages that access the binding. * @param stages Shader stages that access the binding.
* Use @cpp ~Vk::ShaderStages{} @ce to specify that all stages * Use @cpp ~Vk::ShaderStages{} @ce to specify that all stages
* may access the binding. * may access the binding.
@ -163,7 +163,7 @@ class MAGNUM_VK_EXPORT DescriptorSetLayoutBinding {
* @param descriptorType Descriptor type. Should be either * @param descriptorType Descriptor type. Should be either
* @ref DescriptorType::Sampler or * @ref DescriptorType::Sampler or
* @ref DescriptorType::CombinedImageSampler. * @ref DescriptorType::CombinedImageSampler.
* @param immutableSamplers Immutable samplers * @param immutableSamplers Immutable samplers. Allowed to be empty.
* @param stages Shader stages that access the binding. * @param stages Shader stages that access the binding.
* Use @cpp ~Vk::ShaderStages{} @ce to specify that all stages * Use @cpp ~Vk::ShaderStages{} @ce to specify that all stages
* may access the binding. * may access the binding.
@ -283,8 +283,8 @@ class MAGNUM_VK_EXPORT DescriptorSetLayoutCreateInfo {
/** /**
* @brief Constructor * @brief Constructor
* @param bindings Descriptor set layout bindings. At least one * @param bindings Descriptor set layout bindings. Allowed to be
* binding has to be present. * empty.
* @param flags Descriptor set layout creation flags * @param flags Descriptor set layout creation flags
* *
* The following @type_vk{DescriptorSetLayoutCreateInfo} fields are * The following @type_vk{DescriptorSetLayoutCreateInfo} fields are

30
src/Magnum/Vk/Test/DescriptorSetLayoutVkTest.cpp

@ -34,6 +34,8 @@ struct DescriptorSetLayoutVkTest: VulkanTester {
explicit DescriptorSetLayoutVkTest(); explicit DescriptorSetLayoutVkTest();
void construct(); void construct();
void constructEmpty();
void constructEmptyBinding();
void constructMove(); void constructMove();
void wrap(); void wrap();
@ -41,6 +43,8 @@ struct DescriptorSetLayoutVkTest: VulkanTester {
DescriptorSetLayoutVkTest::DescriptorSetLayoutVkTest() { DescriptorSetLayoutVkTest::DescriptorSetLayoutVkTest() {
addTests({&DescriptorSetLayoutVkTest::construct, addTests({&DescriptorSetLayoutVkTest::construct,
&DescriptorSetLayoutVkTest::constructEmpty,
&DescriptorSetLayoutVkTest::constructEmptyBinding,
&DescriptorSetLayoutVkTest::constructMove, &DescriptorSetLayoutVkTest::constructMove,
&DescriptorSetLayoutVkTest::wrap}); &DescriptorSetLayoutVkTest::wrap});
@ -59,6 +63,32 @@ void DescriptorSetLayoutVkTest::construct() {
CORRADE_VERIFY(true); 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() { void DescriptorSetLayoutVkTest::constructMove() {
DescriptorSetLayout a{device(), DescriptorSetLayoutCreateInfo{ DescriptorSetLayout a{device(), DescriptorSetLayoutCreateInfo{
{{15, DescriptorType::UniformBuffer}} {{15, DescriptorType::UniformBuffer}}

Loading…
Cancel
Save