Commit 663a6dc2 authored by Andrey Kleshchev's avatar Andrey Kleshchev

Merged master(DRTVWR-497) into DRTVWR-482

parents 89839721 bac6652c
---
# clang-format version 10.0.0+
Language: Cpp
# BasedOnStyle: Microsoft
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
......@@ -29,21 +30,21 @@ BreakBeforeBraces: Allman
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: AfterColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
ColumnLimit: 140
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ExperimentalAutoDetectBinPacking: true
FixNamespaceComments: true
ForEachMacros:
- foreach
......@@ -62,18 +63,18 @@ IncludeCategories:
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
......@@ -94,16 +95,16 @@ SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
......
......@@ -63,7 +63,13 @@ if (WINDOWS)
# Without PreferredToolArchitecture=x64, as of 2020-06-26 the 32-bit
# compiler on our TeamCity build hosts has started running out of virtual
# memory for the precompiled header file.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /p:PreferredToolArchitecture=x64")
# CP changed to only append the flag for 32bit builds - on 64bit builds,
# locally at least, the build output is spammed with 1000s of 'D9002'
# warnings about this switch being ignored.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
if( ADDRESS_SIZE EQUAL 32 )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /p:PreferredToolArchitecture=x64")
endif()
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Zo"
......
......@@ -1295,6 +1295,9 @@ void LLSettingsSky::clampColor(LLColor3& color, F32 gamma, F32 scale) const
color = linear;
}
// Similar/Shared Algorithms:
// indra\llinventory\llsettingssky.cpp -- LLSettingsSky::calculateLightSettings()
// indra\newview\app_settings\shaders\class1\windlight\atmosphericsFuncs.glsl -- calcAtmosphericVars()
void LLSettingsSky::calculateLightSettings() const
{
// Initialize temp variables
......
......@@ -985,38 +985,56 @@ BOOL LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image)
return FALSE;
}
if( !mHasExplicitFormat )
{
switch (mComponents)
{
case 1:
// Use luminance alpha (for fonts)
mFormatInternal = GL_LUMINANCE8;
mFormatPrimary = GL_LUMINANCE;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 2:
// Use luminance alpha (for fonts)
mFormatInternal = GL_LUMINANCE8_ALPHA8;
mFormatPrimary = GL_LUMINANCE_ALPHA;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 3:
mFormatInternal = GL_RGB8;
mFormatPrimary = GL_RGB;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 4:
mFormatInternal = GL_RGBA8;
mFormatPrimary = GL_RGBA;
mFormatType = GL_UNSIGNED_BYTE;
break;
default:
LL_ERRS() << "Bad number of components for texture: " << (U32)getComponents() << LL_ENDL;
}
}
if (!mHasExplicitFormat)
{
switch (mComponents)
{
case 1:
// Use luminance alpha (for fonts)
mFormatInternal = GL_LUMINANCE8;
mFormatPrimary = GL_LUMINANCE;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 2:
// Use luminance alpha (for fonts)
mFormatInternal = GL_LUMINANCE8_ALPHA8;
mFormatPrimary = GL_LUMINANCE_ALPHA;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 3:
#if USE_SRGB_DECODE
if (gGLManager.mHasTexturesRGBDecode)
{
mFormatInternal = GL_SRGB8;
}
else
#endif
{
mFormatInternal = GL_RGB8;
}
mFormatPrimary = GL_RGB;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 4:
#if USE_SRGB_DECODE
if (gGLManager.mHasTexturesRGBDecode)
{
mFormatInternal = GL_SRGB8_ALPHA8;
}
else
#endif
{
mFormatInternal = GL_RGBA8;
}
mFormatPrimary = GL_RGBA;
mFormatType = GL_UNSIGNED_BYTE;
break;
default:
LL_ERRS() << "Bad number of components for texture: " << (U32) getComponents() << LL_ENDL;
}
}
mCurrentDiscardLevel = discard_level;
mCurrentDiscardLevel = discard_level;
mDiscardLevelInAtlas = discard_level;
mTexelsInAtlas = raw_image->getWidth() * raw_image->getHeight() ;
mLastBindTime = sLastFrameTime;
......
......@@ -849,26 +849,32 @@ void LLTexUnit::debugTextureUnit(void)
}
}
void LLTexUnit::setTextureColorSpace(eTextureColorSpace space) {
void LLTexUnit::setTextureColorSpace(eTextureColorSpace space)
{
mTexColorSpace = space;
#if USE_SRGB_DECODE
if (gGLManager.mHasTexturesRGBDecode) {
if (space == TCS_SRGB) {
if (gGLManager.mHasTexturesRGBDecode)
{
if (space == TCS_SRGB)
{
glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT);
}
else {
else
{
glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
}
if (gDebugGL) {
if (gDebugGL)
{
assert_glerror();
}
}
else
#endif
glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
{
glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
}
}
LLLightState::LLLightState(S32 index)
......@@ -1192,46 +1198,46 @@ void LLRender::refreshState(void)
void LLRender::syncLightState()
{
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
LLGLSLShader *shader = LLGLSLShader::sCurBoundShaderPtr;
if (!shader)
{
return;
}
if (!shader)
{
return;
}
if (shader->mLightHash != mLightHash)
{
shader->mLightHash = mLightHash;
if (shader->mLightHash != mLightHash)
{
shader->mLightHash = mLightHash;
LLVector4 position[8];
LLVector3 direction[8];
LLVector4 attenuation[8];
LLVector3 diffuse[8];
LLVector3 diffuse_b[8];
bool sun_primary[8];
LLVector4 position[LL_NUM_LIGHT_UNITS];
LLVector3 direction[LL_NUM_LIGHT_UNITS];
LLVector4 attenuation[LL_NUM_LIGHT_UNITS];
LLVector3 diffuse[LL_NUM_LIGHT_UNITS];
LLVector3 diffuse_b[LL_NUM_LIGHT_UNITS];
bool sun_primary[LL_NUM_LIGHT_UNITS];
for (U32 i = 0; i < 8; i++)
{
LLLightState* light = mLightState[i];
for (U32 i = 0; i < LL_NUM_LIGHT_UNITS; i++)
{
LLLightState *light = mLightState[i];
position[i] = light->mPosition;
direction[i] = light->mSpotDirection;
position[i] = light->mPosition;
direction[i] = light->mSpotDirection;
attenuation[i].set(light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[2], light->mSpecular.mV[3]);
diffuse[i].set(light->mDiffuse.mV);
diffuse[i].set(light->mDiffuse.mV);
diffuse_b[i].set(light->mDiffuseB.mV);
sun_primary[i] = light->mSunIsPrimary;
}
}
shader->uniform4fv(LLShaderMgr::LIGHT_POSITION, 8, position[0].mV);
shader->uniform3fv(LLShaderMgr::LIGHT_DIRECTION, 8, direction[0].mV);
shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, 8, attenuation[0].mV);
shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, 8, diffuse[0].mV);
shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV);
shader->uniform4fv(LLShaderMgr::LIGHT_POSITION, LL_NUM_LIGHT_UNITS, position[0].mV);
shader->uniform3fv(LLShaderMgr::LIGHT_DIRECTION, LL_NUM_LIGHT_UNITS, direction[0].mV);
shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, LL_NUM_LIGHT_UNITS, attenuation[0].mV);
shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, LL_NUM_LIGHT_UNITS, diffuse[0].mV);
shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV);
shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_primary[0] ? 1 : 0);
shader->uniform4fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV);
shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV);
shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV);
}
}
}
void LLRender::syncMatrices()
......@@ -1539,11 +1545,17 @@ void LLRender::matrixMode(eMatrixMode mode)
{
U32 tex_index = gGL.getCurrentTexUnitIndex();
// the shaders don't actually reference anything beyond texture_matrix0/1 outside of terrain rendering
llassert_always(tex_index <= 3);
mode = eMatrixMode(MM_TEXTURE0 + gGL.getCurrentTexUnitIndex());
llassert(tex_index <= 3);
mode = eMatrixMode(MM_TEXTURE0 + tex_index);
if (mode > MM_TEXTURE3)
{
// getCurrentTexUnitIndex() can go as high as 32 (LL_NUM_TEXTURE_LAYERS)
// Large value will result in a crash at mMatrix
LL_WARNS_ONCE() << "Attempted to assign matrix mode out of bounds: " << mode << LL_ENDL;
mode = MM_TEXTURE0;
}
}
llassert(mode < NUM_MATRIX_MODES);
mMatrixMode = mode;
}
......
......@@ -501,23 +501,23 @@ U32 LLRenderTarget::getNumTextures() const
return mTex.size();
}
void LLRenderTarget::bindTexture(U32 index, S32 channel, LLTexUnit::eTextureFilterOptions filter_options)
{
gGL.getTexUnit(channel)->bindManual(mUsage, getTexture(index));
gGL.getTexUnit(channel)->bindManual(mUsage, getTexture(index));
bool isSRGB = false;
llassert(mInternalFormat.size() > index);
switch (mInternalFormat[index])
{
case GL_SRGB_ALPHA:
case GL_SRGB:
case GL_SRGB8:
case GL_SRGB_ALPHA:
case GL_SRGB8_ALPHA8:
isSRGB = true;
break;
break;
default:
break;
break;
}
gGL.getTexUnit(channel)->setTextureFilteringOption(filter_options);
......
......@@ -1180,7 +1180,7 @@ void LLShaderMgr::initAttribsAndUniforms()
llassert(mReservedUniforms.size() == LLShaderMgr::MULTI_LIGHT_FAR_Z+1);
//NOTE: MUST match order in eGLSLReservedUniforms
mReservedUniforms.push_back("proj_mat");
mReservedUniforms.push_back("proj_near");
mReservedUniforms.push_back("proj_p");
......
......@@ -812,17 +812,6 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>FramePerSecondLimit</key>
<map>
<key>Comment</key>
<string>Controls upper limit of frames per second</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>120</integer>
</map>
<key>BackgroundYieldTime</key>
<map>
<key>Comment</key>
......
/**
/**
* @file WLCloudsV.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2005, 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$
*/
......@@ -33,26 +33,26 @@ ATTRIBUTE vec2 texcoord0;
///////////////////////////////////////////////////////////////////////////////
// Output parameters
VARYING vec4 vary_CloudColorSun;
VARYING vec4 vary_CloudColorAmbient;
VARYING vec4 vary_CloudColorSun;
VARYING vec4 vary_CloudColorAmbient;
VARYING float vary_CloudDensity;
VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3;
VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3;
VARYING float altitude_blend_factor;
// Inputs
uniform vec3 camPosLocal;
uniform vec4 lightnorm;
uniform vec4 sunlight_color;
uniform vec4 moonlight_color;
uniform int sun_up_factor;
uniform vec4 ambient_color;
uniform vec4 blue_horizon;
uniform vec4 blue_density;
uniform vec4 lightnorm;
uniform vec4 sunlight_color;
uniform vec4 moonlight_color;
uniform int sun_up_factor;
uniform vec4 ambient_color;
uniform vec4 blue_horizon;
uniform vec4 blue_density;
uniform float haze_horizon;
uniform float haze_density;
......@@ -60,7 +60,7 @@ uniform float cloud_shadow;
uniform float density_multiplier;
uniform float max_y;
uniform vec4 glow;
uniform vec4 glow;
uniform float sun_moon_glow_factor;
uniform vec4 cloud_color;
......@@ -70,133 +70,123 @@ uniform float cloud_scale;
// NOTE: Keep these in sync!
// indra\newview\app_settings\shaders\class1\deferred\skyV.glsl
// indra\newview\app_settings\shaders\class1\deferred\cloudsV.glsl
// indra\newview\app-settings\shaders\class2\windlight\cloudsV.glsl
// indra\newview\lllegacyatmospherics.cpp
// indra\newview\llsettingsvo.cpp
void main()
{
// World / view / projection
gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
// Texture coords
vary_texcoord0 = texcoord0;
vary_texcoord0.xy -= 0.5;
vary_texcoord0.xy /= cloud_scale;
vary_texcoord0.xy += 0.5;
vary_texcoord1 = vary_texcoord0;
vary_texcoord1.x += lightnorm.x * 0.0125;
vary_texcoord1.y += lightnorm.z * 0.0125;
vary_texcoord2 = vary_texcoord0 * 16.;
vary_texcoord3 = vary_texcoord1 * 16.;
// Get relative position
vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
altitude_blend_factor = clamp((P.y + 512.0) / max_y, 0.0, 1.0);
// Set altitude
if (P.y > 0.)
{
P *= (max_y / P.y);
}
else
{
altitude_blend_factor = 0; // SL-11589 Fix clouds drooping below horizon
P *= (-32000. / P.y);
}
// Can normalize then
vec3 Pn = normalize(P);
float Plen = length(P);
// Initialize temp variables
vec4 temp1 = vec4(0.);
vec4 temp2 = vec4(0.);
vec4 blue_weight;
vec4 haze_weight;
//vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
vec4 sunlight = sunlight_color;
vec4 light_atten;
float dens_mul = density_multiplier;
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
light_atten = (blue_density + vec4(haze_density * 0.25)) * (dens_mul * max_y);
// Calculate relative weights
temp1 = abs(blue_density) + vec4(abs(haze_density));
blue_weight = blue_density / temp1;
haze_weight = haze_density / temp1;
// Compute sunlight from P & lightnorm (for long rays like sky)
temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y );
temp2.y = 1. / temp2.y;
sunlight *= exp( - light_atten * temp2.y);
// Distance
temp2.z = Plen * dens_mul;
// Transparency (-> temp1)
// ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
// compiler gets confused.
temp1 = exp(-temp1 * temp2.z);
// Compute haze glow
temp2.x = dot(Pn, lightnorm.xyz);
temp2.x = 1. - temp2.x;
// temp2.x is 0 at the sun and increases away from sun
temp2.x = max(temp2.x, .001);
// Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
temp2.x *= glow.x;
// Higher glow.x gives dimmer glow (because next step is 1 / "angle")
temp2.x = pow(temp2.x, glow.z);
// glow.z should be negative, so we're doing a sort of (1 / "angle") function
temp2.x *= sun_moon_glow_factor;
// Add "minimum anti-solar illumination"
temp2.x += .25;
// Increase ambient when there are more clouds
vec4 tmpAmbient = ambient_color;
tmpAmbient += (1. - tmpAmbient) * cloud_shadow * 0.5;
// Dim sunlight by cloud shadow percentage
sunlight *= (1. - cloud_shadow);
// Haze color below cloud
vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient)
+ (haze_horizon * haze_weight) * (sunlight * temp2.x + tmpAmbient)
);
// CLOUDS
temp2.y = max(0., lightnorm.y * 2.);
temp2.y = 1. / temp2.y;
sunlight *= exp( - light_atten * temp2.y);