From cd024e88e8de28d06b77b334f5a1ecbf0a71de81 Mon Sep 17 00:00:00 2001 From: raven02 Date: Mon, 14 Apr 2014 11:34:45 +0800 Subject: [PATCH] Add #extension GL_EXT_shader_framebuffer_fetch : require --- GPU/GLES/FragmentShaderGenerator.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/GPU/GLES/FragmentShaderGenerator.cpp b/GPU/GLES/FragmentShaderGenerator.cpp index c31683f53c..a11e5747e2 100644 --- a/GPU/GLES/FragmentShaderGenerator.cpp +++ b/GPU/GLES/FragmentShaderGenerator.cpp @@ -37,9 +37,6 @@ // #define DEBUG_SHADER -// GL_NV_shader_framebuffer_fetch looks interesting.... - - // Dest factors where it's safe to eliminate the alpha test under certain conditions const bool safeDestFactors[16] = { true, // GE_DSTBLEND_SRCCOLOR, @@ -370,6 +367,12 @@ void GenerateFragmentShader(char *buffer) { // PowerVR needs highp to do the fog in MHU correctly. // Others don't, and some can't handle highp in the fragment shader. highpFog = gl_extensions.gpuVendor == GPU_VENDOR_POWERVR; + + // GL_EXT_shader_framebuffer_fetch available on mobile platform and ES 2.0 only but not desktop + if (gl_extensions.EXT_shader_framebuffer_fetch) { + WRITE(p, " #extension GL_EXT_shader_framebuffer_fetch : require\n"); + } + #elif !defined(FORCE_OPENGL_2_0) if (gl_extensions.VersionGEThan(3, 3, 0)) { fragColor0 = "fragColor0"; @@ -601,7 +604,8 @@ void GenerateFragmentShader(char *buffer) { // Handle ABSDIFF blending mode using GL_EXT_shader_framebuffer_fetch if (computeAbsdiff && gl_extensions.EXT_shader_framebuffer_fetch) { - WRITE(p, " gl_FragColor.rgb = abs(v.rgb - gl_LastFragData[0].rgb);\n"); + WRITE(p, " lowp vec4 destColor = gl_LastFragData[0];\n"); + WRITE(p, " gl_FragColor = abs(destColor - v);\n"); } switch (stencilToAlpha) {