mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-25 00:41:07 +01:00
Prevent using multiple push constant variables in one entry point. (#2484)
This commit is contained in:
1 parent
df8107b788
commit
d8b7573b9e
1 file changed
+19
@@ -90,6 +90,8 @@ pub enum EntryPointError {
|
||||
ForbiddenStageOperations,
|
||||
#[error("Global variable {0:?} is used incorrectly as {1:?}")]
|
||||
InvalidGlobalUsage(Handle<crate::GlobalVariable>, GlobalUse),
|
||||
#[error("More than 1 push constant variable is used")]
|
||||
MoreThanOnePushConstantUsed,
|
||||
#[error("Bindings for {0:?} conflict with other resource")]
|
||||
BindingCollision(Handle<crate::GlobalVariable>),
|
||||
#[error("Argument {0} varying error")]
|
||||
@@ -701,6 +703,23 @@ impl super::Validator {
|
||||
bg.clear();
|
||||
}
|
||||
|
||||
#[cfg(feature = "validate")]
|
||||
{
|
||||
let used_push_constants = module
|
||||
.global_variables
|
||||
.iter()
|
||||
.filter(|&(_, var)| var.space == crate::AddressSpace::PushConstant)
|
||||
.map(|(handle, _)| handle)
|
||||
.filter(|&handle| !info[handle].is_empty());
|
||||
// Check if there is more than one push constant, and error if so.
|
||||
// Use a loop for when returning multiple errors is supported.
|
||||
#[allow(clippy::never_loop)]
|
||||
for handle in used_push_constants.skip(1) {
|
||||
return Err(EntryPointError::MoreThanOnePushConstantUsed
|
||||
.with_span_handle(handle, &module.global_variables));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "validate")]
|
||||
for (var_handle, var) in module.global_variables.iter() {
|
||||
let usage = info[var_handle];
|
||||
|
||||
Reference in new issue
Block a user