From b10d5547647e18bc4d8238c44bd743aecc868ff1 Mon Sep 17 00:00:00 2001
From: "gregory.hainaut" <gregory.hainaut@96395faa-99c1-11dd-bbfe-3dabce05a288>
Date: Sun, 16 Jun 2013 07:05:57 +0000
Subject: [PATCH] gsdx (ogl): * fix memory leak of m_wnd * don't escape % in
 the shader string * Fix shadeboost StretchRect parameter

debian: compress package with xz


git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5669 96395faa-99c1-11dd-bbfe-3dabce05a288
---
 debian-unstable-upstream/rules | 3 +++
 linux_various/glsl2h.pl        | 1 -
 plugins/GSdx/GS.cpp            | 6 ++++++
 plugins/GSdx/GSDeviceOGL.cpp   | 2 +-
 plugins/GSdx/res/convert.h     | 4 ++--
 plugins/GSdx/res/shadeboost.h  | 2 +-
 6 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/debian-unstable-upstream/rules b/debian-unstable-upstream/rules
index 748d5c322c..07303953a0 100755
--- a/debian-unstable-upstream/rules
+++ b/debian-unstable-upstream/rules
@@ -21,6 +21,9 @@ override_dh_strip:
 
 override_dh_makeshlibs:
 
+override_dh_builddeb:
+	        dh_builddeb -- -Zxz
+
 clean:
 	dh_auto_clean
 	dh_clean
diff --git a/linux_various/glsl2h.pl b/linux_various/glsl2h.pl
index 9d26116048..510bdae3d2 100755
--- a/linux_various/glsl2h.pl
+++ b/linux_various/glsl2h.pl
@@ -58,7 +58,6 @@ EOS
     my $line;
     while(defined($line = <$GLSL>)) {
         chomp $line;
-        $line =~ s/%/\\%/g;
         $line =~ s/"/\\"/g;
         print $H "\t\"$line\\n\"\n";
     }
diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp
index 698af7c639..be8dbcd9cd 100644
--- a/plugins/GSdx/GS.cpp
+++ b/plugins/GSdx/GS.cpp
@@ -173,11 +173,17 @@ EXPORT_C GSclose()
 
 	s_gs->ResetDevice();
 
+	// Opengl requirement: It must be done before the Detach() of
+	// the context
 	delete s_gs->m_dev;
 
 	s_gs->m_dev = NULL;
 
 	s_gs->m_wnd->Detach();
+
+	delete s_gs->m_wnd;
+
+	s_gs->m_wnd = NULL;
 }
 
 static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp
index 171c8ced93..3e848018b4 100644
--- a/plugins/GSdx/GSDeviceOGL.cpp
+++ b/plugins/GSdx/GSDeviceOGL.cpp
@@ -963,7 +963,7 @@ void GSDeviceOGL::DoShadeBoost(GSTexture* st, GSTexture* dt)
 	SetUniformBuffer(m_shadeboost.cb);
 	m_shadeboost.cb->upload(&cb);
 
-	StretchRect(st, sr, dt, dr, m_shadeboost.ps, m_shadeboost.cb);
+	StretchRect(st, sr, dt, dr, m_shadeboost.ps, true);
 }
 
 void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm)
diff --git a/plugins/GSdx/res/convert.h b/plugins/GSdx/res/convert.h
index f366e1bfed..25ffec27cd 100644
--- a/plugins/GSdx/res/convert.h
+++ b/plugins/GSdx/res/convert.h
@@ -157,7 +157,7 @@ static const char* convert_glsl =
 	"{\n"
 	"	highp uvec4 p = uvec4(PSin_p);\n"
 	"\n"
-	"	vec4 c = ps_crt(((p.x + ((p.y >> 1u) & 1u) * 3u) >> 1u) \% 3u);\n"
+	"	vec4 c = ps_crt(((p.x + ((p.y >> 1u) & 1u) * 3u) >> 1u) % 3u);\n"
 	"\n"
 	"    SV_Target0 = c;\n"
 	"}\n"
@@ -166,7 +166,7 @@ static const char* convert_glsl =
 	"{\n"
 	"	uvec4 p = uvec4(PSin_p);\n"
 	"\n"
-	"	vec4 c = ps_crt((p.x + (p.y \% 3u)) \% 3u);\n"
+	"	vec4 c = ps_crt((p.x + (p.y % 3u)) % 3u);\n"
 	"\n"
 	"    SV_Target0 = c;\n"
 	"}\n"
diff --git a/plugins/GSdx/res/shadeboost.h b/plugins/GSdx/res/shadeboost.h
index 5890feea67..09c8ed7939 100644
--- a/plugins/GSdx/res/shadeboost.h
+++ b/plugins/GSdx/res/shadeboost.h
@@ -75,7 +75,7 @@ static const char* shadeboost_glsl =
 	"layout(binding = 0) uniform sampler2D TextureSampler;\n"
 	"#endif\n"
 	"\n"
-	"// For all settings: 1.0 = 100\% 0.5=50\% 1.5 = 150\% \n"
+	"// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150% \n"
 	"vec4 ContrastSaturationBrightness(vec4 color)\n"
 	"{\n"
 	"	const float sat = SB_SATURATION / 50.0;\n"