diff options
-rw-r--r-- | indra/llrender/llgl.cpp | 12 | ||||
-rw-r--r-- | indra/llrender/llgl.h | 1 | ||||
-rw-r--r-- | indra/llwindow/llwindowwin32.cpp | 8 | ||||
-rw-r--r-- | indra/newview/app_settings/settings.xml | 13 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl | 11 | ||||
-rw-r--r-- | indra/newview/featuretable.txt | 2 | ||||
-rw-r--r-- | indra/newview/featuretable_mac.txt | 6 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 21 | ||||
-rw-r--r-- | indra/newview/llfloaterregioninfo.cpp | 8 | ||||
-rw-r--r-- | indra/newview/llglsandbox.cpp | 59 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 7 | ||||
-rwxr-xr-x | indra/newview/llviewerregion.cpp | 11 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 84 | ||||
-rw-r--r-- | indra/newview/llviewerstats.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llviewertexture.cpp | 69 | ||||
-rw-r--r-- | indra/newview/llviewertexturelist.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llvovolume.cpp | 15 | ||||
-rw-r--r-- | indra/newview/llvovolume.h | 1 | ||||
-rw-r--r-- | indra/newview/llwearablelist.cpp | 17 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_viewer.xml | 3 |
20 files changed, 209 insertions, 144 deletions
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 6f1744b042..02996ecc86 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -1034,6 +1034,7 @@ void LLGLManager::initWGL() GLH_EXT_NAME(wglGetGPUIDsAMD) = (PFNWGLGETGPUIDSAMDPROC)GLH_EXT_GET_PROC_ADDRESS("wglGetGPUIDsAMD"); GLH_EXT_NAME(wglGetGPUInfoAMD) = (PFNWGLGETGPUINFOAMDPROC)GLH_EXT_GET_PROC_ADDRESS("wglGetGPUInfoAMD"); } + mHasNVXGpuMemoryInfo = ExtensionExists("GL_NVX_gpu_memory_info", gGLHExts.mSysExts); if (ExtensionExists("WGL_EXT_swap_control", gGLHExts.mSysExts)) { @@ -1201,6 +1202,17 @@ bool LLGLManager::initGL() LL_WARNS("RenderInit") << "VRAM Detected (AMDAssociations):" << mVRAM << LL_ENDL; } } + else if (mHasNVXGpuMemoryInfo) + { + GLint mem_kb = 0; + glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &mem_kb); + mVRAM = mem_kb / 1024; + + if (mVRAM != 0) + { + LL_WARNS("RenderInit") << "VRAM Detected (NVXGpuMemoryInfo):" << mVRAM << LL_ENDL; + } + } #endif #if LL_WINDOWS diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index be1c0a532a..cd1ba55b16 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -97,6 +97,7 @@ public: // Vendor-specific extensions bool mHasAMDAssociations = false; + bool mHasNVXGpuMemoryInfo = false; bool mIsAMD; bool mIsNVIDIA; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index ad657429ef..76788de876 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -4631,6 +4631,12 @@ void LLWindowWin32::LLWindowWin32Thread::checkDXMem() { if (!mGLReady || mGotGLBuffer) { return; } + if ((gGLManager.mHasAMDAssociations || gGLManager.mHasNVXGpuMemoryInfo) && gGLManager.mVRAM != 0) + { // OpenGL already told us the memory budget, don't ask DX + mGotGLBuffer = true; + return; + } + IDXGIFactory4* p_factory = nullptr; HRESULT res = CreateDXGIFactory1(__uuidof(IDXGIFactory4), (void**)&p_factory); @@ -4727,7 +4733,7 @@ void LLWindowWin32::LLWindowWin32Thread::run() { LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32; - // Check memory budget using DirectX + // Check memory budget using DirectX if OpenGL doesn't have the means to tell us checkDXMem(); if (mWindowHandleThrd != 0) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index e1556e9a1b..72c0888644 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -7194,6 +7194,17 @@ <key>Value</key> <integer>1</integer> </map> + <key>RenderCanUseTerrainBakeShaders</key> + <map> + <key>Comment</key> + <string>Hardware has support for Terrain Bake shaders</string> + <key>Persist</key> + <integer>0</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> <key>RenderClass1MemoryBandwidth</key> <map> <key>Comment</key> @@ -9402,7 +9413,7 @@ <key>Comment</key> <string>EXPERIMENTAL: Enable PBR Terrain texture transforms.</string> <key>Persist</key> - <integer>1</integer> + <integer>0</integer> <key>Type</key> <string>Boolean</string> <key>Value</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index ab0e4fd4d8..3319e32cdf 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -99,10 +99,13 @@ void calcHalfVectors(vec3 lv, vec3 n, vec3 v, { l = normalize(lv); h = normalize(l + v); - nh = clamp(dot(n, h), 0.0, 1.0); - nl = clamp(dot(n, l), 0.0, 1.0); - nv = clamp(dot(n, v), 0.0, 1.0); - vh = clamp(dot(v, h), 0.0, 1.0); + + // lower bound to avoid divide by zero + float eps = 0.000001; + nh = clamp(dot(n, h), eps, 1.0); + nl = clamp(dot(n, l), eps, 1.0); + nv = clamp(dot(n, v), eps, 1.0); + vh = clamp(dot(v, h), eps, 1.0); lightDist = length(lv); } diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 9c585f1ef8..24fd7928a6 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -208,7 +208,7 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 RenderMaxPartCount 1 4096 RenderLocalLightCount 1 1024 -RenderTransparentWater 1 1 +RenderTransparentWater 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTerrainPBRDetail 1 0 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index d66717e2c7..2e220d2b1c 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -135,7 +135,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 1.0 RenderTerrainPBRDetail 1 -1 RenderTerrainPBRPlanarSampleCount 1 1 -RenderTransparentWater 1 1 +RenderTransparentWater 1 0 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.125 RenderDeferredSSAO 1 0 @@ -172,7 +172,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTerrainPBRDetail 1 0 RenderTerrainPBRPlanarSampleCount 1 1 -RenderTransparentWater 1 1 +RenderTransparentWater 1 0 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.25 RenderDeferredSSAO 1 0 @@ -209,7 +209,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTerrainPBRDetail 1 0 RenderTerrainPBRPlanarSampleCount 1 1 -RenderTransparentWater 1 1 +RenderTransparentWater 1 0 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.375 RenderDeferredSSAO 1 0 diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 76b828aebf..f204bdf0eb 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -747,7 +747,9 @@ bool LLAppViewer::init() // inits from settings.xml and from strings.xml if (!initConfiguration()) { - LL_ERRS("InitInfo") << "initConfiguration() failed." << LL_ENDL; + LL_WARNS("InitInfo") << "initConfiguration() failed." << LL_ENDL; + // quit immediately + return false; } LL_INFOS("InitInfo") << "Configuration initialized." << LL_ENDL ; @@ -914,7 +916,9 @@ bool LLAppViewer::init() if (!initHardwareTest()) { // Early out from user choice. - LL_ERRS("InitInfo") << "initHardwareTest() failed." << LL_ENDL; + LL_WARNS("InitInfo") << "initHardwareTest() failed." << LL_ENDL; + // quit immediately + return false; } LL_INFOS("InitInfo") << "Hardware test initialization done." << LL_ENDL ; @@ -930,7 +934,9 @@ bool LLAppViewer::init() { std::string msg = LLTrans::getString("MBUnableToAccessFile"); OSMessageBox(msg.c_str(), LLStringUtil::null, OSMB_OK); - LL_ERRS("InitInfo") << "Failed to init cache" << LL_ENDL; + LL_WARNS("InitInfo") << "Failed to init cache" << LL_ENDL; + // quit immediately + return false; } LL_INFOS("InitInfo") << "Cache initialization is done." << LL_ENDL ; @@ -963,7 +969,9 @@ bool LLAppViewer::init() if (!gGLManager.mHasRequirements) { // Already handled with a MBVideoDrvErr - LL_ERRS("InitInfo") << "gGLManager.mHasRequirements is false." << LL_ENDL; + LL_WARNS("InitInfo") << "gGLManager.mHasRequirements is false." << LL_ENDL; + // quit immediately + return false; } // Without SSE2 support we will crash almost immediately, warn here. @@ -973,7 +981,9 @@ bool LLAppViewer::init() // all hell breaks lose. std::string msg = LLNotifications::instance().getGlobalString("UnsupportedCPUSSE2"); OSMessageBox(msg.c_str(), LLStringUtil::null, OSMB_OK); - LL_ERRS("InitInfo") << "SSE2 is not supported" << LL_ENDL; + LL_WARNS("InitInfo") << "SSE2 is not supported" << LL_ENDL; + // quit immediately + return false; } // alert the user if they are using unsupported hardware @@ -3977,7 +3987,6 @@ void LLAppViewer::forceQuit() LLApp::setQuitting(); } -//TODO: remove void LLAppViewer::fastQuit(S32 error_code) { // finish pending transfers diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index a94661ad7c..0da250644e 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -268,7 +268,7 @@ bool LLFloaterRegionInfo::postBuild() mInfoPanels.push_back(panel); static LLCachedControl<bool> feature_pbr_terrain_enabled(gSavedSettings, "RenderTerrainPBREnabled", false); static LLCachedControl<bool> feature_pbr_terrain_transforms_enabled(gSavedSettings, "RenderTerrainPBRTransformsEnabled", false); - if (!feature_pbr_terrain_transforms_enabled || !feature_pbr_terrain_enabled) + if (!feature_pbr_terrain_transforms_enabled() || !feature_pbr_terrain_enabled()) { panel->buildFromFile("panel_region_terrain.xml"); } @@ -1694,7 +1694,7 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) static LLCachedControl<bool> feature_pbr_terrain_enabled(gSavedSettings, "RenderTerrainPBREnabled", false); const bool textures_ready = compp->makeTexturesReady(false, false); - const bool materials_ready = feature_pbr_terrain_enabled && compp->makeMaterialsReady(false, false); + const bool materials_ready = feature_pbr_terrain_enabled() && compp->makeMaterialsReady(false, false); bool set_texture_swatches; bool set_material_swatches; @@ -1724,7 +1724,7 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) { material_type_to_ctrl(mMaterialTypeCtrl, material_type); updateForMaterialType(); - mMaterialTypeCtrl->setVisible(feature_pbr_terrain_enabled); + mMaterialTypeCtrl->setVisible(feature_pbr_terrain_enabled()); } if (set_texture_swatches) @@ -1938,7 +1938,7 @@ bool LLPanelRegionTerrainInfo::sendUpdate() // POST to ModifyRegion endpoint, if enabled static LLCachedControl<bool> feature_pbr_terrain_transforms_enabled(gSavedSettings, "RenderTerrainPBRTransformsEnabled", false); - if (material_type == LLTerrainMaterials::Type::PBR && feature_pbr_terrain_transforms_enabled) + if (material_type == LLTerrainMaterials::Type::PBR && feature_pbr_terrain_transforms_enabled()) { LLTerrainMaterials composition; for (S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 19cb4d04e2..0248f5710f 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -1075,6 +1075,9 @@ F32 gpu_benchmark() return -1.f; } LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_RGBA, res,res,GL_RGBA, GL_UNSIGNED_BYTE, pixels); + // disable mipmaps and use point filtering to cause cache misses + gGL.getTexUnit(0)->setHasMipMaps(false); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); if (alloc_timer.getElapsedTimeF32() > time_limit) { @@ -1118,57 +1121,6 @@ F32 gpu_benchmark() LLGLSLShader::unbind(); - F32 time_passed = 0; // seconds - - { //run CPU timer benchmark - glFinish(); - gBenchmarkProgram.bind(); - for (S32 c = -1; c < samples && time_passed < time_limit; ++c) - { - LLTimer timer; - timer.start(); - - for (U32 i = 0; i < count; ++i) - { - dest[i].bindTarget(); - texHolder.bind(i); - buff->setBuffer(); - buff->drawArrays(LLRender::TRIANGLES, 0, 3); - dest[i].flush(); - } - - //wait for current batch of copies to finish - glFinish(); - - F32 time = timer.getElapsedTimeF32(); - time_passed += time; - - if (c >= 0) // <-- ignore the first sample as it tends to be artificially slow - { - //store result in gigabytes per second - F32 gb = (F32)((F64)(res * res * 8 * count)) / (1000000000); - F32 gbps = gb / time; - results.push_back(gbps); - } - } - gBenchmarkProgram.unbind(); - } - - std::sort(results.begin(), results.end()); - - F32 gbps = results[results.size()/2]; - - LL_INFOS("Benchmark") << "Memory bandwidth is " << llformat("%.3f", gbps) << " GB/sec according to CPU timers, " << (F32)results.size() << " tests took " << time_passed << " seconds" << LL_ENDL; - -#if LL_DARWIN - if (gbps > 512.f) - { - LL_WARNS("Benchmark") << "Memory bandwidth is improbably high and likely incorrect; discarding result." << LL_ENDL; - //OSX is probably lying, discard result - return -1.f; - } -#endif - // run GPU timer benchmark { ShaderProfileHelper initProfile; @@ -1191,8 +1143,9 @@ F32 gpu_benchmark() F32 seconds = ms/1000.f; F64 samples_drawn = (F64)gBenchmarkProgram.mSamplesDrawn; - F32 samples_sec = (F32)((samples_drawn/1000000000.0)/seconds); - gbps = samples_sec*4; // 4 bytes per sample + F64 gpixels_drawn = samples_drawn / 1000000000.0; + F32 samples_sec = (F32)(gpixels_drawn/seconds); + F32 gbps = samples_sec*4; // 4 bytes per sample LL_INFOS("Benchmark") << "Memory bandwidth is " << llformat("%.3f", gbps) << " GB/sec according to ARB_timer_query, total time " << seconds << " seconds" << LL_ENDL; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index a32e5d23e3..344a9737b1 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -3446,6 +3446,12 @@ bool enable_gltf_upload() return enable_gltf_save_as(); } +bool enable_terrain_local_paintmap() +{ + static LLCachedControl<bool> can_use_shaders(gSavedSettings, "RenderCanUseTerrainBakeShaders", true); + return can_use_shaders; +} + class LLSelfRemoveAllAttachments : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -10223,6 +10229,7 @@ void initialize_menus() enable.add("EnableGLTF", boost::bind(&enable_gltf)); enable.add("EnableGLTFSaveAs", boost::bind(&enable_gltf_save_as)); enable.add("EnableGLTFUpload", boost::bind(&enable_gltf_upload)); + enable.add("EnableTerrainLocalPaintMap", std::bind(&enable_terrain_local_paintmap)); view_listener_t::addMenu(new LLFloaterVisible(), "FloaterVisible"); view_listener_t::addMenu(new LLShowSidetrayPanel(), "ShowSidetrayPanel"); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 72e066eb74..d315183ad0 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -2488,7 +2488,16 @@ void LLViewerRegion::setSimulatorFeatures(const LLSD& sim_features) if (features.has("GLTFEnabled")) { bool enabled = features["GLTFEnabled"]; - gSavedSettings.setBOOL("GLTFEnabled", enabled); + + // call setShaders the first time GLTFEnabled is received as true (causes GLTF specific shaders to be loaded) + if (enabled != gSavedSettings.getBOOL("GLTFEnabled")) + { + gSavedSettings.setBOOL("GLTFEnabled", enabled); + if (enabled) + { + LLViewerShaderMgr::instance()->setShaders(); + } + } } else { diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index c422e1d3ae..58b541b19b 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -439,13 +439,20 @@ void LLViewerShaderMgr::finalizeShaderList() 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); @@ -1340,26 +1347,29 @@ 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); - 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; + //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; + } } } @@ -3140,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) diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 0cc2eb8b7c..ad503cbac7 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -541,6 +541,9 @@ void send_viewer_stats(bool include_preferences) agent["run_time"] = run_time; } + // report time the viewer has spent in the foreground + agent["foreground_time"] = gForegroundTime.getElapsedTimeF32(); + // send fps only for time app spends in foreground agent["fps"] = (F32)gForegroundFrameCount / gForegroundTime.getElapsedTimeF32(); agent["version"] = LLVersionInfo::instance().getChannelAndVersion(); diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index bb16fec32a..012ef5924a 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -511,44 +511,52 @@ void LLViewerTexture::updateClass() F32 over_pct = (used - target) / target; - bool is_low = over_pct > 0.f; + bool is_sys_low = isSystemMemoryLow(); + bool is_low = is_sys_low || over_pct > 0.f; - if (isSystemMemoryLow()) + static bool was_low = false; + static bool was_sys_low = false; + + if (is_low && !was_low) + { + // slam to 1.5 bias the moment we hit low memory (discards off screen textures immediately) + sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.5f); + + if (is_sys_low) + { // if we're low on system memory, emergency purge off screen textures to avoid a death spiral + LL_WARNS() << "Low system memory detected, emergency downrezzing off screen textures" << LL_ENDL; + for (auto& image : gTextureList) + { + gTextureList.updateImageDecodePriority(image, false /*will modify gTextureList otherwise!*/); + } + } + } + + was_low = is_low; + was_sys_low = is_sys_low; + + if (is_low) { - is_low = true; - // System RAM is low -> ramp up discard bias over time to free memory + // ramp up discard bias over time to free memory if (sEvaluationTimer.getElapsedTimeF32() > MEMORY_CHECK_WAIT_TIME) { static LLCachedControl<F32> low_mem_min_discard_increment(gSavedSettings, "RenderLowMemMinDiscardIncrement", .1f); - sDesiredDiscardBias += (F32) low_mem_min_discard_increment * (F32) gFrameIntervalSeconds; + sDesiredDiscardBias += (F32)low_mem_min_discard_increment * (F32)gFrameIntervalSeconds; sEvaluationTimer.reset(); } } else { - sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.f + over_pct); + // don't execute above until the slam to 1.5 has a chance to take effect + sEvaluationTimer.reset(); + // lower discard bias over time when free memory is available if (sDesiredDiscardBias > 1.f && over_pct < 0.f) { sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01f; } } - static bool was_low = false; - if (is_low && !was_low) - { - LL_WARNS() << "Low system memory detected, emergency downrezzing off screen textures" << LL_ENDL; - sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.5f); - - for (auto& image : gTextureList) - { - gTextureList.updateImageDecodePriority(image, false /*will modify gTextureList otherwise!*/); - } - } - - was_low = is_low; - - // set to max discard bias if the window has been backgrounded for a while static bool was_backgrounded = false; static LLFrameTimer backgrounded_timer; @@ -1545,6 +1553,17 @@ void LLViewerFetchedTexture::postCreateTexture() setActive(); + // rebuild any volumes that are using this texture for sculpts in case their LoD has changed + for (U32 i = 0; i < mNumVolumes[LLRender::SCULPT_TEX]; ++i) + { + LLVOVolume* volume = mVolumeList[LLRender::SCULPT_TEX][i]; + if (volume) + { + volume->mSculptChanged = true; + gPipeline.markRebuild(volume->mDrawable); + } + } + if (!needsToSaveRawImage()) { mNeedsAux = false; @@ -2639,7 +2658,7 @@ void LLViewerFetchedTexture::destroyRawImage() if (mAuxRawImage.notNull() && !needsToSaveRawImage()) { sAuxCount--; - mAuxRawImage = NULL; + mAuxRawImage = nullptr; } if (mRawImage.notNull()) @@ -2654,7 +2673,7 @@ void LLViewerFetchedTexture::destroyRawImage() } } - mRawImage = NULL; + mRawImage = nullptr; mIsRawImageValid = false; mRawDiscardLevel = INVALID_DISCARD_LEVEL; @@ -2766,7 +2785,9 @@ void LLViewerFetchedTexture::readbackRawImage() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - if (mGLTexturep.notNull() && mGLTexturep->getTexName() != 0 && mRawImage.isNull()) + // readback the raw image from vram if the current raw image is null or smaller than the texture + if (mGLTexturep.notNull() && mGLTexturep->getTexName() != 0 && + (mRawImage.isNull() || mRawImage->getWidth() < mGLTexturep->getWidth() || mRawImage->getHeight() < mGLTexturep->getHeight() )) { mRawImage = new LLImageRaw(); if (!mGLTexturep->readBackRaw(-1, mRawImage, false)) diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 2df60dbf6c..7b89ae4e44 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -964,7 +964,7 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag // this is an alternative to decaying mMaxVirtualSize over time // that keeps textures from continously downrezzing and uprezzing in the background - if (LLViewerTexture::sDesiredDiscardBias > 2.f || + if (LLViewerTexture::sDesiredDiscardBias > 1.5f || (!on_screen && LLViewerTexture::sDesiredDiscardBias > 1.f)) { imagep->mMaxVirtualSize = 0.f; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 7d85b2b7da..28a7be6569 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1149,7 +1149,7 @@ void LLVOVolume::updateSculptTexture() { mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, true, LLGLTexture::BOOST_SCULPTED, LLViewerTexture::LOD_TEXTURE); mSculptTexture->forceToSaveRawImage(0, F32_MAX); - mSculptTexture->addTextureStats(256.f*256.f); + mSculptTexture->setKnownDrawSize(256, 256); } mSkinInfoUnavaliable = false; @@ -1251,7 +1251,7 @@ void LLVOVolume::sculpt() discard_level = mSculptTexture->getSavedRawImageLevel(); } - if (!raw_image) + if (!raw_image || raw_image->getWidth() < mSculptTexture->getWidth() || raw_image->getHeight() < mSculptTexture->getHeight()) { // last resort, read back from GL mSculptTexture->readbackRawImage(); @@ -1338,17 +1338,8 @@ void LLVOVolume::sculpt() mSculptTexture->updateBindStatsForTester() ; } } - getVolume()->sculpt(sculpt_width, sculpt_height, sculpt_components, sculpt_data, discard_level, mSculptTexture->isMissingAsset()); - //notify rebuild any other VOVolumes that reference this sculpty volume - for (S32 i = 0; i < mSculptTexture->getNumVolumes(LLRender::SCULPT_TEX); ++i) - { - LLVOVolume* volume = (*(mSculptTexture->getVolumeList(LLRender::SCULPT_TEX)))[i]; - if (volume != this && volume->getVolume() == getVolume()) - { - gPipeline.markRebuild(volume->mDrawable, LLDrawable::REBUILD_GEOMETRY); - } - } + getVolume()->sculpt(sculpt_width, sculpt_height, sculpt_components, sculpt_data, discard_level, mSculptTexture->isMissingAsset()); } } diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 6241bf42d6..97a5131260 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -451,6 +451,7 @@ public: private: friend class LLDrawable; friend class LLFace; + friend class LLViewerFetchedTexture; bool mFaceMappingChanged; LLFrameTimer mTextureUpdateTimer; diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp index 76348d4ea1..2d59712142 100644 --- a/indra/newview/llwearablelist.cpp +++ b/indra/newview/llwearablelist.cpp @@ -36,6 +36,7 @@ #include "llnotificationsutil.h" #include "llinventorymodel.h" #include "lltrans.h" +#include "llappviewer.h" // Callback struct struct LLWearableArrivedData @@ -97,6 +98,22 @@ void LLWearableList::getAsset(const LLAssetID& assetID, const std::string& weara // static void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID& uuid, void* userdata, S32 status, LLExtStat ext_status ) { + if (!LLCoros::on_main_coro()) + { + // if triggered from a coroutine, dispatch to main thread before accessing app state + std::string filename_in = filename; + LLUUID uuid_in = uuid; + + LLAppViewer::instance()->postToMainCoro([=]() + { + processGetAssetReply(filename_in.c_str(), uuid_in, userdata, status, ext_status); + }); + + return; + } + + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; + bool isNewWearable = false; LLWearableArrivedData* data = (LLWearableArrivedData*) userdata; LLViewerWearable* wearable = NULL; // NULL indicates failure diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 25ad9da5ea..fb556a6587 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -3672,9 +3672,10 @@ function="World.EnvPreset" <menu_item_separator/> <menu_item_call - enabled="true" label="Create Local Paintmap" name="Create Local Paintmap"> + <menu_item_call.on_enable + function="EnableTerrainLocalPaintMap"/> <menu_item_call.on_click function="Advanced.TerrainCreateLocalPaintMap" /> </menu_item_call> |