Skip to content

Commit

Permalink
[naga wgsl-in] Include base when printing pointer and array types.
Browse files Browse the repository at this point in the history
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>`
  • Loading branch information
jimblandy authored and teoxoy committed Nov 17, 2023
1 parent 8859310 commit c9ae35e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions naga/src/front/wgsl/to_wgsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}>"),
Expand Down

0 comments on commit c9ae35e

Please sign in to comment.