Commit 358c8a95 by Geoff Lang

Track bound render targets in D3D9 with uintptr_t and dirty them with -1.

BUG=447419 Change-Id: Ia77e3b00db0f327eb278285de14cd438c5cf538b Reviewed-on: https://chromium-review.googlesource.com/244664Tested-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent cf077794
......@@ -1281,21 +1281,22 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorBuf
D3DFORMAT renderTargetFormat = D3DFMT_UNKNOWN;
bool renderTargetChanged = false;
unsigned int renderTargetSerial = GetAttachmentSerial(colorBuffer);
if (renderTargetSerial != mAppliedRenderTargetSerial)
// Apply the render target on the device
RenderTarget9 *renderTarget = NULL;
gl::Error error = d3d9::GetAttachmentRenderTarget(colorBuffer, &renderTarget);
if (error.isError())
{
// Apply the render target on the device
RenderTarget9 *renderTarget = NULL;
gl::Error error = d3d9::GetAttachmentRenderTarget(colorBuffer, &renderTarget);
if (error.isError())
{
return error;
}
ASSERT(renderTarget);
return error;
}
ASSERT(renderTarget);
IDirect3DSurface9 *renderTargetSurface = renderTarget->getSurface();
ASSERT(renderTargetSurface);
IDirect3DSurface9 *renderTargetSurface = renderTarget->getSurface();
uintptr_t renderTargetUintPtr = reinterpret_cast<uintptr_t>(renderTargetSurface);
ASSERT(renderTargetSurface);
if (renderTargetUintPtr != mAppliedRenderTarget)
{
mDevice->SetRenderTarget(0, renderTargetSurface);
SafeRelease(renderTargetSurface);
......@@ -1303,57 +1304,59 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorBuf
renderTargetHeight = renderTarget->getHeight();
renderTargetFormat = renderTarget->getD3DFormat();
mAppliedRenderTargetSerial = renderTargetSerial;
mAppliedRenderTarget = renderTargetUintPtr;
renderTargetChanged = true;
}
unsigned int depthStencilSerial = (depthStencilBuffer != nullptr) ? GetAttachmentSerial(depthStencilBuffer) : 0;
if (depthStencilSerial != mAppliedDepthStencilSerial || !mDepthStencilInitialized)
{
unsigned int depthSize = 0;
unsigned int stencilSize = 0;
unsigned int depthSize = 0;
unsigned int stencilSize = 0;
// Apply the depth stencil on the device
if (depthStencilBuffer)
// Apply the depth stencil on the device
if (depthStencilBuffer)
{
RenderTarget9 *depthStencilRenderTarget = NULL;
gl::Error error = d3d9::GetAttachmentRenderTarget(depthStencilBuffer, &depthStencilRenderTarget);
if (error.isError())
{
RenderTarget9 *depthStencilRenderTarget = NULL;
gl::Error error = d3d9::GetAttachmentRenderTarget(depthStencilBuffer, &depthStencilRenderTarget);
if (error.isError())
{
return error;
}
ASSERT(depthStencilRenderTarget);
return error;
}
ASSERT(depthStencilRenderTarget);
IDirect3DSurface9 *depthStencilSurface = depthStencilRenderTarget->getSurface();
ASSERT(depthStencilSurface);
IDirect3DSurface9 *depthStencilSurface = depthStencilRenderTarget->getSurface();
uintptr_t depthStencilUintPtr = reinterpret_cast<uintptr_t>(depthStencilSurface);
ASSERT(depthStencilSurface);
if (depthStencilUintPtr != mAppliedDepthStencil || !mDepthStencilInitialized)
{
mDevice->SetDepthStencilSurface(depthStencilSurface);
SafeRelease(depthStencilSurface);
depthSize = depthStencilBuffer->getDepthSize();
stencilSize = depthStencilBuffer->getStencilSize();
}
else
{
mDevice->SetDepthStencilSurface(NULL);
}
if (!mDepthStencilInitialized || depthSize != mCurDepthSize)
{
mCurDepthSize = depthSize;
mForceSetRasterState = true;
mAppliedDepthStencil = depthStencilUintPtr;
}
}
else if (mAppliedDepthStencil != 0)
{
mDevice->SetDepthStencilSurface(NULL);
mAppliedDepthStencil = 0;
}
if (!mDepthStencilInitialized || stencilSize != mCurStencilSize)
{
mCurStencilSize = stencilSize;
mForceSetDepthStencilState = true;
}
if (!mDepthStencilInitialized || depthSize != mCurDepthSize)
{
mCurDepthSize = depthSize;
mForceSetRasterState = true;
}
mAppliedDepthStencilSerial = depthStencilSerial;
mDepthStencilInitialized = true;
if (!mDepthStencilInitialized || stencilSize != mCurStencilSize)
{
mCurStencilSize = stencilSize;
mForceSetDepthStencilState = true;
}
mDepthStencilInitialized = true;
if (renderTargetChanged || !mRenderTargetDescInitialized)
{
mForceSetScissor = true;
......@@ -2173,8 +2176,11 @@ gl::Error Renderer9::clear(const gl::ClearParameters &clearParams, const gl::Fra
void Renderer9::markAllStateDirty()
{
mAppliedRenderTargetSerial = 0;
mAppliedDepthStencilSerial = 0;
// dirtyPointer is a special value that will make the comparison with any valid pointer fail and force the renderer to re-apply the state.
const uintptr_t dirtyPointer = -1;
mAppliedRenderTarget = dirtyPointer;
mAppliedDepthStencil = dirtyPointer;
mDepthStencilInitialized = false;
mRenderTargetDescInitialized = false;
......
......@@ -260,8 +260,8 @@ class Renderer9 : public RendererD3D
bool mVertexTextureSupport;
// current render target states
unsigned int mAppliedRenderTargetSerial;
unsigned int mAppliedDepthStencilSerial;
uintptr_t mAppliedRenderTarget;
uintptr_t mAppliedDepthStencil;
bool mDepthStencilInitialized;
bool mRenderTargetDescInitialized;
unsigned int mCurStencilSize;
......
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