diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index 07cf6d5212..2a2503dec6 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -91,6 +91,7 @@ void VideoConfig::Load(const char *ini_file) iniFile.Get("Hacks", "EFBCopyDisable", &bEFBCopyDisable, 0); iniFile.Get("Hacks", "EFBCopyDisableHotKey", &bOSDHotKey, 0); iniFile.Get("Hacks", "EFBToTextureEnable", &bCopyEFBToRAM, true); + iniFile.Get("Hacks", "EFBScaledCopy", &bCopyEFBScaled, true); iniFile.Get("Hacks", "ProjectionHack", &iPhackvalue, 0); iniFile.Get("Hardware", "Adapter", &iAdapter, 0); @@ -120,6 +121,8 @@ void VideoConfig::GameIniLoad(const char *ini_file) iniFile.Get("Video", "EFBCopyDisableHotKey", &bOSDHotKey, 0); if (iniFile.Exists("Video", "EFBToRAMEnable")) iniFile.Get("Video", "EFBToRAMEnable", &bCopyEFBToRAM, 0); + if (iniFile.Exists("Video", "EFBScaledCopy")) + iniFile.Get("Video", "EFBScaledCopy", &bCopyEFBScaled, 0); if (iniFile.Exists("Video", "SafeTextureCache")) iniFile.Get("Video", "SafeTextureCache", &bSafeTextureCache, false); if (iniFile.Exists("Video", "MSAA")) @@ -181,6 +184,7 @@ void VideoConfig::Save(const char *ini_file) iniFile.Set("Hacks", "EFBCopyDisable", bEFBCopyDisable); iniFile.Set("Hacks", "EFBCopyDisableHotKey", bOSDHotKey); iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToRAM); + iniFile.Set("Hacks", "EFBScaledCopy", bCopyEFBScaled); iniFile.Set("Hacks", "ProjectionHack", iPhackvalue); iniFile.Set("Hardware", "Adapter", iAdapter); diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h index eb32ce99e2..23bc326178 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.h +++ b/Source/Core/VideoCommon/Src/VideoConfig.h @@ -109,6 +109,7 @@ struct VideoConfig bool bOSDHotKey; bool bHack; bool bCopyEFBToRAM; + bool bCopyEFBScaled; bool bSafeTextureCache; int iPhackvalue; bool bPhackvalue1, bPhackvalue2; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp index f12a077248..ed45db2834 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp @@ -457,6 +457,11 @@ void SetTexture(DWORD Stage, LPDIRECT3DBASETEXTURE9 pTexture) } } +void RefreshRenderState(D3DRENDERSTATETYPE State) +{ + D3D::dev->SetRenderState(State, m_RenderStates[State]); +} + void SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) { if (m_RenderStates[State] != Value) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.h b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.h index 89894b692a..97d4e449d2 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.h @@ -75,6 +75,7 @@ void ShowD3DError(HRESULT err); // The following are "filtered" versions of the corresponding D3Ddev-> functions. void SetTexture(DWORD Stage, IDirect3DBaseTexture9 *pTexture); void SetRenderState(D3DRENDERSTATETYPE State, DWORD Value); +void RefreshRenderState(D3DRENDERSTATETYPE State); void SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value); void RefreshSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type); void SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp index 8aaac9c6a8..4f765d88d5 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp @@ -451,12 +451,15 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo int tex_w = (abs(source_rect.GetWidth()) >> bScaleByHalf); int tex_h = (abs(source_rect.GetHeight()) >> bScaleByHalf); + + int Scaledtex_w = (g_ActiveConfig.bCopyEFBScaled)?((int)(Renderer::GetTargetScaleX() * tex_w)):tex_w; + int Scaledtex_h = (g_ActiveConfig.bCopyEFBScaled)?((int)(Renderer::GetTargetScaleY() * tex_h)):tex_h; TexCache::iterator iter; LPDIRECT3DTEXTURE9 tex; iter = textures.find(address); if (iter != textures.end()) { - if (iter->second.isRenderTarget && iter->second.w == tex_w && iter->second.h == tex_h) + if (iter->second.isRenderTarget && iter->second.Scaledw == Scaledtex_w && iter->second.Scaledh == Scaledtex_h) { tex = iter->second.texture; @@ -479,9 +482,11 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo entry.frameCount = frameCount; entry.w = tex_w; entry.h = tex_h; + entry.Scaledw = Scaledtex_w; + entry.Scaledh = Scaledtex_h; entry.fmt = copyfmt; - D3D::dev->CreateTexture(tex_w, tex_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &entry.texture, 0); + D3D::dev->CreateTexture(Scaledtex_w, Scaledtex_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &entry.texture, 0); textures[address] = entry; tex = entry.texture; } @@ -610,15 +615,15 @@ have_texture: // Stretch picture with increased internal resolution vp.X = 0; vp.Y = 0; - vp.Width = tex_w; - vp.Height = tex_h; + vp.Width = Scaledtex_w; + vp.Height = Scaledtex_h; vp.MinZ = 0.0f; vp.MaxZ = 1.0f; D3D::dev->SetViewport(&vp); RECT destrect; - destrect.bottom = tex_h; + destrect.bottom = Scaledtex_h; destrect.left = 0; - destrect.right = tex_w; + destrect.right = Scaledtex_w; destrect.top = 0; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.h b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.h index fcb8f5e632..ca925e9143 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.h @@ -40,6 +40,7 @@ public: int frameCount; int w, h, fmt; + int Scaledw, Scaledh; float scaleX, scaleY; // Hires texutres need this @@ -59,6 +60,10 @@ public: scaleX = 1.0f; scaleY = 1.0f; isNonPow2 = true; + w = 0; + h = 0; + Scaledw = 0; + Scaledh = 0; } void Destroy(bool shutdown); bool IntersectsMemoryRange(u32 range_address, u32 range_size);