From 38e0b7de96de02243453eeaf5710b924f68abc7a Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 6 Feb 2012 18:56:19 -0600
Subject: SH-2729 Fix for horizontal line of glitching graphics when DoF
 enabled

---
 indra/llrender/llshadermgr.cpp                               |  2 ++
 indra/llrender/llshadermgr.h                                 |  2 ++
 .../app_settings/shaders/class1/deferred/dofCombineF.glsl    | 12 +++++++++++-
 indra/newview/pipeline.cpp                                   |  9 +++++++--
 4 files changed, 22 insertions(+), 3 deletions(-)

(limited to 'indra')

diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 908443e8cf..d03d349f0f 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -1070,6 +1070,8 @@ void LLShaderMgr::initAttribsAndUniforms()
 	mReservedUniforms.push_back("magnification");
 	mReservedUniforms.push_back("max_cof");
 	mReservedUniforms.push_back("res_scale");
+	mReservedUniforms.push_back("dof_width");
+	mReservedUniforms.push_back("dof_height");
 
 	mReservedUniforms.push_back("depthMap");
 	mReservedUniforms.push_back("shadowMap0");
diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h
index 950e6c9c2f..e28bda6de2 100644
--- a/indra/llrender/llshadermgr.h
+++ b/indra/llrender/llshadermgr.h
@@ -142,6 +142,8 @@ public:
 		DOF_MAGNIFICATION,
 		DOF_MAX_COF,
 		DOF_RES_SCALE,
+		DOF_WIDTH,
+		DOF_HEIGHT,
 
 		DEFERRED_DEPTH,
 		DEFERRED_SHADOW0,
diff --git a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
index 01e3505359..0cf5afc568 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
@@ -37,14 +37,24 @@ uniform vec2 screen_res;
 
 uniform float max_cof;
 uniform float res_scale;
+uniform float dof_width;
+uniform float dof_height;
 
 VARYING vec2 vary_fragcoord;
 
+vec4 dofSample(sampler2DRect tex, vec2 tc)
+{
+	tc.x = min(tc.x, dof_width);
+	tc.y = min(tc.y, dof_height);
+
+	return texture2DRect(tex, tc);
+}
+
 void main() 
 {
 	vec2 tc = vary_fragcoord.xy;
 	
-	vec4 dof = texture2DRect(diffuseRect, vary_fragcoord.xy*res_scale);
+	vec4 dof = dofSample(diffuseRect, vary_fragcoord.xy*res_scale);
 	
 	vec4 diff = texture2DRect(lightMap, vary_fragcoord.xy);
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index a64655960f..dffc541001 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6642,9 +6642,12 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 				mDeferredLight.flush();
 			}
 
+			U32 dof_width = mScreen.getWidth()*CameraDoFResScale;
+			U32 dof_height = mScreen.getHeight()*CameraDoFResScale;
+			
 			{ //perform DoF sampling at half-res (preserve alpha channel)
 				mScreen.bindTarget();
-				glViewport(0,0,(GLsizei) (mScreen.getWidth()*CameraDoFResScale), (GLsizei) (mScreen.getHeight()*CameraDoFResScale));
+				glViewport(0,0, dof_width, dof_height);
 				gGL.setColorMask(true, false);
 
 				shader = &gDeferredPostProgram;
@@ -6657,7 +6660,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 				shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF);
 				shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale);
-
+				
 				gGL.begin(LLRender::TRIANGLE_STRIP);
 				gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
 				gGL.vertex2f(-1,-1);
@@ -6702,6 +6705,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 				shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF);
 				shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale);
+				shader->uniform1f(LLShaderMgr::DOF_WIDTH, dof_width-1);
+				shader->uniform1f(LLShaderMgr::DOF_HEIGHT, dof_height-1);
 
 				gGL.begin(LLRender::TRIANGLE_STRIP);
 				gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
-- 
cgit v1.2.3


From 8c15a7e17fceeba9e55e254d7654c1a4f8c3b871 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 7 Feb 2012 14:51:30 -0600
Subject: SH-2902 Fix for avatar bakes etc. getting garbage data sometimes.

---
 indra/newview/lldynamictexture.cpp | 28 ++++++++++++++++++++++++----
 indra/newview/pipeline.cpp         |  5 +++--
 2 files changed, 27 insertions(+), 6 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp
index 5d6081a35c..a93b2b71de 100644
--- a/indra/newview/lldynamictexture.cpp
+++ b/indra/newview/lldynamictexture.cpp
@@ -125,8 +125,16 @@ BOOL LLViewerDynamicTexture::render()
 //-----------------------------------------------------------------------------
 void LLViewerDynamicTexture::preRender(BOOL clear_depth)
 {
-	{
-		// force rendering to on-screen portion of frame buffer
+	//only images up to 512x512 are supported
+	llassert(mFullHeight <= 512);
+	llassert(mFullWidth <= 512);
+
+	if (gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete())
+	{ //using offscreen render target, just use the bottom left corner
+		mOrigin.set(0, 0);
+	}
+	else
+	{ // force rendering to on-screen portion of frame buffer
 		LLCoordScreen window_pos;
 		gViewerWindow->getWindow()->getPosition( &window_pos );
 		mOrigin.set(0, gViewerWindow->getWindowHeightRaw() - mFullHeight);  // top left corner
@@ -140,9 +148,9 @@ void LLViewerDynamicTexture::preRender(BOOL clear_depth)
 			mOrigin.mY += window_pos.mY;
 			mOrigin.mY = llmax(mOrigin.mY, 0) ;
 		}
-
-		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	}
+
+	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	// Set up camera
 	LLViewerCamera* camera = LLViewerCamera::getInstance();
 	mCamera.setOrigin(*camera);
@@ -208,6 +216,13 @@ BOOL LLViewerDynamicTexture::updateAllInstances()
 		return TRUE;
 	}
 
+	bool use_fbo = gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete();
+
+	if (use_fbo)
+	{
+		gPipeline.mWaterDis.bindTarget();
+	}
+
 	LLGLSLShader::bindNoShader();
 	LLVertexBuffer::unbind();
 	
@@ -241,6 +256,11 @@ BOOL LLViewerDynamicTexture::updateAllInstances()
 		}
 	}
 
+	if (use_fbo)
+	{
+		gPipeline.mWaterDis.flush();
+	}
+
 	return ret;
 }
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index dffc541001..c8a8b910ea 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1076,10 +1076,11 @@ void LLPipeline::createGLBuffers()
 
 	if (LLPipeline::sWaterReflections)
 	{ //water reflection texture
-		U32 res = (U32) gSavedSettings.getS32("RenderWaterRefResolution");
+		U32 res = (U32) llmax(gSavedSettings.getS32("RenderWaterRefResolution"), 512);
 			
 		mWaterRef.allocate(res,res,GL_RGBA,TRUE,FALSE);
-		mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE);
+		//always use FBO for mWaterDis so it can be used for avatar texture bakes
+		mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE,LLTexUnit::TT_TEXTURE, true);
 	}
 
 	mHighlight.allocate(256,256,GL_RGBA, FALSE, FALSE);
-- 
cgit v1.2.3


From 95be0571537805c238e37e747c4c3bb298be98d8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 7 Feb 2012 17:25:12 -0600
Subject: SH-2719 Fix for lines in off-sim water

---
 indra/newview/llvowater.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp
index 315616e8a5..cd78157944 100644
--- a/indra/newview/llvowater.cpp
+++ b/indra/newview/llvowater.cpp
@@ -160,7 +160,7 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable)
 	static const unsigned int vertices_per_quad = 4;
 	static const unsigned int indices_per_quad = 6;
 
-	const S32 size = gSavedSettings.getBOOL("RenderTransparentWater") && !LLGLSLShader::sNoFixedFunction ? 16 : 1;
+	const S32 size = gSavedSettings.getBOOL("RenderTransparentWater") && LLGLSLShader::sNoFixedFunction ? 16 : 1;
 
 	const S32 num_quads = size * size;
 	face->setSize(vertices_per_quad * num_quads,
@@ -197,6 +197,13 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable)
 
 	F32 size_inv = 1.f / size;
 
+	F32 z_fudge = 0.f;
+
+	if (getIsEdgePatch())
+	{ //bump edge patches down 10 cm to prevent aliasing along edges
+		z_fudge = -0.1f;
+	}
+
 	for (y = 0; y < size; y++)
 	{
 		for (x = 0; x < size; x++)
@@ -205,6 +212,7 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable)
 			position_agent = getPositionAgent() - getScale() * 0.5f;
 			position_agent.mV[VX] += (x + 0.5f) * step_x;
 			position_agent.mV[VY] += (y + 0.5f) * step_y;
+			position_agent.mV[VZ] += z_fudge;
 
 			*verticesp++  = position_agent - right + up;
 			*verticesp++  = position_agent - right - up;
-- 
cgit v1.2.3


From d10bcca167e2d4332dced910660aa1a6a85bc175 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 8 Feb 2012 15:14:03 -0600
Subject: SH-2592 Fix for some shader uniforms using the wrong vector size.

---
 indra/newview/app_settings/shaders/class1/deferred/skyV.glsl     | 2 --
 indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl | 4 ++--
 indra/newview/app_settings/shaders/class2/windlight/skyV.glsl    | 2 --
 indra/newview/llwaterparammanager.cpp                            | 2 +-
 indra/newview/llwlparamset.cpp                                   | 4 ++--
 5 files changed, 5 insertions(+), 9 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
index 2c8808bdce..cb7603f4fd 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
@@ -55,8 +55,6 @@ uniform vec4 glow;
 
 uniform vec4 cloud_color;
 
-uniform vec4 cloud_scale;
-
 void main()
 {
 
diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
index 2406359721..c1dd45cd67 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
@@ -60,7 +60,7 @@ uniform vec4 glow;
 
 uniform vec4 cloud_color;
 
-uniform vec4 cloud_scale;
+uniform float cloud_scale;
 
 void main()
 {
@@ -169,7 +169,7 @@ void main()
 	// Texture coords
 	vary_texcoord0 = texcoord0;
 	vary_texcoord0.xy -= 0.5;
-	vary_texcoord0.xy /= cloud_scale.x;
+	vary_texcoord0.xy /= cloud_scale;
 	vary_texcoord0.xy += 0.5;
 
 	vary_texcoord1 = vary_texcoord0;
diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
index 6a87caa8cf..3788ddaf2d 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
@@ -53,8 +53,6 @@ uniform vec4 glow;
 
 uniform vec4 cloud_color;
 
-uniform vec4 cloud_scale;
-
 void main()
 {
 
diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp
index 20b34637b8..e386112334 100644
--- a/indra/newview/llwaterparammanager.cpp
+++ b/indra/newview/llwaterparammanager.cpp
@@ -194,7 +194,7 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader)
 		shader->uniform4fv("waterPlane", 1, mWaterPlane.mV);
 		shader->uniform1f("waterFogDensity", getFogDensity());
 		shader->uniform1f("waterFogKS", mWaterFogKS);
-		shader->uniform4f("distance_multiplier", 0, 0, 0, 0);
+		shader->uniform1f("distance_multiplier", 0);
 	}
 }
 
diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp
index 1e95b3ea4a..b04d30db55 100644
--- a/indra/newview/llwlparamset.cpp
+++ b/indra/newview/llwlparamset.cpp
@@ -75,9 +75,9 @@ void LLWLParamSet::update(LLGLSLShader * shader) const
 			stop_glerror();
 		}
 		else if (param == "cloud_scale" || param == "cloud_shadow" ||
-				 param == "density_multiplier" ||
+				 param == "density_multiplier" || param == "distance_multiplier" ||
 				 param == "haze_density" || param == "haze_horizon" ||
-				 param == "max_y")
+				 param == "max_y" )
 		{
 			F32 val = (F32) i->second[0].asReal();
 
-- 
cgit v1.2.3


From e0582d4bc71e2f367b4cf4a6f0b808451620b52f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 8 Feb 2012 19:01:08 -0600
Subject: Fix for Debug GL generating errors when changing graphics preferences
 (reloading shaders).

---
 indra/llrender/llglslshader.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 3773568ad8..7eba62e59e 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -109,7 +109,10 @@ void LLGLSLShader::unload()
 		glGetAttachedObjectsARB(mProgramObject, 1024, &count, obj);
 		for (GLsizei i = 0; i < count; i++)
 		{
-			glDeleteObjectARB(obj[i]);
+			if (glIsProgramARB(obj[i]))
+			{
+				glDeleteObjectARB(obj[i]);
+			}
 		}
 
 		glDeleteObjectARB(mProgramObject);
-- 
cgit v1.2.3


From 8d22adbbed589125c89ea8e28610816361615753 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 10 Feb 2012 14:28:16 -0600
Subject: SH-2963 Fix for highlight transparent not highlighting 100%
 transparent objects.

---
 indra/newview/lldrawpool.h        |  1 +
 indra/newview/lldrawpoolalpha.cpp |  1 +
 indra/newview/llvovolume.cpp      | 10 +++++++---
 3 files changed, 9 insertions(+), 3 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h
index 5a2981e749..64774d06df 100644
--- a/indra/newview/lldrawpool.h
+++ b/indra/newview/lldrawpool.h
@@ -133,6 +133,7 @@ public:
 		PASS_ALPHA,
 		PASS_ALPHA_MASK,
 		PASS_FULLBRIGHT_ALPHA_MASK,
+		PASS_ALPHA_INVISIBLE,
 		NUM_RENDER_TYPES,
 	};
 
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index ddb7d3ceeb..5b62dbc560 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -337,6 +337,7 @@ void LLDrawPoolAlpha::render(S32 pass)
 
 		pushBatches(LLRenderPass::PASS_ALPHA_MASK, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE);
 		pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE);
+		pushBatches(LLRenderPass::PASS_ALPHA_INVISIBLE, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE);
 
 		if(shaders) 
 		{
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 6354230796..438d578ac5 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4433,10 +4433,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 					else
 					{
 						if (te->getColor().mV[3] > 0.f)
-						{
+						{ //only treat as alpha in the pipeline if < 100% transparent
 							drawablep->setState(LLDrawable::HAS_ALPHA);
-							alpha_faces.push_back(facep);
 						}
+						alpha_faces.push_back(facep);
 					}
 				}
 				else
@@ -4952,7 +4952,11 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 			if (is_alpha)
 			{
 				// can we safely treat this as an alpha mask?
-				if (facep->canRenderAsMask())
+				if (facep->getFaceColor().mV[3] <= 0.f)
+				{ //100% transparent, don't render unless we're highlighting transparent
+					registerFace(group, facep, LLRenderPass::PASS_ALPHA_INVISIBLE);
+				}
+				else if (facep->canRenderAsMask())
 				{
 					if (te->getFullbright() || LLPipeline::sNoAlpha)
 					{
-- 
cgit v1.2.3


From 3710c6110d65d3a604f7b419cd764cf5b9b98600 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 10 Feb 2012 20:04:19 -0600
Subject: SH-2908 Rework indexed texture rendering to use a uvec4 instead of a
 float for texture indices in the data stream.  Also rework gl_FragColor
 overrides to not collide with some odd driver implementations.

---
 indra/llrender/llgl.cpp                            | 62 ++++++++++++++-
 indra/llrender/llgl.h                              |  2 +
 indra/llrender/llglheaders.h                       |  3 +
 indra/llrender/llglslshader.cpp                    |  5 +-
 indra/llrender/llshadermgr.cpp                     | 92 ++++++++++------------
 indra/llrender/llvertexbuffer.cpp                  | 46 +++++++++--
 .../shaders/class1/avatar/pickAvatarF.glsl         |  6 +-
 .../shaders/class1/deferred/alphaF.glsl            |  6 +-
 .../shaders/class1/deferred/alphaNonIndexedF.glsl  | 10 ++-
 .../class1/deferred/alphaNonIndexedNoColorF.glsl   |  6 +-
 .../shaders/class1/deferred/attachmentShadowF.glsl |  8 +-
 .../shaders/class1/deferred/avatarF.glsl           | 10 ++-
 .../shaders/class1/deferred/avatarShadowF.glsl     |  6 +-
 .../shaders/class1/deferred/blurLightF.glsl        |  6 +-
 .../shaders/class1/deferred/bumpF.glsl             | 12 +--
 .../shaders/class1/deferred/cloudsF.glsl           | 10 ++-
 .../app_settings/shaders/class1/deferred/cofF.glsl |  8 +-
 .../shaders/class1/deferred/diffuseAlphaMaskF.glsl | 10 ++-
 .../class1/deferred/diffuseAlphaMaskIndexedF.glsl  | 10 ++-
 .../class1/deferred/diffuseAlphaMaskNoColorF.glsl  | 10 ++-
 .../shaders/class1/deferred/diffuseF.glsl          | 12 +--
 .../shaders/class1/deferred/diffuseIndexedF.glsl   | 12 +--
 .../shaders/class1/deferred/dofCombineF.glsl       |  6 +-
 .../shaders/class1/deferred/emissiveF.glsl         |  6 +-
 .../shaders/class1/deferred/fullbrightF.glsl       |  6 +-
 .../shaders/class1/deferred/fxaaF.glsl             |  6 +-
 .../app_settings/shaders/class1/deferred/giF.glsl  |  6 +-
 .../app_settings/shaders/class1/deferred/giV.glsl  | 48 -----------
 .../shaders/class1/deferred/impostorF.glsl         | 10 ++-
 .../shaders/class1/deferred/luminanceF.glsl        |  6 +-
 .../shaders/class1/deferred/multiPointLightF.glsl  |  8 +-
 .../shaders/class1/deferred/multiSpotLightF.glsl   |  8 +-
 .../shaders/class1/deferred/normgenF.glsl          |  6 +-
 .../shaders/class1/deferred/pointLightF.glsl       |  8 +-
 .../shaders/class1/deferred/postDeferredF.glsl     |  6 +-
 .../class1/deferred/postDeferredNoDoFF.glsl        |  6 +-
 .../shaders/class1/deferred/postgiF.glsl           |  8 +-
 .../shaders/class1/deferred/postgiV.glsl           | 40 ----------
 .../shaders/class1/deferred/shadowAlphaMaskF.glsl  |  6 +-
 .../shaders/class1/deferred/shadowF.glsl           |  6 +-
 .../app_settings/shaders/class1/deferred/skyF.glsl | 10 ++-
 .../shaders/class1/deferred/softenLightF.glsl      |  8 +-
 .../shaders/class1/deferred/spotLightF.glsl        |  8 +-
 .../shaders/class1/deferred/starsF.glsl            | 10 ++-
 .../shaders/class1/deferred/sunLightF.glsl         |  6 +-
 .../shaders/class1/deferred/sunLightSSAOF.glsl     | 12 +--
 .../shaders/class1/deferred/terrainF.glsl          | 10 ++-
 .../shaders/class1/deferred/treeF.glsl             | 10 ++-
 .../shaders/class1/deferred/treeShadowF.glsl       |  6 +-
 .../shaders/class1/deferred/waterF.glsl            | 10 ++-
 .../shaders/class1/effects/glowExtractF.glsl       |  8 +-
 .../app_settings/shaders/class1/effects/glowF.glsl |  6 +-
 .../shaders/class1/environment/terrainF.glsl       |  6 +-
 .../shaders/class1/environment/terrainWaterF.glsl  |  6 +-
 .../shaders/class1/environment/underWaterF.glsl    |  6 +-
 .../shaders/class1/environment/waterF.glsl         |  6 +-
 .../shaders/class1/interface/alphamaskF.glsl       |  6 +-
 .../shaders/class1/interface/customalphaF.glsl     |  6 +-
 .../shaders/class1/interface/debugF.glsl           |  6 +-
 .../shaders/class1/interface/glowcombineF.glsl     |  6 +-
 .../shaders/class1/interface/glowcombineFXAAF.glsl |  6 +-
 .../shaders/class1/interface/highlightF.glsl       |  6 +-
 .../shaders/class1/interface/occlusionF.glsl       |  6 +-
 .../class1/interface/onetexturenocolorF.glsl       |  6 +-
 .../shaders/class1/interface/solidcolorF.glsl      |  6 +-
 .../class1/interface/splattexturerectF.glsl        |  6 +-
 .../shaders/class1/interface/twotextureaddF.glsl   |  6 +-
 .../app_settings/shaders/class1/interface/uiF.glsl |  6 +-
 .../shaders/class1/lighting/lightAlphaMaskF.glsl   |  6 +-
 .../class1/lighting/lightAlphaMaskNonIndexedF.glsl |  6 +-
 .../shaders/class1/lighting/lightF.glsl            |  6 +-
 .../class1/lighting/lightFullbrightAlphaMaskF.glsl |  6 +-
 .../shaders/class1/lighting/lightFullbrightF.glsl  |  6 +-
 .../lightFullbrightNonIndexedAlphaMaskF.glsl       |  6 +-
 .../lighting/lightFullbrightNonIndexedF.glsl       |  6 +-
 .../class1/lighting/lightFullbrightShinyF.glsl     |  6 +-
 .../lighting/lightFullbrightShinyNonIndexedF.glsl  |  6 +-
 .../lighting/lightFullbrightShinyWaterF.glsl       |  6 +-
 .../lightFullbrightShinyWaterNonIndexedF.glsl      |  6 +-
 .../lighting/lightFullbrightWaterAlphaMaskF.glsl   |  6 +-
 .../class1/lighting/lightFullbrightWaterF.glsl     |  6 +-
 .../lightFullbrightWaterNonIndexedAlphaMaskF.glsl  |  6 +-
 .../lighting/lightFullbrightWaterNonIndexedF.glsl  |  6 +-
 .../shaders/class1/lighting/lightNonIndexedF.glsl  |  6 +-
 .../shaders/class1/lighting/lightShinyF.glsl       |  6 +-
 .../class1/lighting/lightShinyNonIndexedF.glsl     |  6 +-
 .../shaders/class1/lighting/lightShinyWaterF.glsl  |  6 +-
 .../lighting/lightShinyWaterNonIndexedF.glsl       |  6 +-
 .../class1/lighting/lightWaterAlphaMaskF.glsl      |  6 +-
 .../lighting/lightWaterAlphaMaskNonIndexedF.glsl   |  6 +-
 .../shaders/class1/lighting/lightWaterF.glsl       |  8 +-
 .../class1/lighting/lightWaterNonIndexedF.glsl     |  6 +-
 .../app_settings/shaders/class1/objects/bumpF.glsl |  6 +-
 .../shaders/class1/objects/impostorF.glsl          |  6 +-
 .../shaders/class1/objects/indexedTextureV.glsl    |  4 +-
 .../shaders/class2/deferred/alphaF.glsl            |  6 +-
 .../shaders/class2/deferred/alphaNonIndexedF.glsl  |  6 +-
 .../class2/deferred/alphaNonIndexedNoColorF.glsl   |  6 +-
 .../shaders/class2/deferred/multiSpotLightF.glsl   |  8 +-
 .../shaders/class2/deferred/softenLightF.glsl      |  8 +-
 .../shaders/class2/deferred/spotLightF.glsl        |  8 +-
 .../shaders/class2/deferred/sunLightF.glsl         | 18 +++--
 .../shaders/class2/deferred/sunLightSSAOF.glsl     | 18 +++--
 .../shaders/class2/windlight/cloudsF.glsl          |  8 +-
 .../shaders/class2/windlight/skyF.glsl             |  8 +-
 indra/newview/llface.cpp                           | 12 ++-
 indra/newview/llviewershadermgr.cpp                | 14 ++--
 indra/newview/llvovolume.cpp                       |  6 +-
 108 files changed, 624 insertions(+), 412 deletions(-)
 delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/giV.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl

(limited to 'indra')

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 946e602fee..79d4415117 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -97,6 +97,8 @@ void APIENTRY gl_debug_callback(GLenum source,
 }
 #endif
 
+void parse_glsl_version(S32& major, S32& minor);
+
 void ll_init_fail_log(std::string filename)
 {
 	gFailLog.open(filename.c_str());
@@ -295,6 +297,7 @@ PFNGLGETACTIVEUNIFORMARBPROC glGetActiveUniformARB = NULL;
 PFNGLGETUNIFORMFVARBPROC glGetUniformfvARB = NULL;
 PFNGLGETUNIFORMIVARBPROC glGetUniformivARB = NULL;
 PFNGLGETSHADERSOURCEARBPROC glGetShaderSourceARB = NULL;
+PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = NULL;
 
 #if LL_WINDOWS
 PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL;
@@ -341,6 +344,7 @@ PFNGLVERTEXATTRIB4UBVARBPROC glVertexAttrib4ubvARB = NULL;
 PFNGLVERTEXATTRIB4UIVARBPROC glVertexAttrib4uivARB = NULL;
 PFNGLVERTEXATTRIB4USVARBPROC glVertexAttrib4usvARB = NULL;
 PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB = NULL;
+PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = NULL;
 PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB = NULL;
 PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB = NULL;
 PFNGLPROGRAMSTRINGARBPROC glProgramStringARB = NULL;
@@ -443,7 +447,8 @@ LLGLManager::LLGLManager() :
 	mDriverVersionMinor(0),
 	mDriverVersionRelease(0),
 	mGLVersion(1.0f),
-		
+	mGLSLVersionMajor(0),
+	mGLSLVersionMinor(0),		
 	mVRAM(0),
 	mGLMaxVertexRange(0),
 	mGLMaxIndexRange(0)
@@ -554,6 +559,11 @@ bool LLGLManager::initGL()
 
 	mGLVersion = mDriverVersionMajor + mDriverVersionMinor * .1f;
 
+	if (mGLVersion >= 2.f)
+	{
+		parse_glsl_version(mGLSLVersionMajor, mGLSLVersionMinor);
+	}
+
 	// Trailing space necessary to keep "nVidia Corpor_ati_on" cards
 	// from being recognized as ATI.
 	if (mGLVendor.substr(0,4) == "ATI ")
@@ -1300,6 +1310,7 @@ void LLGLManager::initExtensions()
 		glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4uivARB");
 		glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4usvARB");
 		glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttribPointerARB");
+		glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttribIPointer");
 		glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) GLH_EXT_GET_PROC_ADDRESS("glEnableVertexAttribArrayARB");
 		glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) GLH_EXT_GET_PROC_ADDRESS("glDisableVertexAttribArrayARB");
 		glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) GLH_EXT_GET_PROC_ADDRESS("glProgramStringARB");
@@ -2098,6 +2109,55 @@ void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor
 	}
 }
 
+
+void parse_glsl_version(S32& major, S32& minor)
+{
+	// GL_SHADING_LANGUAGE_VERSION returns a null-terminated string with the format: 
+	// <major>.<minor>[.<release>] [<vendor specific>]
+
+	const char* version = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION);
+	major = 0;
+	minor = 0;
+	
+	if( !version )
+	{
+		return;
+	}
+
+	std::string ver_copy( version );
+	S32 len = (S32)strlen( version );	/* Flawfinder: ignore */
+	S32 i = 0;
+	S32 start;
+	// Find the major version
+	start = i;
+	for( ; i < len; i++ )
+	{
+		if( '.' == version[i] )
+		{
+			break;
+		}
+	}
+	std::string major_str = ver_copy.substr(start,i-start);
+	LLStringUtil::convertToS32(major_str, major);
+
+	if( '.' == version[i] )
+	{
+		i++;
+	}
+
+	// Find the minor version
+	start = i;
+	for( ; i < len; i++ )
+	{
+		if( ('.' == version[i]) || isspace(version[i]) )
+		{
+			break;
+		}
+	}
+	std::string minor_str = ver_copy.substr(start,i-start);
+	LLStringUtil::convertToS32(minor_str, minor);
+}
+
 LLGLUserClipPlane::LLGLUserClipPlane(const LLPlane& p, const glh::matrix4f& modelview, const glh::matrix4f& projection, bool apply)
 {
 	mApply = apply;
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index 6a147b8e19..5a33c98708 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -138,6 +138,8 @@ public:
 	S32 mDriverVersionMinor;
 	S32 mDriverVersionRelease;
 	F32 mGLVersion; // e.g = 1.4
+	S32 mGLSLVersionMajor;
+	S32 mGLSLVersionMinor;
 	std::string mDriverVersionVendorString;
 
 	S32 mVRAM; // VRAM in MB
diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h
index 10aad202e1..d61ec707f0 100644
--- a/indra/llrender/llglheaders.h
+++ b/indra/llrender/llglheaders.h
@@ -199,6 +199,7 @@ extern PFNGLVERTEXATTRIB4UBVARBPROC glVertexAttrib4ubvARB;
 extern PFNGLVERTEXATTRIB4UIVARBPROC glVertexAttrib4uivARB;
 extern PFNGLVERTEXATTRIB4USVARBPROC glVertexAttrib4usvARB;
 extern PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB;
+extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
 extern PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB;
 extern PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB;
 extern PFNGLPROGRAMSTRINGARBPROC glProgramStringARB;
@@ -460,6 +461,7 @@ extern PFNGLVERTEXATTRIB4UBVARBPROC glVertexAttrib4ubvARB;
 extern PFNGLVERTEXATTRIB4UIVARBPROC glVertexAttrib4uivARB;
 extern PFNGLVERTEXATTRIB4USVARBPROC glVertexAttrib4usvARB;
 extern PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB;
+extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
 extern PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB;
 extern PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB;
 extern PFNGLPROGRAMSTRINGARBPROC glProgramStringARB;
@@ -693,6 +695,7 @@ extern PFNGLVERTEXATTRIB4UBVARBPROC glVertexAttrib4ubvARB;
 extern PFNGLVERTEXATTRIB4UIVARBPROC glVertexAttrib4uivARB;
 extern PFNGLVERTEXATTRIB4USVARBPROC glVertexAttrib4usvARB;
 extern PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB;
+extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
 extern PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB;
 extern PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB;
 extern PFNGLPROGRAMSTRINGARBPROC glProgramStringARB;
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 7eba62e59e..a879a18895 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -164,8 +164,9 @@ BOOL LLGLSLShader::createShader(vector<string> * attributes,
 		return FALSE;
 	}
 
-	if (gGLManager.mGLVersion < 3.1f)
-	{ //attachShaderFeatures may have set the number of indexed texture channels, so set to 1 again
+	if (gGLManager.mGLSLVersionMajor < 2 && gGLManager.mGLSLVersionMinor < 3)
+	{ //indexed texture rendering requires GLSL 1.3 or later
+		//attachShaderFeatures may have set the number of indexed texture channels, so set to 1 again
 		mFeatures.mIndexedTextureChannels = llmin(mFeatures.mIndexedTextureChannels, 1);
 	}
 
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index d03d349f0f..321b139181 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -575,31 +575,39 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 	GLcharARB* text[4096];
 	GLuint count = 0;
 
-	F32 version = gGLManager.mGLVersion;
-
-//hack to never use GLSL > 1.20 on OSX
-#if LL_DARWIN
-	version = llmin(version, 2.9f);
-#endif
-
-	if (version < 2.1f)
-	{
-		text[count++] = strdup("#version 110\n");
-		text[count++] = strdup("#define ATTRIBUTE attribute\n");
-		text[count++] = strdup("#define VARYING varying\n");
-	}
-	else if (version < 3.3f)
+	S32 major_version = gGLManager.mGLSLVersionMajor;
+	S32 minor_version = gGLManager.mGLSLVersionMinor;
+	
+	if (major_version == 1 && minor_version < 30)
 	{
-		//set version to 1.20
-		text[count++] = strdup("#version 120\n");
-		text[count++] = strdup("#define FXAA_GLSL_120 1\n");
-		text[count++] = strdup("#define FXAA_FAST_PIXEL_OFFSET 0\n");
-		text[count++] = strdup("#define ATTRIBUTE attribute\n");
-		text[count++] = strdup("#define VARYING varying\n");
+		if (minor_version < 10)
+		{
+			//should NEVER get here -- if major version is 1 and minor version is less than 10, 
+			// viewer should never attempt to use shaders, continuing will result in undefined behavior
+			llerrs << "Unsupported GLSL Version." << llendl;
+		}
+
+		if (minor_version <= 19)
+		{
+			text[count++] = strdup("#version 110\n");
+			text[count++] = strdup("#define ATTRIBUTE attribute\n");
+			text[count++] = strdup("#define VARYING varying\n");
+			text[count++] = strdup("#define VARYING_FLAT varying\n");
+		}
+		else if (minor_version <= 29)
+		{
+			//set version to 1.20
+			text[count++] = strdup("#version 120\n");
+			text[count++] = strdup("#define FXAA_GLSL_120 1\n");
+			text[count++] = strdup("#define FXAA_FAST_PIXEL_OFFSET 0\n");
+			text[count++] = strdup("#define ATTRIBUTE attribute\n");
+			text[count++] = strdup("#define VARYING varying\n");
+			text[count++] = strdup("#define VARYING_FLAT varying\n");
+		}
 	}
 	else
 	{  
-		if (version < 4.f)
+		if (major_version < 4)
 		{
 			//set version to 1.30
 			text[count++] = strdup("#version 130\n");
@@ -618,13 +626,17 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 		{ //"varying" state is "out" in a vertex program, "in" in a fragment program 
 			// ("varying" is deprecated after version 1.20)
 			text[count++] = strdup("#define VARYING out\n");
+			text[count++] = strdup("#define VARYING_FLAT flat out\n");
 		}
 		else
 		{
 			text[count++] = strdup("#define VARYING in\n");
+			text[count++] = strdup("#define VARYING_FLAT flat in\n");
 		}
 
 		//backwards compatibility with legacy texture lookup syntax
+		text[count++] = strdup("#define texture2D texture\n");
+		text[count++] = strdup("#define texture2DRect texture\n");
 		text[count++] = strdup("#define textureCube texture\n");
 		text[count++] = strdup("#define texture2DLod textureLod\n");
 		text[count++] = strdup("#define	shadow2D(a,b) vec2(texture(a,b))\n");
@@ -651,11 +663,11 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 		.
 		uniform sampler2D texN;
 		
-		VARYING float vary_texture_index;
+		VARYING uvec4 vary_texture_index;
 
 		vec4 diffuseLookup(vec2 texcoord)
 		{
-			switch (int(vary_texture_index+0.25))
+			switch (vary_texture_index.r))
 			{
 				case 0: return texture2D(tex0, texcoord);
 				case 1: return texture2D(tex1, texcoord);
@@ -679,7 +691,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 
 		if (texture_index_channels > 1)
 		{
-			text[count++] = strdup("VARYING float vary_texture_index;\n");
+			text[count++] = strdup("VARYING_FLAT uvec4 vary_texture_index;\n");
 		}
 
 		text[count++] = strdup("vec4 diffuseLookup(vec2 texcoord)\n");
@@ -691,9 +703,9 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 			text[count++] = strdup("return texture2D(tex0, texcoord);\n");
 			text[count++] = strdup("}\n");
 		}
-		else if (gGLManager.mGLVersion >= 3.f)
-		{ 
-			text[count++] = strdup("\tswitch (int(vary_texture_index+0.25))\n");
+		else if (major_version > 1 || minor_version >= 30)
+		{  //switches are supported in GLSL 1.30 and later
+			text[count++] = strdup("\tswitch (vary_texture_index.r)\n");
 			text[count++] = strdup("\t{\n");
 		
 			//switch body
@@ -708,28 +720,10 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 			text[count++] = strdup("}\n");
 		}
 		else
-		{
-			//switches aren't supported, make block that looks like:
-			/*
-				int ti = int(vary_texture_index+0.25);
-				if (ti == 0) return texture2D(tex0, texcoord);
-				if (ti == 1) return texture2D(tex1, texcoord);
-				.
-				.
-				.
-				if (ti == N) return texture2D(texN, texcoord);
-			*/
-				
-			text[count++] = strdup("int ti = int(vary_texture_index+0.25);\n");
-			for (S32 i = 0; i < texture_index_channels; ++i)
-			{
-				std::string if_str = llformat("if (ti == %d) return texture2D(tex%d, texcoord);\n", i, i);
-				text[count++] = strdup(if_str.c_str());
-			}
-
-			text[count++] = strdup("\treturn vec4(1,0,1,1);\n");
-			text[count++] = strdup("}\n");
-		}			
+		{ //should never get here.  Indexed texture rendering requires GLSL 1.30 or later 
+			// (for passing integers between vertex and fragment shaders)
+			llerrs << "Indexed texture rendering requires GLSL 1.30 or later." << llendl;
+		}
 	}
 
 	//copy file into memory
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index e4a5cd0299..b2438ef824 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -284,6 +284,12 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
 	{
 		bool error = false;
 
+		if (gGLManager.mGLSLVersionMajor < 2 && gGLManager.mGLSLVersionMinor < 30)
+		{
+			//make sure texture index is disabled
+			data_mask = data_mask & ~MAP_TEXTURE_INDEX;
+		}
+
 		if (LLGLSLShader::sNoFixedFunction)
 		{
 			for (U32 i = 0; i < TYPE_MAX; ++i)
@@ -1193,7 +1199,7 @@ void LLVertexBuffer::setupVertexArray()
 		1, //TYPE_WEIGHT,
 		4, //TYPE_WEIGHT4,
 		4, //TYPE_CLOTHWEIGHT,
-		1, //TYPE_TEXTURE_INDEX
+		4, //TYPE_TEXTURE_INDEX
 	};
 
 	U32 attrib_type[] =
@@ -1210,7 +1216,24 @@ void LLVertexBuffer::setupVertexArray()
 		GL_FLOAT, //TYPE_WEIGHT,
 		GL_FLOAT, //TYPE_WEIGHT4,
 		GL_FLOAT, //TYPE_CLOTHWEIGHT,
-		GL_FLOAT, //TYPE_TEXTURE_INDEX
+		GL_UNSIGNED_BYTE, //TYPE_TEXTURE_INDEX
+	};
+
+	bool attrib_integer[] = 
+	{
+		false, //TYPE_VERTEX,
+		false, //TYPE_NORMAL,
+		false, //TYPE_TEXCOORD0,
+		false, //TYPE_TEXCOORD1,
+		false, //TYPE_TEXCOORD2,
+		false, //TYPE_TEXCOORD3,
+		false, //TYPE_COLOR,
+		false, //TYPE_EMISSIVE,
+		false, //TYPE_BINORMAL,
+		false, //TYPE_WEIGHT,
+		false, //TYPE_WEIGHT4,
+		false, //TYPE_CLOTHWEIGHT,
+		true, //TYPE_TEXTURE_INDEX
 	};
 
 	U32 attrib_normalized[] =
@@ -1238,7 +1261,19 @@ void LLVertexBuffer::setupVertexArray()
 		if (mTypeMask & (1 << i))
 		{
 			glEnableVertexAttribArrayARB(i);
-			glVertexAttribPointerARB(i, attrib_size[i], attrib_type[i], attrib_normalized[i], sTypeSize[i], (void*) mOffsets[i]); 
+
+			if (attrib_integer)
+			{
+				//glVertexattribIPointer requires GLSL 1.30 or later
+				if (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 30)
+				{
+					glVertexAttribIPointer(i, attrib_size[i], attrib_type[i], sTypeSize[i], (void*) mOffsets[i]); 
+				}
+			}
+			else
+			{
+				glVertexAttribPointerARB(i, attrib_size[i], attrib_type[i], attrib_normalized[i], sTypeSize[i], (void*) mOffsets[i]); 
+			}
 		}
 		else
 		{
@@ -2220,11 +2255,12 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask)
 			void* ptr = (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]);
 			glVertexAttribPointerARB(loc, 4, GL_FLOAT, GL_TRUE,  LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], ptr);
 		}
-		if (data_mask & MAP_TEXTURE_INDEX)
+		if (data_mask & MAP_TEXTURE_INDEX && 
+				(gGLManager.mGLSLVersionMajor >= 2 || gGLManager.mGLSLVersionMinor >= 30)) //indexed texture rendering requires GLSL 1.30 or later
 		{
 			S32 loc = TYPE_TEXTURE_INDEX;
 			void *ptr = (void*) (base + mOffsets[TYPE_VERTEX] + 12);
-			glVertexAttribPointerARB(loc, 1, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr);
+			glVertexAttribIPointer(loc, 4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr);
 		}
 		if (data_mask & MAP_VERTEX)
 		{
diff --git a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl
index 3e4d438ed3..54e2f04459 100644
--- a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl
+++ b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -34,5 +36,5 @@ uniform sampler2D diffuseMap;
 
 void main() 
 {
-	gl_FragColor = vec4(vertex_color.rgb, texture2D(diffuseMap, vary_texcoord0.xy).a);
+	frag_color = vec4(vertex_color.rgb, texture2D(diffuseMap, vary_texcoord0.xy).a);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index c012efa056..37fd63b7d5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect depthMap;
@@ -69,6 +71,6 @@ void main()
 
 	color.rgb += diff.rgb * vary_pointlight_col.rgb;
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
index 8641827777..14ac9f1f78 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect depthMap;
@@ -81,9 +83,9 @@ void main()
 
 	color.rgb += diff.rgb * vary_pointlight_col.rgb;
 
-	gl_FragColor = color;
-	//gl_FragColor = vec4(1,0,1,1);
-	//gl_FragColor = vec4(1,0,1,1)*shadow;
+	frag_color = color;
+	//frag_color = vec4(1,0,1,1);
+	//frag_color = vec4(1,0,1,1)*shadow;
 	
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
index c13ea702db..654e272b06 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect depthMap;
@@ -79,6 +81,6 @@ void main()
 
 	color.rgb += diff.rgb * vary_pointlight_col.rgb;
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
index 402f681631..b88041490a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
@@ -23,7 +23,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D diffuseMap;
@@ -33,7 +35,7 @@ VARYING vec2 vary_texcoord0;
 
 void main() 
 {
-	//gl_FragColor = vec4(1,1,1,vertex_color.a * texture2D(diffuseMap, vary_texcoord0.xy).a);
-	gl_FragColor = vec4(1,1,1,1);
+	//frag_color = vec4(1,1,1,vertex_color.a * texture2D(diffuseMap, vary_texcoord0.xy).a);
+	frag_color = vec4(1,1,1,1);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
index 9a3b2e3e8a..4912c9a50c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 uniform sampler2D diffuseMap;
@@ -41,9 +43,9 @@ void main()
 		discard;
 	}
 	
-	gl_FragData[0] = vec4(diff.rgb, 0.0);
-	gl_FragData[1] = vec4(0,0,0,0);
+	frag_data[0] = vec4(diff.rgb, 0.0);
+	frag_data[1] = vec4(0,0,0,0);
 	vec3 nvn = normalize(vary_normal);
-	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
+	frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
index 558a88009a..594ed778e3 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D diffuseMap;
@@ -33,7 +35,7 @@ VARYING vec4 post_pos;
 
 void main() 
 {
-	gl_FragColor = vec4(1,1,1,1);
+	frag_color = vec4(1,1,1,1);
 
 	gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index 60d4dae99f..a08b018702 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect depthMap;
@@ -111,6 +113,6 @@ void main()
 	col /= defined_weight.xyxx;
 	col.y *= col.y;
 	
-	gl_FragColor = col;
+	frag_color = col;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index 6cc5f23aca..141738023d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 uniform sampler2D diffuseMap;
@@ -46,9 +48,9 @@ void main()
 			  dot(norm,vary_mat1),
 			  dot(norm,vary_mat2));
 						
-	gl_FragData[0] = vec4(col, 0.0);
-	gl_FragData[1] = vertex_color.aaaa; // spec
-	//gl_FragData[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
+	frag_data[0] = vec4(col, 0.0);
+	frag_data[1] = vertex_color.aaaa; // spec
+	//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
 	vec3 nvn = normalize(tnorm);
-	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
+	frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
index db272cf601..d2afc148b1 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
@@ -25,7 +25,9 @@
  
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 /////////////////////////////////////////////////////////////////////////
@@ -98,8 +100,8 @@ void main()
 	color *= 2.;
 
 	/// Gamma correct for WL (soft clip effect).
-	gl_FragData[0] = vec4(scaleSoftClip(color.rgb), alpha1);
-	gl_FragData[1] = vec4(0.0,0.0,0.0,0.0);
-	gl_FragData[2] = vec4(0,0,1,0);
+	frag_data[0] = vec4(scaleSoftClip(color.rgb), alpha1);
+	frag_data[1] = vec4(0.0,0.0,0.0,0.0);
+	frag_data[2] = vec4(0,0,1,0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
index e612efba61..3fcfbf55c4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect diffuseRect;
@@ -83,6 +85,6 @@ void main()
 	sc = max(sc, -max_cof);
 	
 	vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
-	gl_FragColor.rgb = diff.rgb + bloom.rgb;
-	gl_FragColor.a = sc/max_cof*0.5+0.5;
+	frag_color.rgb = diff.rgb + bloom.rgb;
+	frag_color.a = sc/max_cof*0.5+0.5;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
index e9989a4e48..c8acaee134 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 uniform float minimum_alpha;
@@ -44,9 +46,9 @@ void main()
 		discard;
 	}
 
-	gl_FragData[0] = vec4(col.rgb, 0.0);
-	gl_FragData[1] = vec4(0,0,0,0); // spec
+	frag_data[0] = vec4(col.rgb, 0.0);
+	frag_data[1] = vec4(0,0,0,0); // spec
 	vec3 nvn = normalize(vary_normal);
-	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
+	frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
index fdf8d72b38..d960cbc2fe 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 VARYING vec3 vary_normal;
@@ -43,8 +45,8 @@ void main()
 		discard;
 	}
 
-	gl_FragData[0] = vec4(col.rgb, 0.0);
-	gl_FragData[1] = vec4(0,0,0,0);
+	frag_data[0] = vec4(col.rgb, 0.0);
+	frag_data[1] = vec4(0,0,0,0);
 	vec3 nvn = normalize(vary_normal);
-	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
+	frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
index bb20e2ca47..b1c9b52569 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
@@ -25,7 +25,9 @@
  
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 uniform float minimum_alpha;
@@ -44,9 +46,9 @@ void main()
 		discard;
 	}
 
-	gl_FragData[0] = vec4(col.rgb, 0.0);
-	gl_FragData[1] = vec4(0,0,0,0); // spec
+	frag_data[0] = vec4(col.rgb, 0.0);
+	frag_data[1] = vec4(0,0,0,0); // spec
 	vec3 nvn = normalize(vary_normal);
-	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
+	frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index 7bde49eb86..caefe84957 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 uniform sampler2D diffuseMap;
@@ -36,10 +38,10 @@ VARYING vec2 vary_texcoord0;
 void main() 
 {
 	vec3 col = vertex_color.rgb * texture2D(diffuseMap, vary_texcoord0.xy).rgb;
-	gl_FragData[0] = vec4(col, 0.0);
-	gl_FragData[1] = vertex_color.aaaa; // spec
-	//gl_FragData[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
+	frag_data[0] = vec4(col, 0.0);
+	frag_data[1] = vertex_color.aaaa; // spec
+	//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
 	vec3 nvn = normalize(vary_normal);
-	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
+	frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
index 75b45111e0..c89f389954 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 VARYING vec3 vary_normal;
@@ -35,9 +37,9 @@ void main()
 {
 	vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb;
 
-	gl_FragData[0] = vec4(col, 0.0);
-	gl_FragData[1] = vertex_color.aaaa; // spec
-	//gl_FragData[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
+	frag_data[0] = vec4(col, 0.0);
+	frag_data[1] = vertex_color.aaaa; // spec
+	//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
 	vec3 nvn = normalize(vary_normal);
-	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
+	frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
index 0cf5afc568..f05ea557e3 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect diffuseRect;
@@ -73,5 +75,5 @@ void main()
 		diff = mix(diff, col*0.25, a);
 	}
 
-	gl_FragColor = mix(diff, dof, a);
+	frag_color = mix(diff, dof, a);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl
index 92f78125d8..ebe9a66bb4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 vec3 fullbrightAtmosTransport(vec3 light);
@@ -45,6 +47,6 @@ void main()
 
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
index 84ae2f9f10..616ffca2d1 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -46,6 +48,6 @@ void main()
 
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
index 5af9406452..76b1748813 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 #define FXAA_PC 1
@@ -2113,6 +2115,6 @@ void main()
 
 	//diff = texture2D(diffuseMap, vary_tc);
 	
-	gl_FragColor = diff;
+	frag_color = diff;
 	
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
index 29ca80ae92..28ed70d49d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect depthMap;
@@ -184,5 +186,5 @@ void main()
 	vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
 	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 	
-	gl_FragColor.xyz = giAmbient(pos, norm);
+	frag_color.xyz = giAmbient(pos, norm);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/giV.glsl b/indra/newview/app_settings/shaders/class1/deferred/giV.glsl
deleted file mode 100644
index e5d3bb8ea6..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/giV.glsl
+++ /dev/null
@@ -1,48 +0,0 @@
-/** 
- * @file giV.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$
- */
-
-uniform mat4 modelview_projection_matrix;
-
-ATTRIBUTE vec3 position;
-ATTRIBUTE vec4 diffuse_color;
-ATTRIBUTE vec2 texcoord0;
-
-VARYING vec4 vertex_color;
-VARYING vec2 vary_fragcoord;
-
-uniform vec2 screen_res;
-
-void main()
-{
-	//transform vertex
-	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
-	gl_Position = pos; 
-	
-	vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;	
-	vec4 tex = vec4(texcoord0,0,1);
-	tex.w = 1.0;
-
-	vertex_color = diffuse_color;
-}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
index a44173a2a4..d7bc8d02d9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 uniform float minimum_alpha;
@@ -45,7 +47,7 @@ void main()
 		discard;
 	}
 
-	gl_FragData[0] = vec4(col.rgb, col.a * 0.005);
-	gl_FragData[1] = texture2D(specularMap, vary_texcoord0.xy);
-	gl_FragData[2] = vec4(texture2D(normalMap, vary_texcoord0.xy).xyz, 0.0);
+	frag_data[0] = vec4(col.rgb, col.a * 0.005);
+	frag_data[1] = texture2D(specularMap, vary_texcoord0.xy);
+	frag_data[2] = vec4(texture2D(normalMap, vary_texcoord0.xy).xyz, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
index e014a14ad8..31da124cb1 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
@@ -26,12 +26,14 @@
 uniform sampler2DRect diffuseMap;
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec2 vary_fragcoord;
 
 void main() 
 {
-	gl_FragColor = texture2DRect(diffuseMap, vary_fragcoord.xy);
+	frag_color = texture2DRect(diffuseMap, vary_fragcoord.xy);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index 179c721a2f..cd50e17d7e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect depthMap;
@@ -141,6 +143,6 @@ void main()
 		discard;
 	}
 	
-	gl_FragColor.rgb = out_col;
-	gl_FragColor.a = 0.0;
+	frag_color.rgb = out_col;
+	frag_color.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 2196d14895..40dd363061 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 //class 1 -- no shadows
@@ -242,6 +244,6 @@ void main()
 		}
 	}
 	
-	gl_FragColor.rgb = col;	
-	gl_FragColor.a = 0.0;
+	frag_color.rgb = col;	
+	frag_color.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl
index 879942d8fa..32881ef042 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D alphaMap;
@@ -52,5 +54,5 @@ void main()
 	norm *= 0.5;
 	norm += 0.5;	
 	
-	gl_FragColor = vec4(norm, alpha);
+	frag_color = vec4(norm, alpha);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index b673d00d6e..619b7bcd03 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect diffuseRect;
@@ -118,6 +120,6 @@ void main()
 		discard;
 	}
 		
-	gl_FragColor.rgb = col;	
-	gl_FragColor.a = 0.0;
+	frag_color.rgb = col;	
+	frag_color.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
index 18d451bf87..e7b2174280 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect diffuseRect;
@@ -122,5 +124,5 @@ void main()
 		diff /= w;
 	}
 		
-	gl_FragColor = diff;
+	frag_color = diff;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
index c275434777..ed2352b51f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect diffuseRect;
@@ -40,6 +42,6 @@ void main()
 	vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
 	
 	vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
-	gl_FragColor = diff + bloom;
+	frag_color = diff + bloom;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
index 84d65d5b3b..18550b2e12 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
@@ -24,8 +24,10 @@
  */
 
  #ifdef DEFINE_GL_FRAGCOLOR
- out vec4 gl_FragColor;
- #endif
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
+#endif
  
 uniform sampler2DRect depthMap;
 uniform sampler2DRect normalMap;
@@ -96,5 +98,5 @@ void main()
 	
 	col = col*col*blur_quad.x + col*blur_quad.y + blur_quad.z;
 	
-	gl_FragColor.rgb = col;
+	frag_color.rgb = col;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl
deleted file mode 100644
index 0d5c8e7287..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl
+++ /dev/null
@@ -1,40 +0,0 @@
-/** 
- * @file postgiV.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$
- */
-
-uniform mat4 modelview_projection_matrix;
- 
-ATTRIBUTE vec3 position;
-
-
-VARYING vec2 vary_fragcoord;
-uniform vec2 screen_res;
-
-void main()
-{
-	//transform vertex
-	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
-	gl_Position = pos; 	
-	vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
-}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl
index c1fb7b55d4..7d75b50aa2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform float minimum_alpha;
@@ -44,7 +46,7 @@ void main()
 		discard;
 	}
 
-	gl_FragColor = vec4(1,1,1,1);
+	frag_color = vec4(1,1,1,1);
 	
 	gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
index bf75ca262e..3eb733aa51 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
@@ -24,14 +24,16 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 post_pos;
 
 void main() 
 {
-	gl_FragColor = vec4(1,1,1,1);
+	frag_color = vec4(1,1,1,1);
 	
 	gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
index 96ad0aa93a..7d80f07da4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 /////////////////////////////////////////////////////////////////////////
@@ -57,8 +59,8 @@ void main()
 	color *= 2.;
 
 	/// Gamma correct for WL (soft clip effect).
-	gl_FragData[0] = vec4(scaleSoftClip(color.rgb), 1.0);
-	gl_FragData[1] = vec4(0.0,0.0,0.0,0.0);
-	gl_FragData[2] = vec4(0,0,1,0);
+	frag_data[0] = vec4(scaleSoftClip(color.rgb), 1.0);
+	frag_data[1] = vec4(0.0,0.0,0.0,0.0);
+	frag_data[2] = vec4(0,0,1,0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 0c53a4ffa5..70b0f6fbd0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect diffuseRect;
@@ -322,7 +324,7 @@ void main()
 		col = diffuse.rgb;
 	}
 
-	gl_FragColor.rgb = col;
+	frag_color.rgb = col;
 
-	gl_FragColor.a = bloom;
+	frag_color.a = bloom;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index cc0f4e5b6b..d3d6a155f0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -27,7 +27,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect diffuseRect;
@@ -184,6 +186,6 @@ void main()
 		}
 	}
 	
-	gl_FragColor.rgb = col;	
-	gl_FragColor.a = 0.0;
+	frag_color.rgb = col;	
+	frag_color.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
index 03fccd2766..1cfcca4f5d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 VARYING vec4 vertex_color;
@@ -36,7 +38,7 @@ void main()
 {
 	vec4 col = vertex_color * texture2D(diffuseMap, vary_texcoord0.xy);
 	
-	gl_FragData[0] = col;
-	gl_FragData[1] = vec4(0,0,0,0);
-	gl_FragData[2] = vec4(0,0,1,0);	
+	frag_data[0] = col;
+	frag_data[1] = vec4(0,0,0,0);
+	frag_data[2] = vec4(0,0,1,0);	
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
index adc7c5d005..aa29be09a1 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
@@ -28,10 +28,12 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 void main() 
 {
-	gl_FragColor = vec4(0,0,0,0);
+	frag_color = vec4(0,0,0,0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index fc5959a33c..9bee632472 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 //class 1 -- no shadow, SSAO only
@@ -128,8 +130,8 @@ void main()
 	vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
 	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
 		
-	gl_FragColor[0] = 1.0;
-	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
-	gl_FragColor[2] = 1.0; 
-	gl_FragColor[3] = 1.0;
+	frag_color[0] = 1.0;
+	frag_color[1] = calcAmbientOcclusion(pos, norm);
+	frag_color[2] = 1.0; 
+	frag_color[3] = 1.0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
index 5522e6c41d..021c23f76c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 uniform sampler2D detail_0;
@@ -51,9 +53,9 @@ void main()
 	float alphaFinal = texture2D(alpha_ramp, vary_texcoord1.zw).a;
 	vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal );
 	
-	gl_FragData[0] = vec4(outColor.rgb, 0.0);
-	gl_FragData[1] = vec4(0,0,0,0);
+	frag_data[0] = vec4(outColor.rgb, 0.0);
+	frag_data[1] = vec4(0,0,0,0);
 	vec3 nvn = normalize(vary_normal);
-	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
+	frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
index ea98d6884c..10d8a5c321 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 uniform sampler2D diffuseMap;
@@ -43,8 +45,8 @@ void main()
 		discard;
 	}
 
-	gl_FragData[0] = vec4(vertex_color.rgb*col.rgb, 0.0);
-	gl_FragData[1] = vec4(0,0,0,0);
+	frag_data[0] = vec4(vertex_color.rgb*col.rgb, 0.0);
+	frag_data[1] = vec4(0,0,0,0);
 	vec3 nvn = normalize(vary_normal);
-	gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
+	frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl
index 20d0170535..6be66a402f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform float minimum_alpha;
@@ -43,7 +45,7 @@ void main()
 		discard;
 	}
 
-	gl_FragColor = vec4(1,1,1,1);
+	frag_color = vec4(1,1,1,1);
 	
 	gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 4c9ea24a24..e4c655ed7d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragData[3];
+out vec4 frag_data[3];
+#else
+#define frag_data gl_FragData;
 #endif
 
 vec3 scaleSoftClip(vec3 inColor);
@@ -157,7 +159,7 @@ void main()
 	//wavef = normalize(wavef);
 	vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz;
 	
-	gl_FragData[0] = vec4(color.rgb, 0.5); // diffuse
-	gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec
-	gl_FragData[2] = vec4(screenspacewavef.xy*0.5+0.5, screenspacewavef.z, screenspacewavef.z*0.5); // normalxyz, displace
+	frag_data[0] = vec4(color.rgb, 0.5); // diffuse
+	frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec
+	frag_data[2] = vec4(screenspacewavef.xy*0.5+0.5, screenspacewavef.z, screenspacewavef.z*0.5); // normalxyz, displace
 }
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
index 9a3d792224..952706841d 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect diffuseMap;
@@ -46,7 +48,7 @@ void main()
 	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)) ); 
 	
-	gl_FragColor.rgb = col.rgb; 
-	gl_FragColor.a = max(col.a, mix(lum, warmth, warmthAmount) * maxExtractAlpha);
+	frag_color.rgb = col.rgb; 
+	frag_color.a = max(col.a, mix(lum, warmth, warmthAmount) * maxExtractAlpha);
 	
 }
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl
index 90bb84323c..289c5b367f 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D diffuseMap;
@@ -54,5 +56,5 @@ void main()
 	col += kern[6] * texture2D(diffuseMap, vary_texcoord2.zw);	
 	col += kern[7] * texture2D(diffuseMap, vary_texcoord3.zw);	
 	
-	gl_FragColor = vec4(col.rgb * glowStrength, col.a);
+	frag_color = vec4(col.rgb * glowStrength, col.a);
 }
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
index 18f6d91804..51efdd4b39 100644
--- a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -59,6 +61,6 @@ void main()
 	/// Add WL Components
 	outColor.rgb = atmosLighting(outColor.rgb * vertex_color.rgb);
 	
-	gl_FragColor = vec4(scaleSoftClip(outColor.rgb), 1.0);
+	frag_color = vec4(scaleSoftClip(outColor.rgb), 1.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
index e5c7ced52c..d9b5c5f7f5 100644
--- a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -60,6 +62,6 @@ void main()
 	outColor.rgb = atmosLighting(outColor.rgb * vertex_color.rgb);
 	
 	outColor = applyWaterFog(outColor);
-	gl_FragColor = outColor;
+	frag_color = outColor;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl
index 1fdb90f792..32459eff6a 100644
--- a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D diffuseMap;
@@ -106,5 +108,5 @@ void main()
 		
 	vec4 fb = texture2D(screenTex, distort);
 	
-	gl_FragColor = applyWaterFog(fb,view.xyz);
+	frag_color = applyWaterFog(fb,view.xyz);
 }
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
index 444c896d38..0cde7d0133 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 vec3 scaleSoftClip(vec3 inColor);
@@ -135,5 +137,5 @@ void main()
 	color.rgb = scaleSoftClip(color.rgb);
 	color.a = spec * sunAngle2;
 
-	gl_FragColor = color;
+	frag_color = color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl
index d2f5e1987a..e8b8513bd1 100644
--- a/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D diffuseMap;
@@ -42,5 +44,5 @@ void main()
 		discard;
 	}
 
-	gl_FragColor = col;
+	frag_color = col;
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl b/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl
index 4b481ba834..b990ce9f03 100644
--- a/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D diffuseMap;
@@ -38,5 +40,5 @@ void main()
 {
 	vec4 color = vertex_color*texture2D(diffuseMap, vary_texcoord0.xy);
 	color.a *= custom_alpha;
-	gl_FragColor = color;
+	frag_color = color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/debugF.glsl b/indra/newview/app_settings/shaders/class1/interface/debugF.glsl
index 6bcc97ba18..ad05f17a30 100644
--- a/indra/newview/app_settings/shaders/class1/interface/debugF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/debugF.glsl
@@ -24,12 +24,14 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform vec4 color;
 
 void main() 
 {
-	gl_FragColor = color;
+	frag_color = color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
index f67703b839..7e4515db40 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 #extension GL_ARB_texture_rectangle : enable
@@ -37,6 +39,6 @@ VARYING vec2 vary_texcoord1;
 
 void main() 
 {
-	gl_FragColor = texture2D(glowMap, vary_texcoord0.xy) +
+	frag_color = texture2D(glowMap, vary_texcoord0.xy) +
 					texture2DRect(screenMap, vary_texcoord1.xy);
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
index c66a6e5b48..5a5894523d 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect diffuseRect;
@@ -38,5 +40,5 @@ void main()
 {
 	vec3 col = texture2DRect(diffuseRect, vary_tc*screen_res).rgb;
 	
-	gl_FragColor = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144)));
+	frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144)));
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl
index ecbc30f05f..d1d140d2a6 100644
--- a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform vec4 color;
@@ -34,5 +36,5 @@ VARYING vec2 vary_texcoord0;
 
 void main() 
 {
-	gl_FragColor = color*texture2D(diffuseMap, vary_texcoord0.xy);
+	frag_color = color*texture2D(diffuseMap, vary_texcoord0.xy);
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl
index 85f819f4c2..a18a3cdb50 100644
--- a/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl
@@ -24,10 +24,12 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 void main() 
 {
-	gl_FragColor = vec4(1,1,1,1);
+	frag_color = vec4(1,1,1,1);
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl
index fafeb5a7b4..bfaa4774d9 100644
--- a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D tex0;
@@ -33,5 +35,5 @@ VARYING vec2 vary_texcoord0;
 
 void main() 
 {
-	gl_FragColor = texture2D(tex0, vary_texcoord0.xy);
+	frag_color = texture2D(tex0, vary_texcoord0.xy);
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl b/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl
index f790122749..5d7edf33a9 100644
--- a/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D tex0;
@@ -36,5 +38,5 @@ void main()
 {
 	float alpha = texture2D(tex0, vary_texcoord0.xy).a * vertex_color.a;
 
-	gl_FragColor = vec4(vertex_color.rgb, alpha);
+	frag_color = vec4(vertex_color.rgb, alpha);
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
index a0bb255cfa..7a28ca847a 100644
--- a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect screenMap;
@@ -36,5 +38,5 @@ VARYING vec2 vary_texcoord0;
 
 void main() 
 {
-	gl_FragColor = 	texture2DRect(screenMap, vary_texcoord0.xy) * vertex_color;
+	frag_color = 	texture2DRect(screenMap, vary_texcoord0.xy) * vertex_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl b/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl
index cdb48163dd..73a5839028 100644
--- a/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D tex0;
@@ -35,5 +37,5 @@ VARYING vec2 vary_texcoord1;
 
 void main() 
 {
-	gl_FragColor = texture2D(tex0, vary_texcoord0.xy)+texture2D(tex1, vary_texcoord1.xy);
+	frag_color = texture2D(tex0, vary_texcoord0.xy)+texture2D(tex1, vary_texcoord1.xy);
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/uiF.glsl b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl
index 36d6e06fc5..8fac2862b1 100644
--- a/indra/newview/app_settings/shaders/class1/interface/uiF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D diffuseMap;
@@ -34,5 +36,5 @@ VARYING vec4 vertex_color;
 
 void main() 
 {
-	gl_FragColor = vertex_color*texture2D(diffuseMap, vary_texcoord0.xy);
+	frag_color = vertex_color*texture2D(diffuseMap, vary_texcoord0.xy);
 }
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl
index 10413bdeb0..aabff3196a 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform float minimum_alpha;
@@ -48,6 +50,6 @@ void default_lighting()
 
 	color.rgb = scaleSoftClip(color.rgb);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl
index 1164e5b0a6..6e6aec8532 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform float minimum_alpha;
@@ -50,6 +52,6 @@ void default_lighting()
 
 	color.rgb = scaleSoftClip(color.rgb);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl
index 735f5b3813..f9a3eb8d90 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -41,6 +43,6 @@ void default_lighting()
 
 	color.rgb = scaleSoftClip(color.rgb);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl
index ba99c0ed71..a3eb133133 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform float minimum_alpha;
@@ -48,6 +50,6 @@ void fullbright_lighting()
 	
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl
index c3edc0bd70..222c6bbf0e 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -41,6 +43,6 @@ void fullbright_lighting()
 	
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl
index 276fad4f44..441fcd0d7a 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform float minimum_alpha;
@@ -50,6 +52,6 @@ void fullbright_lighting()
 	
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl
index 4e1e664e6b..7020fbc72b 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -43,6 +45,6 @@ void fullbright_lighting()
 	
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl
index c981e9eba2..889a3e48ba 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -50,6 +52,6 @@ void fullbright_shiny_lighting()
 
 	color.a = max(color.a, vertex_color.a);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl
index a4893f0359..f0727c377b 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -51,6 +53,6 @@ void fullbright_shiny_lighting()
 
 	color.a = max(color.a, vertex_color.a);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl
index c10cde98e0..aac13462b3 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl
@@ -23,7 +23,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -48,6 +50,6 @@ void fullbright_shiny_lighting_water()
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
 	color.a = max(color.a, vertex_color.a);
 
-	gl_FragColor = applyWaterFog(color);
+	frag_color = applyWaterFog(color);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl
index e9b26087f4..4f57b7a9f5 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl
@@ -23,7 +23,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -49,6 +51,6 @@ void fullbright_shiny_lighting_water()
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
 	color.a = max(color.a, vertex_color.a);
 
-	gl_FragColor = applyWaterFog(color);
+	frag_color = applyWaterFog(color);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl
index 754b2922d9..6c277cddc1 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform float minimum_alpha;
@@ -48,6 +50,6 @@ void fullbright_lighting_water()
 
 	color.rgb = fullbrightAtmosTransport(color.rgb);
 	
-	gl_FragColor = applyWaterFog(color);
+	frag_color = applyWaterFog(color);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl
index 2547f9e750..5c4bedefcc 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -41,6 +43,6 @@ void fullbright_lighting_water()
 
 	color.rgb = fullbrightAtmosTransport(color.rgb);
 	
-	gl_FragColor = applyWaterFog(color);
+	frag_color = applyWaterFog(color);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl
index f69b907dc7..df07071236 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform float minimum_alpha;
@@ -48,6 +50,6 @@ void fullbright_lighting_water()
 
 	color.rgb = fullbrightAtmosTransport(color.rgb);
 	
-	gl_FragColor = applyWaterFog(color);
+	frag_color = applyWaterFog(color);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl
index aa3ef8cdd9..91208bc56a 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -41,6 +43,6 @@ void fullbright_lighting_water()
 
 	color.rgb = fullbrightAtmosTransport(color.rgb);
 	
-	gl_FragColor = applyWaterFog(color);
+	frag_color = applyWaterFog(color);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl
index 9f1a358b53..1a0473b9e2 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
  
 VARYING vec4 vertex_color;
@@ -43,6 +45,6 @@ void default_lighting()
 
 	color.rgb = scaleSoftClip(color.rgb);
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl
index e9c27dbefd..a24d8d4ecd 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -49,6 +51,6 @@ void shiny_lighting()
 
 	color.rgb = scaleSoftClip(color.rgb);
 	color.a = max(color.a, vertex_color.a);
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl
index 595ad74365..16f64633ac 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
  
 VARYING vec4 vertex_color;
@@ -50,6 +52,6 @@ void shiny_lighting()
 
 	color.rgb = scaleSoftClip(color.rgb);
 	color.a = max(color.a, vertex_color.a);
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl
index 68c727d62c..cf78149733 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -46,6 +48,6 @@ void shiny_lighting_water()
 
 	color.rgb = atmosLighting(color.rgb);
 	color.a = max(color.a, vertex_color.a);
-	gl_FragColor = applyWaterFog(color);
+	frag_color = applyWaterFog(color);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl
index f32b9e1958..97531fd937 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -47,6 +49,6 @@ void shiny_lighting_water()
 
 	color.rgb = atmosLighting(color.rgb);
 	color.a = max(color.a, vertex_color.a);
-	gl_FragColor = applyWaterFog(color);
+	frag_color = applyWaterFog(color);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl
index 103dd633c9..4fcdad09fc 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform float minimum_alpha;
@@ -46,6 +48,6 @@ void default_lighting_water()
 
 	color.rgb = atmosLighting(color.rgb);
 
-	gl_FragColor = applyWaterFog(color);
+	frag_color = applyWaterFog(color);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl
index bef72752da..d235ed2491 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform float minimum_alpha;
@@ -50,6 +52,6 @@ void default_lighting_water()
 
 	color = applyWaterFog(color);
 	
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl
index e9537d1e9d..c295579028 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl
@@ -24,8 +24,10 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
-#endif 
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
+#endif
 
 VARYING vec4 vertex_color;
 VARYING vec2 vary_texcoord0;
@@ -39,6 +41,6 @@ void default_lighting_water()
 
 	color.rgb = atmosLighting(color.rgb);
 
-	gl_FragColor = applyWaterFog(color);
+	frag_color = applyWaterFog(color);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl
index 8b0c25b705..5a5cc2c821 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -41,6 +43,6 @@ void default_lighting_water()
 
 	color.rgb = atmosLighting(color.rgb);
 
-	gl_FragColor = applyWaterFog(color);
+	frag_color = applyWaterFog(color);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl b/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl
index 4b85d61aca..df6130cc58 100644
--- a/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2D texture0;
@@ -38,5 +40,5 @@ void main()
 	float tex0 = texture2D(texture0, vary_texcoord0.xy).a;
 	float tex1 = texture2D(texture1, vary_texcoord1.xy).a;
 
-	gl_FragColor = vec4(tex0+(1.0-tex1)-0.5);
+	frag_color = vec4(tex0+(1.0-tex1)-0.5);
 }
diff --git a/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl b/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl
index 3c6e22b295..6358fdfeae 100644
--- a/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl
@@ -24,7 +24,9 @@
  */
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform float minimum_alpha;
@@ -42,5 +44,5 @@ void main()
 		discard;
 	}
 
-	gl_FragColor = color;
+	frag_color = color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/objects/indexedTextureV.glsl b/indra/newview/app_settings/shaders/class1/objects/indexedTextureV.glsl
index a95c9e0ab9..a0f513d73d 100644
--- a/indra/newview/app_settings/shaders/class1/objects/indexedTextureV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/indexedTextureV.glsl
@@ -23,9 +23,9 @@
  * $/LicenseInfo$
  */
 
-ATTRIBUTE float texture_index;
+ATTRIBUTE uvec4 texture_index;
 
-VARYING float vary_texture_index;
+VARYING_FLAT uvec4 vary_texture_index;
 
 void passTextureIndex()
 {
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
index 1179b212ae..373a6c157b 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -125,6 +127,6 @@ void main()
 
 	color.rgb += diff.rgb * vary_pointlight_col.rgb;
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
index 0df557f2aa..04460ea7c0 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRectShadow shadowMap0;
@@ -138,6 +140,6 @@ void main()
 
 	color.rgb += diff.rgb * vary_pointlight_col.rgb;
 
-	gl_FragColor = color;	
+	frag_color = color;	
 }
 
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
index 331dbc7079..c50145f753 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRectShadow shadowMap0;
@@ -137,6 +139,6 @@ void main()
 
 	color.rgb += diff.rgb * vary_pointlight_col.rgb;
 
-	gl_FragColor = color;
+	frag_color = color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 14a683971a..7d78a888a5 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect diffuseRect;
@@ -253,6 +255,6 @@ void main()
 		}
 	}
 	
-	gl_FragColor.rgb = col;	
-	gl_FragColor.a = 0.0;
+	frag_color.rgb = col;	
+	frag_color.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 27ea77b5a2..f73163898e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 uniform sampler2DRect diffuseRect;
@@ -330,6 +332,6 @@ void main()
 		col = diffuse.rgb;
 	}
 		
-	gl_FragColor.rgb = col;
-	gl_FragColor.a = bloom;
+	frag_color.rgb = col;
+	frag_color.a = bloom;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index 31bd0c79da..7cc621b1f6 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 VARYING vec4 vertex_color;
@@ -201,6 +203,6 @@ void main()
 		}
 	}
 	
-	gl_FragColor.rgb = col;	
-	gl_FragColor.a = 0.0;
+	frag_color.rgb = col;	
+	frag_color.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 229c2f4b67..a92a9fc8e8 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -26,7 +26,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 //class 2, shadows, no SSAO
@@ -129,7 +131,7 @@ void main()
 	
 	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
 	{
-		gl_FragColor = vec4(0.0); // doesn't matter
+		frag_color = vec4(0.0); // doesn't matter
 		return;
 	}*/
 	
@@ -198,19 +200,19 @@ void main()
 		shadow = 1.0;
 	}
 	
-	gl_FragColor[0] = shadow;
-	gl_FragColor[1] = 1.0;
+	frag_color[0] = shadow;
+	frag_color[1] = 1.0;
 	
 	spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0);
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8); 
+	frag_color[2] = pcfShadow(shadowMap4, lpos, 0.8); 
 	
 	//spotlight shadow 2
 	lpos = shadow_matrix[5]*spos;
-	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8); 
+	frag_color[3] = pcfShadow(shadowMap5, lpos, 0.8); 
 
-	//gl_FragColor.rgb = pos.xyz;
-	//gl_FragColor.b = shadow;
+	//frag_color.rgb = pos.xyz;
+	//frag_color.b = shadow;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index 6b420833b9..45b8db5adc 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -25,7 +25,9 @@
 #extension GL_ARB_texture_rectangle : enable
 
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 //class 2 -- shadows and SSAO
@@ -190,7 +192,7 @@ void main()
 	
 	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
 	{
-		gl_FragColor = vec4(0.0); // doesn't matter
+		frag_color = vec4(0.0); // doesn't matter
 		return;
 	}*/
 	
@@ -259,19 +261,19 @@ void main()
 		shadow = 1.0;
 	}
 	
-	gl_FragColor[0] = shadow;
-	gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
+	frag_color[0] = shadow;
+	frag_color[1] = calcAmbientOcclusion(pos, norm);
 	
 	spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0);
 	
 	//spotlight shadow 1
 	vec4 lpos = shadow_matrix[4]*spos;
-	gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8); 
+	frag_color[2] = pcfShadow(shadowMap4, lpos, 0.8); 
 	
 	//spotlight shadow 2
 	lpos = shadow_matrix[5]*spos;
-	gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8); 
+	frag_color[3] = pcfShadow(shadowMap5, lpos, 0.8); 
 
-	//gl_FragColor.rgb = pos.xyz;
-	//gl_FragColor.b = shadow;
+	//frag_color.rgb = pos.xyz;
+	//frag_color.b = shadow;
 }
diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
index 4ab06c6e21..c8d89095d8 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 /////////////////////////////////////////////////////////////////////////
@@ -96,7 +98,7 @@ void main()
 	color *= 2.;
 
 	/// Gamma correct for WL (soft clip effect).
-	gl_FragColor.rgb = scaleSoftClip(color.rgb);
-	gl_FragColor.a = alpha1;
+	frag_color.rgb = scaleSoftClip(color.rgb);
+	frag_color.a = alpha1;
 }
 
diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
index c9d96b2cf4..4aece6e032 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
@@ -24,7 +24,9 @@
  */
  
 #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 gl_FragColor;
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor;
 #endif
 
 /////////////////////////////////////////////////////////////////////////
@@ -57,7 +59,7 @@ void main()
 	color *= 2.;
 
 	/// Gamma correct for WL (soft clip effect).
-	gl_FragColor.rgb = scaleSoftClip(color.rgb);
-	gl_FragColor.a = 1.0;
+	frag_color.rgb = scaleSoftClip(color.rgb);
+	frag_color.a = 1.0;
 }
 
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index cd33a19a2a..838e541145 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1742,14 +1742,22 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		LLVector4a texIdx;
 
-		F32 index = (F32) (mTextureIndex < 255 ? mTextureIndex : 0);
+		U8 index = mTextureIndex < 255 ? mTextureIndex : 0;
+
+		F32 val = 0.f;
+		U8* vp = (U8*) &val;
+		vp[0] = index;
+		vp[1] = 0;
+		vp[2] = 0;
+		vp[3] = 0;
+
 		llassert(index <= LLGLSLShader::sIndexedTextureChannels-1);
 
 		LLVector4Logical mask;
 		mask.clear();
 		mask.setElement<3>();
 		
-		texIdx.set(0,0,0,index);
+		texIdx.set(0,0,0,val);
 
 		{
 			LLFastTimer t(FTM_FACE_POSITION_STORE);
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 6db2138688..36a402e05e 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -416,6 +416,7 @@ void LLViewerShaderMgr::setShaders()
 	LLGLSLShader::sNoFixedFunction = false;
 	LLVertexBuffer::unbind();
 	if (LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") 
+		&& (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 10)
 		&& gSavedSettings.getBOOL("VertexShaderEnable"))
 	{
 		//using shaders, disable fixed function
@@ -741,7 +742,10 @@ BOOL LLViewerShaderMgr::loadBasicShaders()
 	shaders.push_back( make_pair( "windlight/atmosphericsV.glsl",			mVertexShaderLevel[SHADER_WINDLIGHT] ) );
 	shaders.push_back( make_pair( "avatar/avatarSkinV.glsl",				1 ) );
 	shaders.push_back( make_pair( "avatar/objectSkinV.glsl",				1 ) );
-	shaders.push_back( make_pair( "objects/indexedTextureV.glsl",			1 ) );
+	if (gGLManager.mGLSLVersionMajor >= 2 || gGLManager.mGLSLVersionMinor >= 30)
+	{
+		shaders.push_back( make_pair( "objects/indexedTextureV.glsl",			1 ) );
+	}
 	shaders.push_back( make_pair( "objects/nonindexedTextureV.glsl",		1 ) );
 
 	// We no longer have to bind the shaders to global glhandles, they are automatically added to a map now.
@@ -758,11 +762,11 @@ BOOL LLViewerShaderMgr::loadBasicShaders()
 	// (in order of shader function call depth for reference purposes, deepest level first)
 
 	shaders.clear();
-	S32 ch = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1);
+	S32 ch = 1;
 
-	if (gGLManager.mGLVersion < 3.1f)
-	{ //force to 1 texture index channel for old drivers
-		ch = 1;
+	if (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 30)
+	{ //use indexed texture rendering for GLSL >= 1.30
+		ch = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1);
 	}
 
 	std::vector<S32> index_channels;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 6354230796..4d50a920d9 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4714,11 +4714,11 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 		buffer_index = -1;
 	}
 
-	S32 texture_index_channels = LLGLSLShader::sIndexedTextureChannels-1; //always reserve one for shiny for now just for simplicity
+	S32 texture_index_channels = 1;
 	
-	if (gGLManager.mGLVersion < 3.1f)
+	if (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 30)
 	{
-		texture_index_channels = 1;
+		texture_index_channels = LLGLSLShader::sIndexedTextureChannels-1; //always reserve one for shiny for now just for simplicity;
 	}
 
 	if (LLPipeline::sRenderDeferred && distance_sort)
-- 
cgit v1.2.3


From 76a27f5100666739aae53c0988318a6dae647666 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 13 Feb 2012 13:55:51 -0600
Subject: SH-2964 Fix for shader compilation error on some older NVIDIA cards.

---
 indra/llrender/llshadermgr.cpp                                        | 4 ++--
 .../newview/app_settings/shaders/class1/objects/indexedTextureV.glsl  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

(limited to 'indra')

diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 321b139181..269f78c8cd 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -663,7 +663,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 		.
 		uniform sampler2D texN;
 		
-		VARYING uvec4 vary_texture_index;
+		VARYING ivec4 vary_texture_index;
 
 		vec4 diffuseLookup(vec2 texcoord)
 		{
@@ -691,7 +691,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 
 		if (texture_index_channels > 1)
 		{
-			text[count++] = strdup("VARYING_FLAT uvec4 vary_texture_index;\n");
+			text[count++] = strdup("VARYING_FLAT ivec4 vary_texture_index;\n");
 		}
 
 		text[count++] = strdup("vec4 diffuseLookup(vec2 texcoord)\n");
diff --git a/indra/newview/app_settings/shaders/class1/objects/indexedTextureV.glsl b/indra/newview/app_settings/shaders/class1/objects/indexedTextureV.glsl
index a0f513d73d..7c0699d72f 100644
--- a/indra/newview/app_settings/shaders/class1/objects/indexedTextureV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/indexedTextureV.glsl
@@ -23,9 +23,9 @@
  * $/LicenseInfo$
  */
 
-ATTRIBUTE uvec4 texture_index;
+ATTRIBUTE ivec4 texture_index;
 
-VARYING_FLAT uvec4 vary_texture_index;
+VARYING_FLAT ivec4 vary_texture_index;
 
 void passTextureIndex()
 {
-- 
cgit v1.2.3


From 80505ddf68c8a0a962a720a1c1d2a894df47157f Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 13 Feb 2012 15:02:07 -0600
Subject: SH-2908 Fix for linux build.

---
 indra/llrender/llgl.cpp | 1 -
 1 file changed, 1 deletion(-)

(limited to 'indra')

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 79d4415117..e855dda57d 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -344,7 +344,6 @@ PFNGLVERTEXATTRIB4UBVARBPROC glVertexAttrib4ubvARB = NULL;
 PFNGLVERTEXATTRIB4UIVARBPROC glVertexAttrib4uivARB = NULL;
 PFNGLVERTEXATTRIB4USVARBPROC glVertexAttrib4usvARB = NULL;
 PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB = NULL;
-PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = NULL;
 PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB = NULL;
 PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB = NULL;
 PFNGLPROGRAMSTRINGARBPROC glProgramStringARB = NULL;
-- 
cgit v1.2.3


From 001e32074d4fbc5d115c9a2fa1cb5de4b5932731 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 13 Feb 2012 15:32:15 -0600
Subject: SH-2908 More linux build fixes.

---
 indra/newview/pipeline.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index c8a8b910ea..ce3a4893bf 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6643,8 +6643,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 				mDeferredLight.flush();
 			}
 
-			U32 dof_width = mScreen.getWidth()*CameraDoFResScale;
-			U32 dof_height = mScreen.getHeight()*CameraDoFResScale;
+			U32 dof_width = (U32) (mScreen.getWidth()*CameraDoFResScale);
+			U32 dof_height = (U32) (mScreen.getHeight()*CameraDoFResScale);
 			
 			{ //perform DoF sampling at half-res (preserve alpha channel)
 				mScreen.bindTarget();
-- 
cgit v1.2.3


From 64c89ee2c51c539d38d4d55807b18172d6606514 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 13 Feb 2012 15:41:21 -0600
Subject: SH-2908 Fix for mac build

---
 indra/llrender/llgl.cpp           | 9 +++++++++
 indra/llrender/llvertexbuffer.cpp | 4 ++++
 2 files changed, 13 insertions(+)

(limited to 'indra')

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index e855dda57d..197bc2b422 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -561,6 +561,15 @@ bool LLGLManager::initGL()
 	if (mGLVersion >= 2.f)
 	{
 		parse_glsl_version(mGLSLVersionMajor, mGLSLVersionMinor);
+
+#if LL_DARWIN
+		//never use GLSL greater than 1.20 on OSX
+		if (mGLSLVersionMajor > 1 || mGLSLVersionMinor >= 30)
+		{
+			mGLSLVersionMajor = 1;
+			mGLSLVersionMinor = 20;
+		}
+#endif
 	}
 
 	// Trailing space necessary to keep "nVidia Corpor_ati_on" cards
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index b2438ef824..a7f0170658 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -1264,11 +1264,13 @@ void LLVertexBuffer::setupVertexArray()
 
 			if (attrib_integer)
 			{
+#if !LL_DARWIN
 				//glVertexattribIPointer requires GLSL 1.30 or later
 				if (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 30)
 				{
 					glVertexAttribIPointer(i, attrib_size[i], attrib_type[i], sTypeSize[i], (void*) mOffsets[i]); 
 				}
+#endif
 			}
 			else
 			{
@@ -2258,9 +2260,11 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask)
 		if (data_mask & MAP_TEXTURE_INDEX && 
 				(gGLManager.mGLSLVersionMajor >= 2 || gGLManager.mGLSLVersionMinor >= 30)) //indexed texture rendering requires GLSL 1.30 or later
 		{
+#if !LL_DARWIN
 			S32 loc = TYPE_TEXTURE_INDEX;
 			void *ptr = (void*) (base + mOffsets[TYPE_VERTEX] + 12);
 			glVertexAttribIPointer(loc, 4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr);
+#endif
 		}
 		if (data_mask & MAP_VERTEX)
 		{
-- 
cgit v1.2.3


From 3267b42ee521a7a059e0e87cba75a3d32af678e5 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 13 Feb 2012 18:26:48 -0600
Subject: SH-2908 Temporary fix for mac build

---
 indra/llrender/llglslshader.cpp | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'indra')

diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index a879a18895..4b7e639aed 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -109,7 +109,9 @@ void LLGLSLShader::unload()
 		glGetAttachedObjectsARB(mProgramObject, 1024, &count, obj);
 		for (GLsizei i = 0; i < count; i++)
 		{
+#if !LL_DARWIN
 			if (glIsProgramARB(obj[i]))
+#endif
 			{
 				glDeleteObjectARB(obj[i]);
 			}
-- 
cgit v1.2.3


From 7206160fb5d1e8ef2e7fa4d037f34ba1633b0981 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 13 Feb 2012 19:13:22 -0600
Subject: SH-2973 Potential fix for crash in ~LLVOAvatarSelf

---
 indra/newview/llappviewer.cpp    | 2 ++
 indra/newview/lldriverparam.cpp  | 2 +-
 indra/newview/llvoavatarself.cpp | 5 +++--
 indra/newview/llvoavatarself.h   | 2 +-
 indra/newview/llwearable.cpp     | 2 +-
 5 files changed, 8 insertions(+), 5 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 49fbdbf1df..3a257e1f1c 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1769,6 +1769,8 @@ bool LLAppViewer::cleanup()
 
 	LLAvatarIconIDCache::getInstance()->save();
 	
+	gAgentAvatarp = NULL;
+
 	LLViewerMedia::saveCookieFile();
 
 	// Stop the plugin read thread if it's running.
diff --git a/indra/newview/lldriverparam.cpp b/indra/newview/lldriverparam.cpp
index 8f47d3c5e5..64eb11fc9b 100644
--- a/indra/newview/lldriverparam.cpp
+++ b/indra/newview/lldriverparam.cpp
@@ -139,7 +139,7 @@ void LLDriverParamInfo::toStream(std::ostream &out)
 			}
 			else
 			{
-				llwarns << "could not get parameter " << driven.mDrivenID << " from avatar " << gAgentAvatarp << " for driver parameter " << getID() << llendl;
+				llwarns << "could not get parameter " << driven.mDrivenID << " from avatar " << gAgentAvatarp.get() << " for driver parameter " << getID() << llendl;
 			}
 			out << std::endl;
 		}
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index f1df67494f..e525d6bad0 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -66,10 +66,11 @@
 
 #include <boost/lexical_cast.hpp>
 
-LLVOAvatarSelf *gAgentAvatarp = NULL;
+LLPointer<LLVOAvatarSelf> gAgentAvatarp = NULL;
+
 BOOL isAgentAvatarValid()
 {
-	return (gAgentAvatarp &&
+	return (gAgentAvatarp.notNull() &&
 			(gAgentAvatarp->getRegion() != NULL) &&
 			(!gAgentAvatarp->isDead()));
 }
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index 54dbe81993..655fb3a012 100644
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -383,7 +383,7 @@ private:
 
 };
 
-extern LLVOAvatarSelf *gAgentAvatarp;
+extern LLPointer<LLVOAvatarSelf> gAgentAvatarp;
 
 BOOL isAgentAvatarValid();
 
diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp
index d8aa0b7d5c..0f7f63061b 100644
--- a/indra/newview/llwearable.cpp
+++ b/indra/newview/llwearable.cpp
@@ -221,7 +221,7 @@ void LLWearable::createVisualParams()
 		param->resetDrivenParams();
 		if(!param->linkDrivenParams(boost::bind(wearable_function,(LLWearable*)this, _1), false))
 		{
-			if( !param->linkDrivenParams(boost::bind(avatar_function,gAgentAvatarp,_1 ), true))
+			if( !param->linkDrivenParams(boost::bind(avatar_function,gAgentAvatarp.get(),_1 ), true))
 			{
 				llwarns << "could not link driven params for wearable " << getName() << " id: " << param->getID() << llendl;
 				continue;
-- 
cgit v1.2.3


From 60fa5c3d4e23967d1ecd1e5189685ca94223cfb4 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 13 Feb 2012 19:53:39 -0600
Subject: SH-2908 Fix for shaders failing to compile when using GLSL 1.20 or
 1.10 profile.

---
 indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl       | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl          | 2 +-
 .../newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl  | 2 +-
 .../app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl   | 2 +-
 .../newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl   | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl      | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/cofF.glsl            | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl     | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl       | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl     | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl           | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl      | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl        | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl     | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl   | 2 +-
 .../app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl        | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl         | 2 +-
 .../newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl  | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl         | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl    | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl      | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl       | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl   | 2 +-
 indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl     | 2 +-
 indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl     | 2 +-
 indra/newview/app_settings/shaders/class1/effects/glowF.glsl            | 2 +-
 indra/newview/app_settings/shaders/class1/environment/terrainF.glsl     | 2 +-
 .../newview/app_settings/shaders/class1/environment/terrainWaterF.glsl  | 2 +-
 indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl  | 2 +-
 indra/newview/app_settings/shaders/class1/environment/waterF.glsl       | 2 +-
 indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl     | 2 +-
 indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl   | 2 +-
 indra/newview/app_settings/shaders/class1/interface/debugF.glsl         | 2 +-
 indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl   | 2 +-
 .../newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl | 2 +-
 indra/newview/app_settings/shaders/class1/interface/highlightF.glsl     | 2 +-
 indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl     | 2 +-
 .../app_settings/shaders/class1/interface/onetexturenocolorF.glsl       | 2 +-
 indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl    | 2 +-
 .../app_settings/shaders/class1/interface/splattexturerectF.glsl        | 2 +-
 indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl | 2 +-
 indra/newview/app_settings/shaders/class1/interface/uiF.glsl            | 2 +-
 indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl | 2 +-
 .../app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl | 2 +-
 indra/newview/app_settings/shaders/class1/lighting/lightF.glsl          | 2 +-
 .../app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl | 2 +-
 .../newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl  | 2 +-
 .../shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl    | 2 +-
 .../shaders/class1/lighting/lightFullbrightNonIndexedF.glsl             | 2 +-
 .../app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl     | 2 +-
 .../shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl        | 2 +-
 .../shaders/class1/lighting/lightFullbrightShinyWaterF.glsl             | 2 +-
 .../shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl   | 2 +-
 .../shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl         | 2 +-
 .../app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl     | 2 +-
 .../class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl       | 2 +-
 .../shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl        | 2 +-
 .../newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl  | 2 +-
 indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl     | 2 +-
 .../app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl     | 2 +-
 .../newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl  | 2 +-
 .../shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl             | 2 +-
 .../app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl      | 2 +-
 .../shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl         | 2 +-
 indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl     | 2 +-
 .../app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl     | 2 +-
 indra/newview/app_settings/shaders/class1/objects/impostorF.glsl        | 2 +-
 indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl          | 2 +-
 .../newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl  | 2 +-
 .../app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl   | 2 +-
 indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl | 2 +-
 indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl    | 2 +-
 indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl      | 2 +-
 indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl       | 2 +-
 indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl   | 2 +-
 indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl        | 2 +-
 indra/newview/app_settings/shaders/class2/windlight/skyF.glsl           | 2 +-
 79 files changed, 79 insertions(+), 79 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl
index 54e2f04459..7a35905280 100644
--- a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl
+++ b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 37fd63b7d5..73f05a5dd4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect depthMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
index 14ac9f1f78..bfbd30a455 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect depthMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
index 654e272b06..dae1131bbb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect depthMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
index b88041490a..92e3f7f388 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
@@ -25,7 +25,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
index 594ed778e3..3686f2f647 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index a08b018702..f400eb7a5b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect depthMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
index 3fcfbf55c4..ccbc3c557c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect diffuseRect;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
index f05ea557e3..a425e5062e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect diffuseRect;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl
index ebe9a66bb4..6aa4d7b4ed 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 vec3 fullbrightAtmosTransport(vec3 light);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
index 616ffca2d1..36433a5827 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
index 76b1748813..d93e897029 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 #define FXAA_PC 1
diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
index 31da124cb1..dcf474824d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
@@ -28,7 +28,7 @@ uniform sampler2DRect diffuseMap;
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec2 vary_fragcoord;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 40dd363061..75de47614c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 //class 1 -- no shadows
diff --git a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl
index 32881ef042..62cfa5c316 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D alphaMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index 619b7bcd03..a5e04fba57 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect diffuseRect;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
index e7b2174280..bf362e21a4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect diffuseRect;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
index ed2352b51f..eb5beeef39 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect diffuseRect;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
index 18550b2e12..96f9628424 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
@@ -26,7 +26,7 @@
  #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
  
 uniform sampler2DRect depthMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl
index 7d75b50aa2..cf8cf8364a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
index 3eb733aa51..7e55fdc12a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 post_pos;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 70b0f6fbd0..b5501c2820 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect diffuseRect;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index d3d6a155f0..7ed8ed3370 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -29,7 +29,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect diffuseRect;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
index aa29be09a1..5ca817aff6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
@@ -30,7 +30,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 void main() 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index 9bee632472..7fa666a739 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 //class 1 -- no shadow, SSAO only
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl
index 6be66a402f..d4d2f5f571 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeShadowF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
index 952706841d..0f5eb288fd 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl
index 289c5b367f..c1f6af9f57 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
index 51efdd4b39..668a710c04 100644
--- a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
index d9b5c5f7f5..a956562396 100644
--- a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl
index 32459eff6a..0d8dab0a41 100644
--- a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
index 0cde7d0133..79bffab745 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 vec3 scaleSoftClip(vec3 inColor);
diff --git a/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl
index e8b8513bd1..f520f301d9 100644
--- a/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl b/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl
index b990ce9f03..a96d04cc39 100644
--- a/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/interface/debugF.glsl b/indra/newview/app_settings/shaders/class1/interface/debugF.glsl
index ad05f17a30..67c6baddbb 100644
--- a/indra/newview/app_settings/shaders/class1/interface/debugF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/debugF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform vec4 color;
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
index 7e4515db40..ed803de277 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 #extension GL_ARB_texture_rectangle : enable
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
index 5a5894523d..59520bb99f 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect diffuseRect;
diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl
index d1d140d2a6..6cc9bbbea2 100644
--- a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform vec4 color;
diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl
index a18a3cdb50..db130e456c 100644
--- a/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 void main() 
diff --git a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl
index bfaa4774d9..415181126b 100644
--- a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D tex0;
diff --git a/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl b/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl
index 5d7edf33a9..67dc500493 100644
--- a/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D tex0;
diff --git a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
index 7a28ca847a..772bb374e8 100644
--- a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect screenMap;
diff --git a/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl b/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl
index 73a5839028..95679e93e7 100644
--- a/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D tex0;
diff --git a/indra/newview/app_settings/shaders/class1/interface/uiF.glsl b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl
index 8fac2862b1..299bfb72aa 100644
--- a/indra/newview/app_settings/shaders/class1/interface/uiF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl
index aabff3196a..cf29939cb2 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl
index 6e6aec8532..4070d41f47 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl
index f9a3eb8d90..d6ebfcb825 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl
index a3eb133133..6c34643aab 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl
index 222c6bbf0e..2ff7f795b0 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl
index 441fcd0d7a..f4477bd29a 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl
index 7020fbc72b..2738ff8947 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl
index 889a3e48ba..777c8b45bb 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl
index f0727c377b..4fa3b1d939 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyNonIndexedF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl
index aac13462b3..58984a4263 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl
@@ -25,7 +25,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl
index 4f57b7a9f5..a39b7205d7 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterNonIndexedF.glsl
@@ -25,7 +25,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl
index 6c277cddc1..99a6fe85fe 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl
index 5c4bedefcc..df182168f3 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl
index df07071236..63f92a8844 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl
index 91208bc56a..0e68091e7c 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl
index 1a0473b9e2..0aca768021 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
  
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl
index a24d8d4ecd..52e3b2ad02 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl
index 16f64633ac..474d5ea496 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyNonIndexedF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
  
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl
index cf78149733..d2a4c47aac 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl
index 97531fd937..f3bd662364 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterNonIndexedF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl
index 4fcdad09fc..b68240ba0d 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl
index d235ed2491..da3b20012d 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl
index c295579028..00609e93cd 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl
index 5a5cc2c821..13ecb7a636 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl b/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl
index 6358fdfeae..add437d144 100644
--- a/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
index 373a6c157b..e5edb482a9 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
index 04460ea7c0..c467e6c5cb 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRectShadow shadowMap0;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
index c50145f753..8aaf87a1b5 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRectShadow shadowMap0;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 7d78a888a5..f7f1f649ce 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect diffuseRect;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index f73163898e..61a7f1e32f 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect diffuseRect;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index 7cc621b1f6..99a277fbfc 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index a92a9fc8e8..a40b29d2c4 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 //class 2, shadows, no SSAO
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index 45b8db5adc..774f70262a 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -27,7 +27,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 //class 2 -- shadows and SSAO
diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
index c8d89095d8..96c70651b1 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 /////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
index 4aece6e032..e2a2367626 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 /////////////////////////////////////////////////////////////////////////
-- 
cgit v1.2.3


From 4f18f9d6bd1e11b92040fbcc5ca1c2a173d38fc9 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 14 Feb 2012 16:11:30 -0600
Subject: SH-2908 More complete GLSL 1.20 compatibility pass.

---
 .../shaders/class1/deferred/avatarF.glsl            |  2 +-
 .../app_settings/shaders/class1/deferred/bumpF.glsl |  2 +-
 .../shaders/class1/deferred/cloudsF.glsl            |  2 +-
 .../shaders/class1/deferred/diffuseAlphaMaskF.glsl  |  2 +-
 .../class1/deferred/diffuseAlphaMaskIndexedF.glsl   |  2 +-
 .../class1/deferred/diffuseAlphaMaskNoColorF.glsl   |  2 +-
 .../shaders/class1/deferred/diffuseF.glsl           |  2 +-
 .../shaders/class1/deferred/diffuseIndexedF.glsl    |  2 +-
 .../app_settings/shaders/class1/deferred/fxaaF.glsl | 21 +++++++++++++--------
 .../app_settings/shaders/class1/deferred/giF.glsl   |  2 +-
 .../shaders/class1/deferred/impostorF.glsl          |  2 +-
 .../shaders/class1/deferred/multiPointLightF.glsl   |  2 +-
 .../app_settings/shaders/class1/deferred/skyF.glsl  |  2 +-
 .../shaders/class1/deferred/starsF.glsl             |  2 +-
 .../shaders/class1/deferred/terrainF.glsl           |  2 +-
 .../app_settings/shaders/class1/deferred/treeF.glsl |  2 +-
 .../shaders/class1/deferred/waterF.glsl             |  2 +-
 .../app_settings/shaders/class1/objects/bumpF.glsl  |  2 +-
 indra/newview/llviewershadermgr.cpp                 |  6 ++++++
 19 files changed, 36 insertions(+), 25 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
index 4912c9a50c..46d2aa4877 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index 141738023d..680eadb852 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
index d2afc148b1..1d8ca04ccd 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
@@ -27,7 +27,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 /////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
index c8acaee134..b2027d3a5d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
index d960cbc2fe..ead384b07c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 VARYING vec3 vary_normal;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
index b1c9b52569..f73fa6f231 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
@@ -27,7 +27,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index caefe84957..227aa2aae3 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
index c89f389954..d442e5403a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 VARYING vec3 vary_normal;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
index d93e897029..e02a7b405b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
@@ -343,18 +343,23 @@ A. Or use FXAA_GREEN_AS_LUMA.
     // 1 = API supports gather4 on alpha channel.
     // 0 = API does not support gather4 on alpha channel.
     //
+	#if (FXAA_GLSL_130 == 0)
+		#define FXAA_GATHER4_ALPHA 0
+	#endif
     #if (FXAA_HLSL_5 == 1)
         #define FXAA_GATHER4_ALPHA 1
     #endif
-    #ifdef GL_ARB_gpu_shader5
-        #define FXAA_GATHER4_ALPHA 1
-    #endif
-    #ifdef GL_NV_gpu_shader5
-        #define FXAA_GATHER4_ALPHA 1
-    #endif
     #ifndef FXAA_GATHER4_ALPHA
-        #define FXAA_GATHER4_ALPHA 0
-    #endif
+		#ifdef GL_ARB_gpu_shader5
+			#define FXAA_GATHER4_ALPHA 1
+		#endif
+	    #ifdef GL_NV_gpu_shader5
+		    #define FXAA_GATHER4_ALPHA 1
+		#endif
+		#ifndef FXAA_GATHER4_ALPHA
+			#define FXAA_GATHER4_ALPHA 0
+		#endif
+	#endif
 #endif
 
 /*============================================================================
diff --git a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
index 28ed70d49d..da1b234240 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect depthMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
index d7bc8d02d9..bc0719cb82 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 uniform float minimum_alpha;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index cd50e17d7e..53a2a13392 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2DRect depthMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
index 7d80f07da4..faa54a316e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 /////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
index 1cfcca4f5d..821058804c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 VARYING vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
index 021c23f76c..8a5e482e80 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 uniform sampler2D detail_0;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
index 10d8a5c321..6cf6106b51 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index e4c655ed7d..42dc7c0980 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -28,7 +28,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_data[3];
 #else
-#define frag_data gl_FragData;
+#define frag_data gl_FragData
 #endif
 
 vec3 scaleSoftClip(vec3 inColor);
diff --git a/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl b/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl
index df6130cc58..d55f0db530 100644
--- a/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl
@@ -26,7 +26,7 @@
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
-#define frag_color gl_FragColor;
+#define frag_color gl_FragColor
 #endif
 
 uniform sampler2D texture0;
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 36a402e05e..c84fb8facb 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -363,6 +363,12 @@ void LLViewerShaderMgr::setShaders()
 	//NEVER use more than 16 texture channels (work around for prevalent driver bug)
 	LLGLSLShader::sIndexedTextureChannels = llmin(LLGLSLShader::sIndexedTextureChannels, 16);
 
+	if (gGLManager.mGLSLVersionMajor < 1 ||
+		(gGLManager.mGLSLVersionMajor == 1 && gGLManager.mGLSLVersionMinor <= 20))
+	{ //NEVER use indexed texture rendering when GLSL version is 1.20 or earlier
+		LLGLSLShader::sIndexedTextureChannels = 1;
+	}
+
 	reentrance = true;
 
 	if (LLRender::sGLCoreProfile)
-- 
cgit v1.2.3


From 54b1847b3ca7678d7c9b65e9b8e701f6f9869b98 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 14 Feb 2012 17:09:42 -0600
Subject: SH-2973 Rearrange shutdown operations to prevent crash on exit on OSX

---
 indra/newview/llappviewer.cpp    |  5 +++--
 indra/newview/llviewerwindow.cpp | 10 ++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 3a257e1f1c..1174d108d2 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1487,6 +1487,9 @@ void LLAppViewer::flushVFSIO()
 
 bool LLAppViewer::cleanup()
 {
+	//ditch LLVOAvatarSelf instance
+	gAgentAvatarp = NULL;
+
 	// workaround for DEV-35406 crash on shutdown
 	LLEventPumps::instance().reset();
 
@@ -1769,8 +1772,6 @@ bool LLAppViewer::cleanup()
 
 	LLAvatarIconIDCache::getInstance()->save();
 	
-	gAgentAvatarp = NULL;
-
 	LLViewerMedia::saveCookieFile();
 
 	// Stop the plugin read thread if it's running.
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 8a713ae22c..e0653fec30 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -2021,6 +2021,12 @@ void LLViewerWindow::shutdownGL()
 	gSky.cleanup();
 	stop_glerror();
 
+	llinfos << "Cleaning up pipeline" << llendl;
+	gPipeline.cleanup();
+	stop_glerror();
+
+	//MUST clean up pipeline before cleaning up wearables
+	llinfos << "Cleaning up wearables" << llendl;
 	LLWearableList::instance().cleanup() ;
 
 	gTextureList.shutdown();
@@ -2031,10 +2037,6 @@ void LLViewerWindow::shutdownGL()
 
 	LLWorldMapView::cleanupTextures();
 
-	llinfos << "Cleaning up pipeline" << llendl;
-	gPipeline.cleanup();
-	stop_glerror();
-
 	LLViewerTextureManager::cleanup() ;
 	LLImageGL::cleanupClass() ;
 
-- 
cgit v1.2.3


From 9dde773a5a6b7dd8c48dd373774935c2d8415fef Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 15 Feb 2012 18:11:43 -0600
Subject: SH-2961 Fix for bumpiness not working on rigged meshes when L&S
 enabled.

---
 indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
index 6c205074b4..8ba75010a2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
@@ -30,7 +30,7 @@ ATTRIBUTE vec3 position;
 ATTRIBUTE vec4 diffuse_color;
 ATTRIBUTE vec3 normal;
 ATTRIBUTE vec2 texcoord0;
-ATTRIBUTE vec2 texcoord2;
+ATTRIBUTE vec3 binormal;
 
 VARYING vec3 vary_mat0;
 VARYING vec3 vary_mat1;
@@ -52,7 +52,7 @@ void main()
 	
 	
 	vec3 n = normalize((mat * vec4(normal.xyz+position.xyz, 1.0)).xyz-pos.xyz);
-	vec3 b = normalize((mat * vec4(vec4(texcoord2,0,1).xyz+position.xyz, 1.0)).xyz-pos.xyz);
+	vec3 b = normalize((mat * vec4(binormal.xyz+position.xyz, 1.0)).xyz-pos.xyz);
 	vec3 t = cross(b, n);
 	
 	vary_mat0 = vec3(t.x, b.x, n.x);
-- 
cgit v1.2.3


From 8d12038ef674dca701f313431b1089458816f638 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 17 Feb 2012 15:06:48 -0600
Subject: SH-2908 Potential fix for precision complaints from some AMD OpenGL
 3.1 implementations.

---
 indra/llrender/llshadermgr.cpp      | 5 ++++-
 indra/newview/llviewershadermgr.cpp | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 269f78c8cd..9aeb1a99f8 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -611,6 +611,9 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 		{
 			//set version to 1.30
 			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");
 		}
 		else
 		{ //set version to 400
@@ -663,7 +666,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 		.
 		uniform sampler2D texN;
 		
-		VARYING ivec4 vary_texture_index;
+		VARYING_FLAT ivec4 vary_texture_index;
 
 		vec4 diffuseLookup(vec2 texcoord)
 		{
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index c84fb8facb..06db644851 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -413,6 +413,8 @@ void LLViewerShaderMgr::setShaders()
 
 	// Shaders
 	LL_INFOS("ShaderLoading") << "\n~~~~~~~~~~~~~~~~~~\n Loading Shaders:\n~~~~~~~~~~~~~~~~~~" << LL_ENDL;
+	LL_INFOS("ShaderLoading") << llformat("Using GLSL %d.%d", gGLManager.mGLSLVersionMajor, gGLManager.mGLSLVersionMinor) << llendl;
+
 	for (S32 i = 0; i < SHADER_COUNT; i++)
 	{
 		mVertexShaderLevel[i] = 0;
-- 
cgit v1.2.3


From 6ecae04d358cc27bc4890778a1493b3818236fb9 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 17 Feb 2012 15:33:09 -0600
Subject: SH-2941 Fix for crash on shutdown due to race condition between
 LLCurl and LLMeshRepository

---
 indra/newview/llmeshrepository.cpp | 288 +++++++++++++++----------------------
 1 file changed, 118 insertions(+), 170 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index bd20210190..f461c7e46f 100755
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -508,6 +508,7 @@ void LLMeshRepoThread::run()
 			
 			while (!mLODReqQ.empty() && count < MAX_MESH_REQUESTS_PER_SECOND && sActiveLODRequests < sMaxConcurrentRequests)
 			{
+				if (mMutex)
 				{
 					mMutex->lock();
 					LODRequest req = mLODReqQ.front();
@@ -525,6 +526,7 @@ void LLMeshRepoThread::run()
 
 			while (!mHeaderReqQ.empty() && count < MAX_MESH_REQUESTS_PER_SECOND && sActiveHeaderRequests < sMaxConcurrentRequests)
 			{
+				if (mMutex)
 				{
 					mMutex->lock();
 					HeaderRequest req = mHeaderReqQ.front();
@@ -671,6 +673,12 @@ std::string LLMeshRepoThread::constructUrl(LLUUID mesh_id)
 
 bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id)
 { //protected by mMutex
+	
+	if (!mHeaderMutex)
+	{
+		return false;
+	}
+
 	mHeaderMutex->lock();
 
 	if (mMeshHeader.find(mesh_id) == mMeshHeader.end())
@@ -747,6 +755,11 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id)
 
 bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id)
 { //protected by mMutex
+	if (!mHeaderMutex)
+	{
+		return false;
+	}
+
 	mHeaderMutex->lock();
 
 	if (mMeshHeader.find(mesh_id) == mMeshHeader.end())
@@ -824,6 +837,11 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id)
 
 bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id)
 { //protected by mMutex
+	if (!mHeaderMutex)
+	{
+		return false;
+	}
+
 	mHeaderMutex->lock();
 
 	if (mMeshHeader.find(mesh_id) == mMeshHeader.end())
@@ -950,6 +968,11 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, U32& c
 //return false if failed to get mesh lod.
 bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, U32& count)
 { //protected by mMutex
+	if (!mHeaderMutex)
+	{
+		return false;
+	}
+
 	mHeaderMutex->lock();
 
 	bool retval = true;
@@ -1068,10 +1091,11 @@ bool LLMeshRepoThread::headerReceived(const LLVolumeParams& mesh_params, U8* dat
 	{
 		LLUUID mesh_id = mesh_params.getSculptID();
 		
-		mHeaderMutex->lock();
-		mMeshHeaderSize[mesh_id] = header_size;
-		mMeshHeader[mesh_id] = header;
-		mHeaderMutex->unlock();
+		{
+			LLMutexLock lock(mHeaderMutex);
+			mMeshHeaderSize[mesh_id] = header_size;
+			mMeshHeader[mesh_id] = header;
+			}
 
 		//check for pending requests
 		pending_lod_map::iterator iter = mPendingLOD.find(mesh_params);
@@ -1646,6 +1670,11 @@ void LLMeshUploadThread::requestWholeModelFee()
 
 void LLMeshRepoThread::notifyLoadedMeshes()
 {
+	if (!mMutex)
+	{
+		return;
+	}
+
 	while (!mLoadedQ.empty())
 	{
 		mMutex->lock();
@@ -2357,93 +2386,92 @@ void LLMeshRepository::notifyLoadedMeshes()
 		}
 	}
 
-	mMeshMutex->lock();	
-	mThread->mMutex->lock();
-		
-	//popup queued error messages from background threads
-	while (!mUploadErrorQ.empty())
 	{
-		LLNotificationsUtil::add("MeshUploadError", mUploadErrorQ.front());
-		mUploadErrorQ.pop();
-	}
+		LLMutexLock lock1(mMeshMutex);
+		LLMutexLock lock2(mThread->mMutex);
+		
+		//popup queued error messages from background threads
+		while (!mUploadErrorQ.empty())
+		{
+			LLNotificationsUtil::add("MeshUploadError", mUploadErrorQ.front());
+			mUploadErrorQ.pop();
+		}
 
-	S32 push_count = LLMeshRepoThread::sMaxConcurrentRequests-(LLMeshRepoThread::sActiveHeaderRequests+LLMeshRepoThread::sActiveLODRequests);
+		S32 push_count = LLMeshRepoThread::sMaxConcurrentRequests-(LLMeshRepoThread::sActiveHeaderRequests+LLMeshRepoThread::sActiveLODRequests);
 
-	if (push_count > 0)
-	{
-		//calculate "score" for pending requests
+		if (push_count > 0)
+		{
+			//calculate "score" for pending requests
 
-		//create score map
-		std::map<LLUUID, F32> score_map;
+			//create score map
+			std::map<LLUUID, F32> score_map;
 
-		for (U32 i = 0; i < 4; ++i)
-		{
-			for (mesh_load_map::iterator iter = mLoadingMeshes[i].begin();  iter != mLoadingMeshes[i].end(); ++iter)
+			for (U32 i = 0; i < 4; ++i)
 			{
-				F32 max_score = 0.f;
-				for (std::set<LLUUID>::iterator obj_iter = iter->second.begin(); obj_iter != iter->second.end(); ++obj_iter)
+				for (mesh_load_map::iterator iter = mLoadingMeshes[i].begin();  iter != mLoadingMeshes[i].end(); ++iter)
 				{
-					LLViewerObject* object = gObjectList.findObject(*obj_iter);
-
-					if (object)
+					F32 max_score = 0.f;
+					for (std::set<LLUUID>::iterator obj_iter = iter->second.begin(); obj_iter != iter->second.end(); ++obj_iter)
 					{
-						LLDrawable* drawable = object->mDrawable;
-						if (drawable)
+						LLViewerObject* object = gObjectList.findObject(*obj_iter);
+
+						if (object)
 						{
-							F32 cur_score = drawable->getRadius()/llmax(drawable->mDistanceWRTCamera, 1.f);
-							max_score = llmax(max_score, cur_score);
+							LLDrawable* drawable = object->mDrawable;
+							if (drawable)
+							{
+								F32 cur_score = drawable->getRadius()/llmax(drawable->mDistanceWRTCamera, 1.f);
+								max_score = llmax(max_score, cur_score);
+							}
 						}
 					}
-				}
 				
-				score_map[iter->first.getSculptID()] = max_score;
+					score_map[iter->first.getSculptID()] = max_score;
+				}
+			}
+
+			//set "score" for pending requests
+			for (std::vector<LLMeshRepoThread::LODRequest>::iterator iter = mPendingRequests.begin(); iter != mPendingRequests.end(); ++iter)
+			{
+				iter->mScore = score_map[iter->mMeshParams.getSculptID()];
+			}
+
+			//sort by "score"
+			std::sort(mPendingRequests.begin(), mPendingRequests.end(), LLMeshRepoThread::CompareScoreGreater());
+
+			while (!mPendingRequests.empty() && push_count > 0)
+			{
+				LLMeshRepoThread::LODRequest& request = mPendingRequests.front();
+				mThread->loadMeshLOD(request.mMeshParams, request.mLOD);
+				mPendingRequests.erase(mPendingRequests.begin());
+				LLMeshRepository::sLODPending--;
+				push_count--;
 			}
 		}
 
-		//set "score" for pending requests
-		for (std::vector<LLMeshRepoThread::LODRequest>::iterator iter = mPendingRequests.begin(); iter != mPendingRequests.end(); ++iter)
+		//send skin info requests
+		while (!mPendingSkinRequests.empty())
 		{
-			iter->mScore = score_map[iter->mMeshParams.getSculptID()];
+			mThread->loadMeshSkinInfo(mPendingSkinRequests.front());
+			mPendingSkinRequests.pop();
 		}
-
-		//sort by "score"
-		std::sort(mPendingRequests.begin(), mPendingRequests.end(), LLMeshRepoThread::CompareScoreGreater());
-
-		while (!mPendingRequests.empty() && push_count > 0)
+	
+		//send decomposition requests
+		while (!mPendingDecompositionRequests.empty())
 		{
-			LLMeshRepoThread::LODRequest& request = mPendingRequests.front();
-			mThread->loadMeshLOD(request.mMeshParams, request.mLOD);
-			mPendingRequests.erase(mPendingRequests.begin());
-			LLMeshRepository::sLODPending--;
-			push_count--;
+			mThread->loadMeshDecomposition(mPendingDecompositionRequests.front());
+			mPendingDecompositionRequests.pop();
 		}
-	}
-
-	//send skin info requests
-	while (!mPendingSkinRequests.empty())
-	{
-		mThread->loadMeshSkinInfo(mPendingSkinRequests.front());
-		mPendingSkinRequests.pop();
-	}
 	
-	//send decomposition requests
-	while (!mPendingDecompositionRequests.empty())
-	{
-		mThread->loadMeshDecomposition(mPendingDecompositionRequests.front());
-		mPendingDecompositionRequests.pop();
-	}
+		//send physics shapes decomposition requests
+		while (!mPendingPhysicsShapeRequests.empty())
+		{
+			mThread->loadMeshPhysicsShape(mPendingPhysicsShapeRequests.front());
+			mPendingPhysicsShapeRequests.pop();
+		}
 	
-	//send physics shapes decomposition requests
-	while (!mPendingPhysicsShapeRequests.empty())
-	{
-		mThread->loadMeshPhysicsShape(mPendingPhysicsShapeRequests.front());
-		mPendingPhysicsShapeRequests.pop();
+		mThread->notifyLoadedMeshes();
 	}
-	
-	mThread->notifyLoadedMeshes();
-
-	mThread->mMutex->unlock();
-	mMeshMutex->unlock();
 
 	mThread->mSignal->signal();
 }
@@ -3091,13 +3119,14 @@ void LLPhysicsDecomp::doDecomposition()
 			num_hulls = LLConvexDecomposition::getInstance()->getNumHullsFromStage(stage);
 		}
 		
-		mMutex->lock();
-		mCurRequest->mHull.clear();
-		mCurRequest->mHull.resize(num_hulls);
+		{
+			LLMutexLock lock(mMutex);
+			mCurRequest->mHull.clear();
+			mCurRequest->mHull.resize(num_hulls);
 
-		mCurRequest->mHullMesh.clear();
-		mCurRequest->mHullMesh.resize(num_hulls);
-		mMutex->unlock();
+			mCurRequest->mHullMesh.clear();
+			mCurRequest->mHullMesh.resize(num_hulls);
+		}
 
 		for (S32 i = 0; i < num_hulls; ++i)
 		{
@@ -3121,14 +3150,14 @@ void LLPhysicsDecomp::doDecomposition()
 
 			get_vertex_buffer_from_mesh(mesh, mCurRequest->mHullMesh[i]);
 			
-			mMutex->lock();
-			mCurRequest->mHull[i] = p;
-			mMutex->unlock();
+			{
+				LLMutexLock lock(mMutex);
+				mCurRequest->mHull[i] = p;
+			}
 		}
 	
 		{
 			LLMutexLock lock(mMutex);
-
 			mCurRequest->setStatusMessage("FAIL");
 			completeCurrent();						
 		}
@@ -3196,7 +3225,6 @@ void LLPhysicsDecomp::doDecompositionSingleHull()
 	
 	LLCDMeshData mesh;	
 
-#if 1
 	setMeshData(mesh, true);
 
 	LLCDResult ret = decomp->buildSingleHull() ;
@@ -3207,11 +3235,12 @@ void LLPhysicsDecomp::doDecompositionSingleHull()
 	}
 	else
 	{
-		mMutex->lock();
-		mCurRequest->mHull.clear();
-		mCurRequest->mHull.resize(1);
-		mCurRequest->mHullMesh.clear();
-		mMutex->unlock();
+		{
+			LLMutexLock lock(mMutex);
+			mCurRequest->mHull.clear();
+			mCurRequest->mHull.resize(1);
+			mCurRequest->mHullMesh.clear();
+		}
 
 		std::vector<LLVector3> p;
 		LLCDHull hull;
@@ -3227,93 +3256,12 @@ void LLPhysicsDecomp::doDecompositionSingleHull()
 			p.push_back(vert);
 			v = (F32*) (((U8*) v) + hull.mVertexStrideBytes);
 		}
-						
-		mMutex->lock();
-		mCurRequest->mHull[0] = p;
-		mMutex->unlock();	
-	}		
-#else
-	setMeshData(mesh, false);
-
-	//set all parameters to default
-	std::map<std::string, const LLCDParam*> param_map;
-
-	static const LLCDParam* params = NULL;
-	static S32 param_count = 0;
-
-	if (!params)
-	{
-		param_count = decomp->getParameters(&params);
-	}
-	
-	for (S32 i = 0; i < param_count; ++i)
-	{
-		decomp->setParam(params[i].mName, params[i].mDefault.mIntOrEnumValue);
-	}
-
-	const S32 STAGE_DECOMPOSE = mStageID["Decompose"];	
-	const S32 STAGE_SIMPLIFY = mStageID["Simplify"];
-	const S32 DECOMP_PREVIEW = 0;
-	const S32 SIMPLIFY_RETAIN = 0;
-	
-	decomp->setParam("Decompose Quality", DECOMP_PREVIEW);
-	decomp->setParam("Simplify Method", SIMPLIFY_RETAIN);
-	decomp->setParam("Retain%", 0.f);
-
-	LLCDResult ret = LLCD_OK;
-	ret = decomp->executeStage(STAGE_DECOMPOSE);
-	
-	if (ret)
-	{
-		llwarns << "Could not execute decomposition stage when attempting to create single hull." << llendl;
-		make_box(mCurRequest);
-	}
-	else
-	{
-		ret = decomp->executeStage(STAGE_SIMPLIFY);
-
-		if (ret)
-		{
-			llwarns << "Could not execute simiplification stage when attempting to create single hull." << llendl;
-			make_box(mCurRequest);
-		}
-		else
+					
 		{
-			S32 num_hulls =0;
-			if (LLConvexDecomposition::getInstance() != NULL)
-			{
-				num_hulls = LLConvexDecomposition::getInstance()->getNumHullsFromStage(STAGE_SIMPLIFY);
-			}
-			
-			mMutex->lock();
-			mCurRequest->mHull.clear();
-			mCurRequest->mHull.resize(num_hulls);
-			mCurRequest->mHullMesh.clear();
-			mMutex->unlock();
-
-			for (S32 i = 0; i < num_hulls; ++i)
-			{
-				std::vector<LLVector3> p;
-				LLCDHull hull;
-				// if LLConvexDecomposition is a stub, num_hulls should have been set to 0 above, and we should not reach this code
-				LLConvexDecomposition::getInstance()->getHullFromStage(STAGE_SIMPLIFY, i, &hull);
-
-				const F32* v = hull.mVertexBase;
-
-				for (S32 j = 0; j < hull.mNumVertices; ++j)
-				{
-					LLVector3 vert(v[0], v[1], v[2]); 
-					p.push_back(vert);
-					v = (F32*) (((U8*) v) + hull.mVertexStrideBytes);
-				}
-						
-				mMutex->lock();
-				mCurRequest->mHull[i] = p;
-				mMutex->unlock();
-			}
+			LLMutexLock lock(mMutex);
+			mCurRequest->mHull[0] = p;
 		}
-	}
-#endif
+	}		
 
 	{
 		completeCurrent();
-- 
cgit v1.2.3


From 48f5b69c43d4d4a2b6e272f7ac8d706ccc0c0601 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 17 Feb 2012 19:40:48 -0600
Subject: SH-2915 Smoother transition between sun shadow splits.

---
 .../shaders/class1/deferred/alphaF.glsl            |  2 -
 .../shaders/class1/deferred/alphaNonIndexedF.glsl  |  2 -
 .../class1/deferred/alphaNonIndexedNoColorF.glsl   |  2 -
 .../shaders/class1/deferred/sunLightSSAOF.glsl     |  5 --
 .../shaders/class2/deferred/alphaF.glsl            | 52 ++++++++++++++++----
 .../shaders/class2/deferred/alphaNonIndexedF.glsl  | 55 ++++++++++++++++++----
 .../class2/deferred/alphaNonIndexedNoColorF.glsl   | 52 ++++++++++++++++----
 .../shaders/class2/deferred/sunLightF.glsl         | 48 +++++++++++++++----
 .../shaders/class2/deferred/sunLightSSAOF.glsl     | 50 ++++++++++++++++----
 indra/newview/pipeline.cpp                         | 10 ++--
 10 files changed, 215 insertions(+), 63 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 73f05a5dd4..dd87ddb330 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -35,8 +35,6 @@ uniform sampler2DRect depthMap;
 
 vec4 diffuseLookup(vec2 texcoord);
 
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
 uniform vec2 screen_res;
 
 vec3 atmosLighting(vec3 light);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
index bfbd30a455..beb3290187 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
@@ -35,8 +35,6 @@ uniform sampler2DRect depthMap;
 uniform sampler2D diffuseMap;
 
 
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
 uniform vec2 screen_res;
 
 vec3 atmosLighting(vec3 light);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
index dae1131bbb..cb87b754b4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl
@@ -34,8 +34,6 @@ out vec4 frag_color;
 uniform sampler2DRect depthMap;
 uniform sampler2D diffuseMap;
 
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
 uniform vec2 screen_res;
 
 vec3 atmosLighting(vec3 light);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index 7fa666a739..2422d73a3e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -39,8 +39,6 @@ uniform sampler2D noiseMap;
 
 
 // Inputs
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
 uniform float ssao_radius;
 uniform float ssao_max_radius;
 uniform float ssao_factor;
@@ -51,9 +49,6 @@ VARYING vec2 vary_fragcoord;
 uniform mat4 inv_proj;
 uniform vec2 screen_res;
 
-uniform float shadow_bias;
-uniform float shadow_offset;
-
 vec4 getPosition(vec2 pos_screen)
 {
 	float depth = texture2DRect(depthMap, pos_screen.xy).r;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
index e5edb482a9..08f6ec63fe 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -80,7 +80,7 @@ void main()
 	vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
 	frag *= screen_res;
 	
-	float shadow = 1.0;
+	float shadow = 0.0;
 	vec4 pos = vec4(vary_position, 1.0);
 	
 	vec4 spos = pos;
@@ -89,31 +89,65 @@ void main()
 	{	
 		vec4 lpos;
 		
-		if (spos.z < -shadow_clip.z)
+		vec4 near_split = shadow_clip*-0.75;
+		vec4 far_split = shadow_clip*-1.25;
+		vec4 transition_domain = near_split-far_split;
+		float weight = 0.0;
+
+		if (spos.z < near_split.z)
 		{
 			lpos = shadow_matrix[3]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap3, lpos, 1.5);
+
+			float w = 1.0;
+			w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
+			shadow += pcfShadow(shadowMap3, lpos, 0.25)*w;
+			weight += w;
 			shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
 		}
-		else if (spos.z < -shadow_clip.y)
+
+		if (spos.z < near_split.y && spos.z > far_split.z)
 		{
 			lpos = shadow_matrix[2]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap2, lpos, 1.5);
+
+			float w = 1.0;
+			w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
+			w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
+			shadow += pcfShadow(shadowMap2, lpos, 0.75)*w;
+			weight += w;
 		}
-		else if (spos.z < -shadow_clip.x)
+
+		if (spos.z < near_split.x && spos.z > far_split.y)
 		{
 			lpos = shadow_matrix[1]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap1, lpos, 1.5);
+
+			float w = 1.0;
+			w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
+			w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
+			shadow += pcfShadow(shadowMap1, lpos, 0.75)*w;
+			weight += w;
 		}
-		else
+
+		if (spos.z > far_split.x)
 		{
 			lpos = shadow_matrix[0]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap0, lpos, 1.5);
+				
+			float w = 1.0;
+			w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
+				
+			shadow += pcfShadow(shadowMap0, lpos, 1.0)*w;
+			weight += w;
 		}
+		
+
+		shadow /= weight;
+	}
+	else
+	{
+		shadow = 1.0;
 	}
 	
 	vec4 diff = diffuseLookup(vary_texcoord0.xy);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
index c467e6c5cb..aae6a070e2 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
@@ -93,7 +93,7 @@ void main()
 	vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
 	frag *= screen_res;
 	
-	float shadow = 1.0;
+	float shadow = 0.0;
 	vec4 pos = vec4(vary_position, 1.0);
 	
 	vec4 spos = pos;
@@ -102,33 +102,68 @@ void main()
 	{	
 		vec4 lpos;
 		
-		if (spos.z < -shadow_clip.z)
+		vec4 near_split = shadow_clip*-0.75;
+		vec4 far_split = shadow_clip*-1.25;
+		vec4 transition_domain = near_split-far_split;
+		float weight = 0.0;
+
+		if (spos.z < near_split.z)
 		{
 			lpos = shadow_matrix[3]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap3, lpos, 1.5);
+
+			float w = 1.0;
+			w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
+			shadow += pcfShadow(shadowMap3, lpos, 0.25)*w;
+			weight += w;
 			shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
 		}
-		else if (spos.z < -shadow_clip.y)
+
+		if (spos.z < near_split.y && spos.z > far_split.z)
 		{
 			lpos = shadow_matrix[2]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap2, lpos, 1.5);
+
+			float w = 1.0;
+			w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
+			w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
+			shadow += pcfShadow(shadowMap2, lpos, 0.75)*w;
+			weight += w;
 		}
-		else if (spos.z < -shadow_clip.x)
+
+		if (spos.z < near_split.x && spos.z > far_split.y)
 		{
 			lpos = shadow_matrix[1]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap1, lpos, 1.5);
+
+			float w = 1.0;
+			w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
+			w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
+			shadow += pcfShadow(shadowMap1, lpos, 0.75)*w;
+			weight += w;
 		}
-		else
+
+		if (spos.z > far_split.x)
 		{
 			lpos = shadow_matrix[0]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap0, lpos, 1.5);
+				
+			float w = 1.0;
+			w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
+				
+			shadow += pcfShadow(shadowMap0, lpos, 1.0)*w;
+			weight += w;
 		}
+		
+
+		shadow /= weight;
+
 	}
-	
+	else
+	{
+		shadow = 1.0;
+	}
+
 	vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
 
 	vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, vertex_color.a);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
index 8aaf87a1b5..931577359e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
@@ -92,7 +92,7 @@ void main()
 	vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
 	frag *= screen_res;
 	
-	float shadow = 1.0;
+	float shadow = 0.0;
 	vec4 pos = vec4(vary_position, 1.0);
 	
 	vec4 spos = pos;
@@ -101,31 +101,65 @@ void main()
 	{	
 		vec4 lpos;
 		
-		if (spos.z < -shadow_clip.z)
+		vec4 near_split = shadow_clip*-0.75;
+		vec4 far_split = shadow_clip*-1.25;
+		vec4 transition_domain = near_split-far_split;
+		float weight = 0.0;
+
+		if (spos.z < near_split.z)
 		{
 			lpos = shadow_matrix[3]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap3, lpos, 1.5);
+
+			float w = 1.0;
+			w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
+			shadow += pcfShadow(shadowMap3, lpos, 0.25)*w;
+			weight += w;
 			shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
 		}
-		else if (spos.z < -shadow_clip.y)
+
+		if (spos.z < near_split.y && spos.z > far_split.z)
 		{
 			lpos = shadow_matrix[2]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap2, lpos, 1.5);
+
+			float w = 1.0;
+			w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
+			w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
+			shadow += pcfShadow(shadowMap2, lpos, 0.75)*w;
+			weight += w;
 		}
-		else if (spos.z < -shadow_clip.x)
+
+		if (spos.z < near_split.x && spos.z > far_split.y)
 		{
 			lpos = shadow_matrix[1]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap1, lpos, 1.5);
+
+			float w = 1.0;
+			w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
+			w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
+			shadow += pcfShadow(shadowMap1, lpos, 0.75)*w;
+			weight += w;
 		}
-		else
+
+		if (spos.z > far_split.x)
 		{
 			lpos = shadow_matrix[0]*spos;
 			lpos.xy *= shadow_res;
-			shadow = pcfShadow(shadowMap0, lpos, 1.5);
+				
+			float w = 1.0;
+			w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
+				
+			shadow += pcfShadow(shadowMap0, lpos, 1.0)*w;
+			weight += w;
 		}
+		
+
+		shadow /= weight;
+	}
+	else
+	{
+		shadow = 1.0;
 	}
 	
 	vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index a40b29d2c4..8c4ccf9cb3 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -135,7 +135,7 @@ void main()
 		return;
 	}*/
 	
-	float shadow = 1.0;
+	float shadow = 0.0;
 	float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz));
 
 	vec3 shadow_pos = pos.xyz + displace*norm;
@@ -154,32 +154,62 @@ void main()
 		{
 			vec4 lpos;
 			
-			if (spos.z < -shadow_clip.z)
+			vec4 near_split = shadow_clip*-0.75;
+			vec4 far_split = shadow_clip*-1.25;
+			vec4 transition_domain = near_split-far_split;
+			float weight = 0.0;
+
+			if (spos.z < near_split.z)
 			{
 				lpos = shadow_matrix[3]*spos;
 				lpos.xy *= shadow_res;
-				shadow = pcfShadow(shadowMap3, lpos, 0.25);
+
+				float w = 1.0;
+				w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
+				shadow += pcfShadow(shadowMap3, lpos, 0.25)*w;
+				weight += w;
 				shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
 			}
-			else if (spos.z < -shadow_clip.y)
+
+			if (spos.z < near_split.y && spos.z > far_split.z)
 			{
 				lpos = shadow_matrix[2]*spos;
 				lpos.xy *= shadow_res;
-				shadow = pcfShadow(shadowMap2, lpos, 0.5);
+
+				float w = 1.0;
+				w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
+				w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
+				shadow += pcfShadow(shadowMap2, lpos, 0.75)*w;
+				weight += w;
 			}
-			else if (spos.z < -shadow_clip.x)
+
+			if (spos.z < near_split.x && spos.z > far_split.y)
 			{
 				lpos = shadow_matrix[1]*spos;
 				lpos.xy *= shadow_res;
-				shadow = pcfShadow(shadowMap1, lpos, 0.75);
+
+				float w = 1.0;
+				w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
+				w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
+				shadow += pcfShadow(shadowMap1, lpos, 0.75)*w;
+				weight += w;
 			}
-			else
+
+			if (spos.z > far_split.x)
 			{
 				lpos = shadow_matrix[0]*spos;
 				lpos.xy *= shadow_res;
-				shadow = pcfShadow(shadowMap0, lpos, 1.0);
+				
+				float w = 1.0;
+				w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
+				
+				shadow += pcfShadow(shadowMap0, lpos, 1.0)*w;
+				weight += w;
 			}
 		
+
+			shadow /= weight;
+
 			// take the most-shadowed value out of these two:
 			//  * the blurred sun shadow in the light (shadow) map
 			//  * an unblurred dot product between the sun and this norm
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index 774f70262a..02075a7687 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -196,7 +196,7 @@ void main()
 		return;
 	}*/
 	
-	float shadow = 1.0;
+	float shadow = 0.0;
 	float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz));
 
 	vec3 shadow_pos = pos.xyz + displace*norm;
@@ -214,33 +214,63 @@ void main()
 		else
 		{
 			vec4 lpos;
-			
-			if (spos.z < -shadow_clip.z)
+
+			vec4 near_split = shadow_clip*-0.75;
+			vec4 far_split = shadow_clip*-1.25;
+			vec4 transition_domain = near_split-far_split;
+			float weight = 0.0;
+
+			if (spos.z < near_split.z)
 			{
 				lpos = shadow_matrix[3]*spos;
 				lpos.xy *= shadow_res;
-				shadow = pcfShadow(shadowMap3, lpos, 0.25);
+
+				float w = 1.0;
+				w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
+				shadow += pcfShadow(shadowMap3, lpos, 0.25)*w;
+				weight += w;
 				shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
 			}
-			else if (spos.z < -shadow_clip.y)
+
+			if (spos.z < near_split.y && spos.z > far_split.z)
 			{
 				lpos = shadow_matrix[2]*spos;
 				lpos.xy *= shadow_res;
-				shadow = pcfShadow(shadowMap2, lpos, 0.5);
+
+				float w = 1.0;
+				w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
+				w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
+				shadow += pcfShadow(shadowMap2, lpos, 0.75)*w;
+				weight += w;
 			}
-			else if (spos.z < -shadow_clip.x)
+
+			if (spos.z < near_split.x && spos.z > far_split.y)
 			{
 				lpos = shadow_matrix[1]*spos;
 				lpos.xy *= shadow_res;
-				shadow = pcfShadow(shadowMap1, lpos, 0.75);
+
+				float w = 1.0;
+				w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
+				w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
+				shadow += pcfShadow(shadowMap1, lpos, 0.75)*w;
+				weight += w;
 			}
-			else
+
+			if (spos.z > far_split.x)
 			{
 				lpos = shadow_matrix[0]*spos;
 				lpos.xy *= shadow_res;
-				shadow = pcfShadow(shadowMap0, lpos, 1.0);
+				
+				float w = 1.0;
+				w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
+				
+				shadow += pcfShadow(shadowMap0, lpos, 1.0)*w;
+				weight += w;
 			}
 		
+
+			shadow /= weight;
+
 			// take the most-shadowed value out of these two:
 			//  * the blurred sun shadow in the light (shadow) map
 			//  * an unblurred dot product between the sun and this norm
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index ce3a4893bf..d5bcfe12ab 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8817,16 +8817,16 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		
 		da = powf(da, split_exp.mV[2]);
 
-
 		F32 sxp = split_exp.mV[1] + (split_exp.mV[0]-split_exp.mV[1])*da;
-
-
+		
 		for (U32 i = 0; i < 4; ++i)
 		{
 			F32 x = (F32)(i+1)/4.f;
 			x = powf(x, sxp);
 			mSunClipPlanes.mV[i] = near_clip+range*x;
 		}
+
+		mSunClipPlanes.mV[0] *= 1.25f; //bump back first split for transition padding
 	}
 
 	// convenience array of 4 near clip plane distances
@@ -8883,8 +8883,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 				delta += (frust[i+4]-frust[(i+2)%4+4])*0.05f;
 				delta.normVec();
 				F32 dp = delta*pn;
-				frust[i] = eye + (delta*dist[j]*0.95f)/dp;
-				frust[i+4] = eye + (delta*dist[j+1]*1.05f)/dp;
+				frust[i] = eye + (delta*dist[j]*0.75f)/dp;
+				frust[i+4] = eye + (delta*dist[j+1]*1.25f)/dp;
 			}
 						
 			shadow_cam.calcAgentFrustumPlanes(frust);
-- 
cgit v1.2.3


From e1a71a97cd00d70fedeb6191b6ebb10361019ee1 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 21 Feb 2012 14:02:09 -0600
Subject: SH-2908 Potential fix for pink textures on some OpenGL 3.1
 implementations.

---
 indra/llrender/llshadermgr.cpp | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

(limited to 'indra')

diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 9aeb1a99f8..e1cd8fa62d 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -614,6 +614,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 
 			//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");
 		}
 		else
 		{ //set version to 400
@@ -668,20 +669,22 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 		
 		VARYING_FLAT ivec4 vary_texture_index;
 
+		vec4 ret = vec4(1,0,1,1);
+
 		vec4 diffuseLookup(vec2 texcoord)
 		{
 			switch (vary_texture_index.r))
 			{
-				case 0: return texture2D(tex0, texcoord);
-				case 1: return texture2D(tex1, texcoord);
-				case 2: return texture2D(tex2, texcoord);
+				case 0: ret = texture2D(tex0, texcoord); break;
+				case 1: ret = texture2D(tex1, texcoord); break;
+				case 2: ret = texture2D(tex2, texcoord); break;
 				.
 				.
 				.
-				case N: return texture2D(texN, texcoord);
+				case N: return texture2D(texN, texcoord); break;
 			}
 
-			return vec4(0,0,0,0);
+			return ret;
 		}
 		*/
 
@@ -708,18 +711,19 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 		}
 		else if (major_version > 1 || minor_version >= 30)
 		{  //switches are supported in GLSL 1.30 and later
+			text[count++] = strdup("\tvec4 ret = vec4(1,0,1,1);\n");
 			text[count++] = strdup("\tswitch (vary_texture_index.r)\n");
 			text[count++] = strdup("\t{\n");
 		
 			//switch body
 			for (S32 i = 0; i < texture_index_channels; ++i)
 			{
-				std::string case_str = llformat("\t\tcase %d: return texture2D(tex%d, texcoord);\n", i, i);
+				std::string case_str = llformat("\t\tcase %d: ret = texture2D(tex%d, texcoord); break;\n", i, i);
 				text[count++] = strdup(case_str.c_str());
 			}
 
 			text[count++] = strdup("\t}\n");
-			text[count++] = strdup("\treturn vec4(1,0,1,1);\n");
+			text[count++] = strdup("\treturn ret;\n");
 			text[count++] = strdup("}\n");
 		}
 		else
-- 
cgit v1.2.3


From 8f261582b80d7d4a61cf8bb42c0429fa58f0c186 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 22 Feb 2012 14:30:24 -0600
Subject: SH-2908 Fix for crash when enabling Lighting and Shadows on some AMD
 GPUs

---
 indra/llrender/llshadermgr.cpp                     |   1 +
 .../shaders/class1/deferred/attachmentShadowF.glsl |   2 -
 .../shaders/class1/deferred/attachmentShadowV.glsl |   5 -
 .../class1/deferred/avatarAlphaNoColorV.glsl       | 148 +++++++++++++++++++++
 .../shaders/class1/deferred/postDeferredNoTCV.glsl |  40 ++++++
 .../app_settings/shaders/class1/deferred/skyV.glsl |   5 +-
 indra/newview/llviewershadermgr.cpp                |  10 +-
 7 files changed, 195 insertions(+), 16 deletions(-)
 create mode 100644 indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl

(limited to 'indra')

diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index e1cd8fa62d..b28a97adaa 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -644,6 +644,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 		text[count++] = strdup("#define textureCube texture\n");
 		text[count++] = strdup("#define texture2DLod textureLod\n");
 		text[count++] = strdup("#define	shadow2D(a,b) vec2(texture(a,b))\n");
+		text[count++] = strdup("#define shadow2DRect(a,b) vec2(texture(a,b))\n");
 	}
 
 	//copy preprocessor definitions into buffer
diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
index 92e3f7f388..22c9a4d14e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
@@ -30,12 +30,10 @@ out vec4 frag_color;
 
 uniform sampler2D diffuseMap;
 
-VARYING vec4 vertex_color;
 VARYING vec2 vary_texcoord0;
 
 void main() 
 {
-	//frag_color = vec4(1,1,1,vertex_color.a * texture2D(diffuseMap, vary_texcoord0.xy).a);
 	frag_color = vec4(1,1,1,1);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
index ded6cced27..81961d7746 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
@@ -27,11 +27,8 @@ uniform mat4 modelview_matrix;
 uniform mat4 texture_matrix0;
 
 ATTRIBUTE vec3 position;
-ATTRIBUTE vec4 diffuse_color;
 ATTRIBUTE vec2 texcoord0;
 
-VARYING vec4 vertex_color;
-
 mat4 getObjectSkinnedTransform();
 
 void main()
@@ -42,8 +39,6 @@ void main()
 	mat = modelview_matrix * mat;
 	vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
 	
-	vertex_color = diffuse_color;
-	
 	vec4 p = projection_matrix * vec4(pos, 1.0);
 	p.z = max(p.z, -p.w+0.01);
 	gl_Position = p;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
new file mode 100644
index 0000000000..5f395801e5
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
@@ -0,0 +1,148 @@
+/** 
+ * @file avatarAlphaNoColorV.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$
+ */
+
+uniform mat4 projection_matrix;
+
+ATTRIBUTE vec3 position;
+ATTRIBUTE vec3 normal;
+ATTRIBUTE vec2 texcoord0;
+
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
+mat4 getSkinnedTransform();
+void calcAtmospherics(vec3 inPositionEye);
+
+float calcDirectionalLight(vec3 n, vec3 l);
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
+
+vec3 atmosAmbient(vec3 light);
+vec3 atmosAffectDirectionalLight(float lightIntensity);
+vec3 scaleDownLight(vec3 light);
+vec3 scaleUpLight(vec3 light);
+
+VARYING vec3 vary_position;
+VARYING vec3 vary_ambient;
+VARYING vec3 vary_directional;
+VARYING vec3 vary_fragcoord;
+VARYING vec3 vary_pointlight_col;
+VARYING vec2 vary_texcoord0;
+
+
+uniform float near_clip;
+
+uniform vec4 color;
+
+uniform vec4 light_position[8];
+uniform vec3 light_direction[8];
+uniform vec3 light_attenuation[8]; 
+uniform vec3 light_diffuse[8];
+
+float calcDirectionalLight(vec3 n, vec3 l)
+{
+        float a = max(dot(n,l),0.0);
+        return a;
+}
+
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
+{
+	//get light vector
+	vec3 lv = lp.xyz-v;
+	
+	//get distance
+	float d = dot(lv,lv);
+	
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv = normalize(lv);
+	
+		//distance attenuation
+		float dist2 = d/la;
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
+
+		//angular attenuation
+		da *= max(dot(n, lv), 0.0);		
+	}
+
+	return da;	
+}
+
+void main()
+{
+	vary_texcoord0 = texcoord0;
+				
+	vec4 pos;
+	vec3 norm;
+	
+	mat4 trans = getSkinnedTransform();
+	vec4 pos_in = vec4(position.xyz, 1.0);
+	pos.x = dot(trans[0], pos_in);
+	pos.y = dot(trans[1], pos_in);
+	pos.z = dot(trans[2], pos_in);
+	pos.w = 1.0;
+	
+	norm.x = dot(trans[0].xyz, normal);
+	norm.y = dot(trans[1].xyz, normal);
+	norm.z = dot(trans[2].xyz, normal);
+	norm = normalize(norm);
+		
+	vec4 frag_pos = projection_matrix * pos;
+	gl_Position = frag_pos;
+	
+	vary_position = pos.xyz;
+	
+	calcAtmospherics(pos.xyz);
+
+	vec4 col = vec4(0.0, 0.0, 0.0, 1.0);
+
+	// Collect normal lights
+	col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
+	col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
+	col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
+	col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
+	col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
+	col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
+	
+	vary_pointlight_col = col.rgb*color.rgb;
+
+	col.rgb = vec3(0,0,0);
+
+	// Add windlight lights
+	col.rgb = atmosAmbient(vec3(0.));
+	
+	vary_ambient = col.rgb*color.rgb;
+	vary_directional = color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), 0.0));
+	
+	col.rgb = col.rgb * color.rgb;
+	
+	vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
+}
+
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl
new file mode 100644
index 0000000000..bd0cb50464
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl
@@ -0,0 +1,40 @@
+/** 
+ * @file postDeferredV.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$
+ */
+
+uniform mat4 modelview_projection_matrix;
+
+ATTRIBUTE vec3 position;
+
+VARYING vec2 vary_fragcoord;
+
+uniform vec2 screen_res;
+
+void main()
+{
+	//transform vertex
+	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_Position = pos;	
+	vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
index cb7603f4fd..7c02d31d43 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
@@ -26,7 +26,6 @@
 uniform mat4 modelview_projection_matrix;
 
 ATTRIBUTE vec3 position;
-ATTRIBUTE vec2 texcoord0;
 
 // SKY ////////////////////////////////////////////////////////////////////////
 // The vertex shader for creating the atmospheric sky
@@ -34,7 +33,6 @@ ATTRIBUTE vec2 texcoord0;
 
 // Output parameters
 VARYING vec4 vary_HazeColor;
-VARYING vec2 vary_texcoord0;
 
 // Inputs
 uniform vec3 camPosLocal;
@@ -60,8 +58,7 @@ void main()
 
 	// World / view / projection
 	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
-	vary_texcoord0 = texcoord0;
-
+	
 	// Get relative position
 	vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
 	//vec3 P = position.xyz + vec3(0,50,0);
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 06db644851..a598497392 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -1428,7 +1428,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredAvatarAlphaProgram.mFeatures.isAlphaLighting = true;
 		gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true;
 		gDeferredAvatarAlphaProgram.mShaderFiles.clear();
-		gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaV.glsl", GL_VERTEX_SHADER_ARB));
+		gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaNoColorV.glsl", GL_VERTEX_SHADER_ARB));
 		gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaNonIndexedNoColorF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gDeferredAvatarAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 
@@ -1452,7 +1452,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 	{
 		gDeferredPostProgram.mName = "Deferred Post Shader";
 		gDeferredPostProgram.mShaderFiles.clear();
-		gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
+		gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
 		gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gDeferredPostProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 		success = gDeferredPostProgram.createShader(NULL, NULL);
@@ -1462,7 +1462,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 	{
 		gDeferredCoFProgram.mName = "Deferred CoF Shader";
 		gDeferredCoFProgram.mShaderFiles.clear();
-		gDeferredCoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
+		gDeferredCoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
 		gDeferredCoFProgram.mShaderFiles.push_back(make_pair("deferred/cofF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gDeferredCoFProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 		success = gDeferredCoFProgram.createShader(NULL, NULL);
@@ -1472,7 +1472,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 	{
 		gDeferredDoFCombineProgram.mName = "Deferred DoFCombine Shader";
 		gDeferredDoFCombineProgram.mShaderFiles.clear();
-		gDeferredDoFCombineProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
+		gDeferredDoFCombineProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
 		gDeferredDoFCombineProgram.mShaderFiles.push_back(make_pair("deferred/dofCombineF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gDeferredDoFCombineProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 		success = gDeferredDoFCombineProgram.createShader(NULL, NULL);
@@ -1482,7 +1482,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 	{
 		gDeferredPostNoDoFProgram.mName = "Deferred Post Shader";
 		gDeferredPostNoDoFProgram.mShaderFiles.clear();
-		gDeferredPostNoDoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
+		gDeferredPostNoDoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
 		gDeferredPostNoDoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoDoFF.glsl", GL_FRAGMENT_SHADER_ARB));
 		gDeferredPostNoDoFProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 		success = gDeferredPostNoDoFProgram.createShader(NULL, NULL);
-- 
cgit v1.2.3


From bab8b9d75ad72c338e3228019825a739b41eb677 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 22 Feb 2012 19:41:47 -0600
Subject: SH-2908 Another for crash when enabling Lighting and Shadows on some
 AMD GPUs

---
 .../shaders/class1/deferred/alphaSkinnedV.glsl     |  4 +--
 .../shaders/class1/deferred/alphaV.glsl            |  3 --
 .../class1/deferred/sunLightNoFragCoordV.glsl      | 37 ++++++++++++++++++++++
 indra/newview/llviewershadermgr.cpp                |  7 +++-
 4 files changed, 44 insertions(+), 7 deletions(-)
 create mode 100644 indra/newview/app_settings/shaders/class1/deferred/sunLightNoFragCoordV.glsl

(limited to 'indra')

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
index eada38eaaa..5a0e8ff684 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
@@ -41,7 +41,6 @@ vec3 atmosAffectDirectionalLight(float lightIntensity);
 VARYING vec3 vary_position;
 VARYING vec3 vary_ambient;
 VARYING vec3 vary_directional;
-VARYING vec3 vary_normal;
 VARYING vec3 vary_fragcoord;
 VARYING vec3 vary_pointlight_col;
 VARYING vec4 vertex_color;
@@ -110,8 +109,7 @@ void main()
 	gl_Position = frag_pos;
 	
 	vary_position = pos.xyz;
-	vary_normal = norm;	
-	
+		
 	calcAtmospherics(pos.xyz);
 
 	vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 5c36118a50..cf38a2f4f7 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -48,7 +48,6 @@ VARYING vec3 vary_ambient;
 VARYING vec3 vary_directional;
 VARYING vec3 vary_fragcoord;
 VARYING vec3 vary_position;
-VARYING vec3 vary_light;
 VARYING vec3 vary_pointlight_col;
 
 VARYING vec4 vertex_color;
@@ -134,8 +133,6 @@ void main()
 	// Add windlight lights
 	col.rgb = atmosAmbient(vec3(0.));
 	
-	vary_light = light_position[0].xyz;
-	
 	vary_ambient = col.rgb*diffuse_color.rgb;
 	vary_directional.rgb = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightNoFragCoordV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightNoFragCoordV.glsl
new file mode 100644
index 0000000000..47e9d15fbc
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightNoFragCoordV.glsl
@@ -0,0 +1,37 @@
+/** 
+ * @file sunLightF.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$
+ */
+
+uniform mat4 modelview_projection_matrix;
+ 
+ATTRIBUTE vec3 position;
+
+uniform vec2 screen_res;
+
+void main()
+{
+	//transform vertex
+	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_Position = pos; 
+}
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index a598497392..10c61c01d5 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -1218,6 +1218,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 	if (success)
 	{
 		std::string fragment;
+		std::string vertex = "deferred/sunLightV.glsl";
 
 		if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
 		{
@@ -1226,11 +1227,15 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		else
 		{
 			fragment = "deferred/sunLightF.glsl";
+			if (mVertexShaderLevel[SHADER_DEFERRED] == 1)
+			{ //no shadows, no SSAO, no frag coord
+				vertex = "deferred/sunLightNoFragCoordV.glsl";
+			}
 		}
 
 		gDeferredSunProgram.mName = "Deferred Sun Shader";
 		gDeferredSunProgram.mShaderFiles.clear();
-		gDeferredSunProgram.mShaderFiles.push_back(make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER_ARB));
+		gDeferredSunProgram.mShaderFiles.push_back(make_pair(vertex, GL_VERTEX_SHADER_ARB));
 		gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB));
 		gDeferredSunProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 		success = gDeferredSunProgram.createShader(NULL, NULL);
-- 
cgit v1.2.3


From a128836dedf25dc56807cced9316fbaa09a7f019 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 23 Feb 2012 13:41:19 -0600
Subject: SH-2908 Fix for linux build.

---
 indra/llrender/llvertexbuffer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index a7f0170658..8b5503229f 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -1262,7 +1262,7 @@ void LLVertexBuffer::setupVertexArray()
 		{
 			glEnableVertexAttribArrayARB(i);
 
-			if (attrib_integer)
+			if (attrib_integer[i])
 			{
 #if !LL_DARWIN
 				//glVertexattribIPointer requires GLSL 1.30 or later
-- 
cgit v1.2.3


From d356e2be0ffbc64b5df28b49d8bc3e043957fa21 Mon Sep 17 00:00:00 2001
From: paul_productengine <none@none>
Date: Fri, 24 Feb 2012 21:29:59 +0200
Subject: MAINT-387 FIXED [PUBLIC]Possible crash in
 llviewermenufile/upload_done_callback

- Just moved the deletion to the inspected block
---
 indra/newview/llviewermenufile.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 7e830e14bf..cacb8a8766 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -949,11 +949,12 @@ void upload_done_callback(
 			args["REASON"] = std::string(LLAssetStorage::getErrorString(result));
 			LLNotificationsUtil::add("CannotUploadReason", args);
 		}
+
+		delete data;
+		data = NULL;
 	}
 
 	LLUploadDialog::modalUploadFinished();
-	delete data;
-	data = NULL;
 
 	// *NOTE: This is a pretty big hack. What this does is check the
 	// file picker if there are any more pending uploads. If so,
-- 
cgit v1.2.3


From 523f94cca97c9345277c33b030160adc19539ba3 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 27 Feb 2012 17:15:35 -0600
Subject: SH-2889 Fix for crash when encountering certain attachments.

---
 indra/llcharacter/llcharacter.h    |  2 +-
 indra/newview/lldrawpoolavatar.cpp |  2 ++
 indra/newview/llvoavatar.cpp       | 13 +++++++++----
 indra/newview/llvoavatar.h         |  4 ++--
 4 files changed, 14 insertions(+), 7 deletions(-)

(limited to 'indra')

diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h
index e81a27c2bc..3ebb2bffb0 100644
--- a/indra/llcharacter/llcharacter.h
+++ b/indra/llcharacter/llcharacter.h
@@ -126,7 +126,7 @@ public:
 
 	virtual void addDebugText( const std::string& text ) = 0;
 
-	virtual const LLUUID&	getID() = 0;
+	virtual const LLUUID&	getID() const = 0;
 	//-------------------------------------------------------------------------
 	// End Interface
 	//-------------------------------------------------------------------------
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index b002c11af5..0103373fd2 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -1138,6 +1138,8 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 		return;
 	}
 
+	llassert(LLPipeline::sImpostorRender || !avatarp->isVisuallyMuted());
+
 	/*if (single_avatar && avatarp->mSpecialRenderMode >= 1) // 1=anim preview, 2=image preview,  3=morph view
 	{
 		gPipeline.enableLightsAvatarEdit(LLColor4(.5f, .5f, .5f, 1.f));
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index bc7f5a9744..7cbb47100d 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3365,7 +3365,7 @@ void LLVOAvatar::slamPosition()
 	mRoot.updateWorldMatrixChildren();
 }
 
-bool LLVOAvatar::isVisuallyMuted()
+bool LLVOAvatar::isVisuallyMuted() const
 {
 	static LLCachedControl<U32> max_attachment_bytes(gSavedSettings, "RenderAutoMuteByteLimit");
 	static LLCachedControl<F32> max_attachment_area(gSavedSettings, "RenderAutoMuteSurfaceAreaLimit");
@@ -3434,7 +3434,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
 	// the rest should only be done occasionally for far away avatars
 	//--------------------------------------------------------------------
 
-	if (visible && !isSelf() && !mIsDummy && sUseImpostors && !mNeedsAnimUpdate && !sFreezeCounter)
+	if (visible && (!isSelf() || isVisuallyMuted()) && !mIsDummy && sUseImpostors && !mNeedsAnimUpdate && !sFreezeCounter)
 	{
 		const LLVector4a* ext = mDrawable->getSpatialExtents();
 		LLVector4a size;
@@ -3474,6 +3474,11 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
 
 		visible = (LLDrawable::getCurrentFrame()+mID.mData[0])%mUpdatePeriod == 0 ? TRUE : FALSE;
 	}
+	else
+	{
+		mUpdatePeriod = 1;
+	}
+
 
 	// don't early out for your own avatar, as we rely on your animations playing reliably
 	// for example, the "turn around" animation when entering customize avatar needs to trigger
@@ -5029,7 +5034,7 @@ void LLVOAvatar::addDebugText(const std::string& text)
 //-----------------------------------------------------------------------------
 // getID()
 //-----------------------------------------------------------------------------
-const LLUUID& LLVOAvatar::getID()
+const LLUUID& LLVOAvatar::getID() const
 {
 	return mID;
 }
@@ -8296,7 +8301,7 @@ void LLVOAvatar::updateImpostors()
 
 BOOL LLVOAvatar::isImpostor() const
 {
-	return (sUseImpostors && mUpdatePeriod >= IMPOSTOR_PERIOD) ? TRUE : FALSE;
+	return (isVisuallyMuted() || (sUseImpostors && mUpdatePeriod >= IMPOSTOR_PERIOD)) ? TRUE : FALSE;
 }
 
 
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index dd0317f555..6a4e09593c 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -185,7 +185,7 @@ public:
 	void					resetSpecificJointPosition( const std::string& name );
 	
 	virtual const char*		getAnimationPrefix() { return "avatar"; }
-	virtual const LLUUID&   getID();
+	virtual const LLUUID&   getID() const;
 	virtual LLVector3		getVolumePos(S32 joint_index, LLVector3& volume_offset);
 	virtual LLJoint*		findCollisionVolume(U32 volume_id);
 	virtual S32				getCollisionVolumeID(std::string &name);
@@ -382,7 +382,7 @@ private:
 
 public:
 	U32 		renderImpostor(LLColor4U color = LLColor4U(255,255,255,255), S32 diffuse_channel = 0);
-	bool		isVisuallyMuted();
+	bool		isVisuallyMuted() const;
 
 	U32 		renderRigid();
 	U32 		renderSkinned(EAvatarRenderPass pass);
-- 
cgit v1.2.3


From 353907bac61e6db0aca16e7e43f13f627b414dca Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 28 Feb 2012 16:10:04 -0600
Subject: SH-2908 Fix for incompatibility issue with GLSL 1.30

---
 indra/llrender/llshadermgr.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'indra')

diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index b28a97adaa..7d384450e6 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -640,11 +640,15 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 
 		//backwards compatibility with legacy texture lookup syntax
 		text[count++] = strdup("#define texture2D texture\n");
-		text[count++] = strdup("#define texture2DRect texture\n");
 		text[count++] = strdup("#define textureCube texture\n");
 		text[count++] = strdup("#define texture2DLod textureLod\n");
 		text[count++] = strdup("#define	shadow2D(a,b) vec2(texture(a,b))\n");
-		text[count++] = strdup("#define shadow2DRect(a,b) vec2(texture(a,b))\n");
+
+		if (major_version > 1 || minor_version >= 40)
+		{ //GLSL 1.40 replaces texture2DRect et al with texture
+			text[count++] = strdup("#define texture2DRect texture\n");
+			text[count++] = strdup("#define shadow2DRect(a,b) vec2(texture(a,b))\n");
+		}
 	}
 
 	//copy preprocessor definitions into buffer
-- 
cgit v1.2.3


From 302f4085a5f9fd7b5267fd573a8e15f890cfe573 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 28 Feb 2012 16:35:50 -0600
Subject: SH-2908 Reset graphics drivers to "low" if viewer crashes when
 allocating deferred rendering targets.

---
 indra/newview/pipeline.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'indra')

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index d5bcfe12ab..e2cb22e307 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -811,6 +811,10 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
 
 	if (LLPipeline::sRenderDeferred)
 	{
+		// Set this flag in case we crash while resizing window or allocating space for deferred rendering targets
+		gSavedSettings.setBOOL("RenderInitError", TRUE);
+		gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
+
 		S32 shadow_detail = RenderShadowDetail;
 		BOOL ssao = RenderDeferredSSAO;
 		
@@ -872,6 +876,10 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
 				mShadow[i].release();
 			}
 		}
+
+		// don't disable shaders on next session
+		gSavedSettings.setBOOL("RenderInitError", FALSE);
+		gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
 	}
 	else
 	{
-- 
cgit v1.2.3