diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h b/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h index cfc4dc39da..a320008dc5 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h +++ b/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h @@ -168,7 +168,7 @@ public: //bool canPromoteNoAllocate() const { return _allocatedMip < _populatedMip; } bool canPromote() const { return _allocatedMip > 0; } bool canDemote() const { return _allocatedMip < _maxAllocatedMip; } - bool hasPendingTransfers() const { return !_pendingTransfers.empty(); } + bool hasPendingTransfers() const { return _populatedMip > _allocatedMip; } void executeNextTransfer(const TexturePointer& currentTexture); uint32 size() const override { return _size; } virtual void populateTransferQueue() = 0; diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp index 62f1a3c248..f21530ff9e 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp @@ -338,6 +338,7 @@ void GL45VariableAllocationTexture::updateMemoryPressure() { _transferQueue = WorkQueue(); _promoteQueue = WorkQueue(); _demoteQueue = WorkQueue(); + // Populate the existing textures into the queue for (const auto& texture : strongTextures) { addToWorkQueue(texture); @@ -387,7 +388,7 @@ void GL45VariableAllocationTexture::processWorkQueues() { } if (workQueue.empty()) { - _memoryPressureState = MemoryPressureState::Idle; + _memoryPressureStateStale = true; } } @@ -406,6 +407,14 @@ GL45VariableAllocationTexture::~GL45VariableAllocationTexture() { } void GL45VariableAllocationTexture::executeNextTransfer(const TexturePointer& currentTexture) { + if (_populatedMip <= _allocatedMip) { + return; + } + + if (_pendingTransfers.empty()) { + populateTransferQueue(); + } + if (!_pendingTransfers.empty()) { // Keeping hold of a strong pointer during the transfer ensures that the transfer thread cannot try to access a destroyed texture _currentTransferTexture = currentTexture;