impl Handle<crate::Type> { /// Formats the type as it is written in wgsl. /// /// For example `vec3<f32>`. pubfn to_wgsl(self, gctx: &GlobalCtx) -> String { let ty = &gctx.types[self]; match ty.name {
Some(ref name) => name.clone(),
None => ty.inner.to_wgsl(gctx),
}
}
}
implcrate::TypeInner { /// Formats the type as it is written in wgsl. /// /// For example `vec3<f32>`. /// /// Note: `TypeInner::Struct` doesn't include the name of the /// struct type. Therefore this method will simply return "struct" /// for them. pubfn to_wgsl(&self, gctx: &GlobalCtx) -> String { usecrate::TypeInner as Ti;
match *self {
Ti::Scalar(scalar) => scalar.to_wgsl(),
Ti::Vector { size, scalar } => {
format!("vec{}<{}>", size as u32, scalar.to_wgsl())
}
Ti::Matrix {
columns,
rows,
scalar,
} => {
format!( "mat{}x{}<{}>",
columns as u32,
rows as u32,
scalar.to_wgsl(),
)
}
Ti::Atomic(scalar) => {
format!("atomic<{}>", scalar.to_wgsl())
}
Ti::Pointer { base, .. } => { let name = base.to_wgsl(gctx);
format!("ptr<{name}>")
}
Ti::ValuePointer { scalar, .. } => {
format!("ptr<{}>", scalar.to_wgsl())
}
Ti::Array { base, size, .. } => { let base = base.to_wgsl(gctx); match size { crate::ArraySize::Constant(size) => format!("array<{base}, {size}>"), crate::ArraySize::Pending(_) => unreachable!(), crate::ArraySize::Dynamic => format!("array<{base}>"),
}
}
Ti::Struct { .. } => { // TODO: Actually output the struct? "struct".to_string()
}
Ti::Image {
dim,
arrayed,
class,
} => { let dim_suffix = match dim { crate::ImageDimension::D1 => "_1d", crate::ImageDimension::D2 => "_2d", crate::ImageDimension::D3 => "_3d", crate::ImageDimension::Cube => "_cube",
}; let array_suffix = if arrayed { "_array" } else { "" };
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.