fn update_expressions_to_bake(
        &mut self,
        func: &crate::Function,
        info: &valid::FunctionInfo,
        context: &ExpressionContext,
    ) {
        use crate::Expression;
        self.need_bake_expressions.clear();
        for expr in func.expressions.iter() {
            // Expressions whose reference count is above the
            // threshold should always be stored in temporaries.
            let expr_info = &info[expr.0];
            let min_ref_count = func.expressions[expr.0].bake_ref_count();
            if min_ref_count <= expr_info.ref_count {
                self.need_bake_expressions.insert(expr.0);
            }

            // WGSL's `dot` function works on any `vecN` type, but Metal's only
            // works on floating-point vectors, so we emit inline code for
            // integer vector `dot` calls. But that code uses each argument `N`
            // times, once for each component (see `put_dot_product`), so to
            // avoid duplicated evaluation, we must bake integer operands.
            if let (
                fun_handle,
                &Expression::Math {
                    fun: crate::MathFunction::Dot,
                    arg,
                    arg1,
                    ..
                },
            ) = expr
            {
                use crate::TypeInner;
                // check what kind of product this is depending
                // on the resolve type of the Dot function itself
                let inner = context.resolve_type(fun_handle);
                if let TypeInner::Scalar { kind, .. } = *inner {
                    match kind {
                        crate::ScalarKind::Sint | crate::ScalarKind::Uint => {
                            self.need_bake_expressions.insert(arg);
                            self.need_bake_expressions.insert(arg1.unwrap());
                        }
                        _ => {}
                    }
                }
            }
        }
    }
/// Helper method used to find which expressions of a given function require baking
///
/// # Notes
/// This function overwrites the contents of `self.need_bake_expressions`
Helper method used to find which expressions of a given function require baking
Helper method used to find which expressions of a given function require baking
fn update_expressions_to_bake(
        &mut self,
        func: &crate::Function,
        info: &valid::FunctionInfo,
        context: &ExpressionContext,
    ) {
        use crate::Expression;
        self.need_bake_expressions.clear();
        for expr in func.expressions.iter() {
            // Expressions whose reference count is above the
            // threshold should always be stored in temporaries.
            let expr_info = &info[expr.0];
            let min_ref_count = func.expressions[expr.0].bake_ref_count();
            if min_ref_count <= expr_info.ref_count {
                self.need_bake_expressions.insert(expr.0);
            }
            // WGSL's `dot` function works on any `vecN` type, but Metal's only
            // works on floating-point vectors, so we emit inline code for
            // integer vector `dot` calls. But that code uses each argument `N`
            // times, once for each component (see `put_dot_product`), so to
            // avoid duplicated evaluation, we must bake integer operands.
            if let (
                fun_handle,
                &Expression::Math {
                    fun: crate::MathFunction::Dot,
                    arg,
                    arg1,
                    ..
                },
            ) = expr
            {
                use crate::TypeInner;
                // check what kind of product this is depending
                // on the resolve type of the Dot function itself
                let inner = context.resolve_type(fun_handle);
                if let TypeInner::Scalar { kind, .. } = *inner {
                    match kind {
                        crate::ScalarKind::Sint | crate::ScalarKind::Uint => {
                            self.need_bake_expressions.insert(arg);
                            self.need_bake_expressions.insert(arg1.unwrap());
                        }
                        _ => {}
                    }
                }
            }
        }
    }
fn update_expressions_to_bake ( & mut self , func : & crate :: Function , info : & valid :: FunctionInfo , context : & ExpressionContext , ) { use crate :: Expression ; self . need_bake_expressions . clear ( ) ; for expr in func . expressions . iter ( ) { // Expressions whose reference count is above the // threshold should always be stored in temporaries. let expr_info = & info [ expr . 0 ] ; let min_ref_count = func . expressions [ expr . 0 ] . bake_ref_count ( ) ; if min_ref_count <= expr_info . ref_count { self . need_bake_expressions . insert ( expr . 0 ) ; } // WGSL's `dot` function works on any `vecN` type, but Metal's only // works on floating-point vectors, so we emit inline code for // integer vector `dot` calls. But that code uses each argument `N` // times, once for each component (see `put_dot_product`), so to // avoid duplicated evaluation, we must bake integer operands. if let ( fun_handle , & Expression :: Math { fun : crate :: MathFunction :: Dot , arg , arg1 , .. } , ) = expr { use crate :: TypeInner ; // check what kind of product this is depending // on the resolve type of the Dot function itself let inner = context . resolve_type ( fun_handle ) ; if let TypeInner :: Scalar { kind , .. } = * inner { match kind { crate :: ScalarKind :: Sint | crate :: ScalarKind :: Uint => { self . need_bake_expressions . insert ( arg ) ; self . need_bake_expressions . insert ( arg1 . unwrap ( ) ) ; } _ => { } } } } } }
Helper method used to find which expressions of a given function require baking
Helper method used to find which expressions of a given function require baking
&mut self
func
&crate::Function
info
&valid::FunctionInfo
context
&ExpressionContext
&mut self
func
&crate::Function
info
&valid::FunctionInfo
context
&ExpressionContext
notes
This function overwrites the contents of `self.need_bake_expressions`
This function overwrites the contents of ` self . need_bake_expressions `