Commit 80823cc8 by Jamie Madill Committed by Commit Bot

D3D: Add memcmp filtering for matrix uniforms.

This was already implemented, it simply hooks it up to the rest of the code. Could improve performance on some badly behaved benchmarks. BUG=angleproject:1390 Change-Id: I539df611d51ca085712fa8022bf8a7c1990afc65 Reviewed-on: https://chromium-review.googlesource.com/663896 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 4148fd74
...@@ -2208,8 +2208,13 @@ void ProgramD3D::setUniformInternal(GLint location, GLsizei count, const T *v, G ...@@ -2208,8 +2208,13 @@ void ProgramD3D::setUniformInternal(GLint location, GLsizei count, const T *v, G
if (targetUniform->typeInfo.isSampler) if (targetUniform->typeInfo.isSampler)
{ {
ASSERT(uniformType == GL_INT); ASSERT(uniformType == GL_INT);
memcpy(&targetUniform->mSamplerData[locationInfo.element], v, count * sizeof(T)); size_t size = count * sizeof(T);
mDirtySamplerMapping = true; auto dest = &targetUniform->mSamplerData[locationInfo.element];
if (memcmp(dest, v, size) != 0)
{
memcpy(dest, v, size);
mDirtySamplerMapping = true;
}
return; return;
} }
...@@ -2233,7 +2238,7 @@ void ProgramD3D::setUniformInternal(GLint location, GLsizei count, const T *v, G ...@@ -2233,7 +2238,7 @@ void ProgramD3D::setUniformInternal(GLint location, GLsizei count, const T *v, G
} }
template <int cols, int rows> template <int cols, int rows>
void ProgramD3D::setUniformMatrixfvImpl(GLint location, bool ProgramD3D::setUniformMatrixfvImpl(GLint location,
GLsizei countIn, GLsizei countIn,
GLboolean transpose, GLboolean transpose,
const GLfloat *value, const GLfloat *value,
...@@ -2250,20 +2255,24 @@ void ProgramD3D::setUniformMatrixfvImpl(GLint location, ...@@ -2250,20 +2255,24 @@ void ProgramD3D::setUniformMatrixfvImpl(GLint location,
GLfloat *target = reinterpret_cast<GLfloat *>(targetData + arrayElement * sizeof(GLfloat) * GLfloat *target = reinterpret_cast<GLfloat *>(targetData + arrayElement * sizeof(GLfloat) *
targetMatrixStride); targetMatrixStride);
bool dirty = false;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
// Internally store matrices as transposed versions to accomodate HLSL matrix indexing // Internally store matrices as transposed versions to accomodate HLSL matrix indexing
if (transpose == GL_FALSE) if (transpose == GL_FALSE)
{ {
TransposeExpandMatrix<GLfloat, cols, rows>(target, value); dirty = TransposeExpandMatrix<GLfloat, cols, rows>(target, value) || dirty;
} }
else else
{ {
ExpandMatrix<GLfloat, cols, rows>(target, value); dirty = ExpandMatrix<GLfloat, cols, rows>(target, value) || dirty;
} }
target += targetMatrixStride; target += targetMatrixStride;
value += cols * rows; value += cols * rows;
} }
return dirty;
} }
template <int cols, int rows> template <int cols, int rows>
...@@ -2277,23 +2286,29 @@ void ProgramD3D::setUniformMatrixfvInternal(GLint location, ...@@ -2277,23 +2286,29 @@ void ProgramD3D::setUniformMatrixfvInternal(GLint location,
if (targetUniform->vsData) if (targetUniform->vsData)
{ {
setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value, if (setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value,
targetUniform->vsData, targetUniformType); targetUniform->vsData, targetUniformType))
mVertexUniformsDirty = true; {
mVertexUniformsDirty = true;
}
} }
if (targetUniform->psData) if (targetUniform->psData)
{ {
setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value, if (setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value,
targetUniform->psData, targetUniformType); targetUniform->psData, targetUniformType))
mFragmentUniformsDirty = true; {
mFragmentUniformsDirty = true;
}
} }
if (targetUniform->csData) if (targetUniform->csData)
{ {
setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value, if (setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value,
targetUniform->csData, targetUniformType); targetUniform->csData, targetUniformType))
mComputeUniformsDirty = true; {
mComputeUniformsDirty = true;
}
} }
} }
......
...@@ -402,7 +402,7 @@ class ProgramD3D : public ProgramImpl ...@@ -402,7 +402,7 @@ class ProgramD3D : public ProgramImpl
void setUniformInternal(GLint location, GLsizei count, const T *v, GLenum uniformType); void setUniformInternal(GLint location, GLsizei count, const T *v, GLenum uniformType);
template <int cols, int rows> template <int cols, int rows>
void setUniformMatrixfvImpl(GLint location, bool setUniformMatrixfvImpl(GLint location,
GLsizei count, GLsizei count,
GLboolean transpose, GLboolean transpose,
const GLfloat *value, const GLfloat *value,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment