Shaders not working in Second Life with Mesa + Radeon

I’m a user of the Second Life virtual space platform. So far the SL viewer worked flawlessly for me under Linux. Yesterday however, I decided to dump the proprietary ATI driver (fglrx) and let Linux switch back to the free Radeon driver and Mesa. This completely broke GLSL shaders for the Second Life viewer, although Mesa is clearly capable to support them. fglrx is problematic and I’m not going back to it, and I really need to get SL working properly again. Can anyone help and tell me what I should do?

My Linux distribution is openSUSE 13.1, KDE 4.11.2. X11 1.6.2, MESA 9.2.2, Radeon 7.2.0 (xf86-video-ati) supporting OpenGL <= 3.1. My video card is a Radeon HD 6870. The viewer I use is Firestorm LGPL version 4.5.2. Here is the console output I get when I try to enable shaders while in-world: http://pastebin.com/raw.php?i=z4P1bu91

2013-11-13T13:20:12Z WARNING: llrender/llshadermgr.cpp(842) : loadShaderFile: GLSL Compilation Error: (0) in effects/glowExtractF.glsl
2013-11-13T13:20:12Z WARNING: llrender/llshadermgr.cpp(515) : dumpObjectLog: 0:39(1): error: syntax error, unexpected EXTENSION, expecting $end

2013-11-13T13:20:12Z WARNING: llrender/llshadermgr.cpp(869) : loadShaderFile: #version 130

2013-11-13T13:20:12Z WARNING: llrender/llshadermgr.cpp(842) : loadShaderFile: GLSL Compilation Error: (0) in effects/glowExtractF.glsl
2013-11-13T13:20:12Z WARNING: llrender/llshadermgr.cpp(515) : dumpObjectLog: 0:39(1): error: syntax error, unexpected EXTENSION, expecting $end

2013-11-13T13:20:12Z WARNING: llrender/llshadermgr.cpp(869) : loadShaderFile: #version 130

2013-11-13T13:20:12Z WARNING: llrender/llshadermgr.cpp(905) : loadShaderFile: Failed to load effects/glowExtractF.glsl
2013-11-13T13:20:12Z WARNING: llrender/llglslshader.cpp(432) : createShader: Failed to link shader: Glow Extract Shader (Post)
2013-11-13T13:20:12Z WARNING: llrender/llglslshader.cpp(437) : createShader: Failed to link using shader level 1 trying again using shader level 0
2013-11-13T13:20:12Z WARNING: llrender/llshadermgr.cpp(576) : loadShaderFile: GLSL Shader file not found: effects/glowExtractV.glsl
2013-11-13T13:20:12Z WARNING: llrender/llshadermgr.cpp(576) : loadShaderFile: GLSL Shader file not found: effects/glowExtractF.glsl
2013-11-13T13:20:12Z WARNING: llrender/llglslshader.cpp(432) : createShader: Failed to link shader: Glow Extract Shader (Post)
2013-11-13T13:20:12Z INFO: newview/lldrawpoolbump.cpp(940) : clear: Clearing dynamic bumpmaps.
2013-11-13T13:20:12Z INFO: newview/lldrawpoolbump.cpp(168) : clear: Clearing standard bumpmaps.
2013-11-13T13:20:12Z INFO: newview/lldrawpoolbump.cpp(168) : clear: Clearing standard bumpmaps.
2013-11-13T13:20:12Z INFO: newview/lldrawpoolbump.cpp(168) : clear: Clearing standard bumpmaps.
2013-11-13T13:20:12Z INFO: newview/lldrawpoolbump.cpp(107) : addstandard: Adding standard bumpmaps.
2013-11-13T13:20:12Z INFO: newview/lldrawpoolbump.cpp(940) : clear: Clearing dynamic bumpmaps.
2013-11-13T13:20:12Z INFO: newview/lldrawpoolbump.cpp(168) : clear: Clearing standard bumpmaps.
2013-11-13T13:20:12Z INFO: newview/lldrawpoolbump.cpp(168) : clear: Clearing standard bumpmaps.
2013-11-13T13:20:12Z INFO: newview/llviewershadermgr.cpp(438) : setShaders: 

Problem is that the propritary drivers have additional functionality used in intense 3D that the OS drivers don’t have. I have seen the same thing with NVIDIA cards. I play Eternal Lands and the OS driver simply does not render things right. it is missing special functions. When loaded it lists a bunch of missing function and even though it runs houses and other items are totally missing in the render. Where OS is fine for desktop effects and such there are things missing needed for intense 3D graphic games. Running the NVIDIA driver and all is right with the world again :slight_smile:

Proprietary drivers (especially fglrx from what I can tell) are problematic, and I recommend people to avoid them. First of all, they’re proprietary… what’s the point of an open-source OS if you need closed-source components for open-source software? Worst of all, they have severe bugs. fglrx was constantly causing system freezes and other glitches, while newer versions even made X reach its client limit and rendered the OS unusable. Getting rid of it was an escape from hell.

It is however true that proprietary drivers are better for modern games. Both because they guarantee functionality and are somewhat faster. But especially with the latest versions of X, Mesa and Radeon, I believe the concept that proprietary drivers are needed for gaming will be proved wrong. Xonotic (the most high-end Linux game I’m aware of) finally works almost just as well as on fglrx, with all shaders and effects enabled.

But back on topic, I really need to get SL shaders working on Mesa, if there’s any change that they can work. I don’t believe they’re overly complex shaders, nor does SL rely or anything proprietary other than the Havoc physics engine. The Second Life viewer is also open-source and Linux native, so it would make little sense for it to be completely incompatible with a free driver.

Update: Someone on IRC asked me to take a full GLSL dump output, to see exactly what’s failing in shader compilation. It didn’t help clarify the issue, but I thought to post the detailed error here as well in case it might help: http://pastebin.com/raw.php?i=CsHgM1gV

GLSL source for fragment shader 68:
#version 130
precision mediump int;
precision highp float;
#define DEFINE_GL_FRAGCOLOR 1
#define FXAA_GLSL_130 1
#define ATTRIBUTE in
#define VARYING in
#define VARYING_FLAT flat in
#define texture2D texture
#define textureCube texture
#define texture2DLod textureLod
#define    shadow2D(a,b) vec2(texture(a,b))
#define HAS_DIFFUSE_LOOKUP 0
/** 
 * @file glowExtractF.glsl
 *
 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2007, Linden Research, Inc.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License only.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 * $/LicenseInfo$
 */
 
#extension GL_ARB_texture_rectangle : enable

#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif

uniform sampler2DRect diffuseMap;
uniform float minLuminance;
uniform float maxExtractAlpha;
uniform vec3 lumWeights;
uniform vec3 warmthWeights;
uniform float warmthAmount;

VARYING vec2 vary_texcoord0;

void main()
{
    vec4 col = texture2DRect(diffuseMap, vary_texcoord0.xy);    
    /// CALCULATING LUMINANCE (Using NTSC lum weights)
    /// http://en.wikipedia.org/wiki/Luma_%28video2013-11-14T00:40:35Z WARNING: llrender/llshadermgr.cpp(842) : loadShaderFile: GLSL Compilation Error: (0) in effects/glowExtractF.glsl
2013-11-14T00:40:35Z WARNING: llrender/llshadermgr.cpp(515) : dumpObjectLog: 0:39(1): error: syntax error, unexpected EXTENSION, expecting $end

2013-11-14T00:40:35Z WARNING: llrender/llshadermgr.cpp(869) : loadShaderFile: #version 130

2013-11-14T00:40:35Z INFO: llrender/llshadermgr.cpp(569) : loadShaderFile: Loading file: shaders/class1/effects/glowExtractF.glsl (Want class 1)
2013-11-14T00:40:35Z WARNING: llrender/llshadermgr.cpp(842) : loadShaderFile: GLSL Compilation Error: (0) in effects/glowExtractF.glsl
2013-11-14T00:40:35Z WARNING: llrender/llshadermgr.cpp(515) : dumpObjectLog: 0:39(1): error: syntax error, unexpected EXTENSION, expecting $end

2013-11-14T00:40:35Z WARNING: llrender/llshadermgr.cpp(869) : loadShaderFile: #version 130

2013-11-14T00:40:35Z WARNING: llrender/llshadermgr.cpp(905) : loadShaderFile: Failed to load effects/glowExtractF.glsl
2013-11-14T00:40:35Z WARNING: llrender/llglslshader.cpp(432) : createShader: Failed to link shader: Glow Extract Shader (Post)
2013-11-14T00:40:35Z WARNING: llrender/llglslshader.cpp(437) : createShader: Failed to link using shader level 1 trying again using shader level 0
2013-11-14T00:40:35Z WARNING: llrender/llshadermgr.cpp(576) : loadShaderFile: GLSL Shader file not found: effects/glowExtractV.glsl
2013-11-14T00:40:35Z WARNING: llrender/llshadermgr.cpp(576) : loadShaderFile: GLSL Shader file not found: effects/glowExtractF.glsl
2013-11-14T00:40:35Z WARNING: llrender/llglslshader.cpp(432) : createShader: Failed to link shader: Glow Extract Shader (Post)
2013-11-14T00:40:35Z INFO: newview/lldrawpoolbump.cpp(940) : clear: Clearing dynamic bumpmaps.
2013-11-14T00:40:35Z INFO: newview/lldrawpoolbump.cpp(168) : clear: Clearing standard bumpmaps.
2013-11-14T00:40:35Z INFO: newview/lldrawpoolbump.cpp(168) : clear: Clearing standard bumpmaps.
2013-11-14T00:40:35Z INFO: newview/lldrawpoolbump.cpp(168) : clear: Clearing standard bumpmaps.
2013-11-14T00:40:35Z INFO: newview/lldrawpoolbump.cpp(107) : addstandard: Adding standard bumpmaps.
2013-11-14T00:40:35Z INFO: newview/lldrawpoolbump.cpp(940) : clear: Clearing dynamic bumpmaps.
2013-11-14T00:40:35Z INFO: newview/lldrawpoolbump.cpp(168) : clear: Clearing standard bumpmaps.
2013-11-14T00:40:35Z INFO: newview/lldrawpoolbump.cpp(168) : clear: Clearing standard bumpmaps.
2013-11-14T00:40:35Z INFO: newview/llviewershadermgr.cpp(438) : setShaders: 
~~~~~~~~~~~~~~~~~~
 Loading Shaders:
~~~~~~~~~~~~~~~~~~
2013-11-14T00:40:35Z INFO: newview/llviewershadermgr.cpp(439) : setShaders: Using GLSL 1.30
2013-11-14T00:40:35Z INFO: llrender/llshadermgr.cpp(569) : loadShaderFile: Loading file: shaders/class1/windlight/atmosphericsVarsV.glsl (Want class 1)
%29
    float lum = smoothstep(minLuminance, minLuminance+1.0, dot(col.rgb, lumWeights ) );
    float warmth = smoothstep(minLuminance, minLuminance+1.0, max(col.r * warmthWeights.r, max(col.g * warmthWeights.g, col.b * warmthWeights.b)) ); 
    
    frag_color.rgb = col.rgb; 
    frag_color.a = max(col.a, mix(lum, warmth, warmthAmount) * maxExtractAlpha);
    
}

GLSL shader 68 failed to compile.
GLSL shader 68 info log:
0:39(1): error: syntax error, unexpected EXTENSION, expecting $end

These are the extensions needed for Eernal Lnads most are not found when running the OS driver


17:54:07] Window size adjusted to 1014x713
[17:54:08] GL_ARB_multitexture extension found, using it.
[17:54:08] GL_ARB_texture_env_combine extension found, using it.
[17:54:08] GL_EXT_compiled_vertex_array extension found, using it.
[17:54:08] GL_ARB_point_sprite extension found, using it.
[17:54:08] GL_ARB_texture_compression extension found, using it.
[17:54:08] GL_EXT_texture_compression_s3tc extension found, using it.
[17:54:08] GL_SGIS_generate_mipmap extension found, using it.
[17:54:08] GL_ARB_shadow extension found, using it.
[17:54:08] GL_ARB_vertex_buffer_object extension found, using it.
[17:54:08] GL_EXT_framebuffer_object extension found, using it.
[17:54:08] GL_EXT_draw_range_elements extension found, using it.
[17:54:08] GL_ARB_texture_non_power_of_two extension found, using it.
[17:54:08] GL_ARB_fragment_program extension found, using it.
[17:54:08] GL_ARB_vertex_program extension found, using it.
[17:54:08] GL_ARB_fragment_shader extension found, using it.
[17:54:08] GL_ARB_vertex_shader extension found, using it.
[17:54:08] GL_ARB_shader_objects extension found, using it.
[17:54:08] GL_ARB_shading_language_100 extension found, using it.
[17:54:08] GL_ARB_texture_mirrored_repeat extension found, NOT using it...
[17:54:08] GL_ARB_texture_rectangle extension found, NOT using it...
[17:54:08] GL_EXT_fog_coord extension found, NOT using it...
[17:54:08] Couldn't find the GL_ATI_texture_compression_3dc extension, not using it...
[17:54:08] Couldn't find the GL_EXT_texture_compression_latc extension, not using it...



Note the last two seem to be ATI specific and are not used because I run NVIDIA but do not seem to degrade the game a great deal

So I’d be happy to use OS drivers when they are able to use these extension functions. I just don’t think they can yet

Another important update: I found a simple way to temporarily fix most of the shaders. I can now enable Basic Shaders followed by Atmospheric Shaders, but Advanced Lighting Model will still not work. Seemingly due to the same issue, but in a form that’s not as easy to fix. I would be grateful if someone could use the knowledge I posted up to this point to figure out how to solve those as well.

What fixes the primary shaders is commenting out all #extension lines the from glsl files. To make it easy for everyone to apply the fix, I created a bash script that does it automatically. Create an empty file in SecondLife/app_settings/shaders and paste the code below inside, then save and execute it. Make sure to backup your shaders folder first, this will permanently edit your glsl files!

#!/bin/bash
files=$(find ./* -type f -name *.glsl)
for f in ${files}
do
    echo "Fixing shader file ${f}"
    sed -i 's/#extension/\/\/ #extension/g' ${f}
done