Skip to content

Commit

Permalink
rhi: gl: Destructure mat3 correctly
Browse files Browse the repository at this point in the history
As per std140 packing rules.

Change-Id: I85663d36a9fa617ea387e8f201677471b2ebd948
Fixes: QTBUG-80655
Reviewed-by: Christian Strømme <[email protected]>
  • Loading branch information
alpqr committed Dec 10, 2019
1 parent 979b933 commit 53804f5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gui/rhi/qrhigles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 53804f5

Please sign in to comment.