This commit is separate in two parts:

Fix: fix for lighting equations , that must improve lighting in a lot of games (  test smg :) )
experimental speedup: implemented alpha pass using stencil buffer instead of a duplicate shader. i recommend to test this well as i dono if will work the same way in all the systems. i my system it gives a nice 2-5 fps improvement. if it brings problems in any system or game will revert asap.
enjoy

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5653 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Rodolfo Osvaldo Bogado
2010-06-12 12:36:33 +00:00
parent 7efbc879e5
commit ce3c2700e7
3 changed files with 48 additions and 35 deletions

View File

@ -19,6 +19,7 @@
#include "FileUtil.h"
#include "D3DBase.h"
#include "D3DUtil.h"
#include "Statistics.h"
#include "Profiler.h"
@ -292,25 +293,30 @@ void Flush()
int stride = g_nativeVertexFmt->GetVertexStride();
g_nativeVertexFmt->SetupVertexPointers();
if(bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
{
D3D::SetRenderState(D3DRS_STENCILENABLE, TRUE );
D3D::SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS );
D3D::SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_REPLACE );
D3D::SetRenderState(D3DRS_STENCILREF, 1);
}
Draw(stride);
if (bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
{
DWORD write = 0;
if (!PixelShaderCache::SetShader(true))
{
DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
goto shader_fail;
}
D3D::SetRenderState(D3DRS_STENCILFUNC, D3DCMP_EQUAL );
D3D::SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_DECR );
// update alpha only
D3D::ChangeRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA);
D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false);
Draw(stride);
D3D::ChangeRenderState(D3DRS_ZWRITEENABLE, false);
D3D::drawClearQuad((bpmem.dstalpha.hex & 0xff)<<24,0.0f,PixelShaderCache::GetClearProgram(),VertexShaderCache::GetClearVertexShader());
D3D::RefreshRenderState(D3DRS_ZWRITEENABLE);
D3D::RefreshRenderState(D3DRS_COLORWRITEENABLE);
D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
D3D::SetRenderState(D3DRS_STENCILENABLE, false );
}
DEBUGGER_PAUSE_AT(NEXT_FLUSH,true);