mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 05:52:38 +02:00
Fix populated texture size tracking
This commit is contained in:
parent
91f1d93d4e
commit
3356486f27
4 changed files with 16 additions and 16 deletions
|
@ -338,8 +338,7 @@ Size GL41VariableAllocationTexture::copyMipsFromTexture() {
|
|||
amount += copyMipFaceFromTexture(sourceMip, targetMip, face);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
incrementPopulatedSize(amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
@ -348,7 +347,6 @@ Size GL41VariableAllocationTexture::copyMipFaceLinesFromTexture(uint16_t mip, ui
|
|||
withPreservedTexture([&] {
|
||||
amountCopied = Parent::copyMipFaceLinesFromTexture(mip, face, size, yOffset, internalFormat, format, type, sourceSize, sourcePointer);
|
||||
});
|
||||
incrementPopulatedSize(amountCopied);
|
||||
return amountCopied;
|
||||
}
|
||||
|
||||
|
@ -609,6 +607,8 @@ void GL41VariableAllocationTexture::populateTransferQueue(TransferQueue& pending
|
|||
// queue up the sampler and populated mip change for after the transfer has completed
|
||||
pendingTransfers.emplace(new TransferJob([=] {
|
||||
_populatedMip = sourceMip;
|
||||
incrementPopulatedSize(_gpuObject.evalMipSize(sourceMip));
|
||||
sanityCheck();
|
||||
syncSampler();
|
||||
}));
|
||||
} while (sourceMip != _allocatedMip);
|
||||
|
|
|
@ -123,7 +123,7 @@ GLTexture* GL45Backend::syncGPUObject(const TexturePointer& texturePointer) {
|
|||
}
|
||||
|
||||
void GL45Backend::initTextureManagementStage() {
|
||||
GLBackend::initTextureManagementStage();
|
||||
GLBackend::initTextureManagementStage();
|
||||
// enable the Sparse Texture on gl45
|
||||
_textureManagement._sparseCapable = true;
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ const GL45Texture::Bindless& GL45VariableAllocationTexture::getBindless() const
|
|||
Size GL45VariableAllocationTexture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||
Size amountCopied = 0;
|
||||
amountCopied = Parent::copyMipFaceLinesFromTexture(mip, face, size, yOffset, internalFormat, format, type, sourceSize, sourcePointer);
|
||||
incrementPopulatedSize(amountCopied);
|
||||
return amountCopied;
|
||||
}
|
||||
|
||||
|
@ -81,7 +80,6 @@ void GL45VariableAllocationTexture::copyTextureMipsInGPUMem(GLuint srcId, GLuint
|
|||
copyTexGPUMem(_gpuObject, _target, srcId, destId, numMips, srcMipOffset, destMipOffset, populatedMips);
|
||||
}
|
||||
|
||||
|
||||
// Managed size resource textures
|
||||
using GL45ResourceTexture = GL45Backend::GL45ResourceTexture;
|
||||
|
||||
|
@ -132,6 +130,7 @@ Size GL45ResourceTexture::copyMipsFromTexture() {
|
|||
amount += copyMipFaceFromTexture(sourceMip, targetMip, face);
|
||||
}
|
||||
}
|
||||
incrementPopulatedSize(amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
@ -139,7 +138,7 @@ void GL45ResourceTexture::syncSampler() const {
|
|||
Parent::syncSampler();
|
||||
#if GPU_BINDLESS_TEXTURES
|
||||
if (!isBindless()) {
|
||||
glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, _populatedMip - _allocatedMip);
|
||||
glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, _populatedMip - _allocatedMip);
|
||||
}
|
||||
#else
|
||||
glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, _populatedMip - _allocatedMip);
|
||||
|
@ -169,7 +168,7 @@ size_t GL45ResourceTexture::promote() {
|
|||
|
||||
// allocate storage for new level
|
||||
allocateStorage(targetAllocatedMip);
|
||||
|
||||
|
||||
// copy pre-existing mips
|
||||
copyTextureMipsInGPUMem(oldId, _id, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||
|
||||
|
@ -230,14 +229,14 @@ size_t GL45ResourceTexture::demote() {
|
|||
|
||||
// update the memory usage
|
||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||
// Demoting unpopulate the memory delta
|
||||
// Demoting unpopulate the memory delta
|
||||
if (oldPopulatedMip != _populatedMip) {
|
||||
auto numPopulatedDemoted = _populatedMip - oldPopulatedMip;
|
||||
Size amountUnpopulated = 0;
|
||||
for (int i = 0; i < numPopulatedDemoted; i++) {
|
||||
amountUnpopulated += _gpuObject.evalMipSize(oldPopulatedMip + i);
|
||||
amountUnpopulated += _gpuObject.evalMipSize(oldPopulatedMip + i);
|
||||
}
|
||||
decrementPopulatedSize(amountUnpopulated);
|
||||
decrementPopulatedSize(amountUnpopulated);
|
||||
}
|
||||
return (oldSize - _size);
|
||||
}
|
||||
|
@ -268,12 +267,12 @@ void GL45ResourceTexture::populateTransferQueue(TransferQueue& pendingTransfers)
|
|||
continue;
|
||||
}
|
||||
|
||||
// break down the transfers into chunks so that no single transfer is
|
||||
// break down the transfers into chunks so that no single transfer is
|
||||
// consuming more than X bandwidth
|
||||
// For compressed format, regions must be a multiple of the 4x4 tiles, so enforce 4 lines as the minimum block
|
||||
auto mipSize = _gpuObject.getStoredMipFaceSize(sourceMip, face);
|
||||
const auto lines = mipDimensions.y;
|
||||
const uint32_t BLOCK_NUM_LINES { 4 };
|
||||
const uint32_t BLOCK_NUM_LINES{ 4 };
|
||||
const auto numBlocks = (lines + (BLOCK_NUM_LINES - 1)) / BLOCK_NUM_LINES;
|
||||
auto bytesPerBlock = mipSize / numBlocks;
|
||||
Q_ASSERT(0 == (mipSize % lines));
|
||||
|
@ -289,6 +288,7 @@ void GL45ResourceTexture::populateTransferQueue(TransferQueue& pendingTransfers)
|
|||
// queue up the sampler and populated mip change for after the transfer has completed
|
||||
pendingTransfers.emplace(new TransferJob([=] {
|
||||
_populatedMip = sourceMip;
|
||||
incrementPopulatedSize(_gpuObject.evalMipSize(sourceMip));
|
||||
sanityCheck();
|
||||
syncSampler();
|
||||
}));
|
||||
|
|
|
@ -401,8 +401,7 @@ Size GLESVariableAllocationTexture::copyMipsFromTexture() {
|
|||
amount += copyMipFaceFromTexture(sourceMip, targetMip, face);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
incrementPopulatedSize(amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
@ -411,7 +410,6 @@ Size GLESVariableAllocationTexture::copyMipFaceLinesFromTexture(uint16_t mip, ui
|
|||
withPreservedTexture([&] {
|
||||
amountCopied = Parent::copyMipFaceLinesFromTexture(mip, face, size, yOffset, internalFormat, format, type, sourceSize, sourcePointer);
|
||||
});
|
||||
incrementPopulatedSize(amountCopied);
|
||||
return amountCopied;
|
||||
}
|
||||
|
||||
|
@ -673,6 +671,8 @@ void GLESVariableAllocationTexture::populateTransferQueue(TransferJob::Queue& qu
|
|||
// queue up the sampler and populated mip change for after the transfer has completed
|
||||
queue.emplace(new TransferJob([=] {
|
||||
_populatedMip = sourceMip;
|
||||
incrementPopulatedSize(_gpuObject.evalMipSize(sourceMip));
|
||||
sanityCheck();
|
||||
syncSampler();
|
||||
}));
|
||||
} while (sourceMip != _allocatedMip);
|
||||
|
|
Loading…
Reference in a new issue