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
if (targetUniform->typeInfo.isSampler)
{
ASSERT(uniformType == GL_INT);
memcpy(&targetUniform->mSamplerData[locationInfo.element], v, count * sizeof(T));
mDirtySamplerMapping = true;
size_t size = count * sizeof(T);
auto dest = &targetUniform->mSamplerData[locationInfo.element];
if (memcmp(dest, v, size) != 0)
{
memcpy(dest, v, size);
mDirtySamplerMapping = true;
}
return;
}
......@@ -2233,7 +2238,7 @@ void ProgramD3D::setUniformInternal(GLint location, GLsizei count, const T *v, G
}
template <int cols, int rows>
void ProgramD3D::setUniformMatrixfvImpl(GLint location,
bool ProgramD3D::setUniformMatrixfvImpl(GLint location,
GLsizei countIn,
GLboolean transpose,
const GLfloat *value,
......@@ -2250,20 +2255,24 @@ void ProgramD3D::setUniformMatrixfvImpl(GLint location,
GLfloat *target = reinterpret_cast<GLfloat *>(targetData + arrayElement * sizeof(GLfloat) *
targetMatrixStride);
bool dirty = false;
for (unsigned int i = 0; i < count; i++)
{
// Internally store matrices as transposed versions to accomodate HLSL matrix indexing
if (transpose == GL_FALSE)
{
TransposeExpandMatrix<GLfloat, cols, rows>(target, value);
dirty = TransposeExpandMatrix<GLfloat, cols, rows>(target, value) || dirty;
}
else
{
ExpandMatrix<GLfloat, cols, rows>(target, value);
dirty = ExpandMatrix<GLfloat, cols, rows>(target, value) || dirty;
}
target += targetMatrixStride;
value += cols * rows;
}
return dirty;
}
template <int cols, int rows>
......@@ -2277,23 +2286,29 @@ void ProgramD3D::setUniformMatrixfvInternal(GLint location,
if (targetUniform->vsData)
{
setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value,
targetUniform->vsData, targetUniformType);
mVertexUniformsDirty = true;
if (setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value,
targetUniform->vsData, targetUniformType))
{
mVertexUniformsDirty = true;
}
}
if (targetUniform->psData)
{
setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value,
targetUniform->psData, targetUniformType);
mFragmentUniformsDirty = true;
if (setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value,
targetUniform->psData, targetUniformType))
{
mFragmentUniformsDirty = true;
}
}
if (targetUniform->csData)
{
setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value,
targetUniform->csData, targetUniformType);
mComputeUniformsDirty = true;
if (setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value,
targetUniform->csData, targetUniformType))
{
mComputeUniformsDirty = true;
}
}
}
......
......@@ -402,7 +402,7 @@ class ProgramD3D : public ProgramImpl
void setUniformInternal(GLint location, GLsizei count, const T *v, GLenum uniformType);
template <int cols, int rows>
void setUniformMatrixfvImpl(GLint location,
bool setUniformMatrixfvImpl(GLint location,
GLsizei count,
GLboolean transpose,
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