From f5d4fe0bfe13937fa3736aa6b78974ceb6e190ad Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 3 Mar 2012 20:07:20 +0100 Subject: Fix some minor bugs pointed out by PVS Studio (thanks!) --- Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Plugins/Plugin_VideoDX9') diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp index 3a4b5d0699..9510ad444c 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp @@ -383,7 +383,7 @@ void drawShadedTexQuad(IDirect3DTexture9 *texture, float v2=((float)rSource->bottom) * sh; float g = 1.0f/Gamma; - struct Q2DVertex { float x,y,z,rhw,u,v,w,h,G; } coords[4] = { + const struct Q2DVertex { float x,y,z,rhw,u,v,w,h,G; } coords[4] = { {-1.0f - dw,-1.0f + dh, 0.0f,1.0f, u1, v2, sw, sh, g}, {-1.0f - dw, 1.0f + dh, 0.0f,1.0f, u1, v1, sw, sh, g}, { 1.0f - dw,-1.0f + dh, 0.0f,1.0f, u2, v2, sw, sh, g}, -- cgit v1.2.3 From c3d13b048c40b9df99d401939bd747e1de5c878e Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Sun, 18 Mar 2012 02:31:19 -0700 Subject: build against wxWidgets3 from Externals on Windows. use Externals version of libpng on Windows. --- Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcxproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Source/Plugins/Plugin_VideoDX9') diff --git a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcxproj b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcxproj index 604fea8a2b..c152fcb630 100644 --- a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcxproj +++ b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcxproj @@ -122,7 +122,7 @@ Disabled - ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets3;..\..\..\Externals\wxWidgets3\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDebug stdafx.h @@ -135,7 +135,7 @@ - ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets3;..\..\..\Externals\wxWidgets3\include;%(AdditionalIncludeDirectories) true @@ -144,7 +144,7 @@ - ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets3;..\..\..\Externals\wxWidgets3\include;%(AdditionalIncludeDirectories) true @@ -155,7 +155,7 @@ - ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets3;..\..\..\Externals\wxWidgets3\include;%(AdditionalIncludeDirectories) true @@ -166,7 +166,7 @@ - ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets3;..\..\..\Externals\wxWidgets3\include;%(AdditionalIncludeDirectories) true @@ -177,7 +177,7 @@ - ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\Core\VideoCommon\Src;..\..\Core\DolphinWX\Src;..\..\..\Externals\wxWidgets3;..\..\..\Externals\wxWidgets3\include;%(AdditionalIncludeDirectories) true -- cgit v1.2.3 From fee98b426b5a0c4d78042a2db3b352c4fe79ef56 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Sat, 24 Mar 2012 04:47:28 +0100 Subject: Revert r41bcf657f89d, r3a9fed0ba285, r9adc119e3c2f and re58692653afd (all of them are wrong). --- Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Plugins/Plugin_VideoDX9') diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp index 2083d4f1d8..c4e8225db1 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp @@ -143,7 +143,7 @@ void VertexManager::vFlush() if (tentry) { // 0s are probably for no manual wrapping needed. - PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, tentry->virtual_width, tentry->virtual_height, 0, 0, API_D3D9); + PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, 0, 0); } else ERROR_LOG(VIDEO, "error loading texture"); @@ -152,7 +152,7 @@ void VertexManager::vFlush() // set global constants VertexShaderManager::SetConstants(); - PixelShaderManager::SetConstants(API_D3D9); + PixelShaderManager::SetConstants(); if (!PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components)) { -- cgit v1.2.3 From 450dcc9d2cd874f6ab40d4a339afc29f55751319 Mon Sep 17 00:00:00 2001 From: rodolfoosvaldobogado Date: Tue, 27 Mar 2012 15:44:58 -0300 Subject: 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. --- Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 33 +++++++++++++++++--- Source/Plugins/Plugin_VideoDX9/Src/Render.h | 4 +-- .../Plugins/Plugin_VideoDX9/Src/VertexManager.cpp | 36 +++++++++++++++++----- 3 files changed, 58 insertions(+), 15 deletions(-) (limited to 'Source/Plugins/Plugin_VideoDX9') diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index a5aaa6485b..5d836ec6ed 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -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) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.h b/Source/Plugins/Plugin_VideoDX9/Src/Render.h index 6e5198b3cd..58716a679b 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.h @@ -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); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp index c4e8225db1..82ee8d1623 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp @@ -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); -- cgit v1.2.3 From 48d8d71391fc2cc40d85732680eb6421164bf87c Mon Sep 17 00:00:00 2001 From: rodolfoosvaldobogado Date: Tue, 27 Mar 2012 23:14:59 -0300 Subject: Fix for my last commit, this must fix the problem in the algorithm pointed by neobrain. thanks --- .../Plugins/Plugin_VideoDX9/Src/VertexManager.cpp | 39 +++++++++++----------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'Source/Plugins/Plugin_VideoDX9') diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp index 82ee8d1623..8dd13f3e3b 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp @@ -154,6 +154,9 @@ void VertexManager::vFlush() VertexShaderManager::SetConstants(); PixelShaderManager::SetConstants(); + int stride = g_nativeVertexFmt->GetVertexStride(); + g_nativeVertexFmt->SetupVertexPointers(); + if (!VertexShaderCache::SetShader(g_nativeVertexFmt->m_components)) { GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set vertex shader\n");}); @@ -161,22 +164,6 @@ 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");}); @@ -196,16 +183,28 @@ void VertexManager::vFlush() } // update alpha only g_renderer->ApplyState(RSM_UseDstAlpha); - if(!UseZcomploc && bpmem.zmode.updateenable) + if (bpmem.zmode.updateenable) g_renderer->ApplyState(RSM_Multipass); Draw(stride); g_renderer->RestoreState(RSM_UseDstAlpha); + if (bpmem.zmode.updateenable) + g_renderer->RestoreState(RSM_Multipass); } - - if (UseZcomploc || (useDstAlpha && bpmem.zmode.updateenable)) + + bool UseZcomploc = bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable && g_ActiveConfig.bAcurateZcomploc; + + if (UseZcomploc) { - g_renderer->RestoreState(RSM_Multipass); + 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); } + GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true); shader_fail: -- cgit v1.2.3 From 402006a83a89bc0f790934096e915f0e8c23f808 Mon Sep 17 00:00:00 2001 From: rodolfoosvaldobogado Date: Thu, 29 Mar 2012 18:26:58 -0300 Subject: more fixes to zcomplock and opengl implementation --- Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 3 ++- Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'Source/Plugins/Plugin_VideoDX9') diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 5d836ec6ed..d3de48b190 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -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); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp index 8dd13f3e3b..af5bc3c839 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp @@ -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) { -- cgit v1.2.3 From 460610ea0e0d5083e261ed9d137048f2a5fc7e59 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Fri, 30 Mar 2012 01:56:24 +0200 Subject: Revert Rodolfo's recent zcomploc commits until they actually work correctly. This reverts commit 402006a83a89bc0f790934096e915f0e8c23f808. This reverts commit 48d8d71391fc2cc40d85732680eb6421164bf87c. This reverts commit 450dcc9d2cd874f6ab40d4a339afc29f55751319. --- Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 34 +++---------------- Source/Plugins/Plugin_VideoDX9/Src/Render.h | 4 +-- .../Plugins/Plugin_VideoDX9/Src/VertexManager.cpp | 39 ++++++---------------- 3 files changed, 17 insertions(+), 60 deletions(-) (limited to 'Source/Plugins/Plugin_VideoDX9') diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index d3de48b190..a5aaa6485b 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -1204,43 +1204,19 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons XFBWrited = false; } -void Renderer::ApplyState(RenderStateMode mode) +void Renderer::ApplyState(bool 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) + if (bUseDstAlpha) { D3D::ChangeRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA); D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false); } } -void Renderer::RestoreState(RenderStateMode mode) +void Renderer::RestoreState() { - if(mode == RSM_Zcomploc) - { - D3D::RefreshRenderState(D3DRS_COLORWRITEENABLE); - } - else if(mode == RSM_Multipass) - { - D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE); - 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); - } + 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) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.h b/Source/Plugins/Plugin_VideoDX9/Src/Render.h index 58716a679b..6e5198b3cd 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.h @@ -24,8 +24,8 @@ public: void SetSamplerState(int stage,int texindex); void SetInterlacingMode(); - void ApplyState(RenderStateMode mode); - void RestoreState(RenderStateMode mode); + void ApplyState(bool bUseDstAlpha); + void RestoreState(); void RenderText(const char* pstr, int left, int top, u32 color); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp index af5bc3c839..c4e8225db1 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp @@ -154,9 +154,11 @@ void VertexManager::vFlush() VertexShaderManager::SetConstants(); PixelShaderManager::SetConstants(); - int stride = g_nativeVertexFmt->GetVertexStride(); - g_nativeVertexFmt->SetupVertexPointers(); - + 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");}); @@ -164,11 +166,8 @@ void VertexManager::vFlush() } - 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; - } + int stride = g_nativeVertexFmt->GetVertexStride(); + g_nativeVertexFmt->SetupVertexPointers(); Draw(stride); @@ -176,35 +175,17 @@ 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(RSM_UseDstAlpha); - if (bpmem.zmode.updateenable) - g_renderer->ApplyState(RSM_Multipass); - Draw(stride); - g_renderer->RestoreState(RSM_UseDstAlpha); - if (bpmem.zmode.updateenable) - g_renderer->RestoreState(RSM_Multipass); - } - - bool UseZcomploc = bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable && !g_ActiveConfig.bEnableFastZcomploc; - - 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); + g_renderer->ApplyState(true); Draw(stride); - g_renderer->RestoreState(RSM_Zcomploc); + g_renderer->RestoreState(); } - GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true); shader_fail: -- cgit v1.2.3