From fa44d9d5369378be47cc12fe407651d01992a2ea Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Mon, 11 Apr 2022 06:42:02 +0200 Subject: [PATCH] [glsl-in] error on a `matCx2` used with the std140 layout (#1806) --- src/front/glsl/error.rs | 6 ++++++ src/front/glsl/offset.rs | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/front/glsl/error.rs b/src/front/glsl/error.rs index cd0577a6e8..e1418f1e5c 100644 --- a/src/front/glsl/error.rs +++ b/src/front/glsl/error.rs @@ -94,6 +94,12 @@ pub enum ErrorKind { /// prioritize work. #[error("Unknown layout qualifier: {0}")] UnknownLayoutQualifier(String), + /// Unsupported matrix of the form matCx2 + /// + /// Our IR expects matrices of the form matCx2 to have a stride of 8 however + /// matrices in the std140 layout have a stride of at least 16 + #[error("unsupported matrix of the form matCx2 in std140 block layout")] + UnsupportedMatrixTypeInStd140, /// A variable with the same name already exists in the current scope. #[cfg(feature = "glsl-validate")] #[error("Variable already declared: {0}")] diff --git a/src/front/glsl/offset.rs b/src/front/glsl/offset.rs index 56ee4ab144..9c89b5d2c3 100644 --- a/src/front/glsl/offset.rs +++ b/src/front/glsl/offset.rs @@ -121,6 +121,14 @@ pub fn calculate_offset( align = align_up(align, 16); } + // See comment on the error kind + if StructLayout::Std140 == layout && rows == crate::VectorSize::Bi { + errors.push(Error { + kind: ErrorKind::UnsupportedMatrixTypeInStd140, + meta, + }); + } + (align, align * columns as u32) } TypeInner::Struct { ref members, .. } => {