From 7d0c4d2a9d48aaf214a1a105a5da84b80d1e9ef2 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Wed, 25 Jul 2018 21:45:44 -0400 Subject: [PATCH] pre-allocate space for local descriptor set handles --- libportability-gfx/src/impls.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index dfe9c4c..2f9afc3 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -2339,6 +2339,7 @@ pub extern "C" fn gfxCreateDescriptorPool( pDescriptorPool: *mut VkDescriptorPool, ) -> VkResult { let info = unsafe { &*pCreateInfo }; + let max_sets = info.maxSets as usize; let pool_sizes = unsafe { slice::from_raw_parts(info.pPoolSizes, info.poolSizeCount as _) @@ -2355,12 +2356,12 @@ pub extern "C" fn gfxCreateDescriptorPool( let pool = super::DescriptorPool { raw: gpu.device - .create_descriptor_pool(info.maxSets as _, ranges), - temp_sets: Vec::with_capacity(info.maxSets as _), + .create_descriptor_pool(max_sets, ranges), + temp_sets: Vec::with_capacity(max_sets), set_handles: if info.flags & VkDescriptorPoolCreateFlagBits::VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT as u32 != 0 { None } else { - Some(Vec::new()) + Some(Vec::with_capacity(max_sets)) }, };