From 9894867678c389089360bc32886fc89073e26c2d Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Tue, 5 Jan 2021 20:53:10 +0000 Subject: [PATCH] reader/wgsl: Fix parsing of matrices. https://gpuweb.github.io/gpuweb/wgsl.html#matrix-types : "matNxM Matrix of N columns and M rows" Fixed: tint:432 Change-Id: Ib8fdb836b02c5e6be87acea850f095355545adbd Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36421 Auto-Submit: Ben Clayton Commit-Queue: dan sinclair Reviewed-by: dan sinclair --- src/reader/wgsl/parser_impl.cc | 8 ++++---- src/reader/wgsl/parser_impl_type_decl_test.cc | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 9aaea82c7a..493ac840d1 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -1110,14 +1110,14 @@ Expect ParserImpl::expect_type_decl_matrix(Token t) { uint32_t rows = 2; uint32_t columns = 2; if (t.IsMat3x2() || t.IsMat3x3() || t.IsMat3x4()) { - rows = 3; + columns = 3; } else if (t.IsMat4x2() || t.IsMat4x3() || t.IsMat4x4()) { - rows = 4; + columns = 4; } if (t.IsMat2x3() || t.IsMat3x3() || t.IsMat4x3()) { - columns = 3; + rows = 3; } else if (t.IsMat2x4() || t.IsMat3x4() || t.IsMat4x4()) { - columns = 4; + rows = 4; } const char* use = "matrix"; diff --git a/src/reader/wgsl/parser_impl_type_decl_test.cc b/src/reader/wgsl/parser_impl_type_decl_test.cc index 6c11ba1cbe..9251526c23 100644 --- a/src/reader/wgsl/parser_impl_type_decl_test.cc +++ b/src/reader/wgsl/parser_impl_type_decl_test.cc @@ -604,8 +604,8 @@ TEST_F(ParserImplTest, TypeDecl_Array_MissingComma) { struct MatrixData { const char* input; - size_t rows; size_t columns; + size_t rows; }; inline std::ostream& operator<<(std::ostream& out, MatrixData data) { out << std::string(data.input);