mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:22:57 +02:00
Merge pull request #8770 from jherico/textures_tweak
Fix GPU texture counter, better logging for memory pressure
This commit is contained in:
commit
8e8eba5e0c
2 changed files with 23 additions and 7 deletions
|
@ -666,7 +666,6 @@ void GLBackend::recycle() const {
|
||||||
for (auto pair : externalTexturesTrash) {
|
for (auto pair : externalTexturesTrash) {
|
||||||
auto fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
auto fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||||
pair.second(pair.first, fence);
|
pair.second(pair.first, fence);
|
||||||
decrementTextureGPUCount();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,20 @@ std::shared_ptr<GLTextureTransferHelper> GLTexture::_textureTransferHelper;
|
||||||
|
|
||||||
// FIXME placeholder for texture memory over-use
|
// FIXME placeholder for texture memory over-use
|
||||||
#define DEFAULT_MAX_MEMORY_MB 256
|
#define DEFAULT_MAX_MEMORY_MB 256
|
||||||
#define MIN_FREE_GPU_MEMORY_PERCENTAGE 0.25f
|
|
||||||
#define OVER_MEMORY_PRESSURE 2.0f
|
#define OVER_MEMORY_PRESSURE 2.0f
|
||||||
|
|
||||||
|
// FIXME other apps show things like Oculus home consuming large amounts of GPU memory
|
||||||
|
// which causes us to blur textures needlessly (since other app GPU memory usage will likely
|
||||||
|
// be swapped out and not cause any actual impact
|
||||||
|
//#define CHECK_MIN_FREE_GPU_MEMORY
|
||||||
|
#ifdef CHECK_MIN_FREE_GPU_MEMORY
|
||||||
|
#define MIN_FREE_GPU_MEMORY_PERCENTAGE 0.25f
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Allow 65% of all available GPU memory to be consumed by textures
|
||||||
|
// FIXME overly conservative?
|
||||||
|
#define MAX_CONSUMED_TEXTURE_MEMORY_PERCENTAGE 0.65f
|
||||||
|
|
||||||
const GLenum GLTexture::CUBE_FACE_LAYOUT[6] = {
|
const GLenum GLTexture::CUBE_FACE_LAYOUT[6] = {
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
||||||
|
@ -107,6 +118,7 @@ float GLTexture::getMemoryPressure() {
|
||||||
// If we can't query the dedicated memory just use a fallback fixed value of 256 MB
|
// If we can't query the dedicated memory just use a fallback fixed value of 256 MB
|
||||||
totalGpuMemory = MB_TO_BYTES(DEFAULT_MAX_MEMORY_MB);
|
totalGpuMemory = MB_TO_BYTES(DEFAULT_MAX_MEMORY_MB);
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef CHECK_MIN_FREE_GPU_MEMORY
|
||||||
// Check the global free GPU memory
|
// Check the global free GPU memory
|
||||||
auto freeGpuMemory = getFreeDedicatedMemory();
|
auto freeGpuMemory = getFreeDedicatedMemory();
|
||||||
if (freeGpuMemory) {
|
if (freeGpuMemory) {
|
||||||
|
@ -115,21 +127,26 @@ float GLTexture::getMemoryPressure() {
|
||||||
if (freeGpuMemory != lastFreeGpuMemory) {
|
if (freeGpuMemory != lastFreeGpuMemory) {
|
||||||
lastFreeGpuMemory = freeGpuMemory;
|
lastFreeGpuMemory = freeGpuMemory;
|
||||||
if (freePercentage < MIN_FREE_GPU_MEMORY_PERCENTAGE) {
|
if (freePercentage < MIN_FREE_GPU_MEMORY_PERCENTAGE) {
|
||||||
qDebug() << "Exceeded max GPU memory";
|
qCDebug(gpugllogging) << "Exceeded min free GPU memory " << freePercentage;
|
||||||
return OVER_MEMORY_PRESSURE;
|
return OVER_MEMORY_PRESSURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow 50% of all available GPU memory to be consumed by textures
|
availableTextureMemory = static_cast<gpu::Size>(totalGpuMemory * MAX_CONSUMED_TEXTURE_MEMORY_PERCENTAGE);
|
||||||
// FIXME overly conservative?
|
|
||||||
availableTextureMemory = (totalGpuMemory >> 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the consumed texture memory divided by the available texture memory.
|
// Return the consumed texture memory divided by the available texture memory.
|
||||||
auto consumedGpuMemory = Context::getTextureGPUMemoryUsage();
|
auto consumedGpuMemory = Context::getTextureGPUMemoryUsage();
|
||||||
return (float)consumedGpuMemory / (float)availableTextureMemory;
|
float memoryPressure = (float)consumedGpuMemory / (float)availableTextureMemory;
|
||||||
|
static Context::Size lastConsumedGpuMemory = 0;
|
||||||
|
if (memoryPressure > 1.0f && lastConsumedGpuMemory != consumedGpuMemory) {
|
||||||
|
lastConsumedGpuMemory = consumedGpuMemory;
|
||||||
|
qCDebug(gpugllogging) << "Exceeded max allowed texture memory: " << consumedGpuMemory << " / " << availableTextureMemory;
|
||||||
|
}
|
||||||
|
return memoryPressure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue