Fixup targetAllocatedMip inside gl textures

This commit is contained in:
Ryan Huffman 2017-04-26 14:37:40 -07:00
parent 1bd95ee19f
commit 7bb6010149
2 changed files with 3 additions and 11 deletions

View file

@ -245,6 +245,7 @@ GL41VariableAllocationTexture::GL41VariableAllocationTexture(const std::weak_ptr
_allocatedMip = mipLevels;
_maxAllocatedMip = _populatedMip = mipLevels;
_minAllocatedMip = texture.minAvailableMipLevel();
uvec3 mipDimensions;
for (uint16_t mip = _minAllocatedMip; mip < mipLevels; ++mip) {
if (glm::all(glm::lessThanEqual(texture.evalMipDimensions(mip), INITIAL_MIP_TRANSFER_DIMENSIONS))) {
@ -310,11 +311,7 @@ void GL41VariableAllocationTexture::promote() {
Q_ASSERT(_allocatedMip > 0);
uint16_t targetAllocatedMip = _allocatedMip - std::min<uint16_t>(_allocatedMip, 2);
targetAllocatedMip = std::max<uint16_t>(_gpuObject.minAvailableMipLevel(), targetAllocatedMip);
if (targetAllocatedMip >= _allocatedMip || !_gpuObject.isStoredMipFaceAvailable(targetAllocatedMip, 0)) {
return;
}
targetAllocatedMip = std::max<uint16_t>(_minAllocatedMip, targetAllocatedMip);
GLuint oldId = _id;
auto oldSize = _size;

View file

@ -43,9 +43,7 @@ using GL45ResourceTexture = GL45Backend::GL45ResourceTexture;
GL45ResourceTexture::GL45ResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL45VariableAllocationTexture(backend, texture) {
auto mipLevels = texture.getNumMips();
_allocatedMip = mipLevels;
_maxAllocatedMip = _populatedMip = mipLevels;
_minAllocatedMip = texture.minAvailableMipLevel();
uvec3 mipDimensions;
@ -104,11 +102,8 @@ void GL45ResourceTexture::promote() {
Q_ASSERT(_allocatedMip > 0);
uint16_t targetAllocatedMip = _allocatedMip - std::min<uint16_t>(_allocatedMip, 2);
targetAllocatedMip = std::max<uint16_t>(_gpuObject.minAvailableMipLevel(), targetAllocatedMip);
targetAllocatedMip = std::max<uint16_t>(_minAllocatedMip, targetAllocatedMip);
if (targetAllocatedMip >= _allocatedMip || !_gpuObject.isStoredMipFaceAvailable(targetAllocatedMip, 0)) {
return;
}
GLuint oldId = _id;
auto oldSize = _size;
// create new texture