mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 00:59:44 -06:00
Various ClearScreen fixes.
Will fix some games and break some others. Assist trophies in SSBB work fine now, Super Mario Sunshine is a little broken again. Still needs some more work... git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6627 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -462,9 +462,12 @@ bool Renderer::SetScissorRect()
|
||||
|
||||
void Renderer::SetColorMask()
|
||||
{
|
||||
// Only enable alpha channel if it's supported by the current EFB format
|
||||
UINT8 color_mask = 0;
|
||||
if (bpmem.blendmode.alphaupdate) color_mask |= D3D11_COLOR_WRITE_ENABLE_ALPHA;
|
||||
if (bpmem.blendmode.colorupdate) color_mask |= D3D11_COLOR_WRITE_ENABLE_RED | D3D11_COLOR_WRITE_ENABLE_GREEN | D3D11_COLOR_WRITE_ENABLE_BLUE;
|
||||
if (bpmem.blendmode.alphaupdate && (bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24))
|
||||
color_mask = D3D11_COLOR_WRITE_ENABLE_ALPHA;
|
||||
if (bpmem.blendmode.colorupdate)
|
||||
color_mask |= D3D11_COLOR_WRITE_ENABLE_RED | D3D11_COLOR_WRITE_ENABLE_GREEN | D3D11_COLOR_WRITE_ENABLE_BLUE;
|
||||
D3D::gfxstate->SetRenderTargetWriteMask(color_mask);
|
||||
}
|
||||
|
||||
@ -688,14 +691,15 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
|
||||
{
|
||||
ResetAPIState();
|
||||
|
||||
if (bpmem.blendmode.colorupdate && bpmem.blendmode.alphaupdate) D3D::stateman->PushBlendState(clearblendstates[0]);
|
||||
else if (bpmem.blendmode.colorupdate) D3D::stateman->PushBlendState(clearblendstates[1]);
|
||||
else if (bpmem.blendmode.alphaupdate) D3D::stateman->PushBlendState(clearblendstates[2]);
|
||||
if (colorEnable && alphaEnable) D3D::stateman->PushBlendState(clearblendstates[0]);
|
||||
else if (colorEnable) D3D::stateman->PushBlendState(clearblendstates[1]);
|
||||
else if (alphaEnable) D3D::stateman->PushBlendState(clearblendstates[2]);
|
||||
else D3D::stateman->PushBlendState(clearblendstates[3]);
|
||||
|
||||
if (!bpmem.zmode.testenable) D3D::stateman->PushDepthState(cleardepthstates[0]);
|
||||
else if (bpmem.zmode.updateenable) D3D::stateman->PushDepthState(cleardepthstates[1]);
|
||||
else /*if (!bpmem.zmode.updateenable)*/ D3D::stateman->PushDepthState(cleardepthstates[2]);
|
||||
// TODO: Should we enable Z testing here?
|
||||
/*if (!bpmem.zmode.testenable) D3D::stateman->PushDepthState(cleardepthstates[0]);
|
||||
else */if (zEnable) D3D::stateman->PushDepthState(cleardepthstates[1]);
|
||||
else /*if (!zEnable)*/ D3D::stateman->PushDepthState(cleardepthstates[2]);
|
||||
|
||||
// Update the view port for clearing the picture
|
||||
TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc);
|
||||
@ -1120,4 +1124,4 @@ void Renderer::SetInterlacingMode()
|
||||
// TODO
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -473,8 +473,9 @@ bool Renderer::SetScissorRect()
|
||||
|
||||
void Renderer::SetColorMask()
|
||||
{
|
||||
// Only enable alpha channel if it's supported by the current EFB format
|
||||
DWORD color_mask = 0;
|
||||
if (bpmem.blendmode.alphaupdate)
|
||||
if (bpmem.blendmode.alphaupdate && (bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24))
|
||||
color_mask = D3DCOLORWRITEENABLE_ALPHA;
|
||||
if (bpmem.blendmode.colorupdate)
|
||||
color_mask |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
|
||||
@ -789,11 +790,22 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
|
||||
{
|
||||
// Reset rendering pipeline while keeping color masks and depth buffer settings
|
||||
ResetAPIState();
|
||||
SetDepthMode();
|
||||
SetColorMask();
|
||||
|
||||
if (zEnable) // other depth functions don't make sense here
|
||||
DWORD color_mask = 0;
|
||||
if (alphaEnable)
|
||||
color_mask = D3DCOLORWRITEENABLE_ALPHA;
|
||||
if (colorEnable)
|
||||
color_mask |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
|
||||
D3D::ChangeRenderState(D3DRS_COLORWRITEENABLE, color_mask);
|
||||
|
||||
if (zEnable)
|
||||
{
|
||||
D3D::ChangeRenderState(D3DRS_ZENABLE, TRUE);
|
||||
D3D::ChangeRenderState(D3DRS_ZWRITEENABLE, TRUE);
|
||||
D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
|
||||
}
|
||||
else
|
||||
D3D::ChangeRenderState(D3DRS_ZENABLE, FALSE);
|
||||
|
||||
// Update the viewport for clearing the target EFB rect
|
||||
TargetRectangle targetRc = ConvertEFBRectangle(rc);
|
||||
@ -1304,4 +1316,4 @@ void Renderer::SetInterlacingMode()
|
||||
// TODO
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -661,8 +661,9 @@ bool Renderer::SetScissorRect()
|
||||
|
||||
void Renderer::SetColorMask()
|
||||
{
|
||||
// Only enable alpha channel if it's supported by the current EFB format
|
||||
GLenum ColorMask = (bpmem.blendmode.colorupdate) ? GL_TRUE : GL_FALSE;
|
||||
GLenum AlphaMask = (bpmem.blendmode.alphaupdate) ? GL_TRUE : GL_FALSE;
|
||||
GLenum AlphaMask = (bpmem.blendmode.alphaupdate && (bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24)) ? GL_TRUE : GL_FALSE;
|
||||
glColorMask(ColorMask, ColorMask, ColorMask, AlphaMask);
|
||||
}
|
||||
|
||||
@ -807,13 +808,13 @@ void Renderer::UpdateViewport()
|
||||
glDepthRange(GLNear, GLFar);
|
||||
}
|
||||
|
||||
// TODO: Clearing RGB or alpha only isn't implemented, yet!
|
||||
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
|
||||
{
|
||||
// Update the view port for clearing the picture
|
||||
TargetRectangle targetRc = ConvertEFBRectangle(rc);
|
||||
glViewport(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
|
||||
|
||||
|
||||
// Always set the scissor in case it was set by the game and has not been reset
|
||||
glScissor(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
|
||||
|
||||
@ -1557,4 +1558,4 @@ bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user