Skip to content

Commit 50740c7

Browse files
author
Rye
authored
Merge pull request #3390 from secondlife/rye/forever-2558
Fix world going black and white on apple gpu
2 parents 98473aa + c883c7f commit 50740c7

File tree

7 files changed

+27
-13
lines changed

7 files changed

+27
-13
lines changed

indra/llrender/llcubemaparray.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ LLCubeMapArray::~LLCubeMapArray()
109109
{
110110
}
111111

112-
void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, bool use_mips)
112+
void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, bool use_mips, bool hdr)
113113
{
114114
U32 texname = 0;
115115
mWidth = resolution;
@@ -128,6 +128,10 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, bool us
128128
free_cur_tex_image();
129129

130130
U32 format = components == 4 ? GL_RGBA16F : GL_RGB16F;
131+
if (!hdr)
132+
{
133+
format = components == 4 ? GL_RGBA8 : GL_RGB8;
134+
}
131135
U32 mip = 0;
132136
U32 mip_resolution = resolution;
133137
while (mip_resolution >= 1)

indra/llrender/llcubemaparray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class LLCubeMapArray : public LLRefCount
5252
// components - number of components per pixel
5353
// count - number of cube maps in the array
5454
// use_mips - if true, mipmaps will be allocated for this cube map array and anisotropic filtering will be used
55-
void allocate(U32 res, U32 components, U32 count, bool use_mips = true);
55+
void allocate(U32 res, U32 components, U32 count, bool use_mips = true, bool hdr = true);
5656
void bind(S32 stage);
5757
void unbind();
5858

indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec
150150
float amb_da = 0.0;//ambiance;
151151
if (da > 0)
152152
{
153-
lit = max(da * dist_atten,0.0);
153+
lit = clamp(da * dist_atten, 0.0, 1.0);
154154
col = lit * light_col * diffuse;
155155
amb_da += (da*0.5+0.5) * ambiance;
156156
}

indra/newview/app_settings/shaders/class3/deferred/materialF.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
140140
float amb_da = ambiance;
141141
if (da >= 0)
142142
{
143-
lit = max(da * dist_atten, 0.0);
143+
lit = clamp(da * dist_atten, 0.0, 1.0);
144144
col = lit * light_col * diffuse;
145145
amb_da += (da*0.5 + 0.5) * ambiance;
146146
}

indra/newview/llheroprobemanager.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ void LLHeroProbeManager::update()
8989

9090
initReflectionMaps();
9191

92+
static LLCachedControl<bool> render_hdr(gSavedSettings, "RenderHDREnabled", true);
93+
9294
if (!mRenderTarget.isComplete())
9395
{
94-
U32 color_fmt = GL_RGBA16F;
96+
U32 color_fmt = render_hdr ? GL_RGBA16F : GL_RGBA8;
9597
mRenderTarget.allocate(mProbeResolution, mProbeResolution, color_fmt, true);
9698
}
9799

@@ -103,7 +105,7 @@ void LLHeroProbeManager::update()
103105
mMipChain.resize(count);
104106
for (U32 i = 0; i < count; ++i)
105107
{
106-
mMipChain[i].allocate(res, res, GL_RGBA16F);
108+
mMipChain[i].allocate(res, res, render_hdr ? GL_RGBA16F : GL_RGBA8);
107109
res /= 2;
108110
}
109111
}
@@ -537,8 +539,10 @@ void LLHeroProbeManager::initReflectionMaps()
537539

538540
mTexture = new LLCubeMapArray();
539541

542+
static LLCachedControl<bool> render_hdr(gSavedSettings, "RenderHDREnabled", true);
543+
540544
// store mReflectionProbeCount+2 cube maps, final two cube maps are used for render target and radiance map generation source)
541-
mTexture->allocate(mProbeResolution, 3, mReflectionProbeCount + 2);
545+
mTexture->allocate(mProbeResolution, 3, mReflectionProbeCount + 2, true, render_hdr);
542546

543547
if (mDefaultProbe.isNull())
544548
{

indra/newview/llreflectionmapmanager.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,11 @@ void LLReflectionMapManager::update()
223223

224224
initReflectionMaps();
225225

226+
static LLCachedControl<bool> render_hdr(gSavedSettings, "RenderHDREnabled", true);
227+
226228
if (!mRenderTarget.isComplete())
227229
{
228-
U32 color_fmt = GL_RGB16F;
230+
U32 color_fmt = render_hdr ? GL_RGBA16F : GL_RGBA8;
229231
U32 targetRes = mProbeResolution * 4; // super sample
230232
mRenderTarget.allocate(targetRes, targetRes, color_fmt, true);
231233
}
@@ -238,7 +240,7 @@ void LLReflectionMapManager::update()
238240
mMipChain.resize(count);
239241
for (U32 i = 0; i < count; ++i)
240242
{
241-
mMipChain[i].allocate(res, res, GL_RGB16F);
243+
mMipChain[i].allocate(res, res, render_hdr ? GL_RGB16F : GL_RGB8);
242244
res /= 2;
243245
}
244246
}
@@ -1415,11 +1417,13 @@ void LLReflectionMapManager::initReflectionMaps()
14151417
{
14161418
mTexture = new LLCubeMapArray();
14171419

1420+
static LLCachedControl<bool> render_hdr(gSavedSettings, "RenderHDREnabled", true);
1421+
14181422
// store mReflectionProbeCount+2 cube maps, final two cube maps are used for render target and radiance map generation source)
1419-
mTexture->allocate(mProbeResolution, 3, mReflectionProbeCount + 2);
1423+
mTexture->allocate(mProbeResolution, 3, mReflectionProbeCount + 2, true, render_hdr);
14201424

14211425
mIrradianceMaps = new LLCubeMapArray();
1422-
mIrradianceMaps->allocate(LL_IRRADIANCE_MAP_RESOLUTION, 3, mReflectionProbeCount, false);
1426+
mIrradianceMaps->allocate(LL_IRRADIANCE_MAP_RESOLUTION, 3, mReflectionProbeCount, false, render_hdr);
14231427
}
14241428

14251429
// reset probe state

indra/newview/llviewercontrol.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ static bool handleDisableVintageMode(const LLSD& newvalue)
261261

262262
static bool handleEnableHDR(const LLSD& newvalue)
263263
{
264+
gPipeline.mReflectionMapManager.reset();
265+
gPipeline.mHeroProbeManager.reset();
264266
return handleReleaseGLBufferChanged(newvalue) && handleSetShaderChanged(newvalue);
265267
}
266268

@@ -448,11 +450,11 @@ static bool handleReflectionProbeDetailChanged(const LLSD& newvalue)
448450
if (gPipeline.isInit())
449451
{
450452
LLPipeline::refreshCachedSettings();
453+
gPipeline.mReflectionMapManager.reset();
454+
gPipeline.mHeroProbeManager.reset();
451455
gPipeline.releaseGLBuffers();
452456
gPipeline.createGLBuffers();
453457
LLViewerShaderMgr::instance()->setShaders();
454-
gPipeline.mReflectionMapManager.reset();
455-
gPipeline.mHeroProbeManager.reset();
456458
}
457459
return true;
458460
}

0 commit comments

Comments
 (0)