diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 532ded2a63fab..f413971c6e3de 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -485,7 +485,7 @@ class GSDeviceOGL : public GSDevice struct { GLuint vs; // program object - GLuint ps[10]; // program object + GLuint ps[11]; // program object GLuint ln; // sampler object GLuint pt; // sampler object GSDepthStencilOGL* dss; diff --git a/plugins/GSdx/GSTextureCacheOGL.cpp b/plugins/GSdx/GSTextureCacheOGL.cpp index 206cd705c2ee7..743103c7d2c70 100644 --- a/plugins/GSdx/GSTextureCacheOGL.cpp +++ b/plugins/GSdx/GSTextureCacheOGL.cpp @@ -67,12 +67,12 @@ void GSTextureCacheOGL::Read(Target* t, const GSVector4i& r) case PSM_PSMZ24: fmt = GL_R32UI; - ps_shader = 11; + ps_shader = 10; return; case PSM_PSMZ16: fmt = GL_R16UI; - ps_shader = 12; + ps_shader = 10; return; default: diff --git a/plugins/GSdx/res/glsl/convert.glsl b/plugins/GSdx/res/glsl/convert.glsl index b84778de5ec83..bea451dd1a3b5 100644 --- a/plugins/GSdx/res/glsl/convert.glsl +++ b/plugins/GSdx/res/glsl/convert.glsl @@ -58,7 +58,7 @@ in SHADER #define PSin_t (PSin.t) // Give a different name so I remember there is a special case! -#ifdef ps_main1 +#if defined(ps_main1) || defined(ps_main10) layout(location = 0) out uint SV_Target1; #else layout(location = 0) out vec4 SV_Target0; @@ -137,6 +137,15 @@ void ps_main1() } #endif +#ifdef ps_main10 +void ps_main10() +{ + vec4 c = sample_c(); + const float exp2_32 = exp2(32.0f); + SV_Target1 = uint(exp2_32 * c.r); +} +#endif + #ifdef ps_main7 void ps_main7() { diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index 6368f3164fdeb..e5f4392d89e0f 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -83,7 +83,7 @@ static const char* convert_glsl = "#define PSin_t (PSin.t)\n" "\n" "// Give a different name so I remember there is a special case!\n" - "#ifdef ps_main1\n" + "#if defined(ps_main1) || defined(ps_main10)\n" "layout(location = 0) out uint SV_Target1;\n" "#else\n" "layout(location = 0) out vec4 SV_Target0;\n" @@ -133,18 +133,25 @@ static const char* convert_glsl = "#ifdef ps_main1\n" "void ps_main1()\n" "{\n" - " vec4 c = sample_c();\n" - " // Color is RGBA8\n" + " // Input Color is RGBA8\n" "\n" " // We want to output a pixel on the PSMCT16* format\n" + " // A1-BGR5\n" "\n" "#if 0\n" + " // For me this code is more accurate but it will require some tests\n" + "\n" + " vec4 c = sample_c() * 255.0f + 0.5f; // Denormalize value\n" "\n" - " highp uvec4 i = uvec4(255.0f * c * vec4(1/32.0f, 4.0f, 64.0f, 512.0f));\n" + " highp uvec4 i = uvec4(c * vec4(1/32.0f, 4.0f, 64.0f, 512.0f)); // Shift value\n" "\n" " SV_Target1 = (i.x & uint(0x001f)) | (i.y & uint(0x03e0)) | (i.z & uint(0x7c00)) | (i.w & uint(0x8000));\n" "\n" "#else\n" + " // Old code which is likely wrong.\n" + "\n" + " vec4 c = sample_c();\n" + "\n" " c.a *= 256.0f / 127.0f; // hm, 0.5 won't give us 1.0 if we just multiply with 2\n" "\n" " highp uvec4 i = uvec4(c * vec4(uint(0x001f), uint(0x03e0), uint(0x7c00), uint(0x8000)));\n" @@ -155,6 +162,15 @@ static const char* convert_glsl = "}\n" "#endif\n" "\n" + "#ifdef ps_main10\n" + "void ps_main10()\n" + "{\n" + " vec4 c = sample_c();\n" + " const float exp2_32 = exp2(32.0f);\n" + " SV_Target1 = uint(exp2_32 * c.r);\n" + "}\n" + "#endif\n" + "\n" "#ifdef ps_main7\n" "void ps_main7()\n" "{\n"