From f5257b2c3c4d59954646ca84f29c5a58389a3d66 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sat, 11 Jan 2014 15:01:13 +0000 Subject: [PATCH] gsdx ogl: don't rely on GL_ES builtin (3 differents implementations...). Hopefully fix Linux Intel GPU. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5808 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSShaderOGL.cpp | 13 ++++++++----- plugins/GSdx/res/convert.glsl | 6 +++--- plugins/GSdx/res/glsl_source.h | 28 ++++++++++++++-------------- plugins/GSdx/res/interlace.glsl | 2 +- plugins/GSdx/res/merge.glsl | 2 +- plugins/GSdx/res/shadeboost.glsl | 2 +- plugins/GSdx/res/tfx.glsl | 14 +++++++------- 7 files changed, 35 insertions(+), 32 deletions(-) diff --git a/plugins/GSdx/GSShaderOGL.cpp b/plugins/GSdx/GSShaderOGL.cpp index ab2b22b5d6..ea05ef005e 100644 --- a/plugins/GSdx/GSShaderOGL.cpp +++ b/plugins/GSdx/GSShaderOGL.cpp @@ -406,11 +406,14 @@ std::string GSShaderOGL::GenGlslHeader(const std::string& entry, GLenum type, co header += "#define DISABLE_GL42_image\n"; #endif -#ifndef ENABLE_GLES - // Some driver define the MACRO to 0, others keep it undefined... - header += "#ifndef GL_ES\n"; - header += "#define GL_ES 0\n"; - header += "#endif\n"; + // Stupid GL implementation (can't use GL_ES) + // AMD/nvidia define it to 0 + // intel window don't define it + // intel linux refuse to define it +#ifdef ENABLE_GLES + header += "#define pGL_ES 1\n"; +#else + header += "#define pGL_ES 0\n"; #endif // Allow to puts several shader in 1 files diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index dcd001b330..d03a31a62f 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -9,7 +9,7 @@ struct vertex_basic #ifdef VERTEX_SHADER -#if !GL_ES && __VERSION__ > 140 +#if !pGL_ES && __VERSION__ > 140 out gl_PerVertex { vec4 gl_Position; float gl_PointSize; @@ -28,7 +28,7 @@ layout(location = 1) in vec2 TEXCOORD0; // smooth, the default, means to do perspective-correct interpolation. // // The centroid qualifier only matters when multisampling. If this qualifier is not present, then the value is interpolated to the pixel's center, anywhere in the pixel, or to one of the pixel's samples. This sample may lie outside of the actual primitive being rendered, since a primitive can cover only part of a pixel's area. The centroid qualifier is used to prevent this; the interpolation point must fall within both the pixel's area and the primitive's area. -#if !GL_ES && __VERSION__ > 140 +#if !pGL_ES && __VERSION__ > 140 out SHADER { @@ -64,7 +64,7 @@ void vs_main() #ifdef FRAGMENT_SHADER -#if !GL_ES && __VERSION__ > 140 +#if !pGL_ES && __VERSION__ > 140 in SHADER { diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index 0fe67af3db..9f274bc435 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -34,7 +34,7 @@ static const char* convert_glsl = "\n" "#ifdef VERTEX_SHADER\n" "\n" - "#if !GL_ES && __VERSION__ > 140\n" + "#if !pGL_ES && __VERSION__ > 140\n" "out gl_PerVertex {\n" " vec4 gl_Position;\n" " float gl_PointSize;\n" @@ -53,7 +53,7 @@ static const char* convert_glsl = "// smooth, the default, means to do perspective-correct interpolation.\n" "//\n" "// The centroid qualifier only matters when multisampling. If this qualifier is not present, then the value is interpolated to the pixel's center, anywhere in the pixel, or to one of the pixel's samples. This sample may lie outside of the actual primitive being rendered, since a primitive can cover only part of a pixel's area. The centroid qualifier is used to prevent this; the interpolation point must fall within both the pixel's area and the primitive's area.\n" - "#if !GL_ES && __VERSION__ > 140\n" + "#if !pGL_ES && __VERSION__ > 140\n" "\n" "out SHADER\n" "{\n" @@ -89,7 +89,7 @@ static const char* convert_glsl = "\n" "#ifdef FRAGMENT_SHADER\n" "\n" - "#if !GL_ES && __VERSION__ > 140\n" + "#if !pGL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" @@ -261,7 +261,7 @@ static const char* interlace_glsl = " vec2 t;\n" "};\n" "\n" - "#if !GL_ES && __VERSION__ > 140\n" + "#if !pGL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" @@ -359,7 +359,7 @@ static const char* merge_glsl = " vec2 t;\n" "};\n" "\n" - "#if !GL_ES && __VERSION__ > 140\n" + "#if !pGL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" @@ -441,7 +441,7 @@ static const char* shadeboost_glsl = "\n" "#ifdef FRAGMENT_SHADER\n" "\n" - "#if !GL_ES && __VERSION__ > 140\n" + "#if !pGL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" @@ -582,7 +582,7 @@ static const char* tfx_glsl = "layout(location = 5) in uvec2 i_uv;\n" "layout(location = 6) in vec4 i_f;\n" "\n" - "#if !GL_ES && __VERSION__ > 140\n" + "#if !pGL_ES && __VERSION__ > 140\n" "\n" "out SHADER\n" "{\n" @@ -612,7 +612,7 @@ static const char* tfx_glsl = "\n" "#endif\n" "\n" - "#if !GL_ES && __VERSION__ > 140\n" + "#if !pGL_ES && __VERSION__ > 140\n" "out gl_PerVertex {\n" " invariant vec4 gl_Position;\n" " float gl_PointSize;\n" @@ -819,7 +819,7 @@ static const char* tfx_glsl = "\n" "#ifdef FRAGMENT_SHADER\n" "\n" - "#if !GL_ES && __VERSION__ > 140\n" + "#if !pGL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" @@ -850,7 +850,7 @@ static const char* tfx_glsl = "#endif\n" "\n" "// Same buffer but 2 colors for dual source blending\n" - "#if GL_ES\n" + "#if pGL_ES\n" "layout(location = 0) out vec4 SV_Target0;\n" "#else\n" "layout(location = 0, index = 0) out vec4 SV_Target0;\n" @@ -1562,7 +1562,7 @@ static const char* tfx_glsl = " return c;\n" "}\n" "\n" - "#if GL_ES\n" + "#if pGL_ES\n" "void ps_main()\n" "{\n" " vec4 c = ps_color();\n" @@ -1571,7 +1571,7 @@ static const char* tfx_glsl = "}\n" "#endif\n" "\n" - "#if !GL_ES\n" + "#if !pGL_ES\n" "void ps_main()\n" "{\n" "#if PS_DATE == 3 && !defined(DISABLE_GL42_image)\n" @@ -1626,7 +1626,7 @@ static const char* tfx_glsl = "#endif\n" "\n" "}\n" - "#endif // !GL_ES\n" + "#endif // !pGL_ES\n" "\n" "#endif\n" ; @@ -1725,7 +1725,7 @@ static const char* fxaa_fx = "#endif\n" "#endif\n" "\n" - "#if !GL_ES && __VERSION__ > 140\n" + "#if !pGL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" diff --git a/plugins/GSdx/res/interlace.glsl b/plugins/GSdx/res/interlace.glsl index 18979a1c43..0659c909f8 100644 --- a/plugins/GSdx/res/interlace.glsl +++ b/plugins/GSdx/res/interlace.glsl @@ -6,7 +6,7 @@ struct vertex_basic vec2 t; }; -#if !GL_ES && __VERSION__ > 140 +#if !pGL_ES && __VERSION__ > 140 in SHADER { diff --git a/plugins/GSdx/res/merge.glsl b/plugins/GSdx/res/merge.glsl index 1a20359cfa..64297405a7 100644 --- a/plugins/GSdx/res/merge.glsl +++ b/plugins/GSdx/res/merge.glsl @@ -6,7 +6,7 @@ struct vertex_basic vec2 t; }; -#if !GL_ES && __VERSION__ > 140 +#if !pGL_ES && __VERSION__ > 140 in SHADER { diff --git a/plugins/GSdx/res/shadeboost.glsl b/plugins/GSdx/res/shadeboost.glsl index cd11c0de51..1b74778e27 100644 --- a/plugins/GSdx/res/shadeboost.glsl +++ b/plugins/GSdx/res/shadeboost.glsl @@ -14,7 +14,7 @@ struct vertex_basic #ifdef FRAGMENT_SHADER -#if !GL_ES && __VERSION__ > 140 +#if !pGL_ES && __VERSION__ > 140 in SHADER { diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 7a44a6d919..5d095ee0a1 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -56,7 +56,7 @@ layout(location = 4) in uint i_z; layout(location = 5) in uvec2 i_uv; layout(location = 6) in vec4 i_f; -#if !GL_ES && __VERSION__ > 140 +#if !pGL_ES && __VERSION__ > 140 out SHADER { @@ -86,7 +86,7 @@ flat layout(location = 2) out vec4 SHADERfc; #endif -#if !GL_ES && __VERSION__ > 140 +#if !pGL_ES && __VERSION__ > 140 out gl_PerVertex { invariant vec4 gl_Position; float gl_PointSize; @@ -293,7 +293,7 @@ void gs_main() #ifdef FRAGMENT_SHADER -#if !GL_ES && __VERSION__ > 140 +#if !pGL_ES && __VERSION__ > 140 in SHADER { @@ -324,7 +324,7 @@ flat layout(location = 2) in vec4 SHADERfc; #endif // Same buffer but 2 colors for dual source blending -#if GL_ES +#if pGL_ES layout(location = 0) out vec4 SV_Target0; #else layout(location = 0, index = 0) out vec4 SV_Target0; @@ -1036,7 +1036,7 @@ vec4 ps_color() return c; } -#if GL_ES +#if pGL_ES void ps_main() { vec4 c = ps_color(); @@ -1045,7 +1045,7 @@ void ps_main() } #endif -#if !GL_ES +#if !pGL_ES void ps_main() { #if PS_DATE == 3 && !defined(DISABLE_GL42_image) @@ -1100,6 +1100,6 @@ void ps_main() #endif } -#endif // !GL_ES +#endif // !pGL_ES #endif