From 970be9d2c567a904f0527c304ae893d2aa5ca053 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 21 Apr 2017 01:10:54 -0700 Subject: [PATCH] Add check for canPopulate to gpu backend --- libraries/gpu-gl/src/gpu/gl/GLTexture.cpp | 6 ++++-- libraries/gpu-gl/src/gpu/gl/GLTexture.h | 4 ++-- libraries/gpu-gl/src/gpu/gl41/GL41Backend.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp index 1179403bff..f1bf76b39d 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp @@ -437,6 +437,7 @@ void GLVariableAllocationSupport::updateMemoryPressure() { size_t idealMemoryAllocation = 0; bool canDemote = false; bool canPromote = false; + bool canPopulate = false; bool hasTransfers = false; for (const auto& texture : strongTextures) { // Race conditions can still leave nulls in the list, so we need to check @@ -450,7 +451,8 @@ void GLVariableAllocationSupport::updateMemoryPressure() { // Track how much we're actually using totalVariableMemoryAllocation += gltexture->size(); canDemote |= vartexture->canDemote(); - canPromote |= vartexture->canPromote() || (texture->minAvailableMipLevel() < vartexture->_allocatedMip); + canPromote |= vartexture->canPromote(); + canPopulate |= vartexture->canPopulate(); hasTransfers |= vartexture->hasPendingTransfers(); } @@ -464,7 +466,7 @@ void GLVariableAllocationSupport::updateMemoryPressure() { } else if (pressure > OVERSUBSCRIBED_PRESSURE_VALUE && canDemote) { qDebug() << "Demoting"; newState = MemoryPressureState::Oversubscribed; - } else if (pressure < UNDERSUBSCRIBED_PRESSURE_VALUE && unallocated != 0 && canPromote) { + } else if (pressure < UNDERSUBSCRIBED_PRESSURE_VALUE && ((unallocated != 0 && canPromote) || canPopulate)) { qDebug() << "Promoting"; newState = MemoryPressureState::Undersubscribed; } diff --git a/libraries/gpu-gl/src/gpu/gl/GLTexture.h b/libraries/gpu-gl/src/gpu/gl/GLTexture.h index bc8467b808..9aad49546e 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTexture.h +++ b/libraries/gpu-gl/src/gpu/gl/GLTexture.h @@ -112,11 +112,11 @@ protected: static void manageMemory(); //bool canPromoteNoAllocate() const { return _allocatedMip < _populatedMip; } - bool canPromote() const { return _allocatedMip > 0 || _populatedMip > 0; } + virtual bool canPopulate() const = 0; + bool canPromote() const { return _allocatedMip > 0; } bool canDemote() const { return _allocatedMip < _maxAllocatedMip; } bool hasPendingTransfers() const { return _pendingTransfers.size() > 0; } void executeNextTransfer(const TexturePointer& currentTexture); - virtual bool canPopulate() const = 0; virtual void populateTransferQueue() = 0; virtual void promote() = 0; virtual void demote() = 0; diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h b/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h index c0b9ea0e45..dc6d2b3aa7 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h +++ b/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h @@ -100,7 +100,7 @@ public: GL41VariableAllocationTexture(const std::weak_ptr& backend, const Texture& texture); ~GL41VariableAllocationTexture(); - bool canPopulate() const override { return _gpuObject.isStoredMipFaceAvailable(_populatedMip - 1, 0); } + bool canPopulate() const override { return _populatedMip > _allocatedMip && _gpuObject.isStoredMipFaceAvailable(_populatedMip - 1, 0); } void allocateStorage(uint16 allocatedMip); void syncSampler() const override; void promote() override;