From 120af4261615379c1170845e3fed667a259b891c Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Wed, 14 Oct 2020 16:07:10 +0200 Subject: [PATCH] GLSL: Use need_transpose when checking for non-native matrix. --- spirv_glsl.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 130c2884..dd5a0d9e 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -12040,18 +12040,11 @@ bool CompilerGLSL::is_non_native_row_major_matrix(uint32_t id) if (backend.native_row_major_matrix && !is_legacy()) return false; - // Non-matrix or column-major matrix types do not need to be converted. - if (!has_decoration(id, DecorationRowMajor)) - return false; - - // Only square row-major matrices can be converted at this time. - // Converting non-square matrices will require defining custom GLSL function that - // swaps matrix elements while retaining the original dimensional form of the matrix. - const auto type = expression_type(id); - if (type.columns != type.vecsize) - SPIRV_CROSS_THROW("Row-major matrices must be square on this platform."); - - return true; + auto *e = maybe_get(id); + if (e) + return e->need_transpose; + else + return has_decoration(id, DecorationRowMajor); } // Checks whether the member is a row_major matrix that requires conversion before use