mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
As requested, this is my implementation of zcomploc using a multi-pass algorithm. My apologize to the others devs for committing in the main branch but is the only way to get this tested as soon as possible.
please test for regressions, speed and for other issues fixed, as a example, the black color in water splash in super mario galaxy are fixed with this rev. please as soon as yo find a bug let me know.
This commit is contained in:
@ -1211,11 +1211,11 @@ void Renderer::RestoreAPIState()
|
||||
BPFunctions::SetScissor();
|
||||
}
|
||||
|
||||
void Renderer::ApplyState(bool bUseDstAlpha)
|
||||
void Renderer::ApplyState(RenderStateMode mode)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if (bUseDstAlpha)
|
||||
if (mode == RSM_UseDstAlpha)
|
||||
{
|
||||
// Colors should blend against SRC1_ALPHA
|
||||
if (gx_state.blenddc.RenderTarget[0].SrcBlend == D3D11_BLEND_SRC_ALPHA)
|
||||
@ -1275,7 +1275,7 @@ void Renderer::ApplyState(bool bUseDstAlpha)
|
||||
|
||||
D3D::stateman->Apply();
|
||||
|
||||
if (bUseDstAlpha)
|
||||
if (mode == RSM_UseDstAlpha)
|
||||
{
|
||||
// restore actual state
|
||||
SetBlendMode(false);
|
||||
@ -1289,7 +1289,7 @@ void Renderer::ApplyState(bool bUseDstAlpha)
|
||||
D3D::context->VSSetShader(VertexShaderCache::GetActiveShader(), NULL, 0);
|
||||
}
|
||||
|
||||
void Renderer::RestoreState()
|
||||
void Renderer::RestoreState(RenderStateMode mode)
|
||||
{
|
||||
ID3D11ShaderResourceView* shader_resources[8] = { NULL };
|
||||
D3D::context->PSSetShaderResources(0, 8, shader_resources);
|
||||
|
@ -25,8 +25,8 @@ public:
|
||||
void SetInterlacingMode();
|
||||
|
||||
// TODO: Fix confusing names (see ResetAPIState and RestoreAPIState)
|
||||
void ApplyState(bool bUseDstAlpha);
|
||||
void RestoreState();
|
||||
void ApplyState(RenderStateMode mode);
|
||||
void RestoreState(RenderStateMode mode);
|
||||
|
||||
void ApplyCullDisable();
|
||||
void RestoreCull();
|
||||
|
@ -264,13 +264,13 @@ void VertexManager::vFlush()
|
||||
unsigned int stride = g_nativeVertexFmt->GetVertexStride();
|
||||
g_nativeVertexFmt->SetupVertexPointers();
|
||||
|
||||
g_renderer->ApplyState(useDstAlpha);
|
||||
g_renderer->ApplyState(useDstAlpha ? RSM_UseDstAlpha : RSM_None);
|
||||
LoadBuffers();
|
||||
Draw(stride);
|
||||
|
||||
GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true);
|
||||
|
||||
g_renderer->RestoreState();
|
||||
g_renderer->RestoreState(useDstAlpha ? RSM_UseDstAlpha : RSM_None);
|
||||
|
||||
shader_fail:
|
||||
ResetBuffer();
|
||||
|
@ -1204,19 +1204,42 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
XFBWrited = false;
|
||||
}
|
||||
|
||||
void Renderer::ApplyState(bool bUseDstAlpha)
|
||||
void Renderer::ApplyState(RenderStateMode mode)
|
||||
{
|
||||
if (bUseDstAlpha)
|
||||
if(mode == RSM_Zcomploc)
|
||||
{
|
||||
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);
|
||||
}
|
||||
else if (mode == RSM_UseDstAlpha)
|
||||
{
|
||||
D3D::ChangeRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA);
|
||||
D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false);
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::RestoreState()
|
||||
void Renderer::RestoreState(RenderStateMode mode)
|
||||
{
|
||||
D3D::RefreshRenderState(D3DRS_COLORWRITEENABLE);
|
||||
D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
|
||||
if(mode == RSM_Zcomploc)
|
||||
{
|
||||
D3D::RefreshRenderState(D3DRS_COLORWRITEENABLE);
|
||||
}
|
||||
else if(mode == RSM_Multipass)
|
||||
{
|
||||
D3D::RefreshRenderState(D3DRS_ZENABLE);
|
||||
D3D::RefreshRenderState(D3DRS_ZWRITEENABLE);
|
||||
D3D::RefreshRenderState(D3DRS_ZFUNC);
|
||||
}
|
||||
else if(mode == RSM_UseDstAlpha)
|
||||
{
|
||||
D3D::RefreshRenderState(D3DRS_COLORWRITEENABLE);
|
||||
D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
|
||||
}
|
||||
|
||||
// TODO: Enable this code. Caused glitches for me however (neobrain)
|
||||
// for (unsigned int i = 0; i < 8; ++i)
|
||||
|
@ -24,8 +24,8 @@ public:
|
||||
void SetSamplerState(int stage,int texindex);
|
||||
void SetInterlacingMode();
|
||||
|
||||
void ApplyState(bool bUseDstAlpha);
|
||||
void RestoreState();
|
||||
void ApplyState(RenderStateMode mode);
|
||||
void RestoreState(RenderStateMode mode);
|
||||
|
||||
void RenderText(const char* pstr, int left, int top, u32 color);
|
||||
|
||||
|
@ -154,11 +154,6 @@ void VertexManager::vFlush()
|
||||
VertexShaderManager::SetConstants();
|
||||
PixelShaderManager::SetConstants();
|
||||
|
||||
if (!PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components))
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
|
||||
goto shader_fail;
|
||||
}
|
||||
if (!VertexShaderCache::SetShader(g_nativeVertexFmt->m_components))
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set vertex shader\n");});
|
||||
@ -168,6 +163,25 @@ void VertexManager::vFlush()
|
||||
|
||||
int stride = g_nativeVertexFmt->GetVertexStride();
|
||||
g_nativeVertexFmt->SetupVertexPointers();
|
||||
bool UseZcomploc = bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable && g_ActiveConfig.bAcurateZcomploc;
|
||||
if (UseZcomploc)
|
||||
{
|
||||
if (!PixelShaderCache::SetShader(DSTALPHA_ZCOMPLOC,g_nativeVertexFmt->m_components))
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
|
||||
goto shader_fail;
|
||||
}
|
||||
g_renderer->ApplyState(RSM_Zcomploc);
|
||||
Draw(stride);
|
||||
g_renderer->RestoreState(RSM_Zcomploc);
|
||||
g_renderer->ApplyState(RSM_Multipass);
|
||||
}
|
||||
|
||||
if (!PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components))
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
|
||||
goto shader_fail;
|
||||
}
|
||||
|
||||
Draw(stride);
|
||||
|
||||
@ -175,16 +189,22 @@ void VertexManager::vFlush()
|
||||
bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
|
||||
if (useDstAlpha)
|
||||
{
|
||||
DWORD write = 0;
|
||||
if (!PixelShaderCache::SetShader(DSTALPHA_ALPHA_PASS, g_nativeVertexFmt->m_components))
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
|
||||
goto shader_fail;
|
||||
}
|
||||
// update alpha only
|
||||
g_renderer->ApplyState(true);
|
||||
g_renderer->ApplyState(RSM_UseDstAlpha);
|
||||
if(!UseZcomploc && bpmem.zmode.updateenable)
|
||||
g_renderer->ApplyState(RSM_Multipass);
|
||||
Draw(stride);
|
||||
g_renderer->RestoreState();
|
||||
g_renderer->RestoreState(RSM_UseDstAlpha);
|
||||
}
|
||||
|
||||
if (UseZcomploc || (useDstAlpha && bpmem.zmode.updateenable))
|
||||
{
|
||||
g_renderer->RestoreState(RSM_Multipass);
|
||||
}
|
||||
GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true);
|
||||
|
||||
|
@ -27,8 +27,8 @@ public:
|
||||
void SetInterlacingMode();
|
||||
|
||||
// TODO: Implement and use these
|
||||
void ApplyState(bool bUseDstAlpha) {}
|
||||
void RestoreState() {}
|
||||
void ApplyState(RenderStateMode mode){}
|
||||
void RestoreState(RenderStateMode mode){}
|
||||
|
||||
void RenderText(const char* pstr, int left, int top, u32 color);
|
||||
void DrawDebugInfo();
|
||||
|
Reference in New Issue
Block a user