fn specialization_constant_requirements(
    spirv: &Spirv,
) -> FnvHashMap<u32, SpecializationConstantRequirements> {
    spirv
        .iter_global()
        .filter_map(|instruction| {
            match instruction {
                &Instruction::SpecConstantTrue {
                    result_type_id,
                    result_id,
                }
                | &Instruction::SpecConstantFalse {
                    result_type_id,
                    result_id,
                }
                | &Instruction::SpecConstant {
                    result_type_id,
                    result_id,
                    ..
                }
                | &Instruction::SpecConstantComposite {
                    result_type_id,
                    result_id,
                    ..
                } => spirv
                    .id(result_id)
                    .iter_decoration()
                    .find_map(|instruction| match instruction {
                        Instruction::Decorate {
                            decoration:
                                Decoration::SpecId {
                                    specialization_constant_id,
                                },
                            ..
                        } => Some(*specialization_constant_id),
                        _ => None,
                    })
                    .and_then(|constant_id| {
                        let size = match spirv.id(result_type_id).instruction() {
                            Instruction::TypeBool { .. } => {
                                // Translate bool to Bool32
                                std::mem::size_of::<ash::vk::Bool32>() as DeviceSize
                            }
                            _ => size_of_type(spirv, result_type_id)
                                .expect("Found runtime-sized specialization constant"),
                        };
                        Some((constant_id, SpecializationConstantRequirements { size }))
                    }),
                _ => None,
            }
        })
        .collect()
}
/// Extracts the `SpecializationConstantRequirements` from `spirv`.
Extracts the `SpecializationConstantRequirements` from `spirv`.
Extracts the ` SpecializationConstantRequirements ` from ` spirv ` .
fn specialization_constant_requirements(
    spirv: &Spirv,
) -> FnvHashMap<u32, SpecializationConstantRequirements> {
    spirv
        .iter_global()
        .filter_map(|instruction| {
            match instruction {
                &Instruction::SpecConstantTrue {
                    result_type_id,
                    result_id,
                }
                | &Instruction::SpecConstantFalse {
                    result_type_id,
                    result_id,
                }
                | &Instruction::SpecConstant {
                    result_type_id,
                    result_id,
                    ..
                }
                | &Instruction::SpecConstantComposite {
                    result_type_id,
                    result_id,
                    ..
                } => spirv
                    .id(result_id)
                    .iter_decoration()
                    .find_map(|instruction| match instruction {
                        Instruction::Decorate {
                            decoration:
                                Decoration::SpecId {
                                    specialization_constant_id,
                                },
                            ..
                        } => Some(*specialization_constant_id),
                        _ => None,
                    })
                    .and_then(|constant_id| {
                        let size = match spirv.id(result_type_id).instruction() {
                            Instruction::TypeBool { .. } => {
                                // Translate bool to Bool32
                                std::mem::size_of::<ash::vk::Bool32>() as DeviceSize
                            }
                            _ => size_of_type(spirv, result_type_id)
                                .expect("Found runtime-sized specialization constant"),
                        };
                        Some((constant_id, SpecializationConstantRequirements { size }))
                    }),
                _ => None,
            }
        })
        .collect()
}
fn specialization_constant_requirements ( spirv : & Spirv , ) -> FnvHashMap < u32 , SpecializationConstantRequirements > { spirv . iter_global ( ) . filter_map ( | instruction | { match instruction { & Instruction :: SpecConstantTrue { result_type_id , result_id , } | & Instruction :: SpecConstantFalse { result_type_id , result_id , } | & Instruction :: SpecConstant { result_type_id , result_id , .. } | & Instruction :: SpecConstantComposite { result_type_id , result_id , .. } => spirv . id ( result_id ) . iter_decoration ( ) . find_map ( | instruction | match instruction { Instruction :: Decorate { decoration : Decoration :: SpecId { specialization_constant_id , } , .. } => Some ( * specialization_constant_id ) , _ => None , } ) . and_then ( | constant_id | { let size = match spirv . id ( result_type_id ) . instruction ( ) { Instruction :: TypeBool { .. } => { // Translate bool to Bool32 std :: mem :: size_of :: < ash :: vk :: Bool32 > ( ) as DeviceSize } _ => size_of_type ( spirv , result_type_id ) . expect ( " " ) , } ; Some ( ( constant_id , SpecializationConstantRequirements { size } ) ) } ) , _ => None , } } ) . collect ( ) }
Extracts the `SpecializationConstantRequirements` from `spirv`.
Extracts the ` SpecializationConstantRequirements ` from ` spirv ` .
spirv
&Spirv
spirv
&Spirv