Minimizes changes of the depth stencil buffer
TRAC #12154
This patch reduces calls to SetDepthStencilSurface
Signed-off-by: Nicolas Capens
Signed-off-by: Daniel Koch

Author:    Shannon Woods

git-svn-id: https://angleproject.googlecode.com/svn/trunk@261 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index dda0e35..9c9bc3f 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -285,6 +285,7 @@
 void Context::markAllStateDirty()
 {
     mAppliedRenderTargetSerial = 0;
+    mAppliedDepthbufferSerial = 0;
     mAppliedProgram = 0;
 
     mClearStateDirty = true;
@@ -1642,7 +1643,12 @@
         mAppliedRenderTargetSerial = renderTargetSerial;
     }
 
-    device->SetDepthStencilSurface(depthStencil);
+    unsigned int depthbufferSerial = framebufferObject->getDepthbufferSerial();
+    if (depthbufferSerial != mAppliedDepthbufferSerial)
+    {
+        device->SetDepthStencilSurface(depthStencil);
+        mAppliedDepthbufferSerial = depthbufferSerial;
+    }
 
     D3DVIEWPORT9 viewport;
     D3DSURFACE_DESC desc;