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
This commit is contained in:
Rua 2021-09-29 08:06:49 +02:00 committed by GitHub
parent c1da957797
commit 5e4da07685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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