Howto: Get Second Life Running with Shaders on Intel Linux Graphics

Just got a new laptop: System76 Galago Ultrapro, with Intel Iris Pro graphics. So far, despite some shortcomings, I’m liking it. Programs spring to action, and Dota 2 runs with all the eye candies. But Second Life refuses to load any Shaders, and as a result, the screen looks like it’s from ten years ago.

Snapshot_016

So I had to roll my own viewer :) After messing with stuff for two days, I’ve finally got Windlight atmospheric shaders working. Here’s how:

(Note:  I use Kokua as my primary viewer, so this guide might not 100% match the official release; but most of the stuff is common to all viewers.)

First you need to get the source and compile successfully. Instructions are avaliable on the Second Life wiki, although they aren’t very clear.

First problem is that gcc 4.8, the default for Ubuntu 13.10, complains about “array subscript is above array bounds [-Werror=array-bounds]”. This is most likely a false alarm, so use gcc 4.7:

CC=gcc-4.7 CXX=g++-4.7 AUTOBUILD_PLATFORM_OVERRIDE='linux64' kokua-autobuild/bin/autobuild configure -c RelWithDebInfoOS -- -DLL_TESTS=OFF

(remove AUTOBUILD_PLATFORM_OVERRIDE='linux64') if you’re building the official viewer – it doesn’t support 64-bit Linux that well.

gcc 4.7 still complains about truncating precision, so add explicit casts:

diff -r 4581f8365e7d indra/newview/llworld.cpp
--- a/indra/newview/llworld.cpp	Tue Mar 25 18:54:59 2014 -0500
+++ b/indra/newview/llworld.cpp	Sat Apr 05 19:59:19 2014 -0400
@@ -1427,8 +1427,8 @@
 	center_y = min_y + (wy >> 1);
 
 	S32 add_boundary[4] = {
-		512 - (max_x - (rwidth - 256) - region_x),
-		512 - (max_y - (rwidth - 256) - region_y),
+		512 - (max_x - (rwidth - 256) - (S32)region_x),
+		512 - (max_y - (rwidth - 256) - (S32)region_y),
 		512 - ((S32)region_x - min_x),
 		512 - ((S32)region_y - min_y) };

Now we got the viewer to compile. But this is only the beginning. We need to make a few changes.

First, a few shaders in Second Life use requires some shader extensions. But by OpenGL spec, #extension must come before all non-preprocessing directives… and yes, that includes comments! Other drivers would silently accept those, but Mesa considers that to be a bug in SL (see https://bugs.freedesktop.org/show_bug.cgi?id=69226).

The proper way would be reading the shader files and moving all the #extensions to the front of the shader. For now, I’ll just use this hack that works for non-deferred shaders:

diff -r 4581f8365e7d indra/llrender/llshadermgr.cpp
--- a/indra/llrender/llshadermgr.cpp	Tue Mar 25 18:54:59 2014 -0500
+++ b/indra/llrender/llshadermgr.cpp	Sat Apr 05 19:59:19 2014 -0400
@@ -629,8 +629,8 @@
 			text[count++] = strdup("#version 130\n");
 
 			//some implementations of GLSL 1.30 require integer precision be explicitly declared
-			text[count++] = strdup("precision mediump int;\n");
-			text[count++] = strdup("precision highp float;\n");
+			//text[count++] = strdup("precision mediump int;\n");
+			//text[count++] = strdup("precision highp float;\n");
 		}
 		else
 		{ //set version to 400
@@ -859,6 +859,7 @@

And then we need to edit the shaders to move the extension directive before comments:

diff -r 4581f8365e7d indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
--- a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl	Tue Mar 25 18:54:59 2014 -0500
+++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl	Sat Apr 05 19:59:19 2014 -0400
@@ -1,3 +1,5 @@
+#extension GL_ARB_texture_rectangle : enable
+
 /** 
  * @file glowExtractF.glsl
  *
@@ -23,7 +25,7 @@
  * $/LicenseInfo$
  */
 
-#extension GL_ARB_texture_rectangle : enable
+
 
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
diff -r 4581f8365e7d indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl
--- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl	Tue Mar 25 18:54:59 2014 -0500
+++ b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl	Sat Apr 05 19:59:19 2014 -0400
@@ -1,3 +1,4 @@
+#extension GL_ARB_texture_rectangle : enable
 /** 
  * @file debugF.glsl
  *
@@ -23,7 +24,7 @@
  * $/LicenseInfo$
  */
 
-#extension GL_ARB_texture_rectangle : enable
+
 
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
diff -r 4581f8365e7d indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl	Tue Mar 25 18:54:59 2014 -0500
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl	Sat Apr 05 19:59:19 2014 -0400
@@ -1,3 +1,4 @@
+#extension GL_ARB_texture_rectangle : enable
 /** 
  * @file glowcombineF.glsl
  *
@@ -29,7 +30,7 @@
 #define frag_color gl_FragColor
 #endif
 
-#extension GL_ARB_texture_rectangle : enable
+
 
 uniform sampler2D glowMap;
 uniform sampler2DRect screenMap;
diff -r 4581f8365e7d indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
--- a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl	Tue Mar 25 18:54:59 2014 -0500
+++ b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl	Sat Apr 05 19:59:19 2014 -0400
@@ -1,3 +1,4 @@
+#extension GL_ARB_texture_rectangle : enable
 /** 
  * @file splattexturerectF.glsl
  *
@@ -23,7 +24,7 @@
  * $/LicenseInfo$
  */
 
-#extension GL_ARB_texture_rectangle : enable
+
 
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;

Now we need to edit the launcher script, otherwise LibGL won’t be able to find the graphics drivers.

diff -r 4581f8365e7d indra/newview/linux_tools/wrapper.sh
--- a/indra/newview/linux_tools/wrapper.sh	Tue Mar 25 18:54:59 2014 -0500
+++ b/indra/newview/linux_tools/wrapper.sh	Sat Apr 05 19:59:19 2014 -0400
@@ -65,8 +65,11 @@
 MULTIARCH_ERR=$?
 if [ $MULTIARCH_ERR -eq 0 ]; then
     echo 'Multi-arch support detected.'
-    MULTIARCH_GL_DRIVERS="/usr/lib/${I386_MULTIARCH}/dri"
+    AMD64_MULTIARCH="$(dpkg-architecture -aamd64 -qDEB_HOST_MULTIARCH 2>/dev/null)"
+    
+    MULTIARCH_GL_DRIVERS="/usr/lib/${AMD64_MULTIARCH}/dri:/usr/lib/${I386_MULTIARCH}/dri"
     export LIBGL_DRIVERS_PATH="${LIBGL_DRIVERS_PATH}:${MULTIARCH_GL_DRIVERS}:/usr/lib64/dri:/usr/lib32/dri:/usr/lib/dri"
+    echo ${LIBGL_DRIVERS_PATH}
 else
     export LIBGL_DRIVERS_PATH="${LIBGL_DRIVERS_PATH}:/usr/lib64/dri:/usr/lib32/dri:/usr/lib/dri"
 fi

Almost done! Now we need to mark Mesa as “supported”, so viewer will enable shaders:

diff -r 4581f8365e7d indra/newview/gpu_table.txt
--- a/indra/newview/gpu_table.txt	Tue Mar 25 18:54:59 2014 -0500
+++ b/indra/newview/gpu_table.txt	Sat Apr 05 21:03:49 2014 -0400
@@ -345,7 +345,7 @@
 Intel B45/B43							.*Intel.*B4.*										1	1	1	2.1
 Intel 3D-Analyze						.*Intel.*3D-Analyze.*								2	1	0	0
 Matrox									.*Matrox.*											0	0	0	0
-Mesa									.*Mesa.*											1	0	1	3
+Mesa									.*Mesa.*											1	1	1	3
 Gallium									.*Gallium.*											1	1	1	2.1
 NVIDIA GeForce Pre-Release				.*NVIDIA .*GeForce[ ]Pre-Release.*					2	1	1	3.3
 NVIDIA D1xP1							.*NVIDIA .*D1[0-4]P1.*								0	0	0	0

Turn on cubemap, else there will be an assert error if you enable transparent water:

diff -r 4581f8365e7d indra/newview/featuretable_linux.txt
--- a/indra/newview/featuretable_linux.txt	Tue Mar 25 18:54:59 2014 -0500
+++ b/indra/newview/featuretable_linux.txt	Sat Apr 05 21:03:49 2014 -0400
@@ -441,7 +441,7 @@
 list Intel
 RenderAnisotropic			1	0
 // Avoid some Intel crashes on Linux
-RenderCubeMap				0	0
+RenderCubeMap				1	0
 RenderFSAASamples			1	0
 
 list GeForce2

Finally if you’re building Kokua, you might need to comment out these so you can open the preferences box:

diff -r 4581f8365e7d indra/newview/llfloaterpreference.cpp
--- a/indra/newview/llfloaterpreference.cpp	Tue Mar 25 18:54:59 2014 -0500
+++ b/indra/newview/llfloaterpreference.cpp	Sat Apr 05 21:03:49 2014 -0400
@@ -600,9 +600,9 @@
 
 void LLFloaterPreference::onShowStreamMetadataChanged()
 {
-	BOOL enable = gSavedSettings.getBOOL("ShowStreamMetadata");
-
-	getChild<llcheckboxctrl>("ShowStreamName")->setEnabled(enable);
+//	BOOL enable = gSavedSettings.getBOOL("ShowStreamMetadata");
+//
+//	getChild<llcheckboxctrl>("ShowStreamName")->setEnabled(enable);
 }

All done! Now enjoy your Iris Pro Graphics ^.^
Snapshot_008_g

你的世界,你的语言

Throught the last year I have been translating Second Life client into simplified Chinese, and – it has finally been made it to the Release Candidate! (Along with other languages.) Download from Second Life website.
去年中我一直在翻译第二人生的客户端,因为原来的翻译实在不怎么样。而现在翻译基本完成,结合到最新的 1.22 发行候选版了!(和其他语言一起。) 你可以从第二人生官方网站下载

For the Chinese version, there are a lot of things that could use a proofread, and gloss work to be done. Wanna help out? Not just for Chinese – there are other languages, like Danish, German, French, Japanese and more! Be sure to help volunteer translators out by testing and report any issues you may find for a language you speak.
对于中文版来说,还需要很多校对和词汇定义。想帮忙吗?不止是中文——也有别的语言,像是丹麦语、德语、法语、日语以及很多很多的语言!卡库尔需要你帮助志愿翻译者测试并汇报你能阅读的语言版本的翻译的任何问题。

But I plan to move on, there are other things I want to spend time on. So I’m glad that Ken March has came to help out brining SL to more Chinese residents! Ken is the founder of Islab, which was once an important Chinese SL community. So he has bigger experience and recognition in SL than the unknown Geneko.
不过我打算结束翻译,而转做一些别的事情。我很高兴 Ken March 能够帮助林登实验室将第二人生带给更多的说汉语的居民。Ken 是易思实验室的创始人,而易思实验室曾是第二人生中一个重要的中文社区。我相信相比于根本没人听说过的 Geneko 来说,Ken 对这虚拟世界有着更多的经验和知名度。

But after looking at his first batch of translations… I’m worried that maybe I still need to keep helping for a while.
不过看了 Ken 的第一批翻译…… 我实在有点担心。照这样的话可能卡库尔还要继续翻译一段时间呢。

V-狂热和幻想生活 Of Vee-feever and Fantasy Life

两个月没有写日志,真的是不知道写什么好。卡库尔也是经常很迷糊的——你怎么能指望卡库尔记得住两个月的每件事呢? 那样脑袋要爆炸的。再说, 卡库尔的每一天都差不多: 起床、上网、吃午饭、漫无经心地走到教室、教授开始讲课10分钟后开始在纸上乱涂或睡觉, 吃晚饭, 继续上网到深夜, 再睡觉……没什么好写的。

Two months without blogging, not really sure what I should write about. Kakur doesn’t really have a clear mind at times – how can you expect me to remember everything that happened in the last two months? Not that it matters, as all I do each day is wake up, surf the web, eat lunch, sleep at class, reed more web pages, and go to bed. There’s just nothing you could write about.

So instead I’ll just say that the true reason I didn’t blog was that Mabinogi got an official North American release. (My favorite game so far!)

所以我还是承认说我真正没写日志的原因是因为网络游戏《洛奇》正式在北美地区运营了好了。(是我至今最喜欢的游戏! )

迪尔科内尔的景色 / sceneary of Tir Chonaill

洛奇是什么样的游戏, 我应该也不用说了, 如果有兴趣的话可以到洛奇远古争霸或者Mabinogi fantasy LIFE的官方网站看一下。

I shouldn’t need to mention what kind of game Mabinogi is here, but if you are interested, you could take a look at the official websites of LuoqiThe Ancient Wars or Mabinogi fantasy LIFE.不过无尽的练级也是很无聊的呀……

But an endless grinding is very boring too…

So um… I made a Moongate (a portal in Mabinogi which changes destination with time) Timetable. Of course, the functions ain’t as many as the unofficial patches… but what may be more important is that it doesn’t look nice at all. Kakur certainly doesn’t seem to be an adequate material for becoming an artist does me?

于是呢,呃……我做了个星月门 (洛奇中的传送门,按照时间变换位置) 时间表。当然,功能肯定没有外挂强大……但是更重要的是完全不好看。卡库尔似乎完全不是艺术家的料子呢?

北美
North America
中国
China
日本
Japan
英语
English
察看
View
察看
View
察看
View
汉语(简体中文)
Chinese (Simplified)
察看
View
察看
View

虽然这样说,但是其实还是挺不错的^_^

Still that’s not bad, is it?

And um… so apparantly, I came across this avatar in Second Life, and it was just so cute!

呃,那个……看来,我在第二人生中看到了这个化身,……实在是太可爱了

can'tresist

(“V仔兽化身,500L$ (折合人民币12.8元), 可复制, 可编辑, 不可转让”)
(“Veemon avatar, 500L$ (about 1.82 USD), can copy, can modify, no transfer”)

于是……

And so…

Snapshot_Apr04_006

I present to you Kakurumon XD

我向您正式宣布卡库尔兽的诞生XD

……没错,右边的灯是卡库尔自己做的,周五实在太无聊(?)。不过平常,卡库尔我是做不出这种东西的……

……yeah, the light on the right was made by Kakur myself. Friday is such a bore(?). Though usually, I Kakur can’t make neat things like this…