[spv-in] refactor the matrix stride check

This commit is contained in:
Dzmitry Malyshau
2021-05-26 00:02:00 -04:00
committed by Dzmitry Malyshau
parent f57739d30b
commit badf99653a
2 changed files with 14 additions and 5 deletions

View File

@@ -108,6 +108,4 @@ pub enum Error {
#[error("invalid barrier memory semantics %{0}")]
InvalidBarrierMemorySemantics(spirv::Word),
// incomplete implementation errors
#[error("unsupported matrix stride {0}")]
UnsupportedMatrixStride(spirv::Word),
}

View File

@@ -2965,14 +2965,25 @@ impl<I: Iterator<Item = u32>> Parser<I> {
let offset = decor.offset.unwrap_or(0);
if let crate::TypeInner::Matrix {
columns: _,
columns,
rows,
width,
} = module.types[ty].inner
{
if let Some(stride) = decor.matrix_stride {
if stride.get() != (rows as u32) * (width as u32) {
return Err(Error::UnsupportedMatrixStride(stride.get()));
let rounded_rows = if rows > crate::VectorSize::Bi {
4
} else {
rows as u32
};
if stride.get() != rounded_rows * (width as u32) {
log::warn!(
"Unexpected matrix stride {} for an {}x{} matrix with scalar width={}",
stride.get(),
columns as u8,
rows as u8,
width,
);
}
}
}