fn put_cache_restricted_level(
        &mut self,
        load: Handle<crate::Expression>,
        image: Handle<crate::Expression>,
        mip_level: Option<Handle<crate::Expression>>,
        indent: back::Level,
        context: &StatementContext,
    ) -> BackendResult {
        // Does this image access actually require (or even permit) a
        // level-of-detail, and does the policy require us to restrict it?
        let level_of_detail = match mip_level {
            Some(level) => level,
            None => return Ok(()),
        };

        if context.expression.policies.image != index::BoundsCheckPolicy::Restrict
            || !context.expression.image_needs_lod(image)
        {
            return Ok(());
        }

        write!(
            self.out,
            "{}uint {}{} = ",
            indent,
            CLAMPED_LOD_LOAD_PREFIX,
            load.index(),
        )?;
        self.put_restricted_scalar_image_index(
            image,
            level_of_detail,
            "get_num_mip_levels",
            &context.expression,
        )?;
        writeln!(self.out, ";")?;

        Ok(())
    }
/// Cache a clamped level of detail value, if necessary.
///
/// [`ImageLoad`] accesses covered by [`BoundsCheckPolicy::Restrict`] use a
/// properly clamped level of detail value both in the access itself, and
/// for fetching the size of the requested MIP level, needed to clamp the
/// coordinates. To avoid recomputing this clamped level of detail, we cache
/// it in a temporary variable, as part of the [`Emit`] statement covering
/// the [`ImageLoad`] expression.
///
/// [`ImageLoad`]: crate::Expression::ImageLoad
/// [`BoundsCheckPolicy::Restrict`]: index::BoundsCheckPolicy::Restrict
/// [`Emit`]: crate::Statement::Emit
Cache a clamped level of detail value, if necessary.
[`ImageLoad`] accesses covered by [`BoundsCheckPolicy::Restrict`] use a
properly clamped level of detail value both in the access itself, and
for fetching the size of the requested MIP level, needed to clamp the
coordinates. To avoid recomputing this clamped level of detail, we cache
it in a temporary variable, as part of the [`Emit`] statement covering
the [`ImageLoad`] expression.


Cache a clamped level of detail value if necessary . [ ` ImageLoad ` ] accesses covered by [ ` BoundsCheckPolicy :: Restrict ` ] use a properly clamped level of detail value both in the access itself and for fetching the size of the requested MIP level needed to clamp the coordinates . To avoid recomputing this clamped level of detail we cache it in a temporary variable as part of the [ ` Emit ` ] statement covering the [ ` ImageLoad ` ] expression .
fn put_cache_restricted_level(
        &mut self,
        load: Handle<crate::Expression>,
        image: Handle<crate::Expression>,
        mip_level: Option<Handle<crate::Expression>>,
        indent: back::Level,
        context: &StatementContext,
    ) -> BackendResult {
        // Does this image access actually require (or even permit) a
        // level-of-detail, and does the policy require us to restrict it?
        let level_of_detail = match mip_level {
            Some(level) => level,
            None => return Ok(()),
        };
        if context.expression.policies.image != index::BoundsCheckPolicy::Restrict
            || !context.expression.image_needs_lod(image)
        {
            return Ok(());
        }
        write!(
            self.out,
            "{}uint {}{} = ",
            indent,
            CLAMPED_LOD_LOAD_PREFIX,
            load.index(),
        )?;
        self.put_restricted_scalar_image_index(
            image,
            level_of_detail,
            "get_num_mip_levels",
            &context.expression,
        )?;
        writeln!(self.out, ";")?;
        Ok(())
    }
fn put_cache_restricted_level ( & mut self , load : Handle < crate :: Expression > , image : Handle < crate :: Expression > , mip_level : Option < Handle < crate :: Expression > > , indent : back :: Level , context : & StatementContext , ) -> BackendResult { // Does this image access actually require (or even permit) a // level-of-detail, and does the policy require us to restrict it? let level_of_detail = match mip_level { Some ( level ) => level , None => return Ok ( ( ) ) , } ; if context . expression . policies . image != index :: BoundsCheckPolicy :: Restrict || ! context . expression . image_needs_lod ( image ) { return Ok ( ( ) ) ; } write ! ( self out " " indent CLAMPED_LOD_LOAD_PREFIX load index ( ) ) ? ; self . put_restricted_scalar_image_index ( image , level_of_detail , " " , & context . expression , ) ? ; writeln ! ( self out " " ) ? ; Ok ( ( ) ) }
Cache a clamped level of detail value, if necessary.
Cache a clamped level of detail value if necessary .
&mut self
load
Handle<crate::Expression>
image
Handle<crate::Expression>
mip_level
Option<Handle<crate::Expression>>
indent
back::Level
context
&StatementContext
&mut self
load
Handle<crate::Expression>
image
Handle<crate::Expression>
mip_level
Option<Handle<crate::Expression>>
indent
back::Level
context
&StatementContext