mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 16:24:24 +00:00
validate that override ids are unique
This commit is contained in:
parent
2929ec333c
commit
d7cfe16b79
@ -174,6 +174,7 @@ pub struct Validator {
|
||||
switch_values: FastHashSet<crate::SwitchValue>,
|
||||
valid_expression_list: Vec<Handle<crate::Expression>>,
|
||||
valid_expression_set: BitSet,
|
||||
override_ids: FastHashSet<u16>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, thiserror::Error)]
|
||||
@ -188,6 +189,8 @@ pub enum ConstantError {
|
||||
pub enum OverrideError {
|
||||
#[error("Override name and ID are missing")]
|
||||
MissingNameAndID,
|
||||
#[error("Override ID must be unique")]
|
||||
DuplicateID,
|
||||
#[error("The type doesn't match the override")]
|
||||
InvalidType,
|
||||
#[error("The type is not constructible")]
|
||||
@ -311,6 +314,7 @@ impl Validator {
|
||||
switch_values: FastHashSet::default(),
|
||||
valid_expression_list: Vec::new(),
|
||||
valid_expression_set: BitSet::new(),
|
||||
override_ids: FastHashSet::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,6 +327,7 @@ impl Validator {
|
||||
self.switch_values.clear();
|
||||
self.valid_expression_list.clear();
|
||||
self.valid_expression_set.clear();
|
||||
self.override_ids.clear();
|
||||
}
|
||||
|
||||
fn validate_constant(
|
||||
@ -348,7 +353,7 @@ impl Validator {
|
||||
}
|
||||
|
||||
fn validate_override(
|
||||
&self,
|
||||
&mut self,
|
||||
handle: Handle<crate::Override>,
|
||||
gctx: crate::proc::GlobalCtx,
|
||||
mod_info: &ModuleInfo,
|
||||
@ -359,6 +364,12 @@ impl Validator {
|
||||
return Err(OverrideError::MissingNameAndID);
|
||||
}
|
||||
|
||||
if let Some(id) = o.id {
|
||||
if !self.override_ids.insert(id) {
|
||||
return Err(OverrideError::DuplicateID);
|
||||
}
|
||||
}
|
||||
|
||||
let type_info = &self.types[o.ty.index()];
|
||||
if !type_info.flags.contains(TypeFlags::CONSTRUCTIBLE) {
|
||||
return Err(OverrideError::NonConstructibleType);
|
||||
|
Loading…
Reference in New Issue
Block a user