mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[spv-in] error on unsupported matrix stride
This commit is contained in:
@@ -43,6 +43,13 @@ pub enum Error {
|
||||
UnsupportedBinaryOperator(spirv::Word),
|
||||
#[error("Naga supports OpTypeRuntimeArray in the StorageBuffer storage class only")]
|
||||
UnsupportedRuntimeArrayStorageClass,
|
||||
#[error("unsupported matrix stride {stride} for a {columns}x{rows} matrix with scalar width={width}")]
|
||||
UnsupportedMatrixStride {
|
||||
stride: u32,
|
||||
columns: u8,
|
||||
rows: u8,
|
||||
width: u8,
|
||||
},
|
||||
#[error("unknown binary operator {0:?}")]
|
||||
UnknownBinaryOperator(spirv::Op),
|
||||
#[error("unknown relational function {0:?}")]
|
||||
|
||||
@@ -4208,19 +4208,15 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
} = *inner
|
||||
{
|
||||
if let Some(stride) = decor.matrix_stride {
|
||||
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,
|
||||
let aligned_rows = if rows > crate::VectorSize::Bi { 4 } else { 2 };
|
||||
let expected_stride = aligned_rows * width as u32;
|
||||
if stride.get() != expected_stride {
|
||||
return Err(Error::UnsupportedMatrixStride {
|
||||
stride: stride.get(),
|
||||
columns: columns as u8,
|
||||
rows: rows as u8,
|
||||
width,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user