Skip to content

VRAM Budget adjustments #3378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions indra/llwindow/llwindowwin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "llstring.h"
#include "lldir.h"
#include "llsdutil.h"
#include "llsys.h"
#include "llglslshader.h"
#include "llthreadsafequeue.h"
#include "stringize.h"
Expand Down Expand Up @@ -4681,6 +4682,23 @@ void LLWindowWin32::LLWindowWin32Thread::checkDXMem()

// Alternatively use GetDesc from below to get adapter's memory
UINT64 budget_mb = info.Budget / (1024 * 1024);
if (gGLManager.mIsIntel)
Copy link
Contributor

@Ansariel Ansariel Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More a general question: What about Intel's discrete GPU cards? Isn't there a more general distinction required?

Copy link
Contributor Author

@akleshchev akleshchev Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect those would have accurate gGLManager.mVRAM already, but without having a physical one, hard to be sure. worst case 25% is still a reasonable limit.

Potentially we can substract desc.SharedSystemMemory to get real memory in case of descrete GPU (more than a Gb real=>descrete), but I'm not comfortable doing that without having hardware to test it. Otherwise not sure how to detect those without hardcoding GPU names.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or mIsIntel should only be true for integrated GPUs - if there is a way to detect that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the purpose of mIsIntel. AMD has built in GPUs and those need same treatment just in case OS/bios is overeager with shared memory. The problem is detection.

{
U32Megabytes phys_mb = gSysMemory.getPhysicalMemoryKB();
LL_WARNS() << "Physical memory: " << phys_mb << " MB" << LL_ENDL;

if (phys_mb > 0)
{
// Intel uses 'shared' vram, cap it to 25% of total memory
// Todo: consider caping all adapters at least to 50% ram
budget_mb = llmin(budget_mb, (UINT64)(phys_mb * 0.25));
}
else
{
// if no data available, cap to 2Gb
budget_mb = llmin(budget_mb, (UINT64)2048);
}
}
if (gGLManager.mVRAM < (S32)budget_mb)
{
gGLManager.mVRAM = (S32)budget_mb;
Expand Down
7 changes: 4 additions & 3 deletions indra/newview/llviewertexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,13 @@ void LLViewerTexture::updateClass()
// 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)
// lower discard bias over time when at least 10% of budget is free
const F32 FREE_PERCENTAGE_TRESHOLD = -0.1f;
if (sDesiredDiscardBias > 1.f && over_pct < FREE_PERCENTAGE_TRESHOLD)
{
static LLCachedControl<F32> high_mem_discard_decrement(gSavedSettings, "RenderHighMemMinDiscardDecrement", .1f);

F32 decrement = high_mem_discard_decrement - llmin(over_pct, 0.f);
F32 decrement = high_mem_discard_decrement - llmin(over_pct - FREE_PERCENTAGE_TRESHOLD, 0.f);
sDesiredDiscardBias -= decrement * gFrameIntervalSeconds;
}
}
Expand Down
Loading