mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 13:22:53 +02:00
Replace canPopulate with _minAllocatedMip
This commit is contained in:
parent
70ece9f0fd
commit
a71d246e75
6 changed files with 24 additions and 11 deletions
|
@ -437,7 +437,6 @@ void GLVariableAllocationSupport::updateMemoryPressure() {
|
||||||
size_t idealMemoryAllocation = 0;
|
size_t idealMemoryAllocation = 0;
|
||||||
bool canDemote = false;
|
bool canDemote = false;
|
||||||
bool canPromote = false;
|
bool canPromote = false;
|
||||||
bool canPopulate = false;
|
|
||||||
bool hasTransfers = false;
|
bool hasTransfers = false;
|
||||||
for (const auto& texture : strongTextures) {
|
for (const auto& texture : strongTextures) {
|
||||||
// Race conditions can still leave nulls in the list, so we need to check
|
// Race conditions can still leave nulls in the list, so we need to check
|
||||||
|
@ -452,7 +451,6 @@ void GLVariableAllocationSupport::updateMemoryPressure() {
|
||||||
totalVariableMemoryAllocation += gltexture->size();
|
totalVariableMemoryAllocation += gltexture->size();
|
||||||
canDemote |= vartexture->canDemote();
|
canDemote |= vartexture->canDemote();
|
||||||
canPromote |= vartexture->canPromote();
|
canPromote |= vartexture->canPromote();
|
||||||
canPopulate |= vartexture->canPopulate();
|
|
||||||
hasTransfers |= vartexture->hasPendingTransfers();
|
hasTransfers |= vartexture->hasPendingTransfers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +462,7 @@ void GLVariableAllocationSupport::updateMemoryPressure() {
|
||||||
newState = MemoryPressureState::Transfer;
|
newState = MemoryPressureState::Transfer;
|
||||||
} else if (pressure > OVERSUBSCRIBED_PRESSURE_VALUE && canDemote) {
|
} else if (pressure > OVERSUBSCRIBED_PRESSURE_VALUE && canDemote) {
|
||||||
newState = MemoryPressureState::Oversubscribed;
|
newState = MemoryPressureState::Oversubscribed;
|
||||||
} else if (pressure < UNDERSUBSCRIBED_PRESSURE_VALUE && ((unallocated != 0 && canPromote) && canPopulate)) {
|
} else if (pressure < UNDERSUBSCRIBED_PRESSURE_VALUE && (unallocated != 0 && canPromote)) {
|
||||||
newState = MemoryPressureState::Undersubscribed;
|
newState = MemoryPressureState::Undersubscribed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,7 +519,7 @@ void GLVariableAllocationSupport::processWorkQueues() {
|
||||||
vartexture->demote();
|
vartexture->demote();
|
||||||
_memoryPressureStateStale = true;
|
_memoryPressureStateStale = true;
|
||||||
} else if (MemoryPressureState::Undersubscribed == _memoryPressureState) {
|
} else if (MemoryPressureState::Undersubscribed == _memoryPressureState) {
|
||||||
if (!vartexture->canPromote() || !vartexture->canPopulate()) {
|
if (!vartexture->canPromote()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
vartexture->promote();
|
vartexture->promote();
|
||||||
|
|
|
@ -112,8 +112,7 @@ protected:
|
||||||
static void manageMemory();
|
static void manageMemory();
|
||||||
|
|
||||||
//bool canPromoteNoAllocate() const { return _allocatedMip < _populatedMip; }
|
//bool canPromoteNoAllocate() const { return _allocatedMip < _populatedMip; }
|
||||||
virtual bool canPopulate() const = 0;
|
bool canPromote() const { return _allocatedMip > _minAllocatedMip; }
|
||||||
bool canPromote() const { return _allocatedMip > 0; }
|
|
||||||
bool canDemote() const { return _allocatedMip < _maxAllocatedMip; }
|
bool canDemote() const { return _allocatedMip < _maxAllocatedMip; }
|
||||||
bool hasPendingTransfers() const { return _pendingTransfers.size() > 0; }
|
bool hasPendingTransfers() const { return _pendingTransfers.size() > 0; }
|
||||||
void executeNextTransfer(const TexturePointer& currentTexture);
|
void executeNextTransfer(const TexturePointer& currentTexture);
|
||||||
|
@ -131,6 +130,9 @@ protected:
|
||||||
// The highest (lowest resolution) mip that we will support, relative to the number
|
// The highest (lowest resolution) mip that we will support, relative to the number
|
||||||
// of mips in the gpu::Texture object
|
// of mips in the gpu::Texture object
|
||||||
uint16 _maxAllocatedMip { 0 };
|
uint16 _maxAllocatedMip { 0 };
|
||||||
|
// The lowest (highest resolution) mip that we will support, relative to the number
|
||||||
|
// of mips in the gpu::Texture object
|
||||||
|
uint16 _minAllocatedMip { 0 };
|
||||||
// Contains a series of lambdas that when executed will transfer data to the GPU, modify
|
// Contains a series of lambdas that when executed will transfer data to the GPU, modify
|
||||||
// the _populatedMip and update the sampler in order to fully populate the allocated texture
|
// the _populatedMip and update the sampler in order to fully populate the allocated texture
|
||||||
// until _populatedMip == _allocatedMip
|
// until _populatedMip == _allocatedMip
|
||||||
|
|
|
@ -100,7 +100,6 @@ public:
|
||||||
GL41VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
GL41VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||||
~GL41VariableAllocationTexture();
|
~GL41VariableAllocationTexture();
|
||||||
|
|
||||||
bool canPopulate() const override { return _gpuObject.isStoredMipFaceAvailable(_populatedMip - 1, 0); }
|
|
||||||
void allocateStorage(uint16 allocatedMip);
|
void allocateStorage(uint16 allocatedMip);
|
||||||
void syncSampler() const override;
|
void syncSampler() const override;
|
||||||
void promote() override;
|
void promote() override;
|
||||||
|
|
|
@ -55,6 +55,18 @@ GLTexture* GL41Backend::syncGPUObject(const TexturePointer& texturePointer) {
|
||||||
default:
|
default:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (texture.getUsageType() == TextureUsageType::RESOURCE) {
|
||||||
|
auto varTex = static_cast<GL41VariableAllocationTexture*> (object);
|
||||||
|
|
||||||
|
if (varTex->_minAllocatedMip > 0) {
|
||||||
|
auto minAvailableMip = texture.minAvailableMipLevel();
|
||||||
|
if (minAvailableMip < varTex->_minAllocatedMip) {
|
||||||
|
varTex->_minAllocatedMip = minAvailableMip;
|
||||||
|
GL41VariableAllocationTexture::_memoryPressureStateStale = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
|
|
|
@ -100,7 +100,6 @@ public:
|
||||||
GL45VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
GL45VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||||
~GL45VariableAllocationTexture();
|
~GL45VariableAllocationTexture();
|
||||||
Size size() const override { return _size; }
|
Size size() const override { return _size; }
|
||||||
bool canPopulate() const override { return _gpuObject.isStoredMipFaceAvailable(_populatedMip - 1, 0); }
|
|
||||||
Size _size { 0 };
|
Size _size { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,13 @@ GLTexture* GL45Backend::syncGPUObject(const TexturePointer& texturePointer) {
|
||||||
if (texture.getUsageType() == TextureUsageType::RESOURCE) {
|
if (texture.getUsageType() == TextureUsageType::RESOURCE) {
|
||||||
auto varTex = static_cast<GL45VariableAllocationTexture*> (object);
|
auto varTex = static_cast<GL45VariableAllocationTexture*> (object);
|
||||||
|
|
||||||
if (varTex->canPromote() && varTex->canPopulate()) {
|
if (varTex->_minAllocatedMip > 0) {
|
||||||
GL45VariableAllocationTexture::_memoryPressureStateStale = true;
|
auto minAvailableMip = texture.minAvailableMipLevel();
|
||||||
|
if (minAvailableMip < varTex->_minAllocatedMip) {
|
||||||
|
varTex->_minAllocatedMip = minAvailableMip;
|
||||||
|
GL45VariableAllocationTexture::_memoryPressureStateStale = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue