Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glsl-in: Fix matrix multiplication check #1953

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/front/glsl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,14 @@ impl Context {
width: right_width,
},
) => {
let dimensions_ok = if op == BinaryOperator::Multiply {
left_columns == right_rows
} else {
left_columns == right_columns && left_rows == right_rows
};

// Check that the two arguments have the same dimensions
if left_columns != right_columns
|| left_rows != right_rows
|| left_width != right_width
{
if !dimensions_ok || left_width != right_width {
parser.errors.push(Error {
kind: ErrorKind::SemanticError(
format!(
Expand Down
4 changes: 4 additions & 0 deletions tests/in/glsl/expressions.frag
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ void ternary(bool a) {
uint nested = a ? (a ? (a ? 2u : 3) : 4u) : 5;
}

void testMatrixMultiplication(mat4x3 a, mat4x4 b) {
mat4x3 c = a * b;
}

out vec4 o_color;
void main() {
privatePointer(global);
Expand Down
13 changes: 13 additions & 0 deletions tests/out/wgsl/expressions-frag.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,19 @@ fn ternary(a_20: bool) {
return;
}

fn testMatrixMultiplication(a_22: mat4x3<f32>, b_18: mat4x4<f32>) {
var a_23: mat4x3<f32>;
var b_19: mat4x4<f32>;
var c_2: mat4x3<f32>;

a_23 = a_22;
b_19 = b_18;
let _e5 = a_23;
let _e6 = b_19;
c_2 = (_e5 * _e6);
return;
}

fn main_1() {
var local_5: f32;

Expand Down