From 45dfb0dcdbc427f82057272818d43406c3275333 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Tue, 12 Feb 2019 12:06:02 +0100 Subject: [PATCH] gsdx device: use generic resize texture function V2: add missing size for merge and interlace --- plugins/GSdx/Renderers/Common/GSDevice.cpp | 67 ++++++++-------------- plugins/GSdx/Renderers/Common/GSDevice.h | 3 + 2 files changed, 27 insertions(+), 43 deletions(-) diff --git a/plugins/GSdx/Renderers/Common/GSDevice.cpp b/plugins/GSdx/Renderers/Common/GSDevice.cpp index cc0c47d31e..8c9adededd 100644 --- a/plugins/GSdx/Renderers/Common/GSDevice.cpp +++ b/plugins/GSdx/Renderers/Common/GSDevice.cpp @@ -245,20 +245,13 @@ GSTexture* GSDevice::GetCurrent() void GSDevice::Merge(GSTexture* sTex[3], GSVector4* sRect, GSVector4* dRect, const GSVector2i& fs, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) { - if(m_merge == NULL || m_merge->GetSize() != fs) - { - Recycle(m_merge); - - m_merge = CreateRenderTarget(fs.x, fs.y); - } - // TODO: m_1x1 // KH:COM crashes at startup when booting *through the bios* due to m_merge being NULL. // (texture appears to be non-null, and is being re-created at a size around like 1700x340, // dunno if that's relevant) -- air - if(m_merge) + if(ResizeTarget(&m_merge, fs.x, fs.y)) { GSTexture* tex[3] = {NULL, NULL, NULL}; @@ -290,12 +283,7 @@ void GSDevice::Merge(GSTexture* sTex[3], GSVector4* sRect, GSVector4* dRect, con void GSDevice::Interlace(const GSVector2i& ds, int field, int mode, float yoffset) { - if(m_weavebob == NULL || m_weavebob->GetSize() != ds) - { - delete m_weavebob; - - m_weavebob = CreateRenderTarget(ds.x, ds.y); - } + ResizeTarget(&m_weavebob, ds.x, ds.y); if(mode == 0 || mode == 2) // weave or blend { @@ -307,12 +295,7 @@ void GSDevice::Interlace(const GSVector2i& ds, int field, int mode, float yoffse { // blend - if(m_blend == NULL || m_blend->GetSize() != ds) - { - delete m_blend; - - m_blend = CreateRenderTarget(ds.x, ds.y); - } + ResizeTarget(&m_blend, ds.x, ds.y); DoInterlace(m_weavebob, m_blend, 2, false, 0); @@ -339,13 +322,7 @@ void GSDevice::ExternalFX() { GSVector2i s = m_current->GetSize(); - if (m_shaderfx == NULL || m_shaderfx->GetSize() != s) - { - delete m_shaderfx; - m_shaderfx = CreateRenderTarget(s.x, s.y); - } - - if (m_shaderfx != NULL) + if (ResizeTarget(&m_shaderfx)) { GSVector4 sRect(0, 0, 1, 1); GSVector4 dRect(0, 0, s.x, s.y); @@ -359,13 +336,7 @@ void GSDevice::FXAA() { GSVector2i s = m_current->GetSize(); - if(m_fxaa == NULL || m_fxaa->GetSize() != s) - { - delete m_fxaa; - m_fxaa = CreateRenderTarget(s.x, s.y); - } - - if(m_fxaa != NULL) + if(ResizeTarget(&m_fxaa)) { GSVector4 sRect(0, 0, 1, 1); GSVector4 dRect(0, 0, s.x, s.y); @@ -379,13 +350,7 @@ void GSDevice::ShadeBoost() { GSVector2i s = m_current->GetSize(); - if(m_shadeboost == NULL || m_shadeboost->GetSize() != s) - { - delete m_shadeboost; - m_shadeboost = CreateRenderTarget(s.x, s.y); - } - - if(m_shadeboost != NULL) + if(ResizeTarget(&m_shadeboost)) { GSVector4 sRect(0, 0, 1, 1); GSVector4 dRect(0, 0, s.x, s.y); @@ -395,7 +360,7 @@ void GSDevice::ShadeBoost() } } -bool GSDevice::ResizeTexture(GSTexture** t, int w, int h) +bool GSDevice::ResizeTexture(GSTexture** t, int type, int w, int h) { if(t == NULL) {ASSERT(0); return false;} @@ -405,7 +370,7 @@ bool GSDevice::ResizeTexture(GSTexture** t, int w, int h) { delete t2; - t2 = CreateTexture(w, h); + t2 = FetchSurface(type, w, h, 0); *t = t2; } @@ -413,6 +378,22 @@ bool GSDevice::ResizeTexture(GSTexture** t, int w, int h) return t2 != NULL; } +bool GSDevice::ResizeTexture(GSTexture** t, int w, int h) +{ + return ResizeTexture(t, GSTexture::Texture, w, h); +} + +bool GSDevice::ResizeTarget(GSTexture** t, int w, int h) +{ + return ResizeTexture(t, GSTexture::RenderTarget, w, h); +} + +bool GSDevice::ResizeTarget(GSTexture** t) +{ + GSVector2i s = m_current->GetSize(); + return ResizeTexture(t, GSTexture::RenderTarget, s.x, s.y); +} + GSAdapter::operator std::string() const { char buf[sizeof "12345678:12345678:12345678:12345678"]; diff --git a/plugins/GSdx/Renderers/Common/GSDevice.h b/plugins/GSdx/Renderers/Common/GSDevice.h index e299da88f6..566eceef08 100644 --- a/plugins/GSdx/Renderers/Common/GSDevice.h +++ b/plugins/GSdx/Renderers/Common/GSDevice.h @@ -200,7 +200,10 @@ public: void ExternalFX(); virtual void RenderOsd(GSTexture* dt) {}; + bool ResizeTexture(GSTexture** t, int type, int w, int h); bool ResizeTexture(GSTexture** t, int w, int h); + bool ResizeTarget(GSTexture** t, int w, int h); + bool ResizeTarget(GSTexture** t); bool IsRBSwapped() {return m_rbswapped;}