From d81254469a229953247d222b5859997d7071b5b2 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sun, 30 Jun 2013 11:18:46 +0000 Subject: [PATCH] gsdx ogl: * fix shader compilation on Nvidia (broken on r5682) * fix various memory leak thanks to Valgrind Cmake: fix a minor typo git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5688 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 16 +++++++++++++++- plugins/GSdx/GSWndEGL.cpp | 4 ++++ plugins/GSdx/GSWndOGL.cpp | 4 +++- plugins/GSdx/res/tfx.glsl | 2 +- plugins/GSdx/res/tfx.h | 2 +- plugins/spu2-x/src/CMakeLists.txt | 2 +- 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index b3a567c52f..f645278df8 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -122,6 +122,15 @@ GSDeviceOGL::~GSDeviceOGL() delete m_date.dss; delete m_date.bs; + // Clean shadeboost + delete m_shadeboost.cb; + if (GLLoader::found_GL_ARB_separate_shader_objects) { + gl_DeleteProgram(m_shadeboost.ps); + } else { + gl_DeleteShader(m_shadeboost.ps); + } + + // Clean various opengl allocation if (GLLoader::found_GL_ARB_separate_shader_objects) gl_DeleteProgramPipelines(1, &m_pipeline); @@ -134,6 +143,7 @@ GSDeviceOGL::~GSDeviceOGL() gl_DeleteSamplers(1, &m_palette_ss); delete m_vb; + if (GLLoader::found_GL_ARB_separate_shader_objects) { for (uint32 key = 0; key < VSSelector::size(); key++) gl_DeleteProgram(m_vs[key]); for (uint32 key = 0; key < GSSelector::size(); key++) gl_DeleteProgram(m_gs[key]); @@ -146,11 +156,13 @@ GSDeviceOGL::~GSDeviceOGL() for (auto it = m_single_prog.begin(); it != m_single_prog.end() ; it++) gl_DeleteProgram(it->second); m_single_prog.clear(); } + m_ps.clear(); gl_DeleteSamplers(PSSamplerSelector::size(), m_ps_ss); for (uint32 key = 0; key < OMDepthStencilSelector::size(); key++) delete m_om_dss[key]; - m_ps.clear(); + + for (auto it = m_om_bs.begin(); it != m_om_bs.end(); it++) delete it->second; m_om_bs.clear(); } @@ -1417,6 +1429,8 @@ void GSDeviceOGL::CheckDebugLog() pos += lengths[i]; } } + + delete[] messageLog; } void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message) diff --git a/plugins/GSdx/GSWndEGL.cpp b/plugins/GSdx/GSWndEGL.cpp index 9f3fa5fdfc..0ced8f4ee6 100644 --- a/plugins/GSdx/GSWndEGL.cpp +++ b/plugins/GSdx/GSWndEGL.cpp @@ -136,6 +136,10 @@ void GSWndEGL::Detach() // Actually the destructor is not called when there is only a GSclose/GSshutdown // The window still need to be closed DetachContext(); + eglDestroyContext(m_eglDisplay, m_eglContext); + m_eglContext = NULL; + eglDestroySurface(m_eglDisplay, m_eglSurface); + m_eglSurface = NULL; CloseEGLDisplay(); if (m_NativeDisplay) { diff --git a/plugins/GSdx/GSWndOGL.cpp b/plugins/GSdx/GSWndOGL.cpp index 19d124d5b1..e74123ee99 100644 --- a/plugins/GSdx/GSWndOGL.cpp +++ b/plugins/GSdx/GSWndOGL.cpp @@ -63,6 +63,8 @@ void GSWndOGL::CreateContext(int major, int minor) if (!fbc || fbcount < 1) { throw GSDXRecoverableError(); } + XFree(fbc); + GLXFBConfig fbc_cp = fbc[0]; PFNGLXCREATECONTEXTATTRIBSARBPROC glX_CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB"); if (!glX_CreateContextAttribsARB) { @@ -86,7 +88,7 @@ void GSWndOGL::CreateContext(int major, int minor) None }; - m_context = glX_CreateContextAttribsARB(m_NativeDisplay, fbc[0], 0, true, context_attribs); + m_context = glX_CreateContextAttribsARB(m_NativeDisplay, fbc_cp, 0, true, context_attribs); // Don't forget to reinstall the older Handler XSetErrorHandler(oldHandler); diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 82939e2ca4..d760bfa3de 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -100,7 +100,7 @@ layout(std140, binding = 20) uniform cb20 vec2 TextureScale; }; -const float exp_min32 = exp2(-32); +const float exp_min32 = exp2(-32.0f); void vs_main() { diff --git a/plugins/GSdx/res/tfx.h b/plugins/GSdx/res/tfx.h index 398ed01bdd..1ccec99edd 100644 --- a/plugins/GSdx/res/tfx.h +++ b/plugins/GSdx/res/tfx.h @@ -128,7 +128,7 @@ static const char* tfx_glsl = " vec2 TextureScale;\n" "};\n" "\n" - "const float exp_min32 = exp2(-32);\n" + "const float exp_min32 = exp2(-32.0f);\n" "\n" "void vs_main()\n" "{\n" diff --git a/plugins/spu2-x/src/CMakeLists.txt b/plugins/spu2-x/src/CMakeLists.txt index 9d523e6b63..08de78f3a6 100644 --- a/plugins/spu2-x/src/CMakeLists.txt +++ b/plugins/spu2-x/src/CMakeLists.txt @@ -110,7 +110,7 @@ add_library(${Output} SHARED # link target with project internal libraries -target_link_libraries(${Output} Utilities Utilities) +target_link_libraries(${Output} Utilities) # link target with ALSA target_link_libraries(${Output} ${ALSA_LIBRARIES})