From 5e4da076852dfb011f0f2053150cf63470e2d468 Mon Sep 17 00:00:00 2001 From: Rua Date: Wed, 29 Sep 2021 08:06:49 +0200 Subject: [PATCH] Limit compatibility check for bound descriptor sets to the length of the current layout (#1716) * Limit compatibility check for bound descriptor sets to the length of the current layout * Set new pipeline layout if it's a superset of the old one * Preferentially use new layout if they are identical --- vulkano/src/command_buffer/synced/commands.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vulkano/src/command_buffer/synced/commands.rs b/vulkano/src/command_buffer/synced/commands.rs index 72fd6e12..8b6d1f28 100644 --- a/vulkano/src/command_buffer/synced/commands.rs +++ b/vulkano/src/command_buffer/synced/commands.rs @@ -3121,18 +3121,24 @@ impl<'b> SyncCommandBufferBuilderBindDescriptorSets<'b> { // be disturbed. let current_layouts = state.pipeline_layout.descriptor_set_layouts(); let new_layouts = pipeline_layout.descriptor_set_layouts(); - (0..first_set + num_descriptor_sets).find(|&num| { + let max = (current_layouts.len() as u32).min(first_set + num_descriptor_sets); + (0..max).find(|&num| { let num = num as usize; !current_layouts[num].is_compatible_with(&new_layouts[num]) }) }; - // Remove disturbed sets and set new pipeline layout. if let Some(invalidate_from) = invalidate_from { + // Remove disturbed sets and set new pipeline layout. state .descriptor_sets .retain(|&num, _| num < invalidate_from); state.pipeline_layout = pipeline_layout; + } else if (first_set + num_descriptor_sets) as usize + >= state.pipeline_layout.descriptor_set_layouts().len() + { + // New layout is a superset of the old one. + state.pipeline_layout = pipeline_layout; } state