diff options
| author | Rodolfo Osvaldo Bogado <rodolfoosvaldobogado@gmail.com> | 2010-06-12 12:36:33 +0000 |
|---|---|---|
| committer | Rodolfo Osvaldo Bogado <rodolfoosvaldobogado@gmail.com> | 2010-06-12 12:36:33 +0000 |
| commit | ce3c2700e7fd4226905b2ed652aded96d44eebd2 (patch) | |
| tree | 551eda54f77493bd865723fbe196cbcf755ed0c1 | |
| parent | 7efbc879e544cba7f205b3eeaeff050f46fd9607 (diff) | |
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
| -rw-r--r-- | Source/Core/Common/Src/LinearDiskCache.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexShaderGen.cpp | 55 | ||||
| -rw-r--r-- | Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp | 26 |
3 files changed, 48 insertions, 35 deletions
diff --git a/Source/Core/Common/Src/LinearDiskCache.cpp b/Source/Core/Common/Src/LinearDiskCache.cpp index fbad27f670..96d47a3b26 100644 --- a/Source/Core/Common/Src/LinearDiskCache.cpp +++ b/Source/Core/Common/Src/LinearDiskCache.cpp @@ -22,7 +22,7 @@ static const char ID[4] = {'D', 'C', 'A', 'C'}; // Update this to the current SVN revision every time you change shader generation code. // We don't automatically get this from SVN_REV because that would mean regenerating the // shader cache for every revision, graphics-related or not, which is simply annoying. -const int version = 5597; +const int version = 5653; LinearDiskCache::LinearDiskCache() : file_(NULL), num_entries_(0) { diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index afacb65e97..a2a096d0dd 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -270,37 +270,44 @@ const char *GenerateVertexShaderCode(u32 components, bool D3D) else // from color WRITE(p, "lacc.w = "I_MATERIALS".C%d.w;\n", j); } - - if (color.enablelighting && alpha.enablelighting && (color.GetFullLightMask() != alpha.GetFullLightMask() || color.lightparams != alpha.lightparams)) { - - // both have lighting, except not using the same lights - int mask = 0; // holds already computed lights - - if (color.lightparams == alpha.lightparams && (color.GetFullLightMask() & alpha.GetFullLightMask())) { - // if lights are shared, compute those first - mask = color.GetFullLightMask() & alpha.GetFullLightMask(); - for (int i = 0; i < 8; ++i) { - if (mask & (1<<i)) - p = GenerateLightShader(p, i, color, "lacc", 3); - } - } - + + if(color.enablelighting && alpha.enablelighting) + { + // both have lighting, test if they use the same ligths + int mask = 0; + if(color.lightparams == alpha.lightparams) + { + mask = color.GetFullLightMask() & alpha.GetFullLightMask(); + if(mask) + { + for (int i = 0; i < 8; ++i) + { + if (mask & (1<<i)) + p = GenerateLightShader(p, i, color, "lacc", 3); + } + } + } // no shared lights - for (int i = 0; i < 8; ++i) { + for (int i = 0; i < 8; ++i) + { if (!(mask&(1<<i)) && (color.GetFullLightMask() & (1<<i)) ) p = GenerateLightShader(p, i, color, "lacc", 1); if (!(mask&(1<<i)) && (alpha.GetFullLightMask() & (1<<i)) ) p = GenerateLightShader(p, i, alpha, "lacc", 2); } - } - else if (color.enablelighting || alpha.enablelighting) { - // either one is enabled - int coloralpha = (int)color.enablelighting|((int)alpha.enablelighting<<1); - for (int i = 0; i < 8; ++i) { - if (color.GetFullLightMask() & (1<<i) ) - p = GenerateLightShader(p, i, color.enablelighting?color:alpha, "lacc", coloralpha); + } + else if (color.enablelighting || alpha.enablelighting) + { + //ligths are disabled in one channel so proccess only te active + LitChannel workingchannel = color.enablelighting ? color : alpha; + int coloralpha = color.enablelighting ? 1 : 2; + for (int i = 0; i < 8; ++i) + { + if (workingchannel.GetFullLightMask() & (1<<i)) + p = GenerateLightShader(p, i, workingchannel, "lacc", coloralpha); + } - } + } if (color.enablelighting != alpha.enablelighting) { if (color.enablelighting) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp index 48d9e97d82..083fa1af2f 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp @@ -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); |
