diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-12-10 10:43:53 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-12-10 16:53:06 +0100 |
commit | 53804f553d446c962764ba3365a8b390436fceb4 (patch) | |
tree | 46fb176a592cf77b0a24dc741ee8d6e7e1cbb603 | |
parent | 979b9335e5cec4a4556624dfab06d088b82cec36 (diff) |
rhi: gl: Destructure mat3 correctly
As per std140 packing rules.
Change-Id: I85663d36a9fa617ea387e8f201677471b2ebd948
Fixes: QTBUG-80655
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
-rw-r--r-- | src/gui/rhi/qrhigles2.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 563d59b318..e4490ceedb 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2428,7 +2428,15 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC f->glUniformMatrix2fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast<const float *>(src)); break; case QShaderDescription::Mat3: - f->glUniformMatrix3fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast<const float *>(src)); + { + // 4 floats per column (or row, if row-major) + float mat[9]; + const float *srcMat = reinterpret_cast<const float *>(src); + memcpy(mat, srcMat, 3 * sizeof(float)); + memcpy(mat + 3, srcMat + 4, 3 * sizeof(float)); + memcpy(mat + 6, srcMat + 8, 3 * sizeof(float)); + f->glUniformMatrix3fv(uniform.glslLocation, 1, GL_FALSE, mat); + } break; case QShaderDescription::Mat4: f->glUniformMatrix4fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast<const float *>(src)); |