[naga wgsl-in] Include base when printing pointer and array types.

When formatting `TypeInner::Pointer` and `TypeInner::Array` as WGSL
source code, bother to actually generate text for the target/element
type. This avoids producing ridiculous messages like:

> the type of `foo` is expected to be `array<unknown, 2>`, but got `array<unknown, 2>`
This commit is contained in:
Jim Blandy 2023-11-17 11:07:42 -08:00 committed by Teodor Tanasoaia
parent 8859310be2
commit c9ae35edbb

View File

@ -57,16 +57,14 @@ impl crate::TypeInner {
format!("atomic<{}>", scalar.to_wgsl())
}
Ti::Pointer { base, .. } => {
let base = &gctx.types[base];
let name = base.name.as_deref().unwrap_or("unknown");
let name = base.to_wgsl(gctx);
format!("ptr<{name}>")
}
Ti::ValuePointer { scalar, .. } => {
format!("ptr<{}>", scalar.to_wgsl())
}
Ti::Array { base, size, .. } => {
let member_type = &gctx.types[base];
let base = member_type.name.as_deref().unwrap_or("unknown");
let base = base.to_wgsl(gctx);
match size {
crate::ArraySize::Constant(size) => format!("array<{base}, {size}>"),
crate::ArraySize::Dynamic => format!("array<{base}>"),