From ee19a2789cea9d04cca270fe43a4e96cb1203fdc Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Thu, 30 Apr 2015 19:38:30 +0200 Subject: [PATCH] gsdx: move invalidation from GSDevice to GSTexture Much cleaner this way --- plugins/GSdx/GSDevice.cpp | 2 +- plugins/GSdx/GSDevice.h | 1 - plugins/GSdx/GSDeviceOGL.cpp | 6 ------ plugins/GSdx/GSDeviceOGL.h | 2 -- plugins/GSdx/GSTexture.h | 1 + plugins/GSdx/GSTextureOGL.cpp | 10 ++++++++-- plugins/GSdx/GSTextureOGL.h | 2 ++ 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/GSdx/GSDevice.cpp b/plugins/GSdx/GSDevice.cpp index 1b0c44d51e..f0b4858a49 100644 --- a/plugins/GSdx/GSDevice.cpp +++ b/plugins/GSdx/GSDevice.cpp @@ -154,7 +154,7 @@ void GSDevice::Recycle(GSTexture* t) { if(t) { - Invalidate(t); + t->Invalidate(); t->last_frame_used = m_frame; diff --git a/plugins/GSdx/GSDevice.h b/plugins/GSdx/GSDevice.h index a498cdc5d4..115824e1a3 100644 --- a/plugins/GSdx/GSDevice.h +++ b/plugins/GSdx/GSDevice.h @@ -111,7 +111,6 @@ public: virtual ~GSDevice(); void Recycle(GSTexture* t); - virtual void Invalidate(GSTexture* t) {} enum {Windowed, Fullscreen, DontCare}; diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index d2c43c72d8..21e76e544c 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -607,12 +607,6 @@ void GSDeviceOGL::Barrier(GLbitfield b) #endif } -void GSDeviceOGL::Invalidate(GSTexture* t) -{ - if (gl_InvalidateTexImage) - gl_InvalidateTexImage(static_cast(t)->GetID(), GL_TEX_LEVEL_0); -} - /* Note: must be here because tfx_glsl is static */ GLuint GSDeviceOGL::CompileVS(VSSelector sel, int logz) { diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 064c7056e8..7467e51589 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -601,8 +601,6 @@ class GSDeviceOGL : public GSDevice void BeforeDraw(); void AfterDraw(); - void Invalidate(GSTexture* t); - void ClearRenderTarget(GSTexture* t, const GSVector4& c); void ClearRenderTarget(GSTexture* t, uint32 c); void ClearRenderTarget_ui(GSTexture* t, uint32 c); diff --git a/plugins/GSdx/GSTexture.h b/plugins/GSdx/GSTexture.h index a6c699f071..4a3161b5b3 100644 --- a/plugins/GSdx/GSTexture.h +++ b/plugins/GSdx/GSTexture.h @@ -47,6 +47,7 @@ public: virtual bool Map(GSMap& m, const GSVector4i* r = NULL) = 0; virtual void Unmap() = 0; virtual bool Save(const string& fn, bool dds = false) = 0; + virtual void Invalidate() {}; GSVector2 GetScale() const {return m_scale;} void SetScale(const GSVector2& scale) {m_scale = scale;} diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 167aef6164..f18f0e033b 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -165,8 +165,7 @@ namespace PboPool { // glPixelStorei(GL_UNPACK_ALIGNMENT, 1); GSTextureOGL::GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read) - : m_pbo_id(0), - m_pbo_size(0) + : m_pbo_id(0), m_pbo_size(0), m_dirty(false) { // m_size.x = w; // m_size.y = h; @@ -273,9 +272,16 @@ GSTextureOGL::~GSTextureOGL() glDeleteTextures(1, &m_texture_id); } +void GSTextureOGL::Invalidate() +{ + if (m_dirty && gl_InvalidateTexImage) + gl_InvalidateTexImage(m_texture_id, GL_TEX_LEVEL_0); +} + bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) { ASSERT(m_type != GSTexture::DepthStencil && m_type != GSTexture::Offscreen); + m_dirty = true; // Note: reduce noise for gl retracers // It might introduce bug after an emulator pause so always set it in standard mode diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index 1fe69b49e1..cfd6456780 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -49,6 +49,7 @@ class GSTextureOGL : public GSTexture uint32 m_pbo_id; int m_pbo_size; GLuint m_fbo_read; + bool m_dirty; // internal opengl format/type/alignment GLenum m_int_format; @@ -62,6 +63,7 @@ class GSTextureOGL : public GSTexture explicit GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read); virtual ~GSTextureOGL(); + void Invalidate(); bool Update(const GSVector4i& r, const void* data, int pitch); bool Map(GSMap& m, const GSVector4i* r = NULL); void Unmap();