Avoid unnecessarily copying uniforms
Transpose and expand matrices and float vectors when copied on setUniform (and getUniform) to avoid allocating an array and doing that on applyUniform. Then use straight D3D calls, not D3DX, to possibly avoid another copy. Gets NaCl donuts test from 19->25 fps.
BUG=
TEST=webgl conformance tests
Review URL: http://codereview.appspot.com/5229056
git-svn-id: https://angleproject.googlecode.com/svn/trunk@800 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/utilities.cpp b/src/libGLESv2/utilities.cpp
index 01cca3c..3dba899 100644
--- a/src/libGLESv2/utilities.cpp
+++ b/src/libGLESv2/utilities.cpp
@@ -54,6 +54,42 @@
return 0;
}
+// This is how much data we actually store for a uniform
+int UniformInternalComponentCount(GLenum type)
+{
+ switch (type)
+ {
+ case GL_BOOL:
+ case GL_INT:
+ case GL_SAMPLER_2D:
+ case GL_SAMPLER_CUBE:
+ return 1;
+ case GL_BOOL_VEC2:
+ case GL_INT_VEC2:
+ return 2;
+ case GL_INT_VEC3:
+ case GL_BOOL_VEC3:
+ return 3;
+ case GL_FLOAT:
+ case GL_FLOAT_VEC2:
+ case GL_FLOAT_VEC3:
+ case GL_BOOL_VEC4:
+ case GL_FLOAT_VEC4:
+ case GL_INT_VEC4:
+ return 4;
+ case GL_FLOAT_MAT2:
+ return 8;
+ case GL_FLOAT_MAT3:
+ return 12;
+ case GL_FLOAT_MAT4:
+ return 16;
+ default:
+ UNREACHABLE();
+ }
+
+ return 0;
+}
+
GLenum UniformComponentType(GLenum type)
{
switch(type)
@@ -85,16 +121,22 @@
return GL_NONE;
}
-size_t UniformTypeSize(GLenum type)
+size_t UniformComponentSize(GLenum type)
{
switch(type)
{
case GL_BOOL: return sizeof(GLboolean);
case GL_FLOAT: return sizeof(GLfloat);
case GL_INT: return sizeof(GLint);
+ default: UNREACHABLE();
}
- return UniformTypeSize(UniformComponentType(type)) * UniformComponentCount(type);
+ return 0;
+}
+
+size_t UniformTypeSize(GLenum type)
+{
+ return UniformComponentSize(UniformComponentType(type)) * UniformInternalComponentCount(type);
}
int VariableRowCount(GLenum type)