mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
Add persisting of ktx min mips available to ktx cache file
This commit is contained in:
parent
5594e81fe4
commit
70eaac8d6c
5 changed files with 22 additions and 4 deletions
|
@ -458,12 +458,12 @@ void GLVariableAllocationSupport::updateMemoryPressure() {
|
||||||
float pressure = (float)totalVariableMemoryAllocation / (float)allowedMemoryAllocation;
|
float pressure = (float)totalVariableMemoryAllocation / (float)allowedMemoryAllocation;
|
||||||
|
|
||||||
auto newState = MemoryPressureState::Idle;
|
auto newState = MemoryPressureState::Idle;
|
||||||
if (pressure > OVERSUBSCRIBED_PRESSURE_VALUE && canDemote) {
|
if (hasTransfers) {
|
||||||
|
newState = MemoryPressureState::Transfer;
|
||||||
|
} else if (pressure > OVERSUBSCRIBED_PRESSURE_VALUE && canDemote) {
|
||||||
newState = MemoryPressureState::Oversubscribed;
|
newState = MemoryPressureState::Oversubscribed;
|
||||||
} else if (pressure < UNDERSUBSCRIBED_PRESSURE_VALUE && unallocated != 0 && canPromote) {
|
} else if (pressure < UNDERSUBSCRIBED_PRESSURE_VALUE && unallocated != 0 && canPromote) {
|
||||||
newState = MemoryPressureState::Undersubscribed;
|
newState = MemoryPressureState::Undersubscribed;
|
||||||
} else if (hasTransfers) {
|
|
||||||
newState = MemoryPressureState::Transfer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newState != _memoryPressureState) {
|
if (newState != _memoryPressureState) {
|
||||||
|
|
|
@ -155,6 +155,7 @@ void KtxStorage::assignMipData(uint16 level, const storage::StoragePointer& stor
|
||||||
data += ktx::KTX_HEADER_SIZE + _ktxDescriptor->header.bytesOfKeyValueData + _ktxDescriptor->images[level]._imageOffset;
|
data += ktx::KTX_HEADER_SIZE + _ktxDescriptor->header.bytesOfKeyValueData + _ktxDescriptor->images[level]._imageOffset;
|
||||||
data += 4;
|
data += 4;
|
||||||
|
|
||||||
|
auto offset = _ktxDescriptor->getValueOffsetForKey(ktx::HIFI_MIN_POPULATED_MIP_KEY);
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock { _cacheFileWriteMutex };
|
std::lock_guard<std::mutex> lock { _cacheFileWriteMutex };
|
||||||
|
|
||||||
|
@ -165,6 +166,9 @@ void KtxStorage::assignMipData(uint16 level, const storage::StoragePointer& stor
|
||||||
|
|
||||||
memcpy(data, storage->data(), _ktxDescriptor->images[level]._imageSize);
|
memcpy(data, storage->data(), _ktxDescriptor->images[level]._imageSize);
|
||||||
_minMipLevelAvailable = level;
|
_minMipLevelAvailable = level;
|
||||||
|
if (offset > 0) {
|
||||||
|
memcpy(file->mutableData() + ktx::KTX_HEADER_SIZE + offset, (uint8_t)_minMipLevelAvailable, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,18 @@ size_t Header::evalImageSize(uint32_t level) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t KTXDescriptor::getValueOffsetForKey(const std::string& key) const {
|
||||||
|
size_t offset { 0 };
|
||||||
|
for (auto& kv : keyValues) {
|
||||||
|
if (kv._key == key) {
|
||||||
|
return offset + kv._key.size() + 1;
|
||||||
|
}
|
||||||
|
offset += kv.serializedByteSize();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ImageDescriptors Header::generateImageDescriptors() const {
|
ImageDescriptors Header::generateImageDescriptors() const {
|
||||||
ImageDescriptors descriptors;
|
ImageDescriptors descriptors;
|
||||||
|
|
||||||
|
|
|
@ -471,6 +471,7 @@ namespace ktx {
|
||||||
const ImageDescriptors images;
|
const ImageDescriptors images;
|
||||||
size_t getMipFaceTexelsSize(uint16_t mip = 0, uint8_t face = 0) const;
|
size_t getMipFaceTexelsSize(uint16_t mip = 0, uint8_t face = 0) const;
|
||||||
size_t getMipFaceTexelsOffset(uint16_t mip = 0, uint8_t face = 0) const;
|
size_t getMipFaceTexelsOffset(uint16_t mip = 0, uint8_t face = 0) const;
|
||||||
|
size_t getValueOffsetForKey(const std::string& key) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KTX {
|
class KTX {
|
||||||
|
|
|
@ -377,8 +377,8 @@ void NetworkTexture::makeRequest() {
|
||||||
|
|
||||||
startMipRangeRequest(NULL_MIP_LEVEL, NULL_MIP_LEVEL);
|
startMipRangeRequest(NULL_MIP_LEVEL, NULL_MIP_LEVEL);
|
||||||
} else if (_ktxResourceState == PENDING_MIP_REQUEST) {
|
} else if (_ktxResourceState == PENDING_MIP_REQUEST) {
|
||||||
_ktxResourceState = REQUESTING_MIP;
|
|
||||||
if (_lowestKnownPopulatedMip > 0) {
|
if (_lowestKnownPopulatedMip > 0) {
|
||||||
|
_ktxResourceState = REQUESTING_MIP;
|
||||||
startMipRangeRequest(_lowestKnownPopulatedMip - 1, _lowestKnownPopulatedMip - 1);
|
startMipRangeRequest(_lowestKnownPopulatedMip - 1, _lowestKnownPopulatedMip - 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -393,6 +393,7 @@ void NetworkTexture::handleMipInterestCallback(uint16_t level) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkTexture::handleMipInterestLevel(int level) {
|
void NetworkTexture::handleMipInterestLevel(int level) {
|
||||||
|
_lowestRequestedMipLevel = std::min((uint16_t)level, _lowestRequestedMipLevel);
|
||||||
startRequestForNextMipLevel();
|
startRequestForNextMipLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue