Add separate dirty bits for Pixel and Fragment uniforms.

Also use a single UpdateSubresource call to update the buffer.
Should improve performance on some benchmarks.

BUG=angleproject:1390

Change-Id: I70d54d86d3d3beb0e2caee86338ee03081070ac8
Reviewed-on: https://chromium-review.googlesource.com/663895
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/ProgramD3D.cpp b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
index 2c1bbb2..8cd7485 100644
--- a/src/libANGLE/renderer/d3d/ProgramD3D.cpp
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
@@ -558,7 +558,9 @@
       mUsedComputeSamplerRange(0),
       mDirtySamplerMapping(true),
       mSerial(issueSerial()),
-      mUniformsDirty(true)
+      mVertexUniformsDirty(true),
+      mFragmentUniformsDirty(true),
+      mComputeUniformsDirty(true)
 {
     mDynamicHLSL = new DynamicHLSL(renderer);
 }
@@ -1833,7 +1835,16 @@
 
 void ProgramD3D::dirtyAllUniforms()
 {
-    mUniformsDirty = true;
+    mVertexUniformsDirty   = true;
+    mFragmentUniformsDirty = true;
+    mComputeUniformsDirty  = true;
+}
+
+void ProgramD3D::markUniformsClean()
+{
+    mVertexUniformsDirty   = false;
+    mFragmentUniformsDirty = false;
+    mComputeUniformsDirty  = false;
 }
 
 void ProgramD3D::setUniform1fv(GLint location, GLsizei count, const GLfloat *v)
@@ -2194,8 +2205,6 @@
     const gl::VariableLocation &locationInfo = mState.getUniformLocations()[location];
     D3DUniform *targetUniform                = mD3DUniforms[locationInfo.index];
 
-    mUniformsDirty = true;
-
     if (targetUniform->typeInfo.isSampler)
     {
         ASSERT(uniformType == GL_INT);
@@ -2207,16 +2216,19 @@
     if (targetUniform->vsData)
     {
         setUniformImpl(locationInfo, count, v, targetUniform->vsData, uniformType);
+        mVertexUniformsDirty = true;
     }
 
     if (targetUniform->psData)
     {
         setUniformImpl(locationInfo, count, v, targetUniform->psData, uniformType);
+        mFragmentUniformsDirty = true;
     }
 
     if (targetUniform->csData)
     {
         setUniformImpl(locationInfo, count, v, targetUniform->csData, uniformType);
+        mComputeUniformsDirty = true;
     }
 }
 
@@ -2252,8 +2264,6 @@
         target += targetMatrixStride;
         value += cols * rows;
     }
-
-    mUniformsDirty = true;
 }
 
 template <int cols, int rows>
@@ -2269,18 +2279,21 @@
     {
         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 (targetUniform->csData)
     {
         setUniformMatrixfvImpl<cols, rows>(location, countIn, transpose, value,
                                            targetUniform->csData, targetUniformType);
+        mComputeUniformsDirty = true;
     }
 }
 
@@ -2423,7 +2436,7 @@
 
     mGeometryShaderPreamble.clear();
 
-    mUniformsDirty = true;
+    dirtyAllUniforms();
 
     mCachedPixelExecutableIndex.reset();
     mCachedVertexExecutableIndex.reset();