Fix large performance drop when enabling AA on macOS/lower end GPU hardware
parent
f8a0878c78
commit
24aef9a982
|
|
@ -338,6 +338,7 @@ S32 LLImageGL::dataFormatBits(S32 dataformat)
|
|||
case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac
|
||||
case GL_DEPTH_COMPONENT: return 24;
|
||||
case GL_DEPTH_COMPONENT24: return 24;
|
||||
case GL_RGBA16: return 64;
|
||||
case GL_R16F: return 16;
|
||||
case GL_RG16F: return 32;
|
||||
case GL_RGB16F: return 48;
|
||||
|
|
|
|||
|
|
@ -1351,6 +1351,10 @@ float4 SMAABlendingWeightCalculationPS(float2 texcoord,
|
|||
//-----------------------------------------------------------------------------
|
||||
// Neighborhood Blending Pixel Shader (Third Pass)
|
||||
|
||||
vec3 srgb_to_linear(vec3 cs);
|
||||
vec4 srgb_to_linear4(vec4 cs);
|
||||
vec3 linear_to_srgb(vec3 cl);
|
||||
|
||||
float4 SMAANeighborhoodBlendingPS(float2 texcoord,
|
||||
float4 offset,
|
||||
SMAATexture2D(colorTex),
|
||||
|
|
@ -1369,6 +1373,7 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord,
|
|||
SMAA_BRANCH
|
||||
if (dot(a, float4(1.0, 1.0, 1.0, 1.0)) < 1e-5) {
|
||||
float4 color = SMAASampleLevelZero(colorTex, texcoord);
|
||||
color.rgb = srgb_to_linear(color.rgb);
|
||||
|
||||
#if SMAA_REPROJECTION
|
||||
float2 velocity = SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, texcoord));
|
||||
|
|
@ -1377,6 +1382,7 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord,
|
|||
color.a = sqrt(5.0 * length(velocity));
|
||||
#endif
|
||||
|
||||
color.rgb = linear_to_srgb(color.rgb);
|
||||
return color;
|
||||
} else {
|
||||
bool h = max(a.x, a.z) > max(a.y, a.w); // max(horizontal) > max(vertical)
|
||||
|
|
@ -1393,8 +1399,13 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord,
|
|||
|
||||
// We exploit bilinear filtering to mix current pixel with the chosen
|
||||
// neighbor:
|
||||
float4 color = blendingWeight.x * SMAASampleLevelZero(colorTex, blendingCoord.xy);
|
||||
color += blendingWeight.y * SMAASampleLevelZero(colorTex, blendingCoord.zw);
|
||||
float4 color = SMAASampleLevelZero(colorTex, blendingCoord.xy);
|
||||
color.rgb = srgb_to_linear(color.rgb);
|
||||
color = blendingWeight.x * color;
|
||||
|
||||
float4 color2 = SMAASampleLevelZero(colorTex, blendingCoord.zw);
|
||||
color2.rgb = srgb_to_linear(color2.rgb);
|
||||
color += blendingWeight.y * color2;
|
||||
|
||||
#if SMAA_REPROJECTION
|
||||
// Antialias velocity for proper reprojection in a later stage:
|
||||
|
|
@ -1405,6 +1416,7 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord,
|
|||
color.a = sqrt(5.0 * length(velocity));
|
||||
#endif
|
||||
|
||||
color.rgb = linear_to_srgb(color.rgb);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -523,12 +523,12 @@ bool LLGLTFPreviewTexture::render()
|
|||
gPipeline.copyScreenSpaceReflections(&screen, &gPipeline.mSceneMap);
|
||||
gPipeline.generateLuminance(&screen, &gPipeline.mLuminanceMap);
|
||||
gPipeline.generateExposure(&gPipeline.mLuminanceMap, &gPipeline.mExposureMap, /*use_history = */ false);
|
||||
gPipeline.gammaCorrect(&screen, &gPipeline.mPostMap);
|
||||
gPipeline.gammaCorrect(&screen, &gPipeline.mPostPingMap);
|
||||
LLVertexBuffer::unbind();
|
||||
gPipeline.generateGlow(&gPipeline.mPostMap);
|
||||
gPipeline.combineGlow(&gPipeline.mPostMap, &screen);
|
||||
gPipeline.renderDoF(&screen, &gPipeline.mPostMap);
|
||||
gPipeline.applyFXAA(&gPipeline.mPostMap, &screen);
|
||||
gPipeline.generateGlow(&gPipeline.mPostPingMap);
|
||||
gPipeline.combineGlow(&gPipeline.mPostPingMap, &screen);
|
||||
gPipeline.renderDoF(&screen, &gPipeline.mPostPingMap);
|
||||
gPipeline.applyFXAA(&gPipeline.mPostPingMap, &screen);
|
||||
|
||||
// *HACK: Restore mExposureMap (it will be consumed by generateExposure next frame)
|
||||
gPipeline.mExposureMap.swapFBORefs(gPipeline.mLastExposure);
|
||||
|
|
|
|||
|
|
@ -856,12 +856,12 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY)
|
|||
|
||||
GLuint screenFormat = hdr ? GL_RGBA16F : GL_RGBA;
|
||||
|
||||
if (!mRT->screen.allocate(resX, resY, GL_RGBA16F)) return false;
|
||||
if (!mRT->screen.allocate(resX, resY, screenFormat)) return false;
|
||||
|
||||
mRT->deferredScreen.shareDepthBuffer(mRT->screen);
|
||||
|
||||
if (shadow_detail > 0 || ssao || RenderDepthOfField)
|
||||
{ //only need mRT->deferredLight for shadows OR ssao OR dof
|
||||
if (hdr || shadow_detail > 0 || ssao || RenderDepthOfField)
|
||||
{ //only need mRT->deferredLight for hdr OR shadows OR ssao OR dof
|
||||
if (!mRT->deferredLight.allocate(resX, resY, screenFormat)) return false;
|
||||
}
|
||||
else
|
||||
|
|
@ -907,7 +907,8 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY)
|
|||
mSceneMap.release();
|
||||
}
|
||||
|
||||
mPostMap.allocate(resX, resY, screenFormat);
|
||||
mPostPingMap.allocate(resX, resY, GL_RGBA);
|
||||
mPostPongMap.allocate(resX, resY, GL_RGBA);
|
||||
|
||||
// The water exclusion mask needs its own depth buffer so we can take care of the problem of multiple water planes.
|
||||
// Should we ever make water not just a plane, it also aids with that as well as the water planes will be rendered into the mask.
|
||||
|
|
@ -1179,7 +1180,8 @@ void LLPipeline::releaseGLBuffers()
|
|||
|
||||
mWaterExclusionMask.release();
|
||||
|
||||
mPostMap.release();
|
||||
mPostPingMap.release();
|
||||
mPostPongMap.release();
|
||||
|
||||
mFXAAMap.release();
|
||||
|
||||
|
|
@ -7585,14 +7587,14 @@ void LLPipeline::generateSMAABuffers(LLRenderTarget* src)
|
|||
{
|
||||
if (!use_sample)
|
||||
{
|
||||
src->bindTexture(0, channel, LLTexUnit::TFO_POINT);
|
||||
gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
|
||||
src->bindTexture(0, channel, LLTexUnit::TFO_BILINEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mSMAASampleMap);
|
||||
gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
|
||||
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
|
||||
}
|
||||
gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
|
||||
}
|
||||
|
||||
//if (use_stencil)
|
||||
|
|
@ -7986,7 +7988,7 @@ void LLPipeline::renderFinalize()
|
|||
|
||||
static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true);
|
||||
bool hdr = gGLManager.mGLVersion > 4.05f && has_hdr();
|
||||
|
||||
LLRenderTarget* postHDRBuffer = &mRT->screen;
|
||||
if (hdr)
|
||||
{
|
||||
copyScreenSpaceReflections(&mRT->screen, &mSceneMap);
|
||||
|
|
@ -7995,22 +7997,31 @@ void LLPipeline::renderFinalize()
|
|||
|
||||
generateExposure(&mLuminanceMap, &mExposureMap);
|
||||
|
||||
tonemap(&mRT->screen, &mPostMap);
|
||||
tonemap(&mRT->screen, &mRT->deferredLight);
|
||||
|
||||
applyCAS(&mPostMap, &mRT->screen);
|
||||
static LLCachedControl<F32> cas_sharpness(gSavedSettings, "RenderCASSharpness", 0.4f);
|
||||
if (cas_sharpness != 0.0f && gCASProgram.isComplete())
|
||||
{
|
||||
applyCAS(&mRT->deferredLight, &mRT->screen);
|
||||
postHDRBuffer = &mRT->screen;
|
||||
}
|
||||
else
|
||||
{
|
||||
postHDRBuffer = &mRT->deferredLight;
|
||||
}
|
||||
}
|
||||
|
||||
generateSMAABuffers(&mRT->screen);
|
||||
|
||||
gammaCorrect(&mRT->screen, &mPostMap);
|
||||
gammaCorrect(postHDRBuffer, &mPostPingMap);
|
||||
|
||||
LLVertexBuffer::unbind();
|
||||
|
||||
applySMAA(&mPostMap, &mRT->screen);
|
||||
generateGlow(&mPostPingMap);
|
||||
|
||||
generateGlow(&mRT->screen);
|
||||
LLRenderTarget* sourceBuffer = &mPostPingMap;
|
||||
LLRenderTarget* targetBuffer = &mPostPongMap;
|
||||
|
||||
combineGlow(&mRT->screen, &mPostMap);
|
||||
combineGlow(sourceBuffer, targetBuffer);
|
||||
std::swap(sourceBuffer, targetBuffer);
|
||||
|
||||
gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft;
|
||||
gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom;
|
||||
|
|
@ -8018,13 +8029,24 @@ void LLPipeline::renderFinalize()
|
|||
gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight();
|
||||
glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]);
|
||||
|
||||
renderDoF(&mPostMap, &mRT->screen);
|
||||
|
||||
LLRenderTarget* finalBuffer = &mRT->screen;
|
||||
if (RenderFSAAType == 1)
|
||||
if((RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) &&
|
||||
RenderDepthOfField &&
|
||||
!gCubeSnapshot)
|
||||
{
|
||||
applyFXAA(&mRT->screen, &mPostMap);
|
||||
finalBuffer = &mPostMap;
|
||||
renderDoF(sourceBuffer, targetBuffer);
|
||||
std::swap(sourceBuffer, targetBuffer);
|
||||
}
|
||||
|
||||
if (RenderFSAAType == 1)
|
||||
{
|
||||
applyFXAA(sourceBuffer, targetBuffer);
|
||||
std::swap(sourceBuffer, targetBuffer);
|
||||
}
|
||||
else if (RenderFSAAType == 2)
|
||||
{
|
||||
generateSMAABuffers(sourceBuffer);
|
||||
applySMAA(sourceBuffer, targetBuffer);
|
||||
std::swap(sourceBuffer, targetBuffer);
|
||||
}
|
||||
|
||||
if (RenderBufferVisualization > -1)
|
||||
|
|
@ -8035,16 +8057,16 @@ void LLPipeline::renderFinalize()
|
|||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
visualizeBuffers(&mRT->deferredScreen, finalBuffer, RenderBufferVisualization);
|
||||
visualizeBuffers(&mRT->deferredScreen, sourceBuffer, RenderBufferVisualization);
|
||||
break;
|
||||
case 4:
|
||||
visualizeBuffers(&mLuminanceMap, finalBuffer, 0);
|
||||
visualizeBuffers(&mLuminanceMap, sourceBuffer, 0);
|
||||
break;
|
||||
case 5:
|
||||
{
|
||||
if (RenderFSAAType > 0)
|
||||
{
|
||||
visualizeBuffers(&mFXAAMap, finalBuffer, 0);
|
||||
visualizeBuffers(&mFXAAMap, sourceBuffer, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -8052,7 +8074,7 @@ void LLPipeline::renderFinalize()
|
|||
{
|
||||
if (RenderFSAAType == 2)
|
||||
{
|
||||
visualizeBuffers(&mSMAABlendBuffer, finalBuffer, 0);
|
||||
visualizeBuffers(&mSMAABlendBuffer, sourceBuffer, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -8066,10 +8088,10 @@ void LLPipeline::renderFinalize()
|
|||
gDeferredPostNoDoFNoiseProgram.bind(); // Add noise as part of final render to screen pass to avoid damaging other post effects
|
||||
|
||||
// Whatever is last in the above post processing chain should _always_ be rendered directly here. If not, expect problems.
|
||||
gDeferredPostNoDoFNoiseProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, finalBuffer);
|
||||
gDeferredPostNoDoFNoiseProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, sourceBuffer);
|
||||
gDeferredPostNoDoFNoiseProgram.bindTexture(LLShaderMgr::DEFERRED_DEPTH, &mRT->deferredScreen, true);
|
||||
|
||||
gDeferredPostNoDoFNoiseProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)finalBuffer->getWidth(), (GLfloat)finalBuffer->getHeight());
|
||||
gDeferredPostNoDoFNoiseProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)sourceBuffer->getWidth(), (GLfloat)sourceBuffer->getHeight());
|
||||
|
||||
{
|
||||
LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS);
|
||||
|
|
|
|||
|
|
@ -730,7 +730,8 @@ public:
|
|||
LLRenderTarget mLastExposure;
|
||||
|
||||
// tonemapped and gamma corrected render ready for post
|
||||
LLRenderTarget mPostMap;
|
||||
LLRenderTarget mPostPingMap;
|
||||
LLRenderTarget mPostPongMap;
|
||||
|
||||
// FXAA helper target
|
||||
LLRenderTarget mFXAAMap;
|
||||
|
|
|
|||
Loading…
Reference in New Issue