fn put_image_access_bounds_check(
        &mut self,
        image: Handle<crate::Expression>,
        address: &TexelAddress,
        context: &ExpressionContext,
    ) -> BackendResult {
        let mut conjunction = "";

        // First, check the level of detail. Only if that is in bounds can we
        // use it to find the appropriate bounds for the coordinates.
        let level = if let Some(level) = address.level {
            write!(self.out, "uint(")?;
            self.put_level_of_detail(level, context)?;
            write!(self.out, ") < ")?;
            self.put_expression(image, context, true)?;
            write!(self.out, ".get_num_mip_levels()")?;
            conjunction = " && ";
            Some(level)
        } else {
            None
        };

        // Check sample index, if present.
        if let Some(sample) = address.sample {
            write!(self.out, "uint(")?;
            self.put_expression(sample, context, true)?;
            write!(self.out, ") < ")?;
            self.put_expression(image, context, true)?;
            write!(self.out, ".get_num_samples()")?;
            conjunction = " && ";
        }

        // Check array index, if present.
        if let Some(array_index) = address.array_index {
            write!(self.out, "{}uint(", conjunction)?;
            self.put_expression(array_index, context, true)?;
            write!(self.out, ") < ")?;
            self.put_expression(image, context, true)?;
            write!(self.out, ".get_array_size()")?;
            conjunction = " && ";
        }

        // Finally, check if the coordinates are within bounds.
        let coord_is_vector = match *context.resolve_type(address.coordinate) {
            crate::TypeInner::Vector { .. } => true,
            _ => false,
        };
        write!(self.out, "{}", conjunction)?;
        if coord_is_vector {
            write!(self.out, "{}::all(", NAMESPACE)?;
        }
        self.put_cast_to_uint_scalar_or_vector(address.coordinate, context)?;
        write!(self.out, " < ")?;
        self.put_image_size_query(image, level, crate::ScalarKind::Uint, context)?;
        if coord_is_vector {
            write!(self.out, ")")?;
        }

        Ok(())
    }
/// Write an expression that is true if the given image access is in bounds.
Write an expression that is true if the given image access is in bounds.
Write an expression that is true if the given image access is in bounds .
fn put_image_access_bounds_check(
        &mut self,
        image: Handle<crate::Expression>,
        address: &TexelAddress,
        context: &ExpressionContext,
    ) -> BackendResult {
        let mut conjunction = "";
        // First, check the level of detail. Only if that is in bounds can we
        // use it to find the appropriate bounds for the coordinates.
        let level = if let Some(level) = address.level {
            write!(self.out, "uint(")?;
            self.put_level_of_detail(level, context)?;
            write!(self.out, ") < ")?;
            self.put_expression(image, context, true)?;
            write!(self.out, ".get_num_mip_levels()")?;
            conjunction = " && ";
            Some(level)
        } else {
            None
        };
        // Check sample index, if present.
        if let Some(sample) = address.sample {
            write!(self.out, "uint(")?;
            self.put_expression(sample, context, true)?;
            write!(self.out, ") < ")?;
            self.put_expression(image, context, true)?;
            write!(self.out, ".get_num_samples()")?;
            conjunction = " && ";
        }
        // Check array index, if present.
        if let Some(array_index) = address.array_index {
            write!(self.out, "{}uint(", conjunction)?;
            self.put_expression(array_index, context, true)?;
            write!(self.out, ") < ")?;
            self.put_expression(image, context, true)?;
            write!(self.out, ".get_array_size()")?;
            conjunction = " && ";
        }
        // Finally, check if the coordinates are within bounds.
        let coord_is_vector = match *context.resolve_type(address.coordinate) {
            crate::TypeInner::Vector { .. } => true,
            _ => false,
        };
        write!(self.out, "{}", conjunction)?;
        if coord_is_vector {
            write!(self.out, "{}::all(", NAMESPACE)?;
        }
        self.put_cast_to_uint_scalar_or_vector(address.coordinate, context)?;
        write!(self.out, " < ")?;
        self.put_image_size_query(image, level, crate::ScalarKind::Uint, context)?;
        if coord_is_vector {
            write!(self.out, ")")?;
        }
        Ok(())
    }
fn put_image_access_bounds_check ( & mut self , image : Handle < crate :: Expression > , address : & TexelAddress , context : & ExpressionContext , ) -> BackendResult { let mut conjunction = " " ; // First, check the level of detail. Only if that is in bounds can we // use it to find the appropriate bounds for the coordinates. let level = if let Some ( level ) = address . level { write ! ( self out " " ) ? ; self . put_level_of_detail ( level , context ) ? ; write ! ( self out " " ) ? ; self . put_expression ( image , context , true ) ? ; write ! ( self out " " ) ? ; conjunction = " " ; Some ( level ) } else { None } ; // Check sample index, if present. if let Some ( sample ) = address . sample { write ! ( self out " " ) ? ; self . put_expression ( sample , context , true ) ? ; write ! ( self out " " ) ? ; self . put_expression ( image , context , true ) ? ; write ! ( self out " " ) ? ; conjunction = " " ; } // Check array index, if present. if let Some ( array_index ) = address . array_index { write ! ( self out " " conjunction ) ? ; self . put_expression ( array_index , context , true ) ? ; write ! ( self out " " ) ? ; self . put_expression ( image , context , true ) ? ; write ! ( self out " " ) ? ; conjunction = " " ; } // Finally, check if the coordinates are within bounds. let coord_is_vector = match * context . resolve_type ( address . coordinate ) { crate :: TypeInner :: Vector { .. } => true , _ => false , } ; write ! ( self out " " conjunction ) ? ; if coord_is_vector { write ! ( self out " " NAMESPACE ) ? ; } self . put_cast_to_uint_scalar_or_vector ( address . coordinate , context ) ? ; write ! ( self out " " ) ? ; self . put_image_size_query ( image , level , crate :: ScalarKind :: Uint , context ) ? ; if coord_is_vector { write ! ( self out " " ) ? ; } Ok ( ( ) ) }
Write an expression that is true if the given image access is in bounds.
Write an expression that is true if the given image access is in bounds .
&mut self
image
Handle<crate::Expression>
address
&TexelAddress
context
&ExpressionContext
&mut self
image
Handle<crate::Expression>
address
&TexelAddress
context
&ExpressionContext