From 79587215bb332e1c08a40781d0743d10fd3738ec Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 24 Jun 2016 18:41:55 +0200 Subject: [PATCH] gsdx ogl: add the option force_texture_clear for test purpose Might be completely useless. 1 => always clear framebuffers and textures to black (aka 0) 2 => always clear framebuffers and textures to red --- plugins/GSdx/GSDeviceOGL.cpp | 51 ++++++++++++++++++++++++++++------- plugins/GSdx/GSDeviceOGL.h | 1 + plugins/GSdx/GSTextureOGL.cpp | 3 --- plugins/GSdx/GSdx.cpp | 1 + 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index bab532fa71..6c96ed2a78 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -52,6 +52,7 @@ FILE* GSDeviceOGL::m_debug_gl_file = NULL; GSDeviceOGL::GSDeviceOGL() : m_msaa(0) + , m_force_texture_clear(0) , m_window(NULL) , m_fbo(0) , m_fbo_read(0) @@ -150,15 +151,19 @@ GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int fmt } // NOTE: I'm not sure RenderTarget always need to be cleared. It could be costly for big upscale. - switch(type) - { - case GSTexture::RenderTarget: - ClearRenderTarget(t, 0); - break; - case GSTexture::DepthStencil: - ClearDepth(t, 0); - // No need to clear the stencil now. - break; + // FIXME: it will be more logical to do it in FetchSurface. This code is only called at first creation + // of the texture. However we could reuse a deleted texture. + if (m_force_texture_clear == 0) { + switch(type) + { + case GSTexture::RenderTarget: + ClearRenderTarget(t, 0); + break; + case GSTexture::DepthStencil: + ClearDepth(t, 0); + // No need to clear the stencil now. + break; + } } return t; @@ -166,7 +171,31 @@ GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int fmt GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, bool msaa, int format) { - return GSDevice::FetchSurface(type, w, h, false, format); + GSTexture* t = GSDevice::FetchSurface(type, w, h, false, format); + + + if (m_force_texture_clear) { + GSVector4 red(1.0f, 0.0f, 0.0f, 1.0f); + switch(type) + { + case GSTexture::RenderTarget: + ClearRenderTarget(t, 0); + break; + case GSTexture::DepthStencil: + ClearDepth(t, 0); + // No need to clear the stencil now. + break; + case GSTexture::Texture: + if (m_force_texture_clear > 1) + static_cast(t)->Clear((void*)&red); + else if (m_force_texture_clear) + static_cast(t)->Clear(NULL); + + break; + } + } + + return t; } bool GSDeviceOGL::Create(GSWnd* wnd) @@ -194,6 +223,8 @@ bool GSDeviceOGL::Create(GSWnd* wnd) } #endif + m_force_texture_clear = theApp.GetConfigI("force_texture_clear"); + // WARNING it must be done after the control setup (at least on MESA) GL_PUSH("GSDeviceOGL::Create"); diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 38a580cc92..3a16207bbf 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -398,6 +398,7 @@ public: private: uint32 m_msaa; // Level of Msaa + int m_force_texture_clear; static bool m_debug_gl_call; static FILE* m_debug_gl_file; diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 7593d9fa05..b375e63d7b 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -29,9 +29,6 @@ extern uint64 g_real_texture_upload_byte; #endif -// FIXME find the optimal number of PBO -#define PBO_POOL_SIZE 8 - // FIXME OGL4: investigate, only 1 unpack buffer always bound namespace PboPool { diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp index b96df56dbf..878de1ff33 100644 --- a/plugins/GSdx/GSdx.cpp +++ b/plugins/GSdx/GSdx.cpp @@ -275,6 +275,7 @@ GSdxApp::GSdxApp() m_default_configuration["dump"] = "0"; m_default_configuration["extrathreads"] = "2"; m_default_configuration["filter"] = "2"; + m_default_configuration["force_texture_clear"] = "0"; m_default_configuration["fxaa"] = "0"; m_default_configuration["interlace"] = "7"; m_default_configuration["large_framebuffer"] = "1";