pub fn sampled_to_depth(
    module: &mut Module,
    ctx: &mut Context,
    image: Handle<Expression>,
    meta: Span,
    errors: &mut Vec<Error>,
) {
    let ty = match ctx[image] {
        Expression::GlobalVariable(handle) => &mut module.global_variables.get_mut(handle).ty,
        Expression::FunctionArgument(i) => {
            ctx.parameters_info[i as usize].depth = true;
            &mut ctx.arguments[i as usize].ty
        }
        _ => {
            return errors.push(Error {
                kind: ErrorKind::SemanticError("Not a valid texture expression".into()),
                meta,
            })
        }
    };
    match module.types[*ty].inner {
        TypeInner::Image {
            class,
            dim,
            arrayed,
        } => match class {
            ImageClass::Sampled { multi, .. } => {
                *ty = module.types.insert(
                    Type {
                        name: None,
                        inner: TypeInner::Image {
                            dim,
                            arrayed,
                            class: ImageClass::Depth { multi },
                        },
                    },
                    Span::default(),
                )
            }
            ImageClass::Depth { .. } => {}
            _ => errors.push(Error {
                kind: ErrorKind::SemanticError("Not a texture".into()),
                meta,
            }),
        },
        _ => errors.push(Error {
            kind: ErrorKind::SemanticError("Not a texture".into()),
            meta,
        }),
    };
}
/// Helper function to cast a expression holding a sampled image to a
/// depth image.
Helper function to cast a expression holding a sampled image to a
depth image.
Helper function to cast a expression holding a sampled image to a depth image .
pub fn sampled_to_depth(
    module: &mut Module,
    ctx: &mut Context,
    image: Handle<Expression>,
    meta: Span,
    errors: &mut Vec<Error>,
) {
    let ty = match ctx[image] {
        Expression::GlobalVariable(handle) => &mut module.global_variables.get_mut(handle).ty,
        Expression::FunctionArgument(i) => {
            ctx.parameters_info[i as usize].depth = true;
            &mut ctx.arguments[i as usize].ty
        }
        _ => {
            return errors.push(Error {
                kind: ErrorKind::SemanticError("Not a valid texture expression".into()),
                meta,
            })
        }
    };
    match module.types[*ty].inner {
        TypeInner::Image {
            class,
            dim,
            arrayed,
        } => match class {
            ImageClass::Sampled { multi, .. } => {
                *ty = module.types.insert(
                    Type {
                        name: None,
                        inner: TypeInner::Image {
                            dim,
                            arrayed,
                            class: ImageClass::Depth { multi },
                        },
                    },
                    Span::default(),
                )
            }
            ImageClass::Depth { .. } => {}
            _ => errors.push(Error {
                kind: ErrorKind::SemanticError("Not a texture".into()),
                meta,
            }),
        },
        _ => errors.push(Error {
            kind: ErrorKind::SemanticError("Not a texture".into()),
            meta,
        }),
    };
}
pub fn sampled_to_depth ( module : & mut Module , ctx : & mut Context , image : Handle < Expression > , meta : Span , errors : & mut Vec < Error > , ) { let ty = match ctx [ image ] { Expression :: GlobalVariable ( handle ) => & mut module . global_variables . get_mut ( handle ) . ty , Expression :: FunctionArgument ( i ) => { ctx . parameters_info [ i as usize ] . depth = true ; & mut ctx . arguments [ i as usize ] . ty } _ => { return errors . push ( Error { kind : ErrorKind :: SemanticError ( " " . into ( ) ) , meta , } ) } } ; match module . types [ * ty ] . inner { TypeInner :: Image { class , dim , arrayed , } => match class { ImageClass :: Sampled { multi , .. } => { * ty = module . types . insert ( Type { name : None , inner : TypeInner :: Image { dim , arrayed , class : ImageClass :: Depth { multi } , } , } , Span :: default ( ) , ) } ImageClass :: Depth { .. } => { } _ => errors . push ( Error { kind : ErrorKind :: SemanticError ( " " . into ( ) ) , meta , } ) , } , _ => errors . push ( Error { kind : ErrorKind :: SemanticError ( " " . into ( ) ) , meta , } ) , } ; }
Helper function to cast a expression holding a sampled image to a
depth image.
Helper function to cast a expression holding a sampled image to a depth image .
module
&mut Module
ctx
&mut Context
image
Handle<Expression>
meta
Span
errors
&mut Vec<Error>
module
&mut Module
ctx
&mut Context
image
Handle<Expression>
meta
Span
errors
&mut Vec<Error>