summaryrefslogtreecommitdiffstats
path: root/third_party/rust/naga/src/valid/handles.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/naga/src/valid/handles.rs
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/naga/src/valid/handles.rs')
-rw-r--r--third_party/rust/naga/src/valid/handles.rs91
1 files changed, 79 insertions, 12 deletions
diff --git a/third_party/rust/naga/src/valid/handles.rs b/third_party/rust/naga/src/valid/handles.rs
index e482f293bb..8f78204055 100644
--- a/third_party/rust/naga/src/valid/handles.rs
+++ b/third_party/rust/naga/src/valid/handles.rs
@@ -31,12 +31,13 @@ impl super::Validator {
pub(super) fn validate_module_handles(module: &crate::Module) -> Result<(), ValidationError> {
let &crate::Module {
ref constants,
+ ref overrides,
ref entry_points,
ref functions,
ref global_variables,
ref types,
ref special_types,
- ref const_expressions,
+ ref global_expressions,
} = module;
// NOTE: Types being first is important. All other forms of validation depend on this.
@@ -67,23 +68,31 @@ impl super::Validator {
}
}
- for handle_and_expr in const_expressions.iter() {
- Self::validate_const_expression_handles(handle_and_expr, constants, types)?;
+ for handle_and_expr in global_expressions.iter() {
+ Self::validate_const_expression_handles(handle_and_expr, constants, overrides, types)?;
}
let validate_type = |handle| Self::validate_type_handle(handle, types);
let validate_const_expr =
- |handle| Self::validate_expression_handle(handle, const_expressions);
+ |handle| Self::validate_expression_handle(handle, global_expressions);
for (_handle, constant) in constants.iter() {
- let &crate::Constant {
+ let &crate::Constant { name: _, ty, init } = constant;
+ validate_type(ty)?;
+ validate_const_expr(init)?;
+ }
+
+ for (_handle, override_) in overrides.iter() {
+ let &crate::Override {
name: _,
- r#override: _,
+ id: _,
ty,
init,
- } = constant;
+ } = override_;
validate_type(ty)?;
- validate_const_expr(init)?;
+ if let Some(init_expr) = init {
+ validate_const_expr(init_expr)?;
+ }
}
for (_handle, global_variable) in global_variables.iter() {
@@ -140,7 +149,8 @@ impl super::Validator {
Self::validate_expression_handles(
handle_and_expr,
constants,
- const_expressions,
+ overrides,
+ global_expressions,
types,
local_variables,
global_variables,
@@ -186,6 +196,13 @@ impl super::Validator {
handle.check_valid_for(constants).map(|_| ())
}
+ fn validate_override_handle(
+ handle: Handle<crate::Override>,
+ overrides: &Arena<crate::Override>,
+ ) -> Result<(), InvalidHandleError> {
+ handle.check_valid_for(overrides).map(|_| ())
+ }
+
fn validate_expression_handle(
handle: Handle<crate::Expression>,
expressions: &Arena<crate::Expression>,
@@ -203,9 +220,11 @@ impl super::Validator {
fn validate_const_expression_handles(
(handle, expression): (Handle<crate::Expression>, &crate::Expression),
constants: &Arena<crate::Constant>,
+ overrides: &Arena<crate::Override>,
types: &UniqueArena<crate::Type>,
) -> Result<(), InvalidHandleError> {
let validate_constant = |handle| Self::validate_constant_handle(handle, constants);
+ let validate_override = |handle| Self::validate_override_handle(handle, overrides);
let validate_type = |handle| Self::validate_type_handle(handle, types);
match *expression {
@@ -214,6 +233,12 @@ impl super::Validator {
validate_constant(constant)?;
handle.check_dep(constants[constant].init)?;
}
+ crate::Expression::Override(override_) => {
+ validate_override(override_)?;
+ if let Some(init) = overrides[override_].init {
+ handle.check_dep(init)?;
+ }
+ }
crate::Expression::ZeroValue(ty) => {
validate_type(ty)?;
}
@@ -230,7 +255,8 @@ impl super::Validator {
fn validate_expression_handles(
(handle, expression): (Handle<crate::Expression>, &crate::Expression),
constants: &Arena<crate::Constant>,
- const_expressions: &Arena<crate::Expression>,
+ overrides: &Arena<crate::Override>,
+ global_expressions: &Arena<crate::Expression>,
types: &UniqueArena<crate::Type>,
local_variables: &Arena<crate::LocalVariable>,
global_variables: &Arena<crate::GlobalVariable>,
@@ -239,8 +265,9 @@ impl super::Validator {
current_function: Option<Handle<crate::Function>>,
) -> Result<(), InvalidHandleError> {
let validate_constant = |handle| Self::validate_constant_handle(handle, constants);
+ let validate_override = |handle| Self::validate_override_handle(handle, overrides);
let validate_const_expr =
- |handle| Self::validate_expression_handle(handle, const_expressions);
+ |handle| Self::validate_expression_handle(handle, global_expressions);
let validate_type = |handle| Self::validate_type_handle(handle, types);
match *expression {
@@ -260,6 +287,9 @@ impl super::Validator {
crate::Expression::Constant(constant) => {
validate_constant(constant)?;
}
+ crate::Expression::Override(override_) => {
+ validate_override(override_)?;
+ }
crate::Expression::ZeroValue(ty) => {
validate_type(ty)?;
}
@@ -390,6 +420,8 @@ impl super::Validator {
}
crate::Expression::AtomicResult { .. }
| crate::Expression::RayQueryProceedResult
+ | crate::Expression::SubgroupBallotResult
+ | crate::Expression::SubgroupOperationResult { .. }
| crate::Expression::WorkGroupUniformLoadResult { .. } => (),
crate::Expression::ArrayLength(array) => {
handle.check_dep(array)?;
@@ -535,6 +567,38 @@ impl super::Validator {
}
Ok(())
}
+ crate::Statement::SubgroupBallot { result, predicate } => {
+ validate_expr_opt(predicate)?;
+ validate_expr(result)?;
+ Ok(())
+ }
+ crate::Statement::SubgroupCollectiveOperation {
+ op: _,
+ collective_op: _,
+ argument,
+ result,
+ } => {
+ validate_expr(argument)?;
+ validate_expr(result)?;
+ Ok(())
+ }
+ crate::Statement::SubgroupGather {
+ mode,
+ argument,
+ result,
+ } => {
+ validate_expr(argument)?;
+ match mode {
+ crate::GatherMode::BroadcastFirst => {}
+ crate::GatherMode::Broadcast(index)
+ | crate::GatherMode::Shuffle(index)
+ | crate::GatherMode::ShuffleDown(index)
+ | crate::GatherMode::ShuffleUp(index)
+ | crate::GatherMode::ShuffleXor(index) => validate_expr(index)?,
+ }
+ validate_expr(result)?;
+ Ok(())
+ }
crate::Statement::Break
| crate::Statement::Continue
| crate::Statement::Kill
@@ -562,6 +626,7 @@ impl From<BadRangeError> for ValidationError {
}
#[derive(Clone, Debug, thiserror::Error)]
+#[cfg_attr(test, derive(PartialEq))]
pub enum InvalidHandleError {
#[error(transparent)]
BadHandle(#[from] BadHandle),
@@ -572,6 +637,7 @@ pub enum InvalidHandleError {
}
#[derive(Clone, Debug, thiserror::Error)]
+#[cfg_attr(test, derive(PartialEq))]
#[error(
"{subject:?} of kind {subject_kind:?} depends on {depends_on:?} of kind {depends_on_kind}, \
which has not been processed yet"
@@ -664,6 +730,7 @@ fn constant_deps() {
let mut const_exprs = Arena::new();
let mut fun_exprs = Arena::new();
let mut constants = Arena::new();
+ let overrides = Arena::new();
let i32_handle = types.insert(
Type {
@@ -679,7 +746,6 @@ fn constant_deps() {
let self_referential_const = constants.append(
Constant {
name: None,
- r#override: crate::Override::None,
ty: i32_handle,
init: fun_expr,
},
@@ -692,6 +758,7 @@ fn constant_deps() {
assert!(super::Validator::validate_const_expression_handles(
handle_and_expr,
&constants,
+ &overrides,
&types,
)
.is_err());