mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:28:02 +02:00
Fix issues with integer overflow in memory pressure calculations
This commit is contained in:
parent
0d4987878e
commit
7a186bba34
1 changed files with 7 additions and 4 deletions
|
@ -239,13 +239,16 @@ void GLTextureTransferEngineDefault::updateMemoryPressure() {
|
||||||
float pressure = 0;
|
float pressure = 0;
|
||||||
|
|
||||||
if (useAvailableGlMemory) {
|
if (useAvailableGlMemory) {
|
||||||
float totalMem = GLBackend::getTotalMemory();
|
size_t totalMem = GLBackend::getTotalMemory();
|
||||||
float availMem = GLBackend::getAvailableMemory() - AUTO_RESERVE_TEXTURE_MEMORY;
|
size_t availMem = GLBackend::getAvailableMemory();
|
||||||
if (availMem < 0) {
|
|
||||||
|
if (availMem >= AUTO_RESERVE_TEXTURE_MEMORY) {
|
||||||
|
availMem -= AUTO_RESERVE_TEXTURE_MEMORY;
|
||||||
|
} else {
|
||||||
availMem = 0;
|
availMem = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pressure = (totalMem - availMem) / totalMem;
|
pressure = ((float)totalMem - (float)availMem) / (float)totalMem;
|
||||||
} else {
|
} else {
|
||||||
pressure = (float)totalVariableMemoryAllocation / (float)allowedMemoryAllocation;
|
pressure = (float)totalVariableMemoryAllocation / (float)allowedMemoryAllocation;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue