From ef1fa71bba643f931d458560d895688eaad1d1e7 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Tue, 23 Jul 2019 12:22:40 +0200 Subject: [PATCH] Unpack vector expression in Matrix-Vector multiplies. --- .../packing/matrix-multiply-unpacked-row-major-2.comp | 8 ++++---- spirv_glsl.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/reference/shaders-msl-no-opt/packing/matrix-multiply-unpacked-row-major-2.comp b/reference/shaders-msl-no-opt/packing/matrix-multiply-unpacked-row-major-2.comp index c6d36f10..ab728231 100644 --- a/reference/shaders-msl-no-opt/packing/matrix-multiply-unpacked-row-major-2.comp +++ b/reference/shaders-msl-no-opt/packing/matrix-multiply-unpacked-row-major-2.comp @@ -15,9 +15,9 @@ struct SSBO kernel void main0(device SSBO& _11 [[buffer(0)]]) { - _11.v0 = _11.v1 * (float3x3(float3(_11.m1[0]), float3(_11.m1[1]), float3(_11.m1[2])) * float3x3(float3(_11.m0[0]), float3(_11.m0[1]), float3(_11.m0[2]))); - _11.v0 = (_11.v1 * float3x3(float3(_11.m1[0]), float3(_11.m1[1]), float3(_11.m1[2]))) * float3x3(float3(_11.m0[0]), float3(_11.m0[1]), float3(_11.m0[2])); - _11.v0 = float3x3(float3(_11.m1[0]), float3(_11.m1[1]), float3(_11.m1[2])) * (float3x3(float3(_11.m0[0]), float3(_11.m0[1]), float3(_11.m0[2])) * _11.v1); - _11.v0 = (float3x3(float3(_11.m1[0]), float3(_11.m1[1]), float3(_11.m1[2])) * float3x3(float3(_11.m0[0]), float3(_11.m0[1]), float3(_11.m0[2]))) * _11.v1; + _11.v0 = float3(_11.v1) * (float3x3(float3(_11.m1[0]), float3(_11.m1[1]), float3(_11.m1[2])) * float3x3(float3(_11.m0[0]), float3(_11.m0[1]), float3(_11.m0[2]))); + _11.v0 = (float3(_11.v1) * float3x3(float3(_11.m1[0]), float3(_11.m1[1]), float3(_11.m1[2]))) * float3x3(float3(_11.m0[0]), float3(_11.m0[1]), float3(_11.m0[2])); + _11.v0 = float3x3(float3(_11.m1[0]), float3(_11.m1[1]), float3(_11.m1[2])) * (float3x3(float3(_11.m0[0]), float3(_11.m0[1]), float3(_11.m0[2])) * float3(_11.v1)); + _11.v0 = (float3x3(float3(_11.m1[0]), float3(_11.m1[1]), float3(_11.m1[2])) * float3x3(float3(_11.m0[0]), float3(_11.m0[1]), float3(_11.m0[2]))) * float3(_11.v1); } diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 72718ee8..ca13192d 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -8330,9 +8330,9 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) string expr; if (opcode == OpMatrixTimesVector) - expr = join(to_enclosed_expression(ops[3]), " * ", enclose_expression(to_unpacked_row_major_matrix_expression(ops[2]))); + expr = join(to_enclosed_unpacked_expression(ops[3]), " * ", enclose_expression(to_unpacked_row_major_matrix_expression(ops[2]))); else - expr = join(enclose_expression(to_unpacked_row_major_matrix_expression(ops[3])), " * ", to_enclosed_expression(ops[2])); + expr = join(enclose_expression(to_unpacked_row_major_matrix_expression(ops[3])), " * ", to_enclosed_unpacked_expression(ops[2])); bool forward = should_forward(ops[2]) && should_forward(ops[3]); emit_op(ops[0], ops[1], expr, forward);