Implemented logic to throttle streaming after low memory warnings occur
This commit is contained in:
@@ -32,6 +32,7 @@ KRContext::KRContext() : m_streamer(*this)
|
||||
|
||||
m_bDetectedExtensions = false;
|
||||
m_current_frame = 0;
|
||||
m_last_memory_warning_frame = 0;
|
||||
m_absolute_time = 0.0f;
|
||||
|
||||
m_pBundleManager = new KRBundleManager(*this);
|
||||
@@ -331,9 +332,21 @@ void KRContext::getMemoryStats(long &free_memory)
|
||||
void KRContext::doStreaming()
|
||||
{
|
||||
if(m_streamingEnabled) {
|
||||
const long MEMORY_WARNING_THROTTLE_FRAMES = 15;
|
||||
|
||||
bool memory_warning_throttle = m_last_memory_warning_frame != 0 && m_current_frame - m_last_memory_warning_frame < MEMORY_WARNING_THROTTLE_FRAMES;
|
||||
|
||||
long memoryRemaining = KRENGINE_GPU_MEM_TARGET;
|
||||
long memoryRemainingThisFrame = KRENGINE_GPU_MEM_MAX - m_pTextureManager->getMemUsed() - m_pMeshManager->getMemUsed();
|
||||
|
||||
if(!memory_warning_throttle) {
|
||||
m_pMeshManager->doStreaming(memoryRemaining, memoryRemainingThisFrame);
|
||||
m_pTextureManager->doStreaming(memoryRemaining, memoryRemainingThisFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KRContext::receivedMemoryWarning()
|
||||
{
|
||||
m_last_memory_warning_frame = m_current_frame;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ public:
|
||||
static void Log(log_level level, const std::string &message_format, ...);
|
||||
|
||||
void doStreaming();
|
||||
void receivedMemoryWarning();
|
||||
|
||||
private:
|
||||
KRBundleManager *m_pBundleManager;
|
||||
@@ -102,6 +103,7 @@ private:
|
||||
bool m_bDetectedExtensions;
|
||||
|
||||
long m_current_frame;
|
||||
long m_last_memory_warning_frame;
|
||||
float m_absolute_time;
|
||||
|
||||
mach_timebase_info_data_t m_timebase_info;
|
||||
|
||||
Reference in New Issue
Block a user