diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index 10cd1e5c88..d6709e20e3 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -280,7 +280,7 @@ void BPWritten(const BPCmd& bp) ClearScreen(bp, rc); } - RestoreRenderState(bp); + RestoreRenderState(bp); // TODO: Remove this call, handle this in the plugins instead break; } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp index 9833f793eb..9899d88461 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp @@ -329,7 +329,7 @@ int CD3DFont::Shutdown() return S_OK; } -int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dwColor, const char* strText, bool center) +int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dwColor, const char* strText) { if (!m_pVB) return 0; @@ -355,25 +355,6 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw if (FAILED(hr)) PanicAlert("Mapping vertex buffer failed, %s %d\n", __FILE__, __LINE__); pVertices = (D3D::FONT2DVERTEX*)vbmap.pData; - // if center was requested, set current position as centre - // this is currently never used - if (center) - { - const char *oldText = strText; - float mx=0; - float maxx=0; - - while (c = *strText++) - { - if (c == ('\n')) mx = 0; - if (c < (' ') ) continue; - c -= 32; - mx += (m_fTexCoords[c][2]-m_fTexCoords[c][0])/(m_fTexCoords[0][3] - m_fTexCoords[0][1]) + spacing; - if (mx > maxx) maxx = mx; - } - sx -= scalex*maxx*size; - strText = oldText; - } // set general pipeline state D3D::stateman->PushBlendState(m_blendstate); D3D::stateman->PushRasterizerState(m_raststate); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.h b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.h index b8fa15a907..967963327d 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.h @@ -53,7 +53,7 @@ namespace D3D int DrawTextScaled(float x, float y, float size, float spacing, u32 dwColor, - const char* strText, bool center=true); + const char* strText); }; extern CD3DFont font; diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp index 14092c80ad..928c976ff0 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp @@ -478,7 +478,7 @@ void Renderer::DrawDebugText() void Renderer::RenderText(const char *text, int left, int top, u32 color) { - D3D::font.DrawTextScaled((float)left, (float)top, 20.f, 0.0f, color, text, false); + D3D::font.DrawTextScaled((float)left, (float)top, 20.f, 0.0f, color, text); } TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc) @@ -1024,7 +1024,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons { char fps[20]; StringCchPrintfA(fps, 20, "FPS: %d\n", s_fps); - D3D::font.DrawTextScaled(0, 30, 20, 0.0f, 0xFF00FFFF, fps, false); + D3D::font.DrawTextScaled(0, 30, 20, 0.0f, 0xFF00FFFF, fps); } Renderer::DrawDebugText(); @@ -1032,13 +1032,13 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons { char buf[32768]; Statistics::ToString(buf); - D3D::font.DrawTextScaled(0, 30, 20, 0.0f, 0xFF00FFFF, buf, false); + D3D::font.DrawTextScaled(0, 30, 20, 0.0f, 0xFF00FFFF, buf); } else if (g_ActiveConfig.bOverlayProjStats) { char buf[32768]; Statistics::ToStringProj(buf); - D3D::font.DrawTextScaled(0, 30, 20, 0.0f, 0xFF00FFFF, buf, false); + D3D::font.DrawTextScaled(0, 30, 20, 0.0f, 0xFF00FFFF, buf); } OSD::DrawMessages(); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp index d23de1324f..ee799ea407 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp @@ -43,9 +43,6 @@ namespace DX11 { -ID3D11BlendState* efbcopyblendstate = NULL; -ID3D11RasterizerState* efbcopyraststate = NULL; -ID3D11DepthStencilState* efbcopydepthstate = NULL; ID3D11Buffer* efbcopycbuf[20] = {}; TextureCache::TCacheEntry::~TCacheEntry() @@ -120,6 +117,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(bool bFromZBuffer, bool bScaleB unsigned int cbufid, const float colmat[], const EFBRectangle &source_rect, bool bIsIntensityFmt, u32 copyfmt) { + Renderer::ResetAPIState(); // stretch picture with increased internal resolution const D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, (float)virtualW, (float)virtualH); D3D::context->RSSetViewports(1, &vp); @@ -146,10 +144,6 @@ void TextureCache::TCacheEntry::FromRenderTarget(bool bFromZBuffer, bool bScaleB else D3D::SetPointCopySampler(); - D3D::stateman->PushBlendState(efbcopyblendstate); - D3D::stateman->PushRasterizerState(efbcopyraststate); - D3D::stateman->PushDepthState(efbcopydepthstate); - D3D::context->OMSetRenderTargets(1, &texture->GetRTV(), NULL); D3D::drawShadedTexQuad( @@ -160,9 +154,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(bool bFromZBuffer, bool bScaleB D3D::context->OMSetRenderTargets(1, &g_framebufferManager.GetEFBColorTexture()->GetRTV(), g_framebufferManager.GetEFBDepthTexture()->GetDSV()); - D3D::stateman->PopBlendState(); - D3D::stateman->PopDepthState(); - D3D::stateman->PopRasterizerState(); + Renderer::RestoreAPIState(); } TextureCache::TCacheEntryBase* TextureCache::CreateRenderTargetTexture( @@ -175,56 +167,10 @@ TextureCache::TCacheEntryBase* TextureCache::CreateRenderTargetTexture( TextureCache::TextureCache() { - HRESULT hr; - - D3D11_BLEND_DESC blenddesc; - blenddesc.AlphaToCoverageEnable = FALSE; - blenddesc.IndependentBlendEnable = FALSE; - blenddesc.RenderTarget[0].BlendEnable = FALSE; - blenddesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - blenddesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; - blenddesc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO; - blenddesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; - blenddesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; - blenddesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; - blenddesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - hr = D3D::device->CreateBlendState(&blenddesc, &efbcopyblendstate); - CHECK(hr==S_OK, "Create blend state for CopyRenderTargetToTexture"); - D3D::SetDebugObjectName((ID3D11DeviceChild*)efbcopyblendstate, "blend state used in CopyRenderTargetToTexture"); - - D3D11_DEPTH_STENCIL_DESC depthdesc; - depthdesc.DepthEnable = FALSE; - depthdesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; - depthdesc.DepthFunc = D3D11_COMPARISON_LESS; - depthdesc.StencilEnable = FALSE; - depthdesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK; - depthdesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK; - hr = D3D::device->CreateDepthStencilState(&depthdesc, &efbcopydepthstate); - CHECK(hr==S_OK, "Create depth state for CopyRenderTargetToTexture"); - D3D::SetDebugObjectName((ID3D11DeviceChild*)efbcopydepthstate, "depth stencil state used in CopyRenderTargetToTexture"); - - D3D11_RASTERIZER_DESC rastdesc; - rastdesc.CullMode = D3D11_CULL_NONE; - rastdesc.FillMode = D3D11_FILL_SOLID; - rastdesc.FrontCounterClockwise = false; - rastdesc.DepthBias = false; - rastdesc.DepthBiasClamp = 0; - rastdesc.SlopeScaledDepthBias = 0; - rastdesc.DepthClipEnable = false; - rastdesc.ScissorEnable = false; - rastdesc.MultisampleEnable = false; - rastdesc.AntialiasedLineEnable = false; - hr = D3D::device->CreateRasterizerState(&rastdesc, &efbcopyraststate); - CHECK(hr==S_OK, "Create rasterizer state for CopyRenderTargetToTexture"); - D3D::SetDebugObjectName((ID3D11DeviceChild*)efbcopyraststate, "rasterizer state used in CopyRenderTargetToTexture"); } TextureCache::~TextureCache() { - SAFE_RELEASE(efbcopyblendstate); - SAFE_RELEASE(efbcopyraststate); - SAFE_RELEASE(efbcopydepthstate); - for (unsigned int k = 0; k < 20; ++k) SAFE_RELEASE(efbcopycbuf[k]); } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp index 52b9a285ac..3491fde2e1 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp @@ -164,11 +164,6 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) LogManager::SetInstance((LogManager*)globals->logManager); } -void DllAbout(HWND _hParent) -{ - //DialogBox(g_hInstance,(LPCTSTR)IDD_ABOUT,_hParent,(DLGPROC)AboutProc); -} - void DllConfig(void *_hParent) { DlgSettings_Show(g_hInstance, (HWND)((wxWindow *)_hParent)->GetHandle()); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp index 85234e5681..9ac2c3b88a 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp @@ -230,7 +230,7 @@ void CD3DFont::SetRenderStates() } -int CD3DFont::DrawTextScaled(float x, float y, float fXScale, float fYScale, float spacing, u32 dwColor, const char* strText, bool center) +int CD3DFont::DrawTextScaled(float x, float y, float fXScale, float fYScale, float spacing, u32 dwColor, const char* strText) { if (!m_pVB) return 0; @@ -278,16 +278,11 @@ int CD3DFont::DrawTextScaled(float x, float y, float fXScale, float fYScale, flo float offset = -maxx/2; strText = oldstrText; - //Then let's draw it - if (center) - { - sx+=offset; - fStartX+=offset; - } float wScale = (fXScale*vpHeight)*invLineHeight; float hScale = (fYScale*vpHeight)*invLineHeight; + // Let's draw it while (*strText) { char c = *strText++; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h index c71b7ab35e..8b548f710f 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h @@ -50,7 +50,7 @@ namespace D3D int DrawTextScaled( float x, float y, float fXScale, float fYScale, float spacing, u32 dwColor, - const char* strText, bool center=true ); + const char* strText); // Constructor / destructor diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 423a5da99b..aec9de36bd 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -538,7 +538,7 @@ void Renderer::DrawDebugText() void Renderer::RenderText(const char *text, int left, int top, u32 color) { - D3D::font.DrawTextScaled((float)left, (float)top, 20, 20, 0.0f, color, text, false); + D3D::font.DrawTextScaled((float)left, (float)top, 20, 20, 0.0f, color, text); } TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc) @@ -1267,19 +1267,19 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons { char fps[20]; StringCchPrintfA(fps, 20, "FPS: %d\n", s_fps); - D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, fps, false); + D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, fps); } Renderer::DrawDebugText(); if (g_ActiveConfig.bOverlayStats) { Statistics::ToString(st); - D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, st, false); + D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, st); } else if (g_ActiveConfig.bOverlayProjStats) { Statistics::ToStringProj(st); - D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, st, false); + D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, st); } OSD::DrawMessages();