From d64bc53d9a0fe753eb0111cc391cf39a22f867ac Mon Sep 17 00:00:00 2001 From: hodasemi Date: Sun, 16 Apr 2023 06:57:39 +0200 Subject: [PATCH] Precise descriptor set unit test --- vulkan-rs/src/descriptorset.rs | 13 +++++++++---- vulkan-rs/src/device.rs | 3 +-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/vulkan-rs/src/descriptorset.rs b/vulkan-rs/src/descriptorset.rs index a64875d..b96a615 100644 --- a/vulkan-rs/src/descriptorset.rs +++ b/vulkan-rs/src/descriptorset.rs @@ -347,7 +347,6 @@ mod test { use std::sync::Arc; #[test] - fn create_multiple_sets_from_one_pool() -> Result<()> { const DESCRIPTOR_COUNT: u32 = 2; @@ -367,11 +366,17 @@ mod test { .set_layout(descriptor_layout.clone()) .build(device.clone())?; - let descriptors: Result>> = (0..DESCRIPTOR_COUNT) - .map(|_| descriptor_pool.prepare_set().allocate()) + let descriptors: Vec> = (0..DESCRIPTOR_COUNT) + .map(|_| { + let set = descriptor_pool.prepare_set().allocate(); + + assert!(set.is_ok(), "{}", set.err().unwrap()); + + set.unwrap() + }) .collect(); - assert!(descriptors.is_ok(), "{}", descriptors.err().unwrap()); + assert_eq!(descriptors.len(), DESCRIPTOR_COUNT as usize); Ok(()) } diff --git a/vulkan-rs/src/device.rs b/vulkan-rs/src/device.rs index fa310ed..cba83e8 100644 --- a/vulkan-rs/src/device.rs +++ b/vulkan-rs/src/device.rs @@ -1142,8 +1142,7 @@ impl Device { unsafe { let count = allocate_info.descriptorSetCount as usize; - let mut descriptor_sets = Vec::with_capacity(count); - descriptor_sets.set_len(count); + let mut descriptor_sets = vec![VkDescriptorSet::NULL_HANDLE; count]; let result = self.device_functions.vkAllocateDescriptorSets( self.device,