Merge branch 'release/2024.08-DeltaFPS' of https://github.com/secondlife/viewer

# Conflicts:
#	indra/newview/llglsandbox.cpp
master
Ansariel 2024-09-11 11:18:25 +02:00
commit 08615d7545
4 changed files with 81 additions and 93 deletions

View File

@ -1271,57 +1271,6 @@ F32 gpu_benchmark()
LLGLSLShader::unbind();
F32 time_passed = 0.f; // 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;
@ -1346,7 +1295,7 @@ F32 gpu_benchmark()
F64 samples_drawn = (F64)gBenchmarkProgram.mSamplesDrawn;
F64 gpixels_drawn = samples_drawn / 1000000000.0;
F32 samples_sec = (F32)(gpixels_drawn/seconds);
gbps = samples_sec*4; // 4 bytes per sample
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;

View File

@ -2655,7 +2655,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
{

View File

@ -434,13 +434,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);
@ -1343,26 +1350,29 @@ bool LLViewerShaderMgr::loadShadersDeferred()
llassert(success);
}
if (success)
if (gSavedSettings.getBOOL("GLTFEnabled"))
{
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();
success = make_gltf_variants(gGLTFPBRMetallicRoughnessProgram, use_sun_shadow);
//llassert(success);
if (!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;
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();
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;
}
}
}
@ -3011,29 +3021,32 @@ 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;
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)
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;
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);
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;
}
}
}

View File

@ -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