DX9/DX11: Fix and simplify ClearScreen. At least fixes a small glitch in Super Mario Sunshine with DX11, might fix several other things as well in both plugins though (so test this, please!)

Explanation of this commit: We only have to care about four BP registers in ClearScreen, the remaining API state should be reset. The colorEnable and alphaEnable parameters are obsolete, for some reason directly using them caused the SMS glitch with DX11 (because of that bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24 check in BPFunctions.cpp, is this one actually correct?)

The comment in BPFunctions.cpp was at least misleading (if not even wrong), so I removed it.

For what it's worth, someone needs to port this to the OpenGL and Software plugins (unless they're doing this properly already)


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6327 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX
2010-11-01 19:13:50 +00:00
parent b75a805859
commit 48859da6e3
5 changed files with 33 additions and 57 deletions

View File

@ -990,7 +990,15 @@ void UpdateViewport()
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
{
// Update the view port for clearing the picture
// Reset rendering pipeline while keeping color masks and depth buffer settings
ResetAPIState();
SetDepthMode();
SetColorMask();
if (zEnable) // other depth functions don't make sense here
D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
// Update the view port for clearing the whole EFB texture
TargetRectangle targetRc = ConvertEFBRectangle(rc);
D3DVIEWPORT9 vp;
vp.X = targetRc.left;
@ -1000,23 +1008,8 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
vp.MinZ = 0.0;
vp.MaxZ = 1.0;
D3D::dev->SetViewport(&vp);
// Always set the scissor in case it was set by the game and has not been reset
RECT sicr;
sicr.left = targetRc.left;
sicr.top = targetRc.top;
sicr.right = targetRc.right;
sicr.bottom = targetRc.bottom;
D3D::dev->SetScissorRect(&sicr);
D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false);
if (zEnable)
D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
D3D::drawClearQuad(color, (z & 0xFFFFFF) / float(0xFFFFFF), PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader());
if (zEnable)
D3D::RefreshRenderState(D3DRS_ZFUNC);
D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
UpdateViewport();
SetScissorRect();
RestoreAPIState();
}
void Renderer::SetBlendMode(bool forceUpdate)