diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/naga/src/compact | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-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/compact')
-rw-r--r-- | third_party/rust/naga/src/compact/expressions.rs | 27 | ||||
-rw-r--r-- | third_party/rust/naga/src/compact/functions.rs | 6 | ||||
-rw-r--r-- | third_party/rust/naga/src/compact/mod.rs | 49 | ||||
-rw-r--r-- | third_party/rust/naga/src/compact/statements.rs | 67 |
4 files changed, 125 insertions, 24 deletions
diff --git a/third_party/rust/naga/src/compact/expressions.rs b/third_party/rust/naga/src/compact/expressions.rs index 301bbe3240..a418bde301 100644 --- a/third_party/rust/naga/src/compact/expressions.rs +++ b/third_party/rust/naga/src/compact/expressions.rs @@ -3,6 +3,7 @@ use crate::arena::{Arena, Handle}; pub struct ExpressionTracer<'tracer> { pub constants: &'tracer Arena<crate::Constant>, + pub overrides: &'tracer Arena<crate::Override>, /// The arena in which we are currently tracing expressions. pub expressions: &'tracer Arena<crate::Expression>, @@ -20,11 +21,11 @@ pub struct ExpressionTracer<'tracer> { /// the module's constant expression arena. pub expressions_used: &'tracer mut HandleSet<crate::Expression>, - /// The used set for the module's `const_expressions` arena. + /// The used set for the module's `global_expressions` arena. /// /// If `None`, we are already tracing the constant expressions, /// and `expressions_used` already refers to their handle set. - pub const_expressions_used: Option<&'tracer mut HandleSet<crate::Expression>>, + pub global_expressions_used: Option<&'tracer mut HandleSet<crate::Expression>>, } impl<'tracer> ExpressionTracer<'tracer> { @@ -39,11 +40,11 @@ impl<'tracer> ExpressionTracer<'tracer> { /// marked. /// /// [fe]: crate::Function::expressions - /// [ce]: crate::Module::const_expressions + /// [ce]: crate::Module::global_expressions pub fn trace_expressions(&mut self) { log::trace!( "entering trace_expression of {}", - if self.const_expressions_used.is_some() { + if self.global_expressions_used.is_some() { "function expressions" } else { "const expressions" @@ -71,6 +72,7 @@ impl<'tracer> ExpressionTracer<'tracer> { | Ex::GlobalVariable(_) | Ex::LocalVariable(_) | Ex::CallResult(_) + | Ex::SubgroupBallotResult | Ex::RayQueryProceedResult => {} Ex::Constant(handle) => { @@ -83,11 +85,16 @@ impl<'tracer> ExpressionTracer<'tracer> { // and the constant refers to the initializer, it must // precede `expr` in the arena. let init = self.constants[handle].init; - match self.const_expressions_used { + match self.global_expressions_used { Some(ref mut used) => used.insert(init), None => self.expressions_used.insert(init), } } + Ex::Override(_) => { + // All overrides are considered used by definition. We mark + // their types and initialization expressions as used in + // `compact::compact`, so we have no more work to do here. + } Ex::ZeroValue(ty) => self.types_used.insert(ty), Ex::Compose { ty, ref components } => { self.types_used.insert(ty); @@ -116,7 +123,7 @@ impl<'tracer> ExpressionTracer<'tracer> { self.expressions_used .insert_iter([image, sampler, coordinate]); self.expressions_used.insert_iter(array_index); - match self.const_expressions_used { + match self.global_expressions_used { Some(ref mut used) => used.insert_iter(offset), None => self.expressions_used.insert_iter(offset), } @@ -186,6 +193,7 @@ impl<'tracer> ExpressionTracer<'tracer> { Ex::AtomicResult { ty, comparison: _ } => self.types_used.insert(ty), Ex::WorkGroupUniformLoadResult { ty } => self.types_used.insert(ty), Ex::ArrayLength(expr) => self.expressions_used.insert(expr), + Ex::SubgroupOperationResult { ty } => self.types_used.insert(ty), Ex::RayQueryGetIntersection { query, committed: _, @@ -217,8 +225,12 @@ impl ModuleMap { | Ex::GlobalVariable(_) | Ex::LocalVariable(_) | Ex::CallResult(_) + | Ex::SubgroupBallotResult | Ex::RayQueryProceedResult => {} + // All overrides are retained, so their handles never change. + Ex::Override(_) => {} + // Expressions that contain handles that need to be adjusted. Ex::Constant(ref mut constant) => self.constants.adjust(constant), Ex::ZeroValue(ref mut ty) => self.types.adjust(ty), @@ -267,7 +279,7 @@ impl ModuleMap { adjust(coordinate); operand_map.adjust_option(array_index); if let Some(ref mut offset) = *offset { - self.const_expressions.adjust(offset); + self.global_expressions.adjust(offset); } self.adjust_sample_level(level, operand_map); operand_map.adjust_option(depth_ref); @@ -344,6 +356,7 @@ impl ModuleMap { comparison: _, } => self.types.adjust(ty), Ex::WorkGroupUniformLoadResult { ref mut ty } => self.types.adjust(ty), + Ex::SubgroupOperationResult { ref mut ty } => self.types.adjust(ty), Ex::ArrayLength(ref mut expr) => adjust(expr), Ex::RayQueryGetIntersection { ref mut query, diff --git a/third_party/rust/naga/src/compact/functions.rs b/third_party/rust/naga/src/compact/functions.rs index b0d08c7e96..4ac2223eb7 100644 --- a/third_party/rust/naga/src/compact/functions.rs +++ b/third_party/rust/naga/src/compact/functions.rs @@ -4,10 +4,11 @@ use super::{FunctionMap, ModuleMap}; pub struct FunctionTracer<'a> { pub function: &'a crate::Function, pub constants: &'a crate::Arena<crate::Constant>, + pub overrides: &'a crate::Arena<crate::Override>, pub types_used: &'a mut HandleSet<crate::Type>, pub constants_used: &'a mut HandleSet<crate::Constant>, - pub const_expressions_used: &'a mut HandleSet<crate::Expression>, + pub global_expressions_used: &'a mut HandleSet<crate::Expression>, /// Function-local expressions used. pub expressions_used: HandleSet<crate::Expression>, @@ -47,12 +48,13 @@ impl<'a> FunctionTracer<'a> { fn as_expression(&mut self) -> super::expressions::ExpressionTracer { super::expressions::ExpressionTracer { constants: self.constants, + overrides: self.overrides, expressions: &self.function.expressions, types_used: self.types_used, constants_used: self.constants_used, expressions_used: &mut self.expressions_used, - const_expressions_used: Some(&mut self.const_expressions_used), + global_expressions_used: Some(&mut self.global_expressions_used), } } } diff --git a/third_party/rust/naga/src/compact/mod.rs b/third_party/rust/naga/src/compact/mod.rs index b4e57ed5c9..0d7a37b579 100644 --- a/third_party/rust/naga/src/compact/mod.rs +++ b/third_party/rust/naga/src/compact/mod.rs @@ -38,7 +38,7 @@ pub fn compact(module: &mut crate::Module) { log::trace!("tracing global {:?}", global.name); module_tracer.types_used.insert(global.ty); if let Some(init) = global.init { - module_tracer.const_expressions_used.insert(init); + module_tracer.global_expressions_used.insert(init); } } } @@ -50,7 +50,15 @@ pub fn compact(module: &mut crate::Module) { for (handle, constant) in module.constants.iter() { if constant.name.is_some() { module_tracer.constants_used.insert(handle); - module_tracer.const_expressions_used.insert(constant.init); + module_tracer.global_expressions_used.insert(constant.init); + } + } + + // We treat all overrides as used by definition. + for (_, override_) in module.overrides.iter() { + module_tracer.types_used.insert(override_.ty); + if let Some(init) = override_.init { + module_tracer.global_expressions_used.insert(init); } } @@ -137,9 +145,9 @@ pub fn compact(module: &mut crate::Module) { // Drop unused constant expressions, reusing existing storage. log::trace!("adjusting constant expressions"); - module.const_expressions.retain_mut(|handle, expr| { - if module_map.const_expressions.used(handle) { - module_map.adjust_expression(expr, &module_map.const_expressions); + module.global_expressions.retain_mut(|handle, expr| { + if module_map.global_expressions.used(handle) { + module_map.adjust_expression(expr, &module_map.global_expressions); true } else { false @@ -151,20 +159,29 @@ pub fn compact(module: &mut crate::Module) { module.constants.retain_mut(|handle, constant| { if module_map.constants.used(handle) { module_map.types.adjust(&mut constant.ty); - module_map.const_expressions.adjust(&mut constant.init); + module_map.global_expressions.adjust(&mut constant.init); true } else { false } }); + // Adjust override types and initializers. + log::trace!("adjusting overrides"); + for (_, override_) in module.overrides.iter_mut() { + module_map.types.adjust(&mut override_.ty); + if let Some(init) = override_.init.as_mut() { + module_map.global_expressions.adjust(init); + } + } + // Adjust global variables' types and initializers. log::trace!("adjusting global variables"); for (_, global) in module.global_variables.iter_mut() { log::trace!("adjusting global {:?}", global.name); module_map.types.adjust(&mut global.ty); if let Some(ref mut init) = global.init { - module_map.const_expressions.adjust(init); + module_map.global_expressions.adjust(init); } } @@ -193,7 +210,7 @@ struct ModuleTracer<'module> { module: &'module crate::Module, types_used: HandleSet<crate::Type>, constants_used: HandleSet<crate::Constant>, - const_expressions_used: HandleSet<crate::Expression>, + global_expressions_used: HandleSet<crate::Expression>, } impl<'module> ModuleTracer<'module> { @@ -202,7 +219,7 @@ impl<'module> ModuleTracer<'module> { module, types_used: HandleSet::for_arena(&module.types), constants_used: HandleSet::for_arena(&module.constants), - const_expressions_used: HandleSet::for_arena(&module.const_expressions), + global_expressions_used: HandleSet::for_arena(&module.global_expressions), } } @@ -233,12 +250,13 @@ impl<'module> ModuleTracer<'module> { fn as_const_expression(&mut self) -> expressions::ExpressionTracer { expressions::ExpressionTracer { - expressions: &self.module.const_expressions, + expressions: &self.module.global_expressions, constants: &self.module.constants, + overrides: &self.module.overrides, types_used: &mut self.types_used, constants_used: &mut self.constants_used, - expressions_used: &mut self.const_expressions_used, - const_expressions_used: None, + expressions_used: &mut self.global_expressions_used, + global_expressions_used: None, } } @@ -249,9 +267,10 @@ impl<'module> ModuleTracer<'module> { FunctionTracer { function, constants: &self.module.constants, + overrides: &self.module.overrides, types_used: &mut self.types_used, constants_used: &mut self.constants_used, - const_expressions_used: &mut self.const_expressions_used, + global_expressions_used: &mut self.global_expressions_used, expressions_used: HandleSet::for_arena(&function.expressions), } } @@ -260,7 +279,7 @@ impl<'module> ModuleTracer<'module> { struct ModuleMap { types: HandleMap<crate::Type>, constants: HandleMap<crate::Constant>, - const_expressions: HandleMap<crate::Expression>, + global_expressions: HandleMap<crate::Expression>, } impl From<ModuleTracer<'_>> for ModuleMap { @@ -268,7 +287,7 @@ impl From<ModuleTracer<'_>> for ModuleMap { ModuleMap { types: HandleMap::from_set(used.types_used), constants: HandleMap::from_set(used.constants_used), - const_expressions: HandleMap::from_set(used.const_expressions_used), + global_expressions: HandleMap::from_set(used.global_expressions_used), } } } diff --git a/third_party/rust/naga/src/compact/statements.rs b/third_party/rust/naga/src/compact/statements.rs index 0698b57258..a124281bc1 100644 --- a/third_party/rust/naga/src/compact/statements.rs +++ b/third_party/rust/naga/src/compact/statements.rs @@ -97,6 +97,39 @@ impl FunctionTracer<'_> { self.expressions_used.insert(query); self.trace_ray_query_function(fun); } + St::SubgroupBallot { result, predicate } => { + if let Some(predicate) = predicate { + self.expressions_used.insert(predicate) + } + self.expressions_used.insert(result) + } + St::SubgroupCollectiveOperation { + op: _, + collective_op: _, + argument, + result, + } => { + self.expressions_used.insert(argument); + self.expressions_used.insert(result) + } + St::SubgroupGather { + mode, + argument, + result, + } => { + 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) => { + self.expressions_used.insert(index) + } + } + self.expressions_used.insert(argument); + self.expressions_used.insert(result) + } // Trivial statements. St::Break @@ -250,6 +283,40 @@ impl FunctionMap { adjust(query); self.adjust_ray_query_function(fun); } + St::SubgroupBallot { + ref mut result, + ref mut predicate, + } => { + if let Some(ref mut predicate) = *predicate { + adjust(predicate); + } + adjust(result); + } + St::SubgroupCollectiveOperation { + op: _, + collective_op: _, + ref mut argument, + ref mut result, + } => { + adjust(argument); + adjust(result); + } + St::SubgroupGather { + ref mut mode, + ref mut argument, + ref mut result, + } => { + match *mode { + crate::GatherMode::BroadcastFirst => {} + crate::GatherMode::Broadcast(ref mut index) + | crate::GatherMode::Shuffle(ref mut index) + | crate::GatherMode::ShuffleDown(ref mut index) + | crate::GatherMode::ShuffleUp(ref mut index) + | crate::GatherMode::ShuffleXor(ref mut index) => adjust(index), + } + adjust(argument); + adjust(result); + } // Trivial statements. St::Break |