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 ...@@ -1281,21 +1281,22 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorBuf
D3DFORMAT renderTargetFormat = D3DFMT_UNKNOWN; D3DFORMAT renderTargetFormat = D3DFMT_UNKNOWN;
bool renderTargetChanged = false; 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 return error;
RenderTarget9 *renderTarget = NULL; }
gl::Error error = d3d9::GetAttachmentRenderTarget(colorBuffer, &renderTarget); ASSERT(renderTarget);
if (error.isError())
{
return error;
}
ASSERT(renderTarget);
IDirect3DSurface9 *renderTargetSurface = renderTarget->getSurface(); IDirect3DSurface9 *renderTargetSurface = renderTarget->getSurface();
ASSERT(renderTargetSurface); uintptr_t renderTargetUintPtr = reinterpret_cast<uintptr_t>(renderTargetSurface);
ASSERT(renderTargetSurface);
if (renderTargetUintPtr != mAppliedRenderTarget)
{
mDevice->SetRenderTarget(0, renderTargetSurface); mDevice->SetRenderTarget(0, renderTargetSurface);
SafeRelease(renderTargetSurface); SafeRelease(renderTargetSurface);
...@@ -1303,57 +1304,59 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorBuf ...@@ -1303,57 +1304,59 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorBuf
renderTargetHeight = renderTarget->getHeight(); renderTargetHeight = renderTarget->getHeight();
renderTargetFormat = renderTarget->getD3DFormat(); renderTargetFormat = renderTarget->getD3DFormat();
mAppliedRenderTargetSerial = renderTargetSerial; mAppliedRenderTarget = renderTargetUintPtr;
renderTargetChanged = true; renderTargetChanged = true;
} }
unsigned int depthStencilSerial = (depthStencilBuffer != nullptr) ? GetAttachmentSerial(depthStencilBuffer) : 0; unsigned int depthSize = 0;
if (depthStencilSerial != mAppliedDepthStencilSerial || !mDepthStencilInitialized) unsigned int stencilSize = 0;
{
unsigned int depthSize = 0;
unsigned int stencilSize = 0;
// Apply the depth stencil on the device // Apply the depth stencil on the device
if (depthStencilBuffer) if (depthStencilBuffer)
{
RenderTarget9 *depthStencilRenderTarget = NULL;
gl::Error error = d3d9::GetAttachmentRenderTarget(depthStencilBuffer, &depthStencilRenderTarget);
if (error.isError())
{ {
RenderTarget9 *depthStencilRenderTarget = NULL; return error;
gl::Error error = d3d9::GetAttachmentRenderTarget(depthStencilBuffer, &depthStencilRenderTarget); }
if (error.isError()) ASSERT(depthStencilRenderTarget);
{
return error;
}
ASSERT(depthStencilRenderTarget);
IDirect3DSurface9 *depthStencilSurface = depthStencilRenderTarget->getSurface(); IDirect3DSurface9 *depthStencilSurface = depthStencilRenderTarget->getSurface();
ASSERT(depthStencilSurface); uintptr_t depthStencilUintPtr = reinterpret_cast<uintptr_t>(depthStencilSurface);
ASSERT(depthStencilSurface);
if (depthStencilUintPtr != mAppliedDepthStencil || !mDepthStencilInitialized)
{
mDevice->SetDepthStencilSurface(depthStencilSurface); mDevice->SetDepthStencilSurface(depthStencilSurface);
SafeRelease(depthStencilSurface); SafeRelease(depthStencilSurface);
depthSize = depthStencilBuffer->getDepthSize(); depthSize = depthStencilBuffer->getDepthSize();
stencilSize = depthStencilBuffer->getStencilSize(); stencilSize = depthStencilBuffer->getStencilSize();
}
else
{
mDevice->SetDepthStencilSurface(NULL);
}
if (!mDepthStencilInitialized || depthSize != mCurDepthSize) mAppliedDepthStencil = depthStencilUintPtr;
{
mCurDepthSize = depthSize;
mForceSetRasterState = true;
} }
}
else if (mAppliedDepthStencil != 0)
{
mDevice->SetDepthStencilSurface(NULL);
mAppliedDepthStencil = 0;
}
if (!mDepthStencilInitialized || stencilSize != mCurStencilSize) if (!mDepthStencilInitialized || depthSize != mCurDepthSize)
{ {
mCurStencilSize = stencilSize; mCurDepthSize = depthSize;
mForceSetDepthStencilState = true; mForceSetRasterState = true;
} }
mAppliedDepthStencilSerial = depthStencilSerial; if (!mDepthStencilInitialized || stencilSize != mCurStencilSize)
mDepthStencilInitialized = true; {
mCurStencilSize = stencilSize;
mForceSetDepthStencilState = true;
} }
mDepthStencilInitialized = true;
if (renderTargetChanged || !mRenderTargetDescInitialized) if (renderTargetChanged || !mRenderTargetDescInitialized)
{ {
mForceSetScissor = true; mForceSetScissor = true;
...@@ -2173,8 +2176,11 @@ gl::Error Renderer9::clear(const gl::ClearParameters &clearParams, const gl::Fra ...@@ -2173,8 +2176,11 @@ gl::Error Renderer9::clear(const gl::ClearParameters &clearParams, const gl::Fra
void Renderer9::markAllStateDirty() void Renderer9::markAllStateDirty()
{ {
mAppliedRenderTargetSerial = 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.
mAppliedDepthStencilSerial = 0; const uintptr_t dirtyPointer = -1;
mAppliedRenderTarget = dirtyPointer;
mAppliedDepthStencil = dirtyPointer;
mDepthStencilInitialized = false; mDepthStencilInitialized = false;
mRenderTargetDescInitialized = false; mRenderTargetDescInitialized = false;
......
...@@ -260,8 +260,8 @@ class Renderer9 : public RendererD3D ...@@ -260,8 +260,8 @@ class Renderer9 : public RendererD3D
bool mVertexTextureSupport; bool mVertexTextureSupport;
// current render target states // current render target states
unsigned int mAppliedRenderTargetSerial; uintptr_t mAppliedRenderTarget;
unsigned int mAppliedDepthStencilSerial; uintptr_t mAppliedDepthStencil;
bool mDepthStencilInitialized; bool mDepthStencilInitialized;
bool mRenderTargetDescInitialized; bool mRenderTargetDescInitialized;
unsigned int mCurStencilSize; 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