Ensure complete population of allocated mip levels

This commit is contained in:
Brad Davis 2017-02-24 12:04:17 -08:00
parent b06768d379
commit 3d2e6713ee
2 changed files with 11 additions and 2 deletions

View file

@ -168,7 +168,7 @@ public:
//bool canPromoteNoAllocate() const { return _allocatedMip < _populatedMip; } //bool canPromoteNoAllocate() const { return _allocatedMip < _populatedMip; }
bool canPromote() const { return _allocatedMip > 0; } bool canPromote() const { return _allocatedMip > 0; }
bool canDemote() const { return _allocatedMip < _maxAllocatedMip; } bool canDemote() const { return _allocatedMip < _maxAllocatedMip; }
bool hasPendingTransfers() const { return !_pendingTransfers.empty(); } bool hasPendingTransfers() const { return _populatedMip > _allocatedMip; }
void executeNextTransfer(const TexturePointer& currentTexture); void executeNextTransfer(const TexturePointer& currentTexture);
uint32 size() const override { return _size; } uint32 size() const override { return _size; }
virtual void populateTransferQueue() = 0; virtual void populateTransferQueue() = 0;

View file

@ -338,6 +338,7 @@ void GL45VariableAllocationTexture::updateMemoryPressure() {
_transferQueue = WorkQueue(); _transferQueue = WorkQueue();
_promoteQueue = WorkQueue(); _promoteQueue = WorkQueue();
_demoteQueue = WorkQueue(); _demoteQueue = WorkQueue();
// Populate the existing textures into the queue // Populate the existing textures into the queue
for (const auto& texture : strongTextures) { for (const auto& texture : strongTextures) {
addToWorkQueue(texture); addToWorkQueue(texture);
@ -387,7 +388,7 @@ void GL45VariableAllocationTexture::processWorkQueues() {
} }
if (workQueue.empty()) { if (workQueue.empty()) {
_memoryPressureState = MemoryPressureState::Idle; _memoryPressureStateStale = true;
} }
} }
@ -406,6 +407,14 @@ GL45VariableAllocationTexture::~GL45VariableAllocationTexture() {
} }
void GL45VariableAllocationTexture::executeNextTransfer(const TexturePointer& currentTexture) { void GL45VariableAllocationTexture::executeNextTransfer(const TexturePointer& currentTexture) {
if (_populatedMip <= _allocatedMip) {
return;
}
if (_pendingTransfers.empty()) {
populateTransferQueue();
}
if (!_pendingTransfers.empty()) { if (!_pendingTransfers.empty()) {
// Keeping hold of a strong pointer during the transfer ensures that the transfer thread cannot try to access a destroyed texture // Keeping hold of a strong pointer during the transfer ensures that the transfer thread cannot try to access a destroyed texture
_currentTransferTexture = currentTexture; _currentTransferTexture = currentTexture;