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
parent a79f9d18
......@@ -285,6 +285,7 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
void Context::markAllStateDirty()
{
mAppliedRenderTargetSerial = 0;
mAppliedDepthbufferSerial = 0;
mAppliedProgram = 0;
mClearStateDirty = true;
......@@ -1642,7 +1643,12 @@ bool Context::applyRenderTarget(bool ignoreViewport)
mAppliedRenderTargetSerial = renderTargetSerial;
}
device->SetDepthStencilSurface(depthStencil);
unsigned int depthbufferSerial = framebufferObject->getDepthbufferSerial();
if (depthbufferSerial != mAppliedDepthbufferSerial)
{
device->SetDepthStencilSurface(depthStencil);
mAppliedDepthbufferSerial = depthbufferSerial;
}
D3DVIEWPORT9 viewport;
D3DSURFACE_DESC desc;
......
......@@ -446,6 +446,7 @@ class Context
unsigned int mAppliedProgram;
unsigned int mAppliedRenderTargetSerial;
unsigned int mAppliedDepthbufferSerial;
const char *mPsProfile;
const char *mVsProfile;
......
......@@ -116,6 +116,19 @@ IDirect3DSurface9 *Framebuffer::getRenderTarget()
return NULL;
}
unsigned int Framebuffer::getDepthbufferSerial()
{
gl::Context *context = gl::getContext();
Depthbuffer *depthbuffer = context->getDepthbuffer(mDepthbufferHandle);
if (depthbuffer)
{
return depthbuffer->getSerial();
}
return 0;
}
IDirect3DSurface9 *Framebuffer::getDepthStencil()
{
gl::Context *context = gl::getContext();
......
......@@ -40,6 +40,7 @@ class Framebuffer
IDirect3DSurface9 *getDepthStencil();
unsigned int getRenderTargetSerial();
unsigned int getDepthbufferSerial();
Colorbuffer *getColorbuffer();
Depthbuffer *getDepthbuffer();
......
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