Change destination alpha handling. The blending method introduced in rev 1921 was not the correct way to do it. This way was suggested by hrydgard in October and I should have listened. A simple pixel shader as hrydgard suggested cannot be used because the alpha is not set if the pixel is discarded due to failing depth (after z texture) or alpha (result of tev stages) tests. There is a bit of a performance hit so there should be an option to disable the second render pass which sets the alpha because it is probably not needed most of the time.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2662 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
donkopunchstania
2009-03-16 02:47:48 +00:00
parent b1b2868c8b
commit 90254bd924
8 changed files with 59 additions and 65 deletions

View File

@ -238,7 +238,7 @@ void Flush()
PixelShaderManager::SetTexturesUsed(nonpow2tex);
}
FRAGMENTSHADER* ps = PixelShaderCache::GetShader();
FRAGMENTSHADER* ps = PixelShaderCache::GetShader(false);
VERTEXSHADER* vs = VertexShaderCache::GetShader(g_nativeVertexFmt->m_components);
bool bRestoreBuffers = false;
@ -284,6 +284,31 @@ void Flush()
groupStart += s_vertexGroups[i].second;
}
// run through vertex groups again to set alpha
if (bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate) {
ps = PixelShaderCache::GetShader(true);
if (ps) glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ps->glprogid);
// only update alpha
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
groupStart = 0;
for (unsigned i = 0; i < s_vertexGroups.size(); i++)
{
INCSTAT(stats.thisFrame.numDrawCalls);
glMultiDrawArrays(s_vertexGroups[i].first,
&s_vertexFirstOffset[groupStart],
&s_vertexGroupSize[groupStart],
s_vertexGroups[i].second);
groupStart += s_vertexGroups[i].second;
}
// restore color mask
if (!bRestoreBuffers)
Renderer::SetColorMask();
}
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_Config.iLog & CONF_SAVESHADERS) {
// save the shaders