Skip to content

Commit 2b25553

Browse files
2590 mac intel and radeon pro 5300m horrible fps 2 (#3030)
* OpenGL 3.3 compatibility pass. Fix for FBO driven downscaling corrupting textures. * Increase maximum texture bias, immediately scale down when textures are loaded higher resolution than desired * #2590 Fix for some frame stalls on Intel Macs
1 parent 13c0708 commit 2b25553

28 files changed

+183
-94
lines changed

indra/llrender/llimagegl.cpp

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,41 +2452,32 @@ bool LLImageGL::scaleDown(S32 desired_discard)
24522452

24532453
if (gGLManager.mDownScaleMethod == 0)
24542454
{ // use an FBO to downscale the texture
2455-
// allocate new texture
2456-
U32 temp_texname = 0;
2457-
generateTextures(1, &temp_texname);
2458-
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, temp_texname, true);
2459-
{
2460-
LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glTexImage2D");
2461-
glTexImage2D(mTarget, 0, mFormatInternal, desired_width, desired_height, 0, mFormatPrimary, mFormatType, NULL);
2462-
}
2463-
2464-
// account for new texture getting created
2465-
alloc_tex_image(desired_width, desired_height, mFormatInternal, 1);
2466-
2467-
// Use render-to-texture to scale down the texture
2468-
{
2469-
LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glFramebufferTexture2D");
2470-
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, mTarget, temp_texname, 0);
2471-
}
2472-
24732455
glViewport(0, 0, desired_width, desired_height);
24742456

24752457
// draw a full screen triangle
2476-
gGL.getTexUnit(0)->bind(this);
2477-
glDrawArrays(GL_TRIANGLES, 0, 3);
2478-
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
2458+
if (gGL.getTexUnit(0)->bind(this, true, true))
2459+
{
2460+
glDrawArrays(GL_TRIANGLES, 0, 3);
24792461

2480-
// delete old texture and assign new texture name
2481-
deleteTextures(1, &mTexName);
2482-
mTexName = temp_texname;
2462+
free_tex_image(mTexName);
2463+
glTexImage2D(mTarget, 0, mFormatInternal, desired_width, desired_height, 0, mFormatPrimary, mFormatType, nullptr);
2464+
glCopyTexSubImage2D(mTarget, 0, 0, 0, 0, 0, desired_width, desired_height);
2465+
alloc_tex_image(desired_width, desired_height, mFormatInternal, 1);
24832466

2484-
if (mHasMipMaps)
2485-
{ // generate mipmaps if needed
2486-
LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glGenerateMipmap");
2487-
gGL.getTexUnit(0)->bind(this);
2488-
glGenerateMipmap(mTarget);
2489-
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
2467+
mTexOptionsDirty = true;
2468+
2469+
if (mHasMipMaps)
2470+
{ // generate mipmaps if needed
2471+
LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glGenerateMipmap");
2472+
gGL.getTexUnit(0)->bind(this);
2473+
glGenerateMipmap(mTarget);
2474+
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
2475+
}
2476+
}
2477+
else
2478+
{
2479+
LL_WARNS_ONCE("LLImageGL") << "Failed to bind texture for downscaling." << LL_ENDL;
2480+
return false;
24902481
}
24912482
}
24922483
else

indra/llrender/llvertexbuffer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,13 @@ static GLuint gen_buffer()
272272
{
273273
LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("gen buffer");
274274
sIndex = pool_size;
275+
#if !LL_DARWIN
275276
if (!gGLManager.mIsAMD)
276277
{
277278
glGenBuffers(pool_size, sNamePool);
278279
}
279280
else
281+
#endif
280282
{ // work around for AMD driver bug
281283
for (U32 i = 0; i < pool_size; ++i)
282284
{
@@ -942,6 +944,10 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
942944
void LLVertexBuffer::initClass(LLWindow* window)
943945
{
944946
llassert(sVBOPool == nullptr);
947+
948+
LL_INFOS() << "VBO Pooling Disabled" << LL_ENDL;
949+
sVBOPool = new LLAppleVBOPool();
950+
945951
if (gGLManager.mIsApple)
946952
{
947953
LL_INFOS() << "VBO Pooling Disabled" << LL_ENDL;

indra/newview/app_settings/settings.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7836,7 +7836,7 @@
78367836
<key>Type</key>
78377837
<string>U32</string>
78387838
<key>Value</key>
7839-
<integer>1</integer>
7839+
<integer>0</integer>
78407840
</map>
78417841
<key>RenderDebugTextureBind</key>
78427842
<map>
@@ -16038,5 +16038,16 @@
1603816038
<key>Value</key>
1603916039
<integer>0</integer>
1604016040
</map>
16041+
<key>RenderHDREnabled</key>
16042+
<map>
16043+
<key>Comment</key>
16044+
<string>Enable HDR rendering.</string>
16045+
<key>Persist</key>
16046+
<integer>1</integer>
16047+
<key>Type</key>
16048+
<string>Boolean</string>
16049+
<key>Value</key>
16050+
<integer>1</integer>
16051+
</map>
1604116052
</map>
1604216053
</llsd>

indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ in vec2 vary_texcoord0;
3636
in vec3 vary_position;
3737

3838
void mirrorClip(vec3 pos);
39+
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
3940

4041
void main()
4142
{
@@ -51,7 +52,7 @@ void main()
5152
frag_data[0] = vec4(diff.rgb, 0.0);
5253
frag_data[1] = vec4(0,0,0,0);
5354
vec3 nvn = normalize(vary_normal);
54-
frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
55+
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
5556
frag_data[3] = vec4(0);
5657
}
5758

indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ in vec2 vary_texcoord0;
4040
in vec3 vary_position;
4141

4242
void mirrorClip(vec3 pos);
43+
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
44+
4345
void main()
4446
{
4547
mirrorClip(vary_position);
@@ -62,6 +64,6 @@ void main()
6264
frag_data[1] = vertex_color.aaaa; // spec
6365
//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
6466
vec3 nvn = normalize(tnorm);
65-
frag_data[2] = vec4(nvn, GBUFFER_FLAG_HAS_ATMOS);
67+
frag_data[2] = encodeNormal(nvn, GBUFFER_FLAG_HAS_ATMOS);
6668
frag_data[3] = vec4(vertex_color.a, 0, 0, 0);
6769
}

indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ const float ONE_OVER_PI = 0.3183098861;
7575
vec3 srgb_to_linear(vec3 cs);
7676
vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten);
7777

78+
vec4 decodeNormal(vec4 norm);
79+
80+
7881
float calcLegacyDistanceAttenuation(float distance, float falloff)
7982
{
8083
float dist_atten = 1.0 - clamp((distance + falloff)/(1.0 + falloff), 0.0, 1.0);
@@ -145,8 +148,7 @@ vec2 getScreenCoordinate(vec2 screenpos)
145148

146149
vec4 getNorm(vec2 screenpos)
147150
{
148-
vec4 norm = texture(normalMap, screenpos.xy);
149-
norm.xyz = normalize(norm.xyz);
151+
vec4 norm = decodeNormal(texture(normalMap, screenpos.xy));
150152
return norm;
151153
}
152154

indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ in vec2 vary_texcoord0;
3939

4040
void mirrorClip(vec3 pos);
4141

42+
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
43+
4244
void main()
4345
{
4446
mirrorClip(vary_position);
@@ -53,7 +55,7 @@ void main()
5355
frag_data[0] = vec4(col.rgb, 0.0);
5456
frag_data[1] = vec4(0,0,0,0); // spec
5557
vec3 nvn = normalize(vary_normal);
56-
frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
58+
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
5759
frag_data[3] = vec4(0);
5860
}
5961

indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ in vec4 vertex_color;
3636
in vec2 vary_texcoord0;
3737

3838
void mirrorClip(vec3 pos);
39+
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
3940

4041
void main()
4142
{
@@ -51,6 +52,6 @@ void main()
5152
frag_data[0] = vec4(col.rgb, 0.0);
5253
frag_data[1] = vec4(0,0,0,0);
5354
vec3 nvn = normalize(vary_normal);
54-
frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
55+
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
5556
frag_data[3] = vec4(0);
5657
}

indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ uniform sampler2D diffuseMap;
3333

3434
in vec3 vary_normal;
3535
in vec2 vary_texcoord0;
36+
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
3637

3738
void main()
3839
{
@@ -46,7 +47,7 @@ void main()
4647
frag_data[0] = vec4(col.rgb, 0.0);
4748
frag_data[1] = vec4(0,0,0,0); // spec
4849
vec3 nvn = normalize(vary_normal);
49-
frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
50+
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
5051
frag_data[3] = vec4(0);
5152
}
5253

indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ in vec2 vary_texcoord0;
3535
in vec3 vary_position;
3636

3737
void mirrorClip(vec3 pos);
38+
vec4 encodeNormal(vec3 norm, float gbuffer_flag);
3839

3940
void main()
4041
{
4142
mirrorClip(vary_position);
4243
vec3 col = vertex_color.rgb * texture(diffuseMap, vary_texcoord0.xy).rgb;
4344
frag_data[0] = vec4(col, 0.0);
4445
frag_data[1] = vertex_color.aaaa; // spec
45-
//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
4646
vec3 nvn = normalize(vary_normal);
47-
frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
47+
frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
4848
frag_data[3] = vec4(vertex_color.a, 0, 0, 0);
4949
}
5050

0 commit comments

Comments
 (0)