mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
more fixes to zcomplock and opengl implementation
This commit is contained in:
@ -1211,7 +1211,7 @@ void Renderer::ApplyState(RenderStateMode mode)
|
||||
D3D::ChangeRenderState(D3DRS_COLORWRITEENABLE, 0);
|
||||
}
|
||||
else if(mode == RSM_Multipass)
|
||||
{
|
||||
{
|
||||
D3D::ChangeRenderState(D3DRS_ZENABLE, TRUE);
|
||||
D3D::ChangeRenderState(D3DRS_ZWRITEENABLE, false);
|
||||
D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL);
|
||||
@ -1231,6 +1231,7 @@ void Renderer::RestoreState(RenderStateMode mode)
|
||||
}
|
||||
else if(mode == RSM_Multipass)
|
||||
{
|
||||
D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
|
||||
D3D::RefreshRenderState(D3DRS_ZENABLE);
|
||||
D3D::RefreshRenderState(D3DRS_ZWRITEENABLE);
|
||||
D3D::RefreshRenderState(D3DRS_ZFUNC);
|
||||
|
@ -191,7 +191,7 @@ void VertexManager::vFlush()
|
||||
g_renderer->RestoreState(RSM_Multipass);
|
||||
}
|
||||
|
||||
bool UseZcomploc = bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable && g_ActiveConfig.bAcurateZcomploc;
|
||||
bool UseZcomploc = bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable && !g_ActiveConfig.bEnableFastZcomploc;
|
||||
|
||||
if (UseZcomploc)
|
||||
{
|
||||
|
@ -632,6 +632,43 @@ void Renderer::SetScissorRect(const TargetRectangle& rc)
|
||||
glScissor(rc.left, rc.bottom, rc.GetWidth(), rc.GetHeight());
|
||||
}
|
||||
|
||||
void Renderer::ApplyState(RenderStateMode mode)
|
||||
{
|
||||
if(mode == RSM_Zcomploc)
|
||||
{
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else if(mode == RSM_Multipass)
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDepthFunc(GL_EQUAL);
|
||||
}
|
||||
else if (mode == RSM_UseDstAlpha)
|
||||
{
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::RestoreState(RenderStateMode mode)
|
||||
{
|
||||
if(mode == RSM_Zcomploc)
|
||||
{
|
||||
SetColorMask();
|
||||
}
|
||||
else if(mode == RSM_Multipass)
|
||||
{
|
||||
SetDepthMode();
|
||||
}
|
||||
else if (mode == RSM_UseDstAlpha)
|
||||
{
|
||||
SetColorMask();
|
||||
if (bpmem.blendmode.blendenable || bpmem.blendmode.subtract)
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::SetColorMask()
|
||||
{
|
||||
// Only enable alpha channel if it's supported by the current EFB format
|
||||
|
@ -26,9 +26,8 @@ public:
|
||||
void SetSamplerState(int stage,int texindex);
|
||||
void SetInterlacingMode();
|
||||
|
||||
// TODO: Implement and use these
|
||||
void ApplyState(RenderStateMode mode){}
|
||||
void RestoreState(RenderStateMode mode){}
|
||||
void ApplyState(RenderStateMode mode);
|
||||
void RestoreState(RenderStateMode mode);
|
||||
|
||||
void RenderText(const char* pstr, int left, int top, u32 color);
|
||||
void DrawDebugInfo();
|
||||
|
@ -224,17 +224,26 @@ void VertexManager::vFlush()
|
||||
ps = PixelShaderCache::SetShader(DSTALPHA_ALPHA_PASS,g_nativeVertexFmt->m_components);
|
||||
if (ps) PixelShaderCache::SetCurrentShader(ps->glprogid);
|
||||
|
||||
// only update alpha
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
g_renderer->ApplyState(RSM_UseDstAlpha);
|
||||
if (bpmem.zmode.updateenable)
|
||||
g_renderer->ApplyState(RSM_Multipass);
|
||||
|
||||
Draw();
|
||||
// restore color mask
|
||||
g_renderer->SetColorMask();
|
||||
|
||||
g_renderer->RestoreState(RSM_UseDstAlpha);
|
||||
if (bpmem.zmode.updateenable)
|
||||
g_renderer->RestoreState(RSM_Multipass);
|
||||
}
|
||||
|
||||
if (bpmem.blendmode.blendenable || bpmem.blendmode.subtract)
|
||||
glEnable(GL_BLEND);
|
||||
bool UseZcomploc = bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable && !g_ActiveConfig.bEnableFastZcomploc;
|
||||
|
||||
if (UseZcomploc)
|
||||
{
|
||||
FRAGMENTSHADER* ps = PixelShaderCache::SetShader(DSTALPHA_ZCOMPLOC,g_nativeVertexFmt->m_components);
|
||||
if (ps) PixelShaderCache::SetCurrentShader(ps->glprogid);
|
||||
g_renderer->ApplyState(RSM_Zcomploc);
|
||||
Draw();
|
||||
g_renderer->RestoreState(RSM_Zcomploc);
|
||||
}
|
||||
GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true);
|
||||
|
||||
|
Reference in New Issue
Block a user