for (&binding, _) in assigned_bgl.entries.iter() { if !expected_bgl.entries.contains_key(binding) {
errors.push(EntryError::ExtraAssigned { binding });
}
}
/// Takes the start index of the bind group range to be rebound, and clears it. pubfn take_rebind_start_index(&mutself) -> usize { let start = self.rebind_start; self.rebind_start = self.entries.len();
start
}
#[derive(Clone, Debug, Error)] pubenum BinderError { #[error("The current set {pipeline} expects a BindGroup to be set at index {index}")]
MissingBindGroup {
index: usize,
pipeline: ResourceErrorIdent,
}, #[error("The {assigned_bgl} of current set {assigned_bg} at index {index} is not compatible with the corresponding {expected_bgl} of {pipeline}")]
IncompatibleBindGroup {
expected_bgl: ResourceErrorIdent,
assigned_bgl: ResourceErrorIdent,
assigned_bg: ResourceErrorIdent,
index: usize,
pipeline: ResourceErrorIdent, #[source]
inner: crate::error::MultiError,
},
}
#[derive(Debug, Default)] struct EntryPayload {
group: Option<Arc<BindGroup>>,
dynamic_offsets: Vec<wgt::DynamicOffset>,
late_buffer_bindings: Vec<LateBufferBinding>, /// Since `LateBufferBinding` may contain information about the bindings /// not used by the pipeline, we need to know when to stop validating.
late_bindings_effective_count: usize,
}
/// Returns `true` if the pipeline layout has been changed, i.e. if the /// new PL was not the same as the old PL. pub(super) fn change_pipeline_layout<'a>(
&'a mut self,
new: &Arc<PipelineLayout>,
late_sized_buffer_groups: &[LateSizedBufferGroup],
) -> bool { self.update_late_buffer_bindings(late_sized_buffer_groups);
iflet Some(old) = old { // root constants are the base compatibility property if old.immediate_size != new.immediate_size { self.manager.update_rebind_start_index(0);
}
}
// Fill out the actual binding sizes for buffers, // whose layout doesn't specify `min_binding_size`.
// Update entries that already exist as the pipeline was bound before the group // was bound. for (late_binding, late_info) in payload
.late_buffer_bindings
.iter_mut()
.zip(bind_group.late_buffer_binding_infos.iter())
{
late_binding.binding_index = late_info.binding_index;
late_binding.bound_size = late_info.size.get();
}
// Add new entries for the bindings that were not known when the pipeline was bound. if bind_group.late_buffer_binding_infos.len() > payload.late_buffer_bindings.len() { for late_info in
bind_group.late_buffer_binding_infos[payload.late_buffer_bindings.len()..].iter()
{
payload.late_buffer_bindings.push(LateBufferBinding {
binding_index: late_info.binding_index,
shader_expect_size: 0,
bound_size: late_info.size.get(),
});
}
}
/// Takes the start index of the bind group range to be rebound, and clears it. pub(super) fn take_rebind_start_index(&mutself) -> usize { self.manager.take_rebind_start_index()
}
/// Scan active buffer bindings corresponding to layouts without `min_binding_size` specified. pub(super) fn check_late_buffer_bindings(
&self,
) -> Result<(), LateMinBufferBindingSizeMismatch> { for group_index inself.manager.list_active() { let payload = &self.payloads[group_index]; for late_binding in
&payload.late_buffer_bindings[..payload.late_bindings_effective_count]
{ if late_binding.bound_size < late_binding.shader_expect_size { return Err(LateMinBufferBindingSizeMismatch {
group_index: group_index as u32,
binding_index: late_binding.binding_index,
shader_size: late_binding.shader_expect_size,
bound_size: late_binding.bound_size,
});
}
}
}
Ok(())
}
/// This must be called even when a new pipeline has the same layout /// as the previous one, because different pipelines can have different /// shader-expected buffer sizes even with identical layouts. fn update_late_buffer_bindings(&mutself, late_sized_buffer_groups: &[LateSizedBufferGroup]) { for (payload, late_group) inself.payloads.iter_mut().zip(late_sized_buffer_groups) {
payload.late_bindings_effective_count = late_group.shader_sizes.len();
// Update entries that already exist as the bind group was bound before the pipeline // was bound. for (late_binding, &shader_expect_size) in payload
.late_buffer_bindings
.iter_mut()
.zip(late_group.shader_sizes.iter())
{
late_binding.shader_expect_size = shader_expect_size;
}
// Add new entries for the bindings that were not known when the bind group was bound. if late_group.shader_sizes.len() > payload.late_buffer_bindings.len() { for &shader_expect_size in
late_group.shader_sizes[payload.late_buffer_bindings.len()..].iter()
{
payload.late_buffer_bindings.push(LateBufferBinding {
binding_index: 0,
shader_expect_size,
bound_size: 0,
});
}
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.