summaryrefslogtreecommitdiff
path: root/indra/newview/llviewershadermgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewershadermgr.cpp')
-rw-r--r--indra/newview/llviewershadermgr.cpp278
1 files changed, 218 insertions, 60 deletions
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index d1dea16bc0..58b541b19b 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -194,15 +194,20 @@ LLGLSLShader gDeferredSkinnedEmissiveProgram;
LLGLSLShader gDeferredPostProgram;
LLGLSLShader gDeferredCoFProgram;
LLGLSLShader gDeferredDoFCombineProgram;
+LLGLSLShader gDeferredPostTonemapProgram;
+LLGLSLShader gNoPostTonemapProgram;
LLGLSLShader gDeferredPostGammaCorrectProgram;
-LLGLSLShader gNoPostGammaCorrectProgram;
LLGLSLShader gLegacyPostGammaCorrectProgram;
LLGLSLShader gExposureProgram;
LLGLSLShader gExposureProgramNoFade;
LLGLSLShader gLuminanceProgram;
-LLGLSLShader gFXAAProgram;
+LLGLSLShader gFXAAProgram[4];
+LLGLSLShader gSMAAEdgeDetectProgram[4];
+LLGLSLShader gSMAABlendWeightsProgram[4];
+LLGLSLShader gSMAANeighborhoodBlendProgram[4];
LLGLSLShader gCASProgram;
LLGLSLShader gDeferredPostNoDoFProgram;
+LLGLSLShader gDeferredPostNoDoFNoiseProgram;
LLGLSLShader gDeferredWLSkyProgram;
LLGLSLShader gEnvironmentMapProgram;
LLGLSLShader gDeferredWLCloudProgram;
@@ -427,19 +432,27 @@ void LLViewerShaderMgr::finalizeShaderList()
mShaderList.push_back(&gDeferredWLSunProgram);
mShaderList.push_back(&gDeferredPBRAlphaProgram);
mShaderList.push_back(&gHUDPBRAlphaProgram);
+ mShaderList.push_back(&gDeferredPostTonemapProgram);
+ mShaderList.push_back(&gNoPostTonemapProgram);
mShaderList.push_back(&gDeferredPostGammaCorrectProgram); // for gamma
- mShaderList.push_back(&gNoPostGammaCorrectProgram);
mShaderList.push_back(&gLegacyPostGammaCorrectProgram);
mShaderList.push_back(&gDeferredDiffuseProgram);
mShaderList.push_back(&gDeferredBumpProgram);
mShaderList.push_back(&gDeferredPBROpaqueProgram);
- mShaderList.push_back(&gGLTFPBRMetallicRoughnessProgram);
+
+ if (gSavedSettings.getBOOL("GLTFEnabled"))
+ {
+ mShaderList.push_back(&gGLTFPBRMetallicRoughnessProgram);
+ }
+
mShaderList.push_back(&gDeferredAvatarProgram);
mShaderList.push_back(&gDeferredTerrainProgram);
+
for (U32 paint_type = 0; paint_type < TERRAIN_PAINT_TYPE_COUNT; ++paint_type)
{
mShaderList.push_back(&gDeferredPBRTerrainProgram[paint_type]);
}
+
mShaderList.push_back(&gDeferredDiffuseAlphaMaskProgram);
mShaderList.push_back(&gDeferredNonIndexedDiffuseAlphaMaskProgram);
mShaderList.push_back(&gDeferredTreeProgram);
@@ -1102,9 +1115,17 @@ bool LLViewerShaderMgr::loadShadersDeferred()
gExposureProgramNoFade.unload();
gLuminanceProgram.unload();
gDeferredPostGammaCorrectProgram.unload();
- gNoPostGammaCorrectProgram.unload();
gLegacyPostGammaCorrectProgram.unload();
- gFXAAProgram.unload();
+ gDeferredPostTonemapProgram.unload();
+ gNoPostTonemapProgram.unload();
+ for (auto i = 0; i < 4; ++i)
+ {
+ gFXAAProgram[i].unload();
+ gSMAAEdgeDetectProgram[i].unload();
+ gSMAABlendWeightsProgram[i].unload();
+ gSMAANeighborhoodBlendProgram[i].unload();
+ }
+ gCASProgram.unload();
gEnvironmentMapProgram.unload();
gDeferredWLSkyProgram.unload();
gDeferredWLCloudProgram.unload();
@@ -1326,20 +1347,30 @@ bool LLViewerShaderMgr::loadShadersDeferred()
llassert(success);
}
- if (success)
+ if (gSavedSettings.getBOOL("GLTFEnabled"))
{
- gGLTFPBRMetallicRoughnessProgram.mName = "GLTF PBR Metallic Roughness Shader";
- gGLTFPBRMetallicRoughnessProgram.mFeatures.hasSrgb = true;
+ if (success)
+ {
+ gGLTFPBRMetallicRoughnessProgram.mName = "GLTF PBR Metallic Roughness Shader";
+ gGLTFPBRMetallicRoughnessProgram.mFeatures.hasSrgb = true;
- gGLTFPBRMetallicRoughnessProgram.mShaderFiles.clear();
- gGLTFPBRMetallicRoughnessProgram.mShaderFiles.push_back(make_pair("gltf/pbrmetallicroughnessV.glsl", GL_VERTEX_SHADER));
- gGLTFPBRMetallicRoughnessProgram.mShaderFiles.push_back(make_pair("gltf/pbrmetallicroughnessF.glsl", GL_FRAGMENT_SHADER));
- gGLTFPBRMetallicRoughnessProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
- gGLTFPBRMetallicRoughnessProgram.clearPermutations();
+ gGLTFPBRMetallicRoughnessProgram.mShaderFiles.clear();
+ gGLTFPBRMetallicRoughnessProgram.mShaderFiles.push_back(make_pair("gltf/pbrmetallicroughnessV.glsl", GL_VERTEX_SHADER));
+ gGLTFPBRMetallicRoughnessProgram.mShaderFiles.push_back(make_pair("gltf/pbrmetallicroughnessF.glsl", GL_FRAGMENT_SHADER));
+ gGLTFPBRMetallicRoughnessProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
+ gGLTFPBRMetallicRoughnessProgram.clearPermutations();
- success = make_gltf_variants(gGLTFPBRMetallicRoughnessProgram, use_sun_shadow);
+ success = make_gltf_variants(gGLTFPBRMetallicRoughnessProgram, use_sun_shadow);
- llassert(success);
+ //llassert(success);
+ if (!success)
+ {
+ LL_WARNS() << "Failed to create GLTF PBR Metallic Roughness Shader, disabling!" << LL_ENDL;
+ gSavedSettings.setBOOL("RenderCanUseGLTFPBROpaqueShaders", false);
+ // continue as if this shader never happened
+ success = true;
+ }
+ }
}
if (success)
@@ -2309,21 +2340,6 @@ bool LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
- gNoPostGammaCorrectProgram.mName = "No Post Gamma Correction Post Process";
- gNoPostGammaCorrectProgram.mFeatures.hasSrgb = true;
- gNoPostGammaCorrectProgram.mFeatures.isDeferred = true;
- gNoPostGammaCorrectProgram.mShaderFiles.clear();
- gNoPostGammaCorrectProgram.clearPermutations();
- gNoPostGammaCorrectProgram.addPermutation("NO_POST", "1");
- gNoPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
- gNoPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredGammaCorrect.glsl", GL_FRAGMENT_SHADER));
- gNoPostGammaCorrectProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
- success = gNoPostGammaCorrectProgram.createShader();
- llassert(success);
- }
-
- if (success)
- {
gLegacyPostGammaCorrectProgram.mName = "Legacy Gamma Correction Post Process";
gLegacyPostGammaCorrectProgram.mFeatures.hasSrgb = true;
gLegacyPostGammaCorrectProgram.mFeatures.isDeferred = true;
@@ -2337,27 +2353,143 @@ bool LLViewerShaderMgr::loadShadersDeferred()
llassert(success);
}
+ if (success)
+ {
+ gDeferredPostTonemapProgram.mName = "Deferred Tonemap Post Process";
+ gDeferredPostTonemapProgram.mFeatures.hasSrgb = true;
+ gDeferredPostTonemapProgram.mFeatures.isDeferred = true;
+ gDeferredPostTonemapProgram.mShaderFiles.clear();
+ gDeferredPostTonemapProgram.clearPermutations();
+ gDeferredPostTonemapProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
+ gDeferredPostTonemapProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredTonemap.glsl", GL_FRAGMENT_SHADER));
+ gDeferredPostTonemapProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
+ success = gDeferredPostTonemapProgram.createShader();
+ llassert(success);
+ }
- if (success && gGLManager.mGLVersion > 3.9f)
+ if (success)
{
- gFXAAProgram.mName = "FXAA Shader";
- gFXAAProgram.mFeatures.isDeferred = true;
- gFXAAProgram.mShaderFiles.clear();
- gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER));
- gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/fxaaF.glsl", GL_FRAGMENT_SHADER));
+ gNoPostTonemapProgram.mName = "No Post Tonemap Post Process";
+ gNoPostTonemapProgram.mFeatures.hasSrgb = true;
+ gNoPostTonemapProgram.mFeatures.isDeferred = true;
+ gNoPostTonemapProgram.mShaderFiles.clear();
+ gNoPostTonemapProgram.clearPermutations();
+ gNoPostTonemapProgram.addPermutation("NO_POST", "1");
+ gNoPostTonemapProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
+ gNoPostTonemapProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredTonemap.glsl", GL_FRAGMENT_SHADER));
+ gNoPostTonemapProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
+ success = gNoPostTonemapProgram.createShader();
+ llassert(success);
+ }
- if (gGLManager.mGLVersion > 3.9)
+ if (success && gGLManager.mGLVersion > 3.9f)
+ {
+ std::vector<std::pair<std::string, std::string>> quality_levels = { {"12", "Low"},
+ {"23", "Medium"},
+ {"28", "High"},
+ {"39", "Ultra"} };
+ int i = 0;
+ for (const auto& quality_pair : quality_levels)
{
- gFXAAProgram.addPermutation("FXAA_GLSL_400", "1");
+ if (success)
+ {
+ gFXAAProgram[i].mName = llformat("FXAA Shader (%s)", quality_pair.second.c_str());
+ gFXAAProgram[i].mFeatures.isDeferred = true;
+ gFXAAProgram[i].mShaderFiles.clear();
+ gFXAAProgram[i].mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER));
+ gFXAAProgram[i].mShaderFiles.push_back(make_pair("deferred/fxaaF.glsl", GL_FRAGMENT_SHADER));
+
+ gFXAAProgram[i].clearPermutations();
+ gFXAAProgram[i].addPermutation("FXAA_QUALITY__PRESET", quality_pair.first);
+ if (gGLManager.mGLVersion > 3.9)
+ {
+ gFXAAProgram[i].addPermutation("FXAA_GLSL_400", "1");
+ }
+ else
+ {
+ gFXAAProgram[i].addPermutation("FXAA_GLSL_130", "1");
+ }
+
+ gFXAAProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED];
+ success = gFXAAProgram[i].createShader();
+ llassert(success);
+ }
+ ++i;
}
- else
+ }
+
+ if (success)
+ {
+ std::vector<std::pair<std::string, std::string>> quality_levels = { {"SMAA_PRESET_LOW", "Low"},
+ {"SMAA_PRESET_MEDIUM", "Medium"},
+ {"SMAA_PRESET_HIGH", "High"},
+ {"SMAA_PRESET_ULTRA", "Ultra"} };
+ int i = 0;
+ for (const auto& smaa_pair : quality_levels)
{
- gFXAAProgram.addPermutation("FXAA_GLSL_130", "1");
- }
+ std::map<std::string, std::string> defines;
+ if (gGLManager.mGLVersion >= 4.f)
+ defines.emplace("SMAA_GLSL_4", "1");
+ else if (gGLManager.mGLVersion >= 3.1f)
+ defines.emplace("SMAA_GLSL_3", "1");
+ else
+ defines.emplace("SMAA_GLSL_2", "1");
+ defines.emplace("SMAA_PREDICATION", "0");
+ defines.emplace("SMAA_REPROJECTION", "0");
+ defines.emplace(smaa_pair.first, "1");
- gFXAAProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
- success = gFXAAProgram.createShader();
- llassert(success);
+ if (success)
+ {
+ gSMAAEdgeDetectProgram[i].mName = llformat("SMAA Edge Detection (%s)", smaa_pair.second.c_str());
+ gSMAAEdgeDetectProgram[i].mFeatures.isDeferred = true;
+
+ gSMAAEdgeDetectProgram[i].clearPermutations();
+ gSMAAEdgeDetectProgram[i].addPermutations(defines);
+
+ gSMAAEdgeDetectProgram[i].mShaderFiles.clear();
+ gSMAAEdgeDetectProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAAEdgeDetectF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gSMAAEdgeDetectProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAAEdgeDetectV.glsl", GL_VERTEX_SHADER_ARB));
+ gSMAAEdgeDetectProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_FRAGMENT_SHADER_ARB));
+ gSMAAEdgeDetectProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_VERTEX_SHADER_ARB));
+ gSMAAEdgeDetectProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED];
+ success = gSMAAEdgeDetectProgram[i].createShader();
+ }
+
+ if (success)
+ {
+ gSMAABlendWeightsProgram[i].mName = llformat("SMAA Blending Weights (%s)", smaa_pair.second.c_str());
+ gSMAABlendWeightsProgram[i].mFeatures.isDeferred = true;
+
+ gSMAABlendWeightsProgram[i].clearPermutations();
+ gSMAABlendWeightsProgram[i].addPermutations(defines);
+
+ gSMAABlendWeightsProgram[i].mShaderFiles.clear();
+ gSMAABlendWeightsProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAABlendWeightsF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gSMAABlendWeightsProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAABlendWeightsV.glsl", GL_VERTEX_SHADER_ARB));
+ gSMAABlendWeightsProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_FRAGMENT_SHADER_ARB));
+ gSMAABlendWeightsProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_VERTEX_SHADER_ARB));
+ gSMAABlendWeightsProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED];
+ success = gSMAABlendWeightsProgram[i].createShader();
+ }
+
+ if (success)
+ {
+ gSMAANeighborhoodBlendProgram[i].mName = llformat("SMAA Neighborhood Blending (%s)", smaa_pair.second.c_str());
+ gSMAANeighborhoodBlendProgram[i].mFeatures.isDeferred = true;
+
+ gSMAANeighborhoodBlendProgram[i].clearPermutations();
+ gSMAANeighborhoodBlendProgram[i].addPermutations(defines);
+
+ gSMAANeighborhoodBlendProgram[i].mShaderFiles.clear();
+ gSMAANeighborhoodBlendProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAANeighborhoodBlendF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gSMAANeighborhoodBlendProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAANeighborhoodBlendV.glsl", GL_VERTEX_SHADER_ARB));
+ gSMAANeighborhoodBlendProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_FRAGMENT_SHADER_ARB));
+ gSMAANeighborhoodBlendProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_VERTEX_SHADER_ARB));
+ gSMAANeighborhoodBlendProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED];
+ success = gSMAANeighborhoodBlendProgram[i].createShader();
+ }
+ ++i;
+ }
}
if (success)
@@ -2421,6 +2553,22 @@ bool LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
+ gDeferredPostNoDoFNoiseProgram.mName = "Deferred Post NoDoF Noise Shader";
+ gDeferredPostNoDoFNoiseProgram.mFeatures.isDeferred = true;
+ gDeferredPostNoDoFNoiseProgram.mShaderFiles.clear();
+ gDeferredPostNoDoFNoiseProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
+ gDeferredPostNoDoFNoiseProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoDoFF.glsl", GL_FRAGMENT_SHADER));
+
+ gDeferredPostNoDoFNoiseProgram.clearPermutations();
+ gDeferredPostNoDoFNoiseProgram.addPermutation("HAS_NOISE", "1");
+
+ gDeferredPostNoDoFNoiseProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
+ success = gDeferredPostNoDoFNoiseProgram.createShader();
+ llassert(success);
+ }
+
+ if (success)
+ {
gEnvironmentMapProgram.mName = "Environment Map Program";
gEnvironmentMapProgram.mShaderFiles.clear();
gEnvironmentMapProgram.mFeatures.calculatesAtmospherics = true;
@@ -3002,23 +3150,33 @@ bool LLViewerShaderMgr::loadShadersInterface()
success = gCopyDepthProgram.createShader();
}
- if (success)
+ if (gSavedSettings.getBOOL("LocalTerrainPaintEnabled"))
{
- LLGLSLShader* shader = &gPBRTerrainBakeProgram;
- U32 bit_depth = gSavedSettings.getU32("TerrainPaintBitDepth");
- // LLTerrainPaintMap currently uses an RGB8 texture internally
- bit_depth = llclamp(bit_depth, 1, 8);
- shader->mName = llformat("Terrain Bake Shader RGB%o", bit_depth);
- shader->mFeatures.isPBRTerrain = true;
+ if (success)
+ {
+ LLGLSLShader* shader = &gPBRTerrainBakeProgram;
+ U32 bit_depth = gSavedSettings.getU32("TerrainPaintBitDepth");
+ // LLTerrainPaintMap currently uses an RGB8 texture internally
+ bit_depth = llclamp(bit_depth, 1, 8);
+ shader->mName = llformat("Terrain Bake Shader RGB%o", bit_depth);
+ shader->mFeatures.isPBRTerrain = true;
- shader->mShaderFiles.clear();
- shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeV.glsl", GL_VERTEX_SHADER));
- shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeF.glsl", GL_FRAGMENT_SHADER));
- shader->mShaderLevel = mShaderLevel[SHADER_INTERFACE];
- const U32 value_range = (1 << bit_depth) - 1;
- shader->addPermutation("TERRAIN_PAINT_PRECISION", llformat("%d", value_range));
- success = success && shader->createShader();
- llassert(success);
+ shader->mShaderFiles.clear();
+ shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeV.glsl", GL_VERTEX_SHADER));
+ shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeF.glsl", GL_FRAGMENT_SHADER));
+ shader->mShaderLevel = mShaderLevel[SHADER_INTERFACE];
+ const U32 value_range = (1 << bit_depth) - 1;
+ shader->addPermutation("TERRAIN_PAINT_PRECISION", llformat("%d", value_range));
+ success = success && shader->createShader();
+ //llassert(success);
+ if (!success)
+ {
+ LL_WARNS() << "Failed to create shader '" << shader->mName << "', disabling!" << LL_ENDL;
+ gSavedSettings.setBOOL("RenderCanUseTerrainBakeShaders", false);
+ // continue as if this shader never happened
+ success = true;
+ }
+ }
}
if (success)