summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2017-09-06 15:58:12 +0200
committerSean Harmer <sean.harmer@kdab.com>2017-09-06 14:00:00 +0000
commite9e3208dd7c2e2f755948b1838faa94c2802cc30 (patch)
tree7fe2c79b872bac364e567308ec2fa27bb78d16ef
parent2e4acacfa3a062b8585226500f6cbc65597b8b67 (diff)
GraphicsHelperGL2: Remember to set raw byte size
If one ended up with this helper then the applyUniform would lead to a divide by zero for any type. As a side-effect, the support for more matrix types needed to be done for unit tests to keep passing. Change-Id: I66c8a2eb7e5617f2fed96c689cb4ebc024ef9853 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/render/graphicshelpers/graphicshelpergl2.cpp25
-rw-r--r--tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp6
2 files changed, 31 insertions, 0 deletions
diff --git a/src/render/graphicshelpers/graphicshelpergl2.cpp b/src/render/graphicshelpers/graphicshelpergl2.cpp
index a4f5dd856..001176cd4 100644
--- a/src/render/graphicshelpers/graphicshelpergl2.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl2.cpp
@@ -178,6 +178,7 @@ QVector<ShaderUniform> GraphicsHelperGL2::programUniformsAndLocations(GLuint pro
uniformName[sizeof(uniformName) - 1] = '\0';
uniform.m_location = m_funcs->glGetUniformLocation(programId, uniformName);
uniform.m_name = QString::fromUtf8(uniformName, uniformNameLength);
+ uniform.m_rawByteSize = uniformByteSize(uniform);
uniforms.append(uniform);
}
return uniforms;
@@ -460,14 +461,38 @@ uint GraphicsHelperGL2::uniformByteSize(const ShaderUniform &description)
rawByteSize = matrixStride ? 2 * matrixStride : 16;
break;
+ case GL_FLOAT_MAT2x4:
+ rawByteSize = matrixStride ? 2 * matrixStride : 32;
+ break;
+
+ case GL_FLOAT_MAT4x2:
+ rawByteSize = matrixStride ? 4 * matrixStride : 32;
+ break;
+
case GL_FLOAT_MAT3:
rawByteSize = matrixStride ? 3 * matrixStride : 36;
break;
+ case GL_FLOAT_MAT2x3:
+ rawByteSize = matrixStride ? 2 * matrixStride : 24;
+ break;
+
+ case GL_FLOAT_MAT3x2:
+ rawByteSize = matrixStride ? 3 * matrixStride : 24;
+ break;
+
case GL_FLOAT_MAT4:
rawByteSize = matrixStride ? 4 * matrixStride : 64;
break;
+ case GL_FLOAT_MAT4x3:
+ rawByteSize = matrixStride ? 4 * matrixStride : 48;
+ break;
+
+ case GL_FLOAT_MAT3x4:
+ rawByteSize = matrixStride ? 3 * matrixStride : 48;
+ break;
+
case GL_BOOL:
rawByteSize = 1;
break;
diff --git a/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp b/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp
index 5a6f87e23..afd56e9bd 100644
--- a/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp
+++ b/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp
@@ -922,7 +922,13 @@ private Q_SLOTS:
ADD_UNIFORM_ENTRY(fragCodeUniformsInt, "multiplierVec4", GL_INT_VEC4, 1, 4 * 4);
ADD_UNIFORM_ENTRY(fragCodeUniformsFloatMatrices, "m2", GL_FLOAT_MAT2, 1, 4 * 2 * 2);
+ ADD_UNIFORM_ENTRY(fragCodeUniformsFloatMatrices, "m23", GL_FLOAT_MAT2x3, 1, 4 * 2 * 3);
+ ADD_UNIFORM_ENTRY(fragCodeUniformsFloatMatrices, "m32", GL_FLOAT_MAT3x2, 1, 4 * 3 * 2);
+ ADD_UNIFORM_ENTRY(fragCodeUniformsFloatMatrices, "m24", GL_FLOAT_MAT2x4, 1, 4 * 2 * 4);
+ ADD_UNIFORM_ENTRY(fragCodeUniformsFloatMatrices, "m42", GL_FLOAT_MAT4x2, 1, 4 * 4 * 2);
ADD_UNIFORM_ENTRY(fragCodeUniformsFloatMatrices, "m3", GL_FLOAT_MAT3, 1, 4 * 3 * 3);
+ ADD_UNIFORM_ENTRY(fragCodeUniformsFloatMatrices, "m34", GL_FLOAT_MAT3x4, 1, 4 * 3 * 4);
+ ADD_UNIFORM_ENTRY(fragCodeUniformsFloatMatrices, "m43", GL_FLOAT_MAT4x3, 1, 4 * 4 * 3);
ADD_UNIFORM_ENTRY(fragCodeUniformsFloatMatrices, "m4", GL_FLOAT_MAT4, 1, 4 * 4 * 4);
ADD_UNIFORM_ENTRY(fragCodeSamplers, "s1", GL_SAMPLER_1D, 1, 4);