Skip to content

Commit

Permalink
Correct alignment for buffer pointer TypeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeagc committed Sep 6, 2023
1 parent 133125c commit 5e0b5cb
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/valid/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,16 @@ impl super::Validator {
TypeFlags::empty()
};

let alignment = if let As::PhysicalStorage { .. } = space {
// Buffer pointers require proper alignment.
Alignment::BUFFER_POINTER
} else {
Alignment::ONE
};

TypeInfo::new(
data_flag | argument_flag | TypeFlags::SIZED | TypeFlags::COPY,
Alignment::ONE,
alignment,
)
}
Ti::ValuePointer {
Expand Down Expand Up @@ -396,9 +403,16 @@ impl super::Validator {
TypeFlags::empty()
};

let alignment = if let As::PhysicalStorage { .. } = space {
// Buffer pointers require proper alignment.
Alignment::BUFFER_POINTER
} else {
Alignment::ONE
};

TypeInfo::new(
data_flag | argument_flag | TypeFlags::SIZED | TypeFlags::COPY,
Alignment::ONE,
alignment,
)
}
Ti::Array { base, size, stride } => {
Expand Down

0 comments on commit 5e0b5cb

Please sign in to comment.