fn size(&self, module: &GpuModule) -> usize {
        match self {
            GpuTypeDef::Struct(name, fields) => {
                let mut offset = 0;
                if module.enum_variants.contains(name) {
                    offset += 4;
                }
                for (_name, field) in fields {
                    offset += align_padding(offset, field.alignment(module));
                    offset += field.size(module);
                }
                offset
            }
            GpuTypeDef::Enum(en) => {
                let mut max_offset = 4;
                for (_name, fields) in &en.variants {
                    let mut offset = 4;
                    for field in fields {
                        if let GpuType::InlineStruct(_) = field {
                            if offset == 4 {
                                offset = 0;
                            }
                        }
                        // Alignment needs work :/
                        //offset += align_padding(offset, field.alignment(module));
                        offset += field.size(module);
                    }
                    max_offset = max_offset.max(offset);
                }
                max_offset
            }
        }
    }
/// Size of the body of the definition.
Size of the body of the definition.
Size of the body of the definition .
fn size(&self, module: &GpuModule) -> usize {
        match self {
            GpuTypeDef::Struct(name, fields) => {
                let mut offset = 0;
                if module.enum_variants.contains(name) {
                    offset += 4;
                }
                for (_name, field) in fields {
                    offset += align_padding(offset, field.alignment(module));
                    offset += field.size(module);
                }
                offset
            }
            GpuTypeDef::Enum(en) => {
                let mut max_offset = 4;
                for (_name, fields) in &en.variants {
                    let mut offset = 4;
                    for field in fields {
                        if let GpuType::InlineStruct(_) = field {
                            if offset == 4 {
                                offset = 0;
                            }
                        }
                        // Alignment needs work :/
                        //offset += align_padding(offset, field.alignment(module));
                        offset += field.size(module);
                    }
                    max_offset = max_offset.max(offset);
                }
                max_offset
            }
        }
    }
fn size ( & self , module : & GpuModule ) -> usize { match self { GpuTypeDef :: Struct ( name , fields ) => { let mut offset = 0 ; if module . enum_variants . contains ( name ) { offset += 4 ; } for ( _name , field ) in fields { offset += align_padding ( offset , field . alignment ( module ) ) ; offset += field . size ( module ) ; } offset } GpuTypeDef :: Enum ( en ) => { let mut max_offset = 4 ; for ( _name , fields ) in & en . variants { let mut offset = 4 ; for field in fields { if let GpuType :: InlineStruct ( _ ) = field { if offset == 4 { offset = 0 ; } } // Alignment needs work :/ //offset += align_padding(offset, field.alignment(module)); offset += field . size ( module ) ; } max_offset = max_offset . max ( offset ) ; } max_offset } } }
Size of the body of the definition.
Size of the body of the definition .
&self
module
&GpuModule
&self
module
&GpuModule